/* =========================================================================
   TranscriptHub — Design System
   Tokens: color, type, space, radius, shadow, motion
   ========================================================================= */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Poppins:wght@600;700;800&display=swap');

:root {
  /* --- Neutral surfaces (dark canvas, cyan accent — matches the landing page) --- */
  --color-bg: #07090b;
  --color-bg-soft: #0a0a0c;
  --color-surface: #14171d;
  --color-surface-raised: #171b22;
  --color-surface-sunken: #101318;
  --color-border: #272d37;
  --color-border-strong: #34404c;

  --color-text: #f4f6f8;
  --color-text-muted: #98a1b0;
  --color-text-faint: #6c7585;
  --color-text-on-accent: #04141a;

  /* --- Brand accent: cyan --- */
  --color-accent: #00d4ff;
  --color-accent-hover: #00eaff;
  --color-accent-active: #00b3e6;
  --color-accent-soft: rgba(0, 212, 255, 0.1);
  --color-accent-soft-strong: rgba(0, 212, 255, 0.2);
  --color-accent-text: #00d4ff;
  --gradient-accent: linear-gradient(135deg, #00eaff 0%, #00b3e6 100%);
  --gradient-accent-soft: linear-gradient(135deg, rgba(0, 212, 255, .14) 0%, rgba(0, 180, 230, .1) 100%);

  /* --- Semantic --- */
  --color-success: #37c98a;
  --color-success-soft: rgba(55, 201, 138, 0.14);
  --color-warning: #e0a949;
  --color-warning-soft: rgba(224, 169, 73, 0.14);
  --color-danger: #ef6b66;
  --color-danger-soft: rgba(239, 107, 102, 0.14);

  /* --- Sidebar surface --- */
  --sidebar-bg: #07090b;
  --sidebar-bg-raised: #14171d;
  --sidebar-border: rgba(255, 255, 255, 0.08);
  --sidebar-text: #98a1b0;
  --sidebar-text-muted: #6c7585;
  --sidebar-active-bg: rgba(0, 212, 255, 0.12);
  --sidebar-active-text: #00eaff;

  /* --- Type scale --- */
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-heading: "Poppins", var(--font-sans);
  --text-2xs: 11px;
  --text-xs: 12px;
  --text-sm: 13px;
  --text-base: 15px;
  --text-md: 17px;
  --text-lg: 20px;
  --text-xl: 24px;
  --text-2xl: 30px;
  --text-3xl: 38px;

  /* --- Spacing scale --- */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-7: 32px;
  --space-8: 40px;
  --space-9: 56px;

  /* --- Radius --- */
  --radius-xs: 6px;
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-xl: 28px;
  --radius-full: 999px;

  /* --- Shadow --- */
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-sm: 0 2px 10px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 14px 32px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 28px 64px rgba(0, 0, 0, 0.55);
  --shadow-glow: 0 8px 24px rgba(0, 212, 255, 0.35);

  /* --- Motion --- */
  --ease: cubic-bezier(.2, .7, .2, 1);
  --dur-fast: .12s;
  --dur-base: .2s;
  --dur-slow: .38s;

  --sidebar-width: 260px;
  --topbar-height: 64px;
  --bottom-nav-height: 64px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { line-height: 1.2; margin: 0 0 8px; letter-spacing: -.01em; font-weight: 700; font-family: var(--font-heading); }
h1 { font-size: var(--text-2xl); letter-spacing: -.02em; }
h2 { font-size: var(--text-xl); }
h3 { font-size: var(--text-md); }
p { margin: 0 0 12px; color: var(--color-text); }
small, .text-sm { font-size: var(--text-sm); }
a { color: var(--color-accent-text); text-decoration: none; }
a:hover { text-decoration: underline; }
::selection { background: var(--color-accent-soft-strong); }

:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
  border-radius: var(--radius-xs);
}

.container { max-width: 1080px; margin: 0 auto; padding: 0 24px; }
.text-muted { color: var(--color-text-muted); }
.text-faint { color: var(--color-text-faint); }
.mono-nums { font-variant-numeric: tabular-nums; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  min-height: 40px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-weight: 600;
  font-size: var(--text-sm);
  cursor: pointer;
  text-decoration: none;
  transition: transform var(--dur-fast) var(--ease), background var(--dur-base) var(--ease), border-color var(--dur-base) var(--ease), box-shadow var(--dur-base) var(--ease), opacity var(--dur-base) var(--ease);
  line-height: 1;
  white-space: nowrap;
  user-select: none;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: scale(.97); }

.btn-primary {
  background: var(--gradient-accent);
  color: var(--color-text-on-accent);
  box-shadow: var(--shadow-glow);
}
.btn-primary:hover { filter: brightness(1.05); box-shadow: 0 10px 28px rgba(0, 212, 255, .45); }
.btn-primary:disabled { box-shadow: none; }

.btn-secondary { background: var(--color-surface); color: var(--color-text); border-color: var(--color-border-strong); }
.btn-secondary:hover { background: var(--color-surface-sunken); border-color: var(--color-border-strong); }

.btn-danger { background: var(--color-danger-soft); color: var(--color-danger); }
.btn-danger:hover { background: var(--color-danger); color: #fff; }

.btn-ghost { background: transparent; color: var(--color-text-muted); }
.btn-ghost:hover { background: var(--color-surface-sunken); color: var(--color-text); }

.btn-sm { padding: 6px 12px; min-height: 32px; font-size: var(--text-xs); border-radius: var(--radius-xs); }
.btn-lg { padding: 14px 26px; min-height: 52px; font-size: var(--text-base); border-radius: var(--radius-md); }
.btn-block { width: 100%; }
.btn-icon { width: 36px; height: 36px; padding: 0; flex: none; }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }

/* ---------- Forms ---------- */
label { display: block; font-weight: 600; font-size: var(--text-sm); margin-bottom: 6px; color: var(--color-text); }
.label-hint { font-weight: 400; color: var(--color-text-faint); }
.field { margin-bottom: 20px; }
.field-hint { font-size: var(--text-xs); color: var(--color-text-faint); margin-top: 6px; }
.field-error { font-size: var(--text-xs); color: var(--color-danger); margin-top: 6px; font-weight: 500; }

input[type=text], input[type=email], input[type=password], input[type=url], input[type=number],
textarea, select {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: var(--text-base);
  font-family: inherit;
  background: var(--color-surface);
  color: var(--color-text);
  transition: border-color var(--dur-base) var(--ease), box-shadow var(--dur-base) var(--ease);
}
input::placeholder, textarea::placeholder { color: var(--color-text-faint); }
textarea { resize: vertical; min-height: 96px; line-height: 1.6; }
input:hover, textarea:hover, select:hover { border-color: var(--color-border-strong); }
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 4px var(--color-accent-soft);
}
select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%2398a1b0'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; padding-right: 34px; }

