/* ============================================================
   PodMind / EtchdPodcasts — Design System
   Source: stitch_podcast_insight_engine/cognitive_architecture/DESIGN.md
   Dark-mode-first, tonal layering, Electric Blue accent.
   ============================================================ */

:root {
  /* Surfaces */
  --bg: #020617;
  --surface: #081425;
  --surface-bright: #2f3a4c;
  --sc-lowest: #040e1f;
  --sc-low: #111c2d;
  --sc: #152031;
  --sc-high: #1f2a3c;
  --sc-highest: #2a3548;
  --card: #0f172a;
  --border: #1e293b;
  --border-lum: #334155;

  /* Text */
  --on-surface: #d8e3fb;
  --on-surface-var: #94a3b8;
  --muted: #64748b;

  /* Accent */
  --primary: #38bdf8;
  --primary-dim: #0ea5e9;
  --on-primary: #082032;
  --primary-glow: rgba(56, 189, 248, 0.18);

  /* Status */
  --success: #4ade80;
  --warning: #fbbf24;
  --error: #f87171;
  --error-deep: #93000a;

  /* Type */
  --font-display: 'Plus Jakarta Sans', 'Segoe UI', system-ui, sans-serif;
  --font-body: 'Inter', 'Segoe UI', system-ui, sans-serif;

  /* Shape */
  --r-sm: 0.25rem;
  --r: 0.5rem;
  --r-md: 0.75rem;
  --r-lg: 1rem;
  --r-xl: 1.5rem;
  --r-full: 9999px;

  /* Layout */
  --sidebar-w: 280px;
  --gutter: 24px;
  --player-h: 84px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--on-surface);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

::selection { background: rgba(56, 189, 248, 0.35); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--sc-highest); border-radius: 8px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--border-lum); }

h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 700; letter-spacing: -0.02em; }
a { color: var(--primary); text-decoration: none; }
button { font-family: var(--font-body); cursor: pointer; border: none; background: none; color: inherit; }
input, textarea, select { font-family: var(--font-body); color: var(--on-surface); }

.hidden { display: none !important; }

/* ---------- Labels / chips / pills ---------- */
.label-md {
  font-size: 12px; font-weight: 600; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--primary);
}
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 12px; border-radius: var(--r-xl);
  font-size: 12px; font-weight: 600;
  background: var(--sc-highest); color: var(--on-surface);
  border: 1px solid transparent;
}
.pill.subtle { background: var(--sc-high); color: var(--on-surface-var); }
.pill.blue { background: var(--primary); color: var(--on-primary); }
.pill.amber { background: rgba(251, 191, 36, 0.15); color: var(--warning); border-color: rgba(251, 191, 36, 0.3); }
.pill.green { background: rgba(74, 222, 128, 0.12); color: var(--success); border-color: rgba(74, 222, 128, 0.25); }
.pill .dot {
  width: 6px; height: 6px; border-radius: 50%; background: currentColor;
  animation: pulse 1.6s ease-in-out infinite;
}
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 20px; border-radius: var(--r);
  font-size: 15px; font-weight: 600;
  transition: background 0.15s, transform 0.1s, box-shadow 0.15s, color 0.15s;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: var(--primary); color: var(--on-primary);
  box-shadow: 0 0 24px var(--primary-glow);
}
.btn-primary:hover { background: #5cc9fa; }
.btn-ghost { background: transparent; color: var(--on-surface); border: 1px solid var(--border-lum); }
.btn-ghost:hover { background: var(--sc-high); }
.btn-subtle { background: var(--sc-high); color: var(--on-surface); }
.btn-subtle:hover { background: var(--sc-highest); }
.btn-danger-text { color: var(--error); background: transparent; padding: 6px 10px; font-size: 14px; }
.btn-danger-text:hover { background: rgba(248, 113, 113, 0.1); border-radius: var(--r-sm); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; border-radius: var(--r);
  color: var(--on-surface-var); transition: background 0.15s, color 0.15s;
  position: relative; flex: none;
}
.icon-btn:hover { background: var(--sc-high); color: var(--on-surface); }
.icon-btn.active { color: var(--primary); background: var(--primary-container, rgba(56,189,248,0.12)); }
.icon-btn .badge {
  position: absolute; top: 5px; right: 5px;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--primary); border: 2px solid var(--surface);
}

/* ---------- Inputs ---------- */
.input {
  width: 100%; background: var(--border); border: 1px solid var(--border-lum);
  border-radius: var(--r); padding: 11px 14px; font-size: 15px;
  outline: none; transition: border-color 0.15s, box-shadow 0.15s;
}
.input::placeholder { color: var(--muted); }
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-glow); }

.search-wrap { position: relative; }
.search-wrap svg {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  color: var(--muted); pointer-events: none;
}
.search-wrap .input { padding-left: 40px; }

select.input { appearance: none; cursor: pointer; }

/* ---------- App shell ---------- */
#app { height: 100%; }

.shell { display: flex; height: 100%; overflow: hidden; }

.sidebar {
  width: var(--sidebar-w); flex: none;
  background: var(--card); border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  padding: 20px 16px;
  overflow-y: auto;
}
.sidebar .brand {
  display: flex; align-items: center; gap: 12px; padding: 4px 8px 22px;
}
.brand-mark {
  width: 40px; height: 40px; border-radius: var(--r-md); flex: none;
  background: linear-gradient(135deg, var(--primary), #6366f1);
  display: flex; align-items: center; justify-content: center;
  color: #04121f;
}
.brand-name { font-family: var(--font-display); font-weight: 800; font-size: 20px; line-height: 1.1; }
.brand-sub { font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--on-surface-var); }

.nav-section { margin-bottom: 8px; }
.nav-heading {
  font-size: 11px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--muted); padding: 16px 12px 8px;
}
.nav-item {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 10px 12px; border-radius: var(--r);
  color: var(--on-surface-var); font-size: 15px; font-weight: 500;
  position: relative; transition: background 0.15s, color 0.15s;
  text-align: left;
}
.nav-item:hover { background: var(--sc-low); color: var(--on-surface); }
.nav-item.active { background: rgba(56, 189, 248, 0.1); color: var(--primary); font-weight: 600; }
.nav-item.active::before {
  content: ''; position: absolute; left: -16px; top: 8px; bottom: 8px;
  width: 3px; border-radius: 0 3px 3px 0; background: var(--primary);
}
.nav-item svg { flex: none; }
.nav-item .count { margin-left: auto; font-size: 12px; color: var(--muted); }

.recents-item {
  display: block; width: 100%; text-align: left;
  padding: 8px 12px; border-radius: var(--r);
  transition: background 0.15s;
}
.recents-item:hover { background: var(--sc-low); }
.recents-item .r-title {
  font-size: 14px; font-weight: 500; color: var(--on-surface);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.recents-item .r-time { font-size: 12px; color: var(--muted); }

.collection-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }

