:root {
  color-scheme: dark;
  --bg: #0f1016;
  --surface: #151822;
  --surface-2: #1f2431;
  --border: #2a3142;
  --brand: #8859ff;
  --brand-muted: rgba(136, 89, 255, 0.25);
  --text: #f8f9ff;
  --text-muted: #99a1b7;
  --danger: #f05252;
  --success: #22c55e;
  --warning: #facc15;
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: radial-gradient(circle at top left, rgba(136, 89, 255, 0.15), transparent 55%),
    radial-gradient(circle at bottom right, rgba(52, 211, 153, 0.12), transparent 40%),
    var(--bg);
  color: var(--text);
  min-height: 100vh;
}

#app {
  max-width: 1240px;
  margin: 0 auto;
  padding: 24px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  margin-bottom: 20px;
  background: rgba(21, 24, 34, 0.85);
  border: 1px solid var(--border);
  border-radius: 16px;
  backdrop-filter: blur(12px);
}

.topbar h1 {
  margin: 0;
  font-size: 20px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--brand);
  box-shadow: 0 0 18px rgba(136, 89, 255, 0.8);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

#user-badge {
  padding: 6px 12px;
  background: rgba(136, 89, 255, 0.2);
  border: 1px solid var(--brand);
  border-radius: 999px;
  font-size: 13px;
}

button {
  font: inherit;
  cursor: pointer;
  border-radius: 10px;
  border: none;
  padding: 10px 16px;
  color: inherit;
  background: var(--surface-2);
  border: 1px solid transparent;
  transition: transform 0.15s ease, background 0.15s ease, border 0.15s ease;
}

button:hover:not(:disabled) {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, 0.06);
}

button:disabled {
  opacity: 0.5;
  cursor: default;
}

button.primary {
  background: linear-gradient(135deg, #8859ff, #6366f1);
  border-color: rgba(255, 255, 255, 0.08);
  color: #fff;
  box-shadow: 0 10px 20px rgba(99, 102, 241, 0.25);
}

button.primary:hover {
  background: linear-gradient(135deg, #9f73ff, #7d81ff);
}

button.ghost {
  background: transparent;
  border-color: var(--border);
}

button.google-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-weight: 600;
}

.google-icon {
  font-size: 18px;
}

button.chip {
  border-radius: 999px;
  padding: 8px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 13px;
}

button.chip.active {
  background: rgba(136, 89, 255, 0.18);
  border-color: var(--brand);
}

.hidden {
  display: none !important;
}

.card {
  background: rgba(21, 24, 34, 0.92);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.25);
}

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 14px;
  color: var(--text-muted);
}

input, select, textarea {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
}

textarea {
  resize: vertical;
}

input[type="checkbox"] {
  width: auto;
  margin-right: 8px;
}

.full {
  width: 100%;
}

.muted {
  color: var(--text-muted);
  font-size: 13px;
}

.small {
  font-size: 12px;
}

.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
}

.tabs .tab {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 0;
  font-weight: 600;
}

.tabs .tab.active {
  background: rgba(136, 89, 255, 0.18);
  border-color: var(--brand);
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.panel-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: flex-end;
  margin-bottom: 20px;
}

.panel-toolbar .filters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.panel-toolbar .actions {
  display: flex;
  gap: 8px;
}

.panel-toolbar .combo {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 20px;
}

.series-card {
  position: relative;
  background: linear-gradient(160deg, rgba(136, 89, 255, 0.14), rgba(19, 23, 33, 0.92));
  border: 1px solid rgba(136, 89, 255, 0.2);
  border-radius: 16px;
  overflow: hidden;
  padding-bottom: 16px;
  display: flex;
  flex-direction: column;
}

.series-card img {
  width: 100%;
  height: 160px;
  object-fit: cover;
}

.series-card .series-body {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}

.series-card h3 {
  margin: 0;
  font-size: 18px;
}

.series-card p {
  margin: 0;
  font-size: 13px;
  color: var(--text-muted);
}