.textarea-hero { font-size: var(--text-md); padding: var(--space-5); min-height: 160px; border-radius: var(--radius-lg); box-shadow: var(--shadow-xs); }
.textarea-hero:focus { box-shadow: 0 0 0 4px var(--color-accent-soft), var(--shadow-sm); }

/* ---------- Chips / segmented controls ---------- */
.chip-group { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: var(--radius-full);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text);
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease);
}
.chip:hover { border-color: var(--color-border-strong); background: var(--color-surface-sunken); }
.chip input { position: absolute; opacity: 0; width: 0; height: 0; }
.chip:has(input:checked), .chip.is-selected {
  background: var(--color-accent-soft);
  border-color: var(--color-accent);
  color: var(--color-accent-text);
  box-shadow: 0 0 0 1px var(--color-accent) inset;
}
.chip:has(input:focus-visible) { outline: 2px solid var(--color-accent); outline-offset: 2px; }

/* ---------- Cards ---------- */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-6);
  box-shadow: var(--shadow-xs);
}
.card-interactive { transition: transform var(--dur-base) var(--ease), box-shadow var(--dur-base) var(--ease), border-color var(--dur-base) var(--ease); }
.card-interactive:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--color-border-strong); }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px; border-radius: var(--radius-full); font-size: var(--text-2xs); font-weight: 700; text-transform: uppercase; letter-spacing: .03em; }
.badge-primary { background: var(--color-accent-soft); color: var(--color-accent-text); }
.badge-success { background: var(--color-success-soft); color: var(--color-success); }
.badge-warning { background: var(--color-warning-soft); color: var(--color-warning); }
.badge-danger { background: var(--color-danger-soft); color: var(--color-danger); }
.badge-neutral { background: var(--color-surface-sunken); color: var(--color-text-muted); }