.sidebar-cta { margin-top: auto; padding-top: 18px; }
.sidebar-cta .btn { width: 100%; padding: 13px; font-size: 16px; }

/* ---------- Main column ---------- */
.main-col {
  flex: 1; display: flex; flex-direction: column; min-width: 0;
  background:
    radial-gradient(1200px 500px at 70% -10%, rgba(56, 189, 248, 0.06), transparent 60%),
    var(--bg);
}
.topbar {
  height: 68px; flex: none;
  display: flex; align-items: center; gap: 16px;
  padding: 0 28px; border-bottom: 1px solid var(--border);
  background: rgba(8, 20, 37, 0.7); backdrop-filter: blur(12px);
  position: relative; z-index: 30;
}
.crumbs { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; min-width: 0; }
.crumbs .sep { color: var(--muted); }
.crumbs a { color: var(--on-surface-var); }
.crumbs a:hover { color: var(--on-surface); }
.crumbs .current { color: var(--on-surface); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .spacer { flex: 1; }
.topbar .search-wrap { width: 300px; }

.avatar {
  width: 38px; height: 38px; border-radius: 50%; flex: none;
  background: linear-gradient(135deg, #6366f1, #ec4899);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px; color: #fff;
}
.user-chip { display: flex; align-items: center; gap: 10px; padding-left: 14px; border-left: 1px solid var(--border); }
.user-chip .u-name { font-size: 14px; font-weight: 600; line-height: 1.2; }
.user-chip .u-plan { font-size: 12px; color: var(--on-surface-var); }

.content {
  flex: 1; overflow-y: auto; padding: 32px 40px calc(var(--player-h) + 40px);
  scroll-behavior: smooth;
}
.content.no-player { padding-bottom: 48px; }
.content-inner { max-width: 1180px; margin: 0 auto; }

/* ---------- Notifications dropdown ---------- */
.dropdown {
  position: absolute; top: 58px; right: 24px; width: 360px;
  background: rgba(21, 32, 49, 0.92); backdrop-filter: blur(12px);
  border: 1px solid var(--border-lum); border-radius: var(--r-lg);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.5);
  z-index: 100; overflow: hidden;
}
.dropdown .dd-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; border-bottom: 1px solid var(--border);
  font-family: var(--font-display); font-weight: 700; font-size: 15px;
}
.dropdown .dd-head button { font-size: 12px; color: var(--primary); font-weight: 600; }
.dd-list { max-height: 340px; overflow-y: auto; }
.dd-item { display: flex; gap: 12px; padding: 13px 18px; border-bottom: 1px solid var(--border); font-size: 14px; }
.dd-item:last-child { border-bottom: none; }
.dd-item .ico {
  width: 34px; height: 34px; border-radius: var(--r); flex: none;
  background: var(--sc-highest); display: flex; align-items: center; justify-content: center;
  color: var(--primary);
}
.dd-item .t { color: var(--muted); font-size: 12px; margin-top: 2px; }
.dd-empty { padding: 28px 18px; text-align: center; color: var(--muted); font-size: 14px; }

/* ---------- Landing ---------- */
.landing { height: 100%; overflow-y: auto; background: var(--bg); }
.landing-nav {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 28px;
  padding: 14px 48px;
  background: rgba(2, 6, 23, 0.8); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.landing-nav .links { display: flex; gap: 22px; }
.landing-nav .links a { color: var(--on-surface-var); font-size: 14px; font-weight: 600; }
.landing-nav .links a:hover, .landing-nav .links a.on { color: var(--on-surface); }
.landing-nav .spacer { flex: 1; }

.hero { text-align: center; padding: 90px 24px 40px; }
.hero .kicker { margin-bottom: 18px; }
.hero h1 {
  font-size: clamp(34px, 5vw, 52px); line-height: 1.12; max-width: 760px; margin: 0 auto 20px;
}
.hero h1 .grad {
  background: linear-gradient(90deg, var(--primary), #818cf8);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hero .sub { max-width: 560px; margin: 0 auto 40px; color: var(--on-surface-var); font-size: 18px; }

.demo-card {
  max-width: 980px; margin: 0 auto; padding: 28px;
  background: linear-gradient(180deg, var(--card), var(--sc-lowest));
  border: 1px solid var(--border-lum); border-radius: var(--r-lg);
  display: grid; grid-template-columns: 1fr auto 1fr; gap: 24px; align-items: center;
  text-align: left;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.45);
}
.demo-card .arrow { color: var(--muted); font-size: 26px; }
.demo-in .label-md, .demo-out .label-md { display: block; margin-bottom: 12px; color: var(--on-surface-var); }
.demo-out { display: flex; flex-direction: column; gap: 10px; }
.mini-insight {
  border: 1px solid var(--border-lum); border-radius: var(--r);
  padding: 10px 14px; font-size: 13px; color: var(--on-surface-var);
  background: var(--sc-low);
}
.mini-insight b { display: block; font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--primary); margin-bottom: 3px; }
.mini-insight.q { border-left: 3px solid var(--primary); }

.trust { text-align: center; padding: 56px 24px; border-top: 1px solid var(--border); }
.trust .label-md { color: var(--muted); margin-bottom: 26px; display: block; }
.trust .row { display: flex; flex-wrap: wrap; justify-content: center; gap: 40px; }
.trust .row span {
  font-family: var(--font-display); font-weight: 800; font-size: 17px;
  letter-spacing: 0.06em; color: var(--on-surface-var); opacity: 0.75;
  display: inline-flex; align-items: center; gap: 8px;
}

.features { max-width: 1100px; margin: 0 auto; padding: 70px 24px; }
.features h2 { text-align: center; font-size: 30px; margin-bottom: 10px; }
.features .sub { text-align: center; color: var(--on-surface-var); max-width: 520px; margin: 0 auto 44px; }
.feat-grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: var(--gutter); }
.feat-card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: 30px;
}
.feat-card h3 { font-size: 20px; margin-bottom: 8px; }
.feat-card p { color: var(--on-surface-var); font-size: 15px; }
.feat-card .f-ico {
  width: 44px; height: 44px; border-radius: var(--r-md);
  background: rgba(56, 189, 248, 0.12); color: var(--primary);
  display: flex; align-items: center; justify-content: center; margin-bottom: 18px;
}
.span-7 { grid-column: span 7; } .span-5 { grid-column: span 5; }
.span-4 { grid-column: span 4; } .span-8 { grid-column: span 8; }
.bucket-row { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 22px; }
.bucket {
  border: 1px solid var(--border-lum); background: var(--sc-low);
  border-radius: var(--r); padding: 12px 18px; text-align: center;
  font-size: 13px; font-weight: 600; display: flex; flex-direction: column; gap: 6px; align-items: center;
  color: var(--on-surface-var);
}
.bucket svg { color: var(--primary); }