.series-card .status {
  align-self: flex-start;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}

.status.published {
  background: rgba(34, 197, 94, 0.16);
  color: #34d399;
}

.status.draft {
  background: rgba(251, 191, 36, 0.14);
  color: #fbbf24;
}

.series-card .card-actions {
  display: flex;
  gap: 8px;
  margin-top: auto;
}

.empty {
  border: 1px dashed rgba(255, 255, 255, 0.16);
  border-radius: 16px;
  padding: 48px 24px;
  text-align: center;
  background: rgba(15, 16, 22, 0.4);
  margin-bottom: 32px;
}

.empty-icon {
  font-size: 40px;
  margin-bottom: 12px;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  background: rgba(15, 16, 22, 0.55);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
}

.data-table th,
.data-table td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.data-table tbody tr:hover {
  background: rgba(136, 89, 255, 0.1);
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.badge.success {
  background: rgba(34, 197, 94, 0.16);
  color: #34d399;
}

.badge.warn {
  background: rgba(250, 204, 21, 0.16);
  color: #facc15;
}

.badge.neutral {
  background: rgba(148, 163, 184, 0.18);
  color: #cbd5f5;
}

.form-grid {
  display: grid;
  gap: 16px;
}

.field-inline {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.field-inline.checkbox {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
}

.progress {
  position: relative;
  width: 100%;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 999px;
  overflow: hidden;
  height: 10px;
}

.progress .progress-bar {
  width: 0;
  height: 100%;
  background: linear-gradient(120deg, #8859ff, #6366f1);
  transition: width 0.2s ease;
}

#upload-progress-label {
  display: block;
  margin-top: 8px;
  font-size: 13px;
  color: var(--text-muted);
}

.log {
  margin-top: 20px;
  padding: 16px;
  border-radius: 12px;
  background: rgba(15, 16, 22, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.06);
  font-family: "Menlo", "Consolas", monospace;
  font-size: 13px;
  max-height: 260px;
  overflow: auto;
}

.caption-details {
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 12px 16px;
  border-radius: 12px;
}

.caption-details summary {
  cursor: pointer;
  font-weight: 600;
}

.caption-grid {
  display: grid;
  gap: 12px;
  margin-top: 12px;
}

.caption-grid label.inline {
  flex-direction: row;
  align-items: center;
  gap: 8px;
}

.caption-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 12px;
}

.caption-item {
  background: rgba(15, 16, 22, 0.6);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.caption-label {
  font-weight: 600;
}

.caption-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.upload-caption-btn {
  border: 1px dashed rgba(255, 255, 255, 0.25);
  border-radius: 12px;
  padding: 10px 16px;
  display: inline-flex;
  gap: 8px;
  cursor: pointer;
}

.dialog {
  border: none;
  border-radius: 20px;
  background: rgba(20, 22, 29, 0.92);
  color: var(--text);
  width: min(420px, 90vw);
  padding: 0;
}

.dialog::backdrop {
  background: rgba(10, 12, 18, 0.76);
  backdrop-filter: blur(4px);
}

.dialog-form {
  display: grid;
  gap: 14px;
  padding: 28px;
}

.dialog h2 {
  margin: 0;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 12px;
}

#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: grid;
  gap: 12px;
  z-index: 999;
}

.toast {
  padding: 14px 18px;
  border-radius: 12px;
  background: rgba(21, 24, 34, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.08);
  min-width: 240px;
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.35);
  display: flex;
  gap: 12px;
  align-items: center;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.toast.success {
  border-color: rgba(34, 197, 94, 0.5);
}

.toast.error {
  border-color: rgba(240, 82, 82, 0.45);
}

.toast .icon {
  font-size: 18px;
}

.toast.fade-out {
  opacity: 0;
  transform: translateY(12px);
}

@media (max-width: 800px) {
  #app {
    padding: 16px;
  }
  .topbar {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
  .tabs {
    flex-direction: column;
  }
}