/* ---------- Alerts ---------- */
.alert { display: flex; align-items: flex-start; gap: 10px; padding: 14px 16px; border-radius: var(--radius-sm); font-size: var(--text-sm); margin-bottom: 20px; border: 1px solid transparent; }
.alert-success { background: var(--color-success-soft); color: var(--color-success); border-color: color-mix(in srgb, var(--color-success) 25%, transparent); }
.alert-error { background: var(--color-danger-soft); color: var(--color-danger); border-color: color-mix(in srgb, var(--color-danger) 25%, transparent); }
.alert-info { background: var(--color-accent-soft); color: var(--color-accent-text); border-color: color-mix(in srgb, var(--color-accent) 25%, transparent); }

/* ---------- Toasts ---------- */
.toast-stack {
  position: fixed;
  bottom: var(--space-6);
  right: var(--space-6);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: min(360px, calc(100vw - 32px));
}
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--color-text);
  color: var(--color-bg);
  padding: 13px 16px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  font-size: var(--text-sm);
  font-weight: 600;
  animation: toast-in var(--dur-slow) var(--ease);
}
.toast.toast-leaving { animation: toast-out var(--dur-base) var(--ease) forwards; }
.toast-success::before { content: '✓'; color: #37c98a; font-weight: 800; }
.toast-error::before { content: '!'; color: #ef6b66; font-weight: 800; }
.toast-info::before { content: '✨'; }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px) scale(.96); } to { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(6px) scale(.98); } }

/* ---------- Loaders / skeleton ---------- */
.spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid currentColor; border-top-color: transparent; opacity: .8; animation: spin .7s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
.skeleton { background: linear-gradient(90deg, var(--color-surface-sunken) 25%, var(--color-border) 37%, var(--color-surface-sunken) 63%); background-size: 400% 100%; animation: skeleton-wave 1.4s ease infinite; border-radius: var(--radius-sm); }
@keyframes skeleton-wave { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }

.gen-steps { display: flex; flex-direction: column; gap: var(--space-4); max-width: 380px; margin: 0 auto; }
.gen-step { display: flex; align-items: center; gap: 12px; font-size: var(--text-sm); font-weight: 600; color: var(--color-text-faint); transition: color var(--dur-base) var(--ease); }
.gen-step .gen-dot { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--color-border-strong); display: flex; align-items: center; justify-content: center; flex: none; font-size: 12px; transition: all var(--dur-base) var(--ease); }
.gen-step.done { color: var(--color-text); }
.gen-step.done .gen-dot { background: var(--color-success); border-color: var(--color-success); color: #fff; }
.gen-step.active { color: var(--color-text); }
.gen-step.active .gen-dot { border-color: var(--color-accent); box-shadow: 0 0 0 4px var(--color-accent-soft); }
.gen-step.active .gen-dot::after { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--color-accent); animation: pulse-dot 1.1s ease infinite; }
@keyframes pulse-dot { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: .4; transform: scale(.7); } }