.pricing { max-width: 1000px; margin: 0 auto; padding: 30px 24px 80px; }
.pricing h2 { text-align: center; font-size: 30px; margin-bottom: 44px; }
.price-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--gutter); }
.price-card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: 30px; display: flex; flex-direction: column; gap: 6px;
}
.price-card.hot { border-color: var(--primary); box-shadow: 0 0 40px var(--primary-glow); position: relative; }
.price-card.hot .flag {
  position: absolute; top: -12px; left: 50%; transform: translateX(-50%);
}
.price-card .p-name { font-family: var(--font-display); font-weight: 700; font-size: 18px; }
.price-card .p-price { font-family: var(--font-display); font-size: 34px; font-weight: 800; }
.price-card .p-price span { font-size: 14px; color: var(--muted); font-weight: 500; }
.price-card ul { list-style: none; margin: 14px 0 22px; display: flex; flex-direction: column; gap: 9px; }
.price-card li { font-size: 14px; color: var(--on-surface-var); display: flex; gap: 9px; align-items: flex-start; }
.price-card li svg { color: var(--success); flex: none; margin-top: 3px; }
.price-card .btn { margin-top: auto; }

.cta-band {
  max-width: 980px; margin: 0 auto 80px; padding: 64px 40px; text-align: center;
  background: linear-gradient(135deg, var(--sc-high), var(--sc-lowest));
  border: 1px solid var(--border-lum); border-radius: var(--r-xl);
}
.cta-band h2 { font-size: clamp(26px, 3.4vw, 38px); max-width: 640px; margin: 0 auto 14px; }
.cta-band p { color: var(--on-surface-var); margin-bottom: 30px; }
.cta-band .row { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; }

.landing-footer {
  border-top: 1px solid var(--border); padding: 34px 48px;
  display: flex; align-items: center; gap: 24px; flex-wrap: wrap;
}
.landing-footer .foot-brand { font-family: var(--font-display); font-weight: 800; font-size: 18px; }
.landing-footer .copy { font-size: 13px; color: var(--muted); }
.landing-footer .spacer { flex: 1; }
.landing-footer .links { display: flex; gap: 22px; }
.landing-footer .links a { color: var(--on-surface-var); font-size: 13px; font-weight: 500; }
.landing-footer .links a:hover { color: var(--on-surface); }

/* ---------- Dashboard ---------- */
.ingest-hero {
  background: linear-gradient(180deg, var(--sc-low), var(--sc-lowest));
  border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: 52px 40px; text-align: center; margin-bottom: 40px;
}
.ingest-hero h1 { font-size: clamp(30px, 4vw, 44px); margin-bottom: 12px; }
.ingest-hero .sub { color: var(--on-surface-var); font-size: 17px; margin-bottom: 32px; }
.ingest-row { display: flex; gap: 14px; max-width: 760px; margin: 0 auto 20px; }
.ingest-row .search-wrap { flex: 1; }
.ingest-row .input { padding: 15px 16px 15px 44px; font-size: 16px; }
.ingest-row .btn { padding: 0 26px; font-size: 16px; }
.ingest-hint { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.ingest-error { color: var(--error); font-size: 14px; margin-top: 12px; min-height: 20px; }

.section-head { display: flex; align-items: center; gap: 10px; margin: 0 0 18px; }
.section-head h2 { font-size: 22px; }
.section-head .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--primary); animation: pulse 1.6s infinite; }
.section-head .spacer { flex: 1; }
.section-head a, .section-head .linklike { font-size: 14px; font-weight: 600; color: var(--primary); }

.jobs-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(380px, 1fr)); gap: var(--gutter); margin-bottom: 44px; }
.job-card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: 22px;
}
.job-head { display: flex; gap: 14px; align-items: flex-start; }
.job-ico {
  width: 46px; height: 46px; border-radius: var(--r-md); flex: none;
  background: var(--sc-highest); color: var(--primary);
  display: flex; align-items: center; justify-content: center;
}
.job-title { font-weight: 700; font-family: var(--font-display); font-size: 16px; }
.job-sub { font-size: 13px; color: var(--on-surface-var); margin-top: 2px; }
.job-pct { margin-left: auto; font-family: var(--font-display); font-weight: 800; color: var(--primary); font-size: 17px; }
.progress { height: 8px; border-radius: 6px; background: var(--sc-highest); margin: 18px 0 14px; overflow: hidden; }
.progress > div { height: 100%; border-radius: 6px; background: linear-gradient(90deg, var(--primary-dim), var(--primary)); transition: width 0.4s ease; }
.job-foot { display: flex; align-items: center; gap: 10px; }
.stage-chip { font-size: 12px; font-weight: 600; color: var(--muted); padding: 4px 10px; border-radius: var(--r-sm); }
.stage-chip.on { color: var(--primary); background: rgba(56, 189, 248, 0.12); border: 1px solid rgba(56, 189, 248, 0.3); }
.stage-chip.done { color: var(--success); }
.job-foot .spacer { flex: 1; }

.empty-state {
  border: 1px dashed var(--border-lum); border-radius: var(--r-lg);
  padding: 34px; text-align: center; color: var(--muted); font-size: 15px;
  margin-bottom: 44px;
}

/* ---------- Episode cards ---------- */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: var(--gutter); }
.ep-card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--r-lg);
  overflow: hidden; cursor: pointer; position: relative;
  transition: border-color 0.15s, transform 0.15s, box-shadow 0.2s;
  display: flex; flex-direction: column;
}
.ep-card:hover { border-color: var(--border-lum); transform: translateY(-3px); box-shadow: 0 18px 40px rgba(0, 0, 0, 0.4); }
.ep-cover { height: 158px; position: relative; display: flex; align-items: flex-end; padding: 14px; }
.ep-cover .status { position: absolute; top: 12px; right: 12px; }
.ep-cover .guest-chip {
  display: flex; align-items: center; gap: 9px;
  background: rgba(2, 6, 23, 0.55); backdrop-filter: blur(6px);
  padding: 5px 12px 5px 5px; border-radius: var(--r-full);
  font-size: 13px; font-weight: 600;
}
.g-ava {
  width: 26px; height: 26px; border-radius: 50%; flex: none;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; color: #fff;
}
.ep-body { padding: 18px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.ep-body h3 { font-size: 17px; line-height: 1.35; font-weight: 700; }
.ep-meta { display: flex; align-items: center; gap: 14px; margin-top: auto; padding-top: 10px; color: var(--on-surface-var); font-size: 13px; }
.ep-meta .m { display: inline-flex; align-items: center; gap: 5px; }
.ep-meta .spacer { flex: 1; }
.ep-topics { display: flex; gap: 8px; flex-wrap: wrap; }

/* list view */
.ep-list { display: flex; flex-direction: column; gap: 10px; }
.ep-row {
  display: flex; align-items: center; gap: 16px;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--r-md);
  padding: 12px 18px; cursor: pointer; transition: border-color 0.15s, background 0.15s;
}
.ep-row:hover { border-color: var(--border-lum); background: var(--sc-low); }
.ep-row .cover-mini { width: 52px; height: 52px; border-radius: var(--r); flex: none; }
.ep-row .r-main { flex: 1; min-width: 0; }
.ep-row h3 { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ep-row .r-sub { font-size: 13px; color: var(--on-surface-var); }
.ep-row .ep-meta { padding: 0; margin: 0; flex: none; }

.kebab-menu {
  position: absolute; z-index: 90; min-width: 190px;
  background: rgba(21, 32, 49, 0.95); backdrop-filter: blur(12px);
  border: 1px solid var(--border-lum); border-radius: var(--r-md);
  box-shadow: 0 16px 44px rgba(0, 0, 0, 0.5); padding: 6px; overflow: hidden;
}
.kebab-menu button {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 9px 12px; font-size: 14px; border-radius: var(--r-sm);
  color: var(--on-surface);
}
.kebab-menu button:hover { background: var(--sc-highest); }
.kebab-menu button.danger { color: var(--error); }

/* ---------- Library toolbar ---------- */
.lib-toolbar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 24px; }
.lib-toolbar .search-wrap { flex: 1; min-width: 240px; }
.lib-toolbar select.input { width: auto; padding-right: 34px; }
.view-toggle { display: flex; border: 1px solid var(--border-lum); border-radius: var(--r); overflow: hidden; }
.view-toggle button { padding: 9px 12px; color: var(--muted); display: flex; }
.view-toggle button.on { background: var(--sc-highest); color: var(--primary); }
.lib-sub { display: flex; align-items: baseline; gap: 12px; margin-bottom: 22px; }
.lib-sub p { color: var(--on-surface-var); font-size: 15px; }
.lib-sub .total { margin-left: auto; font-size: 13px; color: var(--muted); }
.load-more-wrap { display: flex; justify-content: center; padding: 30px 0 10px; }