/* ---------- Auth pages ---------- */
.auth-body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: radial-gradient(560px 360px at 50% 0%, rgba(0, 212, 255, 0.12), transparent 70%), var(--color-bg);
}
.auth-header { text-align: center; max-width: 420px; margin-bottom: 32px; }
.auth-header h1 { font-size: var(--text-2xl); margin-bottom: 8px; }
.auth-subtitle { color: var(--color-text-muted); font-size: var(--text-base); margin: 0; }
.auth-card { width: 100%; max-width: 420px; background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-lg); padding: 44px; box-shadow: var(--shadow-lg); }
.auth-brand { font-family: var(--font-heading); font-weight: 700; font-size: var(--text-md); margin-bottom: 28px; display: flex; align-items: center; gap: 8px; letter-spacing: -.01em; }
.auth-header .auth-brand { justify-content: center; margin-bottom: 20px; font-size: var(--text-lg); }
.auth-brand[href] { color: var(--color-text); text-decoration: none; transition: opacity var(--dur-fast) var(--ease); }
.auth-brand[href]:hover { text-decoration: none; opacity: .85; }
.auth-brand .brand-text span { color: var(--color-accent-text); }
.auth-brand-mark {
  width: 36px; height: 36px; border-radius: 10px; flex: none;
  overflow: hidden;
  display: flex; align-items: center; justify-content: center;
}
.auth-brand-mark img { width: 100%; height: 100%; object-fit: cover; display: block; }
.auth-footer-link { text-align: center; margin-top: 20px; font-size: var(--text-sm); color: var(--color-text-muted); }

.auth-card label { text-transform: uppercase; font-size: var(--text-2xs); letter-spacing: .06em; font-weight: 700; color: var(--color-text-faint); }
.auth-card input[type=email], .auth-card input[type=password], .auth-card input[type=text] { background: var(--color-bg-soft); }

.input-password-wrap { position: relative; }
.input-password-wrap input { padding-right: 44px; }
.input-password-toggle {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  background: none; border: none; padding: 8px; cursor: pointer;
  color: var(--color-text-faint); display: flex; border-radius: var(--radius-xs);
}
.input-password-toggle:hover { color: var(--color-text-muted); }

/* ---------- App shell ---------- */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  padding: var(--space-5) var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
  position: fixed;
  top: 0; bottom: 0; left: 0;
  overflow-y: auto;
  z-index: 40;
  transition: transform var(--dur-base) var(--ease);
}
.sidebar-brand { font-family: var(--font-heading); font-weight: 700; font-size: var(--text-md); padding: 4px 8px; display: flex; align-items: center; gap: 8px; color: #fff; letter-spacing: -.01em; }
.sidebar-brand .brand-text span { color: var(--color-accent-hover); }
.sidebar-brand-mark { width: 28px; height: 28px; border-radius: 8px; flex: none; overflow: hidden; display: flex; align-items: center; justify-content: center; }
.sidebar-brand-mark img { width: 100%; height: 100%; object-fit: cover; display: block; }
.sidebar-cta {
  margin: 0 2px;
  justify-content: center;
  font-size: var(--text-sm);
}
.sidebar-nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar-nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  color: var(--sidebar-text); font-weight: 500; font-size: var(--text-sm);
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.sidebar-nav a .nav-ico { width: 18px; text-align: center; opacity: .85; flex: none; }
.sidebar-nav a:hover { background: rgba(255,255,255,.06); color: #fff; text-decoration: none; }
.sidebar-nav a.active { background: var(--sidebar-active-bg); color: var(--sidebar-active-text); font-weight: 600; }
.sidebar-section-title { font-size: var(--text-2xs); text-transform: uppercase; letter-spacing: .08em; color: var(--sidebar-text-muted); padding: 0 12px; margin-top: 10px; font-weight: 700; }
.sidebar-footer { margin-top: auto; border-top: 1px solid var(--sidebar-border); padding-top: var(--space-4); display: flex; flex-direction: column; gap: 8px; }
.sidebar-user { display: flex; align-items: center; gap: 10px; padding: 6px 8px; }
.sidebar-user-avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--gradient-accent); color: var(--color-text-on-accent); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: var(--text-xs); flex: none; }
.sidebar-user-name { font-size: var(--text-sm); color: #fff; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-footer .btn-ghost { color: var(--sidebar-text-muted); }
.sidebar-footer .btn-ghost:hover { background: rgba(255,255,255,.06); color: #fff; }

.app-main { margin-left: var(--sidebar-width); flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: var(--topbar-height);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 28px; border-bottom: 1px solid var(--color-border);
  background: color-mix(in srgb, var(--color-surface) 88%, transparent); backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 30;
}
.topbar-menu-btn { display: none; background: none; border: none; font-size: 20px; cursor: pointer; color: var(--color-text); padding: 6px; border-radius: var(--radius-xs); }
.topbar-menu-btn:hover { background: var(--color-surface-sunken); }
.page-content { padding: var(--space-7); flex: 1; }
.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: var(--space-7); flex-wrap: wrap; }
.page-title { font-family: var(--font-heading); font-size: var(--text-xl); font-weight: 700; letter-spacing: -.01em; }
.page-subtitle { color: var(--color-text-muted); font-size: var(--text-base); margin-top: 2px; }
.eyebrow { font-size: var(--text-xs); font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--color-accent-text); margin-bottom: 6px; }