/* ---------- Episode detail ---------- */
.ep-layout { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(320px, 0.85fr); gap: var(--gutter); align-items: start; }
.ep-header {
  border: 1px solid var(--border); border-radius: var(--r-lg); overflow: hidden;
  margin-bottom: var(--gutter);
}
.ep-header .hd-cover { padding: 34px 30px; position: relative; }
.ep-header h1 { font-size: clamp(26px, 3vw, 38px); line-height: 1.15; max-width: 640px; }
.ep-header .hd-sub { margin-top: 12px; font-size: 16px; color: var(--on-surface); font-weight: 600; }
.ep-header .hd-meta { display: flex; gap: 10px; align-items: center; margin-bottom: 18px; flex-wrap: wrap; }
.ep-header .id-tag { font-size: 12px; color: var(--on-surface-var); font-family: ui-monospace, monospace; }
.hd-actions { position: absolute; top: 22px; right: 22px; display: flex; gap: 8px; }
.hd-actions .icon-btn { background: rgba(2, 6, 23, 0.5); backdrop-filter: blur(6px); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 22px; overflow-x: auto; }
.tab {
  padding: 11px 16px; font-size: 14px; font-weight: 600; color: var(--on-surface-var);
  border-bottom: 2px solid transparent; white-space: nowrap;
}
.tab:hover { color: var(--on-surface); }
.tab.on { color: var(--primary); border-bottom-color: var(--primary); }
.tab .n { font-size: 12px; color: var(--muted); margin-left: 5px; }

.insight-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.insight-card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--r-md);
  padding: 18px; position: relative; transition: border-color 0.15s;
}
.insight-card:hover { border-color: var(--border-lum); }
.insight-card.quote { border-left: 3px solid var(--primary); }
.insight-card.framework {
  background-image:
    linear-gradient(rgba(56, 189, 248, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(56, 189, 248, 0.035) 1px, transparent 1px);
  background-size: 18px 18px;
}
.insight-card .i-type { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.insight-card .i-ts { font-size: 12px; color: var(--muted); font-family: ui-monospace, monospace; cursor: pointer; }
.insight-card .i-ts:hover { color: var(--primary); }
.insight-card h4 { font-size: 16px; margin-bottom: 6px; font-weight: 700; }
.insight-card p { font-size: 14px; color: var(--on-surface-var); }
.insight-card.quote p { font-size: 16px; color: var(--on-surface); font-style: italic; }
.insight-card ol { padding-left: 20px; margin-top: 8px; display: flex; flex-direction: column; gap: 5px; font-size: 14px; color: var(--on-surface-var); }

/* right column panel */
.panel {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--r-lg);
  display: flex; flex-direction: column; overflow: hidden;
}
.panel-head {
  display: flex; align-items: center; gap: 10px;
  padding: 16px 18px; border-bottom: 1px solid var(--border);
}
.panel-head h3 { font-size: 18px; }
.panel-head .spacer { flex: 1; }
.transcript-panel { max-height: 640px; }
.transcript-search { padding: 12px 16px; border-bottom: 1px solid var(--border); }
.transcript-body { overflow-y: auto; padding: 6px 8px 14px; }
.tr-seg { padding: 12px 12px; border-radius: var(--r-md); border: 1px solid transparent; cursor: pointer; }
.tr-seg:hover { background: var(--sc-low); }
.tr-seg.hl { background: rgba(56, 189, 248, 0.08); border-color: rgba(56, 189, 248, 0.4); }
.tr-seg .s-head { display: flex; gap: 10px; align-items: baseline; margin-bottom: 4px; }
.tr-seg .s-time { font-family: ui-monospace, monospace; font-size: 12px; color: var(--primary); }
.tr-seg .s-speaker { font-size: 12px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--on-surface-var); }
.tr-seg p { font-size: 14.5px; color: var(--on-surface); }
.tr-seg mark { background: rgba(251, 191, 36, 0.35); color: inherit; border-radius: 2px; }
.tr-empty { padding: 24px; color: var(--muted); font-size: 14px; text-align: center; }