.grid { display: grid; gap: var(--space-5); }
.grid-2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0,1fr)); }

.stat-card { display: flex; flex-direction: column; gap: 4px; }
.stat-value { font-family: var(--font-heading); font-size: var(--text-xl); font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.stat-label { color: var(--color-text-muted); font-size: var(--text-sm); }
.progress-track { background: var(--color-surface-sunken); border-radius: var(--radius-full); height: 8px; overflow: hidden; margin-top: 12px; }
.progress-fill { background: var(--gradient-accent); height: 100%; border-radius: var(--radius-full); transition: width var(--dur-slow) var(--ease); }

/* ---------- List / script items ---------- */
.list-item {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: var(--space-4) var(--space-5); border: 1px solid var(--color-border); border-radius: var(--radius-md);
  background: var(--color-surface); margin-bottom: 12px;
  transition: border-color var(--dur-base) var(--ease), box-shadow var(--dur-base) var(--ease), transform var(--dur-base) var(--ease);
}
.list-item:hover { border-color: var(--color-border-strong); box-shadow: var(--shadow-sm); transform: translateY(-1px); }
.list-item-title { font-weight: 700; font-size: var(--text-base); }
.list-item-title a { color: var(--color-text); }
.list-item-title a:hover { color: var(--color-accent-text); text-decoration: none; }
.list-item-meta { font-size: var(--text-sm); color: var(--color-text-muted); margin-top: 3px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.list-item-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.script-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: var(--space-4); }
.script-card {
  display: flex; flex-direction: column; gap: 10px;
  padding: var(--space-5); border: 1px solid var(--color-border); border-radius: var(--radius-md);
  background: var(--color-surface); box-shadow: var(--shadow-xs);
  transition: transform var(--dur-base) var(--ease), box-shadow var(--dur-base) var(--ease), border-color var(--dur-base) var(--ease);
  position: relative;
}
.script-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); border-color: var(--color-border-strong); }
.script-card-title { font-weight: 700; font-size: var(--text-base); display: block; color: var(--color-text); }
.script-card-title:hover { color: var(--color-accent-text); text-decoration: none; }
.script-card-meta { font-size: var(--text-xs); color: var(--color-text-muted); display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.script-card-fav { position: absolute; top: 14px; right: 14px; background: none; border: none; cursor: pointer; font-size: 16px; color: var(--color-text-faint); transition: transform var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease); }
.script-card-fav.is-fav { color: #f5b400; }
.script-card-fav:active { transform: scale(1.3); }
.script-card-actions { display: flex; gap: 6px; margin-top: auto; padding-top: 6px; flex-wrap: wrap; }

.view-toggle { display: inline-flex; border: 1px solid var(--color-border); border-radius: var(--radius-sm); overflow: hidden; }
.view-toggle button { background: var(--color-surface); border: none; padding: 8px 12px; cursor: pointer; color: var(--color-text-muted); font-size: var(--text-sm); }
.view-toggle button.active { background: var(--color-accent-soft); color: var(--color-accent-text); font-weight: 600; }

.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--color-border); font-size: var(--text-sm); }
.table th { color: var(--color-text-faint); font-weight: 700; font-size: var(--text-2xs); text-transform: uppercase; letter-spacing: .05em; }
.table tbody tr { transition: background var(--dur-fast) var(--ease); }
.table tbody tr:hover { background: var(--color-surface-sunken); }
.table-wrap { overflow-x: auto; border-radius: var(--radius-md); border: 1px solid var(--color-border); background: var(--color-surface); }
.table-wrap .table { min-width: 640px; }
.table-wrap .table th:first-child, .table-wrap .table td:first-child { padding-left: 18px; }