/* ---------- Chat ---------- */
.chat-panel { min-height: 520px; max-height: 640px; }
.chat-page-panel { height: calc(100vh - 68px - var(--player-h) - 64px); max-height: none; min-height: 480px; }
.chat-head-chips { display: flex; gap: 8px; flex-wrap: wrap; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.chip-btn {
  padding: 7px 14px; border-radius: var(--r-full); font-size: 13px; font-weight: 600;
  background: var(--sc-high); color: var(--on-surface); border: 1px solid var(--border-lum);
  transition: background 0.15s, border-color 0.15s;
}
.chip-btn:hover { border-color: var(--primary); color: var(--primary); }
.chat-body { flex: 1; overflow-y: auto; padding: 20px 18px; display: flex; flex-direction: column; gap: 4px; }
.msg { max-width: 88%; margin-bottom: 12px; }
.msg .bubble {
  padding: 13px 16px; border-radius: var(--r-md); font-size: 14.5px; line-height: 1.55;
}
.msg.ai { align-self: flex-start; }
.msg.ai .bubble { background: var(--sc-high); border: 1px solid var(--border); border-top-left-radius: var(--r-sm); }
.msg.me { align-self: flex-end; }
.msg.me .bubble { background: var(--primary); color: var(--on-primary); font-weight: 500; border-top-right-radius: var(--r-sm); }
.msg .who { font-size: 12px; color: var(--muted); margin-top: 5px; }
.msg.me .who { text-align: right; }
.msg .bubble ul { padding-left: 18px; margin: 8px 0; display: flex; flex-direction: column; gap: 5px; }
.msg .bubble .cite {
  display: inline-flex; align-items: center; gap: 6px; margin-top: 10px;
  font-size: 13px; font-weight: 600; color: var(--primary); cursor: pointer;
}
.msg .bubble .cite:hover { text-decoration: underline; }
.msg .bubble .src-pill {
  display: inline-block; margin: 2px 4px 2px 0; padding: 2px 10px;
  background: rgba(56, 189, 248, 0.1); border: 1px solid rgba(56, 189, 248, 0.3);
  border-radius: var(--r-full); font-size: 12px; color: var(--primary); cursor: pointer;
}
.typing { display: inline-flex; gap: 5px; padding: 6px 2px; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: bounce 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: 0.15s; }
.typing i:nth-child(3) { animation-delay: 0.3s; }
@keyframes bounce { 0%, 60%, 100% { transform: translateY(0); opacity: 0.5; } 30% { transform: translateY(-5px); opacity: 1; } }

.chat-input-row { display: flex; gap: 10px; padding: 14px 16px; border-top: 1px solid var(--border); }
.chat-input-row .input { flex: 1; resize: none; max-height: 120px; }
.chat-input-row .btn { padding: 0 18px; }

.chat-layout { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(300px, 0.8fr); gap: var(--gutter); align-items: stretch; }

/* ---------- Player ---------- */
.player {
  position: fixed; left: var(--sidebar-w); right: 0; bottom: 0; height: var(--player-h);
  background: rgba(4, 14, 31, 0.92); backdrop-filter: blur(14px);
  border-top: 1px solid var(--border);
  display: flex; align-items: center; gap: 20px; padding: 0 28px;
  z-index: 60;
}
.player .p-cover { width: 52px; height: 52px; border-radius: var(--r); flex: none; }
.player .p-info { width: 220px; min-width: 0; }
.player .p-title { font-size: 14px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player .p-sub { font-size: 12px; color: var(--on-surface-var); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player .p-center { flex: 1; display: flex; flex-direction: column; gap: 6px; align-items: center; }
.player .p-controls { display: flex; align-items: center; gap: 14px; }
.play-btn {
  width: 44px; height: 44px; border-radius: 50%; background: #fff; color: #04121f;
  display: flex; align-items: center; justify-content: center;
  transition: transform 0.1s;
}
.play-btn:hover { transform: scale(1.06); }
.p-track { display: flex; align-items: center; gap: 10px; width: 100%; max-width: 560px; }
.p-time { font-size: 12px; color: var(--on-surface-var); font-family: ui-monospace, monospace; flex: none; }
.seek { flex: 1; height: 5px; background: var(--sc-highest); border-radius: 4px; cursor: pointer; position: relative; }
.seek > div { position: absolute; inset: 0 auto 0 0; background: var(--primary); border-radius: 4px; }
.speed-btn {
  font-size: 12px; font-weight: 700; padding: 5px 10px; border-radius: var(--r-sm);
  background: var(--sc-highest); color: var(--on-surface);
}
.player .p-right { display: flex; align-items: center; gap: 10px; }
.player.hidden-player { display: none; }

/* ---------- History ---------- */
.timeline { display: flex; flex-direction: column; }
.tl-item { display: flex; gap: 16px; padding: 0 0 26px; position: relative; }
.tl-item::before {
  content: ''; position: absolute; left: 17px; top: 38px; bottom: 0;
  width: 2px; background: var(--border);
}
.tl-item:last-child::before { display: none; }
.tl-ico {
  width: 36px; height: 36px; border-radius: 50%; flex: none; z-index: 1;
  background: var(--sc-highest); border: 1px solid var(--border-lum);
  display: flex; align-items: center; justify-content: center; color: var(--primary);
}
.tl-body { padding-top: 5px; font-size: 15px; }
.tl-body .t { font-size: 13px; color: var(--muted); margin-top: 2px; }

/* ---------- Settings ---------- */
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--gutter); max-width: 900px; }
.set-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 26px; }
.set-card h3 { font-size: 18px; margin-bottom: 4px; }
.set-card .desc { font-size: 14px; color: var(--on-surface-var); margin-bottom: 18px; }
.set-row { display: flex; align-items: center; justify-content: space-between; padding: 12px 0; border-top: 1px solid var(--border); }
.set-row:first-of-type { border-top: none; }
.set-row .s-label { font-size: 15px; font-weight: 500; }
.set-row .s-sub { font-size: 13px; color: var(--muted); }
.toggle {
  width: 44px; height: 24px; border-radius: 20px; background: var(--sc-highest);
  position: relative; transition: background 0.2s; flex: none;
}
.toggle::after {
  content: ''; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px;
  border-radius: 50%; background: var(--on-surface-var); transition: left 0.2s, background 0.2s;
}
.toggle.on { background: var(--primary); }
.toggle.on::after { left: 23px; background: #04121f; }
.field-label { font-size: 13px; font-weight: 600; color: var(--on-surface-var); margin: 14px 0 6px; display: block; }

/* ---------- Workspaces ---------- */
.ws-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: var(--gutter); }
.ws-card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: 24px; cursor: pointer; transition: border-color 0.15s, transform 0.15s;
}
.ws-card:hover { border-color: var(--border-lum); transform: translateY(-2px); }
.ws-card .ws-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.ws-card h3 { font-size: 18px; }
.ws-card p { font-size: 14px; color: var(--on-surface-var); }
.ws-card .ws-count { margin-top: 16px; font-size: 13px; color: var(--muted); }
.ws-new { border-style: dashed; border-color: var(--border-lum); display: flex; align-items: center; justify-content: center; gap: 10px; color: var(--muted); min-height: 150px; }
.ws-new:hover { color: var(--primary); border-color: var(--primary); }

/* ---------- Modal ---------- */
.modal-back {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(2, 6, 23, 0.7); backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
.modal {
  width: 100%; max-width: 460px;
  background: rgba(21, 32, 49, 0.95); backdrop-filter: blur(12px);
  border: 1px solid var(--border-lum); border-radius: var(--r-lg);
  padding: 28px; box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
}
.modal h3 { font-size: 20px; margin-bottom: 8px; }
.modal p { font-size: 14.5px; color: var(--on-surface-var); }
.modal .m-actions { display: flex; justify-content: flex-end; gap: 12px; margin-top: 26px; }

/* ---------- Toasts ---------- */
#toasts {
  position: fixed; bottom: calc(var(--player-h) + 18px); right: 24px; z-index: 300;
  display: flex; flex-direction: column; gap: 10px;
}
.toast {
  display: flex; align-items: center; gap: 12px;
  background: rgba(21, 32, 49, 0.95); backdrop-filter: blur(12px);
  border: 1px solid var(--border-lum); border-radius: var(--r-md);
  padding: 13px 18px; font-size: 14px; min-width: 280px; max-width: 380px;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.5);
  animation: toast-in 0.25s ease;
}
.toast.ok { border-left: 3px solid var(--success); }
.toast.err { border-left: 3px solid var(--error); }
.toast.info { border-left: 3px solid var(--primary); }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.toast.out { opacity: 0; transform: translateY(8px); transition: 0.25s; }