/* ---------- Source cards ---------- */
.source-input-row { display: flex; gap: 8px; margin-bottom: var(--space-3); }
.source-input-row input { flex: 1; }
.source-card {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  padding: 14px 16px; border: 1px solid var(--color-border); border-radius: var(--radius-md);
  background: var(--color-surface); margin-bottom: 10px;
}
.source-card-body { display: flex; gap: 12px; align-items: flex-start; min-width: 0; }
.source-card-icon { width: 30px; height: 30px; border-radius: var(--radius-sm); background: var(--color-surface-sunken); display: flex; align-items: center; justify-content: center; flex: none; font-size: 14px; }
.source-card-icon.status-processing { background: var(--color-accent-soft); }
.source-card-icon.status-success { background: var(--color-success-soft); }
.source-card-icon.status-failed { background: var(--color-danger-soft); }
.source-card-text { min-width: 0; }
.source-card-domain { font-weight: 700; font-size: var(--text-sm); }
.source-card-snippet { font-size: var(--text-xs); color: var(--color-text-muted); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 46ch; }
.source-card-status { font-size: var(--text-2xs); font-weight: 700; text-transform: uppercase; letter-spacing: .04em; margin-top: 4px; display: flex; align-items: center; gap: 5px; }
.source-card.status-processing .source-card-status { color: var(--color-accent-text); }
.source-card.status-success .source-card-status { color: var(--color-success); }
.source-card.status-failed .source-card-status { color: var(--color-danger); }
.source-card-actions { display: flex; gap: 6px; flex: none; }
.source-empty-hint { font-size: var(--text-sm); color: var(--color-text-faint); padding: 8px 2px; }

.source-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.source-row input { flex: 1; }

.tab-bar { display: flex; gap: var(--space-5); border-bottom: 1px solid var(--color-border); margin-bottom: var(--space-6); }
.tab-bar a { padding: 10px 2px; color: var(--color-text-muted); font-weight: 600; font-size: var(--text-sm); border-bottom: 2px solid transparent; }
.tab-bar a.active { color: var(--color-accent-text); border-color: var(--color-accent); }

/* ---------- Empty states ---------- */
.empty-state { text-align: center; padding: 64px 24px; color: var(--color-text-muted); }
.empty-icon { font-size: 34px; margin-bottom: 12px; }
.empty-state h3 { color: var(--color-text); margin-bottom: 6px; }
.empty-state p { max-width: 380px; margin: 0 auto 20px; }

/* ---------- Hero / create prompt ---------- */
.hero-create {
  background: var(--gradient-accent-soft);
  border: 1px solid var(--color-accent-soft-strong);
  border-radius: var(--radius-xl);
  padding: var(--space-8) var(--space-7);
  text-align: center;
  margin-bottom: var(--space-7);
}
.hero-create h1 { font-size: var(--text-2xl); margin-bottom: 6px; }
.hero-create p { color: var(--color-text-muted); font-size: var(--text-base); max-width: 480px; margin: 0 auto 24px; }

/* ---------- Editor ---------- */
.editor-section { margin-bottom: var(--space-6); background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-md); padding: var(--space-5); transition: border-color var(--dur-base) var(--ease); }
.editor-section:focus-within { border-color: var(--color-accent); box-shadow: 0 0 0 4px var(--color-accent-soft); }
.editor-section.is-generating { border-color: var(--color-accent); box-shadow: 0 0 0 4px var(--color-accent-soft); opacity: .75; }
.editor-section-label { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; gap: 8px; flex-wrap: wrap; }
.editor-section-label .tag { font-size: var(--text-2xs); text-transform: uppercase; letter-spacing: .07em; color: var(--color-accent-text); font-weight: 800; }
.editor-section textarea { border: none; padding: 0; font-size: var(--text-base); line-height: 1.7; }
.editor-section textarea:focus { box-shadow: none; }
.editor-toolbar { display: flex; gap: 12px; margin-bottom: var(--space-5); flex-wrap: wrap; align-items: center; }

.ai-inline-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.ai-inline-actions .btn { font-size: var(--text-2xs); padding: 5px 10px; min-height: 26px; }

/* ---------- Modal ---------- */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.6); backdrop-filter: blur(2px); display: flex; align-items: center; justify-content: center; z-index: 150; padding: 20px; }
.modal-card { background: var(--color-surface); border-radius: var(--radius-lg); padding: var(--space-6); max-width: 420px; width: 100%; box-shadow: var(--shadow-lg); }

/* ---------- Tooltip ---------- */
[data-tooltip] { position: relative; }
[data-tooltip]:hover::after {
  content: attr(data-tooltip);
  position: absolute; bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%);
  background: var(--color-text); color: var(--color-bg); font-size: var(--text-2xs); font-weight: 600;
  padding: 5px 9px; border-radius: var(--radius-xs); white-space: nowrap; z-index: 60; pointer-events: none;
}

/* ---------- Teleprompter ---------- */
.teleprompter-body { background: var(--color-bg); color: var(--color-text); height: 100vh; overflow: hidden; display: flex; flex-direction: column; }
.teleprompter-controls {
  display: flex; align-items: center; gap: var(--space-4); padding: 10px 20px;
  background: rgba(255,255,255,0.05); border-bottom: 1px solid rgba(255,255,255,.06); flex-wrap: wrap;
}
.teleprompter-controls label { color: var(--color-text-muted); margin: 0; font-size: var(--text-2xs); display: flex; align-items: center; gap: 6px; text-transform: uppercase; letter-spacing: .05em; font-weight: 700; }
.teleprompter-viewport { flex: 1; overflow-y: auto; padding: 12vh 10vw 60vh; scroll-behavior: smooth; }
.teleprompter-text { font-size: 42px; line-height: 1.65; font-weight: 600; white-space: pre-wrap; max-width: 900px; margin: 0 auto; }

/* ---------- Mobile bottom nav ---------- */
.mobile-tabbar { display: none; }

@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-lg); bottom: var(--bottom-nav-height); }
  .sidebar.open { transform: translateX(0); }
  .sidebar::before { content: ''; }
  .app-main { margin-left: 0; padding-bottom: var(--bottom-nav-height); }
  .topbar-menu-btn { display: inline-flex; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .page-content { padding: var(--space-5); }
  .hero-create { padding: var(--space-6) var(--space-4); }
  .teleprompter-text { font-size: 28px; }
  .teleprompter-controls { gap: var(--space-3); padding: 10px 12px; }
  .textarea-hero { font-size: var(--text-base); padding: var(--space-4); }
  .mobile-tabbar {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 45;
    background: var(--sidebar-bg); border-top: 1px solid var(--sidebar-border);
    padding: 8px 6px calc(8px + env(safe-area-inset-bottom));
    justify-content: space-between;
  }
  .mobile-tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; color: var(--sidebar-text-muted); font-size: 10px; font-weight: 600; padding: 4px 0; border-radius: var(--radius-xs); }
  .mobile-tabbar a .nav-ico { font-size: 18px; }
  .mobile-tabbar a.active { color: var(--sidebar-active-text); }
  .toast-stack { left: 16px; right: 16px; bottom: 76px; max-width: none; }
}

@media (max-width: 560px) {
  .auth-card { padding: 28px 22px; }
  .page-title { font-size: var(--text-lg); }
  .source-card-snippet { max-width: 32ch; }
}