/* ---------- Page transitions ---------- */
.view-enter { animation: view-in 0.25s ease; }
@keyframes view-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- Responsive ---------- */
@media (max-width: 1180px) {
  .ep-layout, .chat-layout { grid-template-columns: 1fr; }
  .insight-grid { grid-template-columns: 1fr; }
}
@media (max-width: 1024px) {
  .feat-grid .span-7, .feat-grid .span-5, .feat-grid .span-4, .feat-grid .span-8 { grid-column: span 12; }
  .price-grid { grid-template-columns: 1fr; }
  .settings-grid { grid-template-columns: 1fr; }
  .demo-card { grid-template-columns: 1fr; }
  .demo-card .arrow { transform: rotate(90deg); text-align: center; }
}
@media (max-width: 900px) {
  .sidebar { display: none; }
  .player { left: 0; }
  .topbar { padding: 0 16px; }
  .topbar .search-wrap { display: none; }
  .content { padding: 20px 16px calc(var(--player-h) + 24px); }
  .mobile-nav-btn { display: inline-flex !important; }
  .jobs-grid { grid-template-columns: 1fr; }
}
.mobile-nav-btn { display: none; }

/* mobile drawer reuses sidebar */
.sidebar.drawer {
  display: flex; position: fixed; inset: 0 auto 0 0; z-index: 250;
  box-shadow: 30px 0 80px rgba(0, 0, 0, 0.6);
}
.drawer-back { position: fixed; inset: 0; background: rgba(2, 6, 23, 0.6); z-index: 240; }

/* ============================================================
   Etched — API-backed UI components
   ============================================================ */

/* ---------- Auth ---------- */
.auth-wrap {
  min-height: 100%; display: flex; align-items: center; justify-content: center;
  padding: 40px 20px;
  background:
    radial-gradient(900px 420px at 50% 0%, rgba(56,189,248,.08), transparent 60%),
    var(--bg);
}
.auth-card {
  width: 100%; max-width: 420px; padding: 34px;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--r-lg);
  box-shadow: 0 30px 80px rgba(0,0,0,.45);
}
.auth-card h2 { font-size: 24px; margin-bottom: 6px; text-align: center; }
.auth-sub { color: var(--on-surface-var); font-size: 14px; text-align: center; margin-bottom: 22px; }
.auth-error { color: var(--error); font-size: 13px; min-height: 18px; margin-top: 10px; }
.auth-switch { margin-top: 18px; text-align: center; font-size: 14px; color: var(--on-surface-var); }
.auth-switch a { margin-left: 6px; font-weight: 600; }

/* ---------- Stat cards ---------- */
.stat-row {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px; margin-bottom: 36px;
}
.stat-card {
  display: flex; align-items: center; gap: 14px; padding: 18px 20px;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--r-md);
}
.stat-card .s-ico {
  width: 40px; height: 40px; border-radius: var(--r); flex: none;
  background: rgba(56,189,248,.12); color: var(--primary);
  display: flex; align-items: center; justify-content: center;
}
.stat-card .s-value { font-family: var(--font-display); font-size: 24px; font-weight: 800; line-height: 1.1; }
.stat-card .s-label { font-size: 13px; color: var(--on-surface-var); }

/* ---------- Notices ---------- */
.notice {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 14px 16px; border-radius: var(--r-md); font-size: 14px;
  background: rgba(56,189,248,.07); border: 1px solid rgba(56,189,248,.25);
  color: var(--on-surface); line-height: 1.5;
}
.notice svg { flex: none; color: var(--primary); margin-top: 2px; }
.notice.warn { background: rgba(251,191,36,.07); border-color: rgba(251,191,36,.3); }
.notice.warn svg { color: var(--warning); }

/* ---------- Resolve preview ---------- */
.resolve-card {
  max-width: 760px; margin: 18px auto 0; padding: 16px 18px; text-align: center;
  background: var(--sc-low); border: 1px solid var(--border-lum); border-radius: var(--r-md);
  font-size: 14px; color: var(--on-surface-var);
}

/* ---------- Evidence blocks ---------- */
.evidence {
  margin-top: 12px; padding: 11px 13px; border-radius: var(--r);
  background: var(--sc-lowest); border-left: 3px solid var(--primary);
}
.evidence .ev-label {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase;
  color: var(--primary); margin-bottom: 5px;
}
.evidence p { font-size: 13.5px; color: var(--on-surface); font-style: italic; }
/* A derived link is context, never a quotation — visually distinct, not italic. */
.evidence.derived { border-left-color: var(--muted); }
.evidence.derived .ev-label { color: var(--muted); }
.evidence.derived p { font-style: normal; color: var(--on-surface-var); }

/* ---------- Answer meta ---------- */
.answer-meta {
  margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--border);
  font-size: 12px; color: var(--muted); display: flex; align-items: center;
  gap: 6px; flex-wrap: wrap;
}
.answer-meta svg { vertical-align: -2px; }
.msg .bubble .cite {
  display: inline-block; margin: 0 3px; padding: 1px 8px;
  background: rgba(56,189,248,.12); border: 1px solid rgba(56,189,248,.35);
  border-radius: var(--r-full); font-size: 12px; font-weight: 600;
  color: var(--primary); cursor: pointer; font-family: ui-monospace, monospace;
}
.msg .bubble .cite:hover { background: rgba(56,189,248,.25); }

/* ---------- Tokens / code ---------- */
.token-box {
  display: flex; align-items: center; gap: 10px; margin-top: 10px;
  padding: 10px 12px; background: var(--sc-lowest);
  border: 1px solid var(--border-lum); border-radius: var(--r);
}
.token-box code {
  flex: 1; min-width: 0; overflow-x: auto; white-space: nowrap;
  font-family: ui-monospace, monospace; font-size: 12.5px; color: var(--primary);
}
.code-block {
  margin-top: 12px; padding: 14px 16px; overflow-x: auto;
  background: var(--sc-lowest); border: 1px solid var(--border);
  border-radius: var(--r); font-family: ui-monospace, monospace;
  font-size: 12.5px; line-height: 1.6; color: var(--on-surface-var);
}
code { font-family: ui-monospace, monospace; font-size: .92em; color: var(--primary); }
.scope-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 11px; border-radius: var(--r-full); cursor: pointer;
  background: var(--sc-high); border: 1px solid var(--border-lum);
  font-size: 12.5px; font-weight: 500;
}
.scope-chip input { accent-color: var(--primary); cursor: pointer; }

/* ---------- Misc ---------- */
.ws-card .ws-head { flex-wrap: wrap; }
.content.no-player { padding-bottom: 48px; }
.tabs .tab .n { opacity: .7; }

/* ---------- Model answer formatting ---------- */
.msg .bubble .ans-h {
  font-family: var(--font-display); font-weight: 700; font-size: 15px;
  margin: 14px 0 6px; color: var(--on-surface);
}
.msg .bubble .ans-h:first-child { margin-top: 0; }
.msg .bubble p { margin: 0 0 9px; }
.msg .bubble p:last-child { margin-bottom: 0; }
.msg .bubble ul { padding-left: 20px; margin: 6px 0 10px; }
.msg .bubble li { margin-bottom: 5px; }

/* ---------- Studio ---------- */
.tpl-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; }
.tpl-chip {
  display: flex; align-items: flex-start; gap: 10px; cursor: pointer;
  padding: 12px 14px; border-radius: var(--r); background: var(--sc-low);
  border: 1px solid var(--border-lum); transition: border-color .15s, background .15s;
}
.tpl-chip:hover { border-color: var(--primary); }
.tpl-chip input { accent-color: var(--primary); margin-top: 3px; cursor: pointer; }
.tpl-chip b { display: block; font-size: 14px; }
.tpl-chip small { display: block; font-size: 12px; color: var(--muted); margin-top: 2px; line-height: 1.4; }

.doc-body {
  margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--border);
  font-size: 15px; line-height: 1.65;
}
.doc-body .ans-h {
  font-family: var(--font-display); font-weight: 700; font-size: 17px;
  margin: 20px 0 8px; color: var(--on-surface);
}
.doc-body .ans-h:first-child { margin-top: 0; }
.doc-body p { margin: 0 0 11px; color: var(--on-surface-var); }
.doc-body ul, .doc-body ol { padding-left: 22px; margin: 8px 0 14px; color: var(--on-surface-var); }
.doc-body li { margin-bottom: 6px; }
.doc-body sup.cite {
  display: inline-block; padding: 0 5px; margin-left: 2px;
  background: rgba(56,189,248,.14); border-radius: var(--r-sm);
  color: var(--primary); font-size: 11px; font-weight: 700; cursor: help;
}
.doc-sources {
  margin-top: 20px; padding-top: 14px; border-top: 1px solid var(--border);
  font-size: 13px; color: var(--muted);
}
.doc-sources ol { margin-top: 8px; padding-left: 20px; }

/* ---------- Share cards ---------- */
.card-actions {
  margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--border);
  display: flex; gap: 8px;
}
.card-actions .chip-btn { padding: 5px 11px; font-size: 12px; }
.card-preview {
  margin-top: 16px; border-radius: var(--r-md); overflow: hidden;
  border: 1px solid var(--border-lum); background: var(--sc-lowest);
  display: flex; align-items: center; justify-content: center; padding: 14px;
}
.card-preview img { max-width: 100%; max-height: 420px; display: block; }

/* ---------- Audio player ---------- */
body.has-player .content { padding-bottom: 108px; }
.player-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 120;
  display: flex; align-items: center; gap: 18px;
  padding: 12px 22px;
  background: rgba(15, 23, 42, .97); backdrop-filter: blur(14px);
  border-top: 1px solid var(--border-lum);
  box-shadow: 0 -8px 30px rgba(0,0,0,.4);
}
.player-bar .p-meta { width: 240px; min-width: 0; }
.player-bar .p-title {
  font-size: 14px; font-weight: 600; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
.player-bar .p-show { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player-bar .p-error { font-size: 11px; color: var(--error); }
.player-bar .p-controls { display: flex; align-items: center; gap: 6px; }
.play-btn {
  width: 42px; height: 42px; border-radius: 50%; flex: none;
  background: var(--primary); color: var(--on-primary);
  display: flex; align-items: center; justify-content: center;
  transition: transform .12s, background .15s;
}
.play-btn:hover { background: #5cc9fa; transform: scale(1.05); }
.player-bar .p-track { flex: 1; display: flex; align-items: center; gap: 12px; min-width: 120px; }
.player-bar .p-time { font-size: 12px; color: var(--muted); font-family: ui-monospace, monospace; flex: none; }
.player-bar .p-seek {
  flex: 1; height: 6px; border-radius: 4px; background: var(--sc-highest);
  cursor: pointer; position: relative; overflow: hidden;
}
.player-bar .p-seek:hover { height: 8px; }
.player-bar .p-fill { height: 100%; background: var(--primary); border-radius: 4px; width: 0; }
.speed-btn {
  font-size: 12px; font-weight: 700; padding: 6px 11px; border-radius: var(--r-sm);
  background: var(--sc-highest); color: var(--on-surface); flex: none;
}
.speed-btn:hover { background: var(--border-lum); }

.tr-seg { cursor: pointer; }
.tr-seg.playing {
  background: rgba(56,189,248,.13);
  border-color: rgba(56,189,248,.45);
  box-shadow: inset 3px 0 0 var(--primary);
}

@media (max-width: 900px) {
  .player-bar { gap: 10px; padding: 10px 12px; }
  .player-bar .p-meta { width: 120px; }
  .player-bar .speed-btn { display: none; }
}

/* ---------- Quota meters ---------- */
.quota-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.quota-item { padding: 14px 16px; background: var(--card); border: 1px solid var(--border); border-radius: var(--r-md); }
.quota-item .q-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
.quota-item .q-label { font-size: 13px; color: var(--on-surface-var); }
.quota-item .q-value { font-size: 13px; font-weight: 700; }
.quota-bar { height: 6px; border-radius: 4px; background: var(--sc-highest); overflow: hidden; }
.quota-bar > div { height: 100%; border-radius: 4px; background: var(--primary); transition: width .3s; }
.quota-bar.warn > div { background: var(--warning); }
.quota-bar.full > div { background: var(--error); }

/* ---------- Review queue ---------- */
.review-actions {
  display: flex; align-items: center; gap: 10px; margin-bottom: 16px;
  padding: 12px 16px; background: var(--card);
  border: 1px solid var(--border); border-radius: var(--r-md);
  position: sticky; top: 0; z-index: 20;
}
.review-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--r-md); padding: 18px; margin-bottom: 14px;
  transition: opacity .25s, border-color .2s;
}
.review-card.reviewed { opacity: .45; border-color: var(--border-lum); }
.review-card .rv-head {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px;
}
.review-card h4 { font-size: 16px; margin-bottom: 6px; }
.review-card p { font-size: 14px; color: var(--on-surface-var); }
.review-card ol { padding-left: 20px; margin-top: 8px; font-size: 14px; color: var(--on-surface-var); }
.review-card ol li { margin-bottom: 4px; }
.review-card .rv-foot {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border);
}
.review-card .rv-foot .btn { padding: 7px 16px; font-size: 14px; }

/* ---------- Onboarding starter ---------- */
.starter { margin-bottom: 40px; }
.starter-head { text-align: center; max-width: 620px; margin: 0 auto 26px; }
.starter-head h2 { font-size: 24px; margin-bottom: 8px; }
.starter-head p { color: var(--on-surface-var); font-size: 15px; }
.starter-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px;
}
.starter-card {
  text-align: left; padding: 16px; border-radius: var(--r-md);
  background: var(--card); border: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 10px;
  transition: border-color .15s, transform .15s, opacity .2s;
}
.starter-card:hover:not(:disabled) { border-color: var(--primary); transform: translateY(-2px); }
.starter-card:disabled { opacity: .5; cursor: wait; }
.starter-card.picking { border-color: var(--primary); }
.starter-card .sc-top { display: flex; align-items: center; gap: 11px; }
.starter-card .sc-name b { display: block; font-size: 15px; }
.starter-card .sc-name span { font-size: 12px; color: var(--muted); }
.starter-card p { font-size: 13px; color: var(--on-surface-var); flex: 1; }
.starter-card .sc-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding-top: 8px; border-top: 1px solid var(--border);
}
.starter-card .sc-speed { font-size: 12px; color: var(--muted); }
.starter-note {
  display: flex; gap: 10px; align-items: flex-start; margin-top: 18px;
  font-size: 13px; color: var(--muted); line-height: 1.5;
}
.starter-note svg { flex: none; margin-top: 2px; color: var(--primary); }

/* ---------- Deletion modal ---------- */
.del-list { margin: 8px 0 0 20px; font-size: 14px; color: var(--on-surface-var); }
.del-list li { margin-bottom: 4px; }

/* ---------- Admin dashboard ---------- */
.admin-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }
.spark { margin-bottom: 16px; }
.spark:last-child { margin-bottom: 0; }
.spark-head {
  display: flex; justify-content: space-between; align-items: baseline;
  font-size: 13px; color: var(--on-surface-var); margin-bottom: 6px;
}
.spark-head b { font-size: 15px; color: var(--on-surface); }
.spark-svg {
  width: 100%; height: 34px; display: block;
  background: var(--sc-lowest); border-radius: var(--r-sm); padding: 3px 0;
}
.funnel-row { margin-bottom: 14px; }
.funnel-row:last-child { margin-bottom: 0; }
.funnel-row .fn-head {
  display: flex; justify-content: space-between; align-items: baseline;
  font-size: 13px; color: var(--on-surface-var); margin-bottom: 6px;
}
.funnel-row .fn-head b { color: var(--on-surface); font-size: 14px; }
.funnel-row .fn-rate { color: var(--primary); font-size: 12px; font-weight: 600; }
.mini-table { margin-top: 10px; }
.mt-row {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 7px 0; border-bottom: 1px solid var(--border); font-size: 13.5px;
}
.mt-row:last-child { border-bottom: none; }
.mt-row span {
  color: var(--on-surface-var); overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.mt-row b { color: var(--on-surface); flex: none; }

/* ---------- Legal pages ---------- */
.legal-body { max-width: 760px; font-size: 15px; line-height: 1.7; }
.legal-body .ans-h {
  font-family: var(--font-display); font-weight: 700; font-size: 18px;
  margin: 28px 0 10px; color: var(--on-surface);
}
.legal-body .ans-h:first-child { margin-top: 0; }
.legal-body p { margin: 0 0 12px; color: var(--on-surface-var); }
.legal-body ul, .legal-body ol { padding-left: 22px; margin: 8px 0 14px; color: var(--on-surface-var); }
.legal-body li { margin-bottom: 6px; }
.legal-body b { color: var(--on-surface); }

/* ---------------- Task lists, code, diagrams ---------------- */

ul.task-list { list-style: none; padding-left: 2px; margin: 8px 0 14px; }
ul.task-list li.task { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 8px; }
.task-box {
  flex: 0 0 auto; width: 17px; height: 17px; margin-top: 2px;
  border: 1.5px solid var(--border-lum); border-radius: 5px;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; line-height: 1; color: var(--surface);
}
li.task.is-done .task-box { background: var(--success); border-color: var(--success); }
li.task.is-done > span:last-child { color: var(--on-surface-var); text-decoration: line-through; }

pre.code-block {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-md); padding: 14px 16px; margin: 12px 0 16px;
  overflow-x: auto; font-size: 13px; line-height: 1.55;
}
pre.code-block code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--on-surface-var); }

.mmd {
  margin: 16px 0 20px; padding: 0; border: 1px solid var(--border);
  border-radius: var(--r-lg); background: var(--surface); overflow: hidden;
}
.mmd-render { padding: 20px 16px; overflow-x: auto; text-align: center; min-height: 60px; }
.mmd-render svg { max-width: 100%; height: auto; }
.mmd-loading, .mmd-error { color: var(--on-surface-var); font-size: 13px; padding: 12px 0; }
.mmd-error { color: var(--warning); }
.mmd-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 14px; border-top: 1px solid var(--border); flex-wrap: wrap;
}
.mmd-src { flex: 1; min-width: 180px; }
.mmd-src summary { cursor: pointer; font-size: 12px; color: var(--on-surface-var); }
.mmd-src pre {
  margin: 10px 0 2px; padding: 12px; background: var(--card);
  border: 1px solid var(--border); border-radius: var(--r-md);
  overflow-x: auto; font-size: 12px; line-height: 1.5;
}
.mmd-src code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--on-surface-var); white-space: pre; }
.mmd-copy { flex: 0 0 auto; }

/* ---------------- Playable insight cards ---------------- */

/* The card is the affordance: there is no detail page behind an insight, so a
   click plays the moment it came from. */
.insight-card.is-playable { cursor: pointer; transition: border-color .15s, transform .15s, box-shadow .15s; }
.insight-card.is-playable:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(2, 6, 23, 0.5);
}
.insight-card.is-playable:focus-visible {
  outline: 2px solid var(--primary); outline-offset: 2px;
}
.insight-card.is-playable .i-ts {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 8px; border-radius: var(--r-full);
  border: 1px solid var(--border-lum); color: var(--on-surface-var);
}
.insight-card.is-playable:hover .i-ts {
  border-color: var(--primary); color: var(--primary); background: var(--primary-glow);
}
/* Buttons inside the card keep their own cursor and stop the card's click. */
.insight-card.is-playable .card-actions { cursor: default; }

.scope-bar {
  display: flex; align-items: center; gap: 9px; flex-wrap: wrap;
  padding: 10px 18px; font-size: 13px;
  color: var(--on-surface-var);
  background: var(--primary-glow);
  border-bottom: 1px solid var(--border);
}
.scope-bar b { color: var(--on-surface); }
.scope-bar .spacer { flex: 1; }
.scope-bar a { color: var(--primary); text-decoration: none; white-space: nowrap; }
.scope-bar a:hover { text-decoration: underline; }
