/* ======================================================================
   /try interactive demo - v3 design pass
   ----------------------------------------------------------------------
   - Page header (DEMO tag chip, display H1, subhead, inline CTA).
   - Single rounded demo card (radius 18-20, soft hairline border, soft
     shadow).
   - Left rail: sticky filter block + scrollable question cards with the
     "category dot, difficulty badge, two-line text, play icon" layout.
   - Right stage: sticky toolbar with mini avatar + icon buttons; empty
     state hero; active state with constrained 96 px avatar (64 px on
     mobile), gradient backplate, audio progress strip, textarea, action
     footer; critique card with score + sections.
   - Dark mode via prefers-color-scheme.
   - prefers-reduced-motion respected.
   - Mobile <980 px collapses to list-OR-stage two-view toggle inside
     the same card.
   ====================================================================== */

:root {
  /* ===== Brand tokens (mirror copilotinterview.com homepage) ===== */
  --green: #00E5A0;
  --green-deep: #00B582;
  --green-soft: rgba(0, 229, 160, 0.12);
  --green-line: rgba(0, 229, 160, 0.40);
  --purple: #7C5CFC;
  --purple-soft: rgba(124, 92, 252, 0.10);

  /* ===== Surfaces / text ===== */
  --bg: #FFFFFF;
  --bg-page: #F7F9FC;
  --bg-soft: #F8FAFC;
  --bg-card: #FFFFFF;
  --text: #0F172A;
  --text-soft: #1F2937;
  --muted: #64748B;
  --muted-strong: #475569;
  --border: rgba(15, 23, 42, 0.08);
  --border-strong: rgba(15, 23, 42, 0.16);
  --border-soft: rgba(15, 23, 42, 0.06);

  /* ===== v3 category accents (used only inside the demo) ===== */
  --cat-behavioral: #4F8FFF;
  --cat-system: #A480FF;
  --cat-coding: #00C896;

  /* ===== Difficulty accents ===== */
  --diff-easy: #22C55E;
  --diff-medium: #F59E0B;
  --diff-hard: #EF4444;

  /* ===== Type scale ===== */
  --text-xs: 12px;
  --text-sm: 13px;
  --text-base: 14px;
  --text-md: 15px;
  --text-lg: 16px;
  --text-xl: 18px;
  --text-2xl: 24px;
  --display: clamp(32px, 4.4vw, 44px);

  /* ===== Spacing scale (4px base) ===== */
  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 20px;
  --s-6: 24px;
  --s-7: 32px;
  --s-8: 48px;
  --s-9: 64px;
  --s-10: 96px;

  /* ===== Radius ===== */
  --r-pill: 999px;
  --r-xs: 6px;
  --r-sm: 8px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-xl: 16px;
  --r-2xl: 20px;

  /* ===== Shadows ===== */
  --shadow-subtle: 0 1px 3px rgba(15, 23, 42, 0.05);
  --shadow-card: 0 1px 3px rgba(15, 23, 42, 0.04), 0 4px 16px rgba(15, 23, 42, 0.04);
  --shadow-float: 0 4px 16px rgba(15, 23, 42, 0.06);
  --shadow-pop: 0 12px 32px rgba(15, 23, 42, 0.12);

  /* ===== Type stack ===== */
  --font-sans: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0B1220;
    --bg-page: #0B1220;
    --bg-soft: #131B30;
    --bg-card: #0F172A;
    --text: #E2E8F0;
    --text-soft: #CBD5E1;
    --muted: #94A3B8;
    --muted-strong: #CBD5E1;
    --border: rgba(255, 255, 255, 0.08);
    --border-strong: rgba(255, 255, 255, 0.16);
    --border-soft: rgba(255, 255, 255, 0.06);
    --green-soft: rgba(0, 229, 160, 0.16);
    --purple-soft: rgba(124, 92, 252, 0.14);
    --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.4), 0 4px 16px rgba(0, 0, 0, 0.5);
    --shadow-float: 0 4px 16px rgba(0, 0, 0, 0.6);
    --shadow-pop: 0 12px 32px rgba(0, 0, 0, 0.65);
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg-page);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: var(--text-lg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: inherit; text-decoration: none; }
a:hover { color: var(--green-deep); }

:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 2px;
  border-radius: var(--r-xs);
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: auto;
  background: var(--green);
  color: #052e1f;
  padding: 8px 14px;
  border-radius: var(--r-sm);
  font-weight: 700;
  z-index: 9999;
}
.skip-link:focus { left: 12px; top: 12px; }

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

kbd {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 1px 6px;
  border-radius: var(--r-xs);
  background: var(--bg-soft);
  border: 1px solid var(--border);
  color: var(--muted);
}

/* ======================================================================
   TOP NAV
   ====================================================================== */
.try-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px max(20px, calc((100vw - 1280px) / 2 + 24px));
  border-bottom: 1px solid var(--border-soft);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 50;
}
.try-logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  color: var(--text);
  font-size: 17px;
  letter-spacing: -0.01em;
}
.try-logo:hover { color: var(--text); }
.try-nav-right {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.try-icon-btn {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid transparent;
  color: var(--muted-strong);
  border-radius: var(--r-md);
  cursor: pointer;
  transition: background 0.15s ease-out, border-color 0.15s ease-out, color 0.15s ease-out;
}
.try-icon-btn:hover {
  background: var(--bg-soft);
  border-color: var(--border-strong);
  color: var(--text);
}
.try-icon-btn[aria-pressed="true"] {
  background: var(--green-soft);
  color: var(--green-deep);
  border-color: var(--green-line);
}

/* ======================================================================
   PAGE HEADER (hero above the demo card)
   ====================================================================== */
.try-header {
  max-width: 1280px;
  margin: 0 auto;
  padding: var(--s-9) var(--s-6) var(--s-7);
  text-align: center;
}
.try-header h1 {
  font-size: var(--display);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.02em;
  margin: var(--s-3) 0 var(--s-3);
  color: var(--text);
}
.try-tagline {
  color: var(--muted);
  font-size: var(--text-lg);
  margin: 0 auto var(--s-5);
  max-width: 640px;
  line-height: 1.55;
}
.try-header-cta {
  display: inline-flex;
  align-items: center;
  gap: var(--s-3);
  flex-wrap: wrap;
  justify-content: center;
}
.try-header-fine {
  color: var(--muted);
  font-size: var(--text-sm);
}
.try-header-cta-link {
  color: var(--green-deep);
  font-weight: 600;
  font-size: var(--text-base);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 0;
  border-bottom: 1px solid transparent;
  transition: border-color 0.15s ease-out, color 0.15s ease-out;
}
.try-header-cta-link:hover {
  border-color: var(--green-line);
  color: var(--green-deep);
}

.banner-pill {
  display: inline-block;
  padding: 4px 12px;
  border-radius: var(--r-pill);
  font-size: 11px;
  letter-spacing: 1px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--green-deep);
  background: var(--green-soft);
  border: 1px solid var(--green-line);
}

/* ======================================================================
   DEMO CARD (the main 2-column shell)
   ====================================================================== */
.try-main {
  max-width: 1280px;
  margin: 0 auto var(--s-10);
  padding: 0 var(--s-6);
}

.demo-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-2xl);
  box-shadow: var(--shadow-card);
  overflow: hidden;
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  /* Use `height` (not `max-height`) so the implicit grid row gets a
     definite size. Without a definite parent height the inner flex column
     stage-body can't constrain itself to overflow-y:auto, which made the
     active-state body push the page down 4000+ px in v3 testing. */
  height: clamp(560px, calc(100vh - 200px), 920px);
}

/* ======================================================================
   LEFT RAIL
   ====================================================================== */
.try-rail {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border-soft);
  min-height: 0;
  background: var(--bg-card);
}

.rail-head {
  padding: var(--s-5) var(--s-5) var(--s-3);
  border-bottom: 1px solid var(--border-soft);
  background: var(--bg-card);
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  gap: var(--s-4);
}

.rail-head-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s-3);
}
.rail-title {
  margin: 0;
  font-size: var(--text-lg);
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text);
}
.rail-clear {
  background: transparent;
  border: 0;
  color: var(--muted);
  font-family: inherit;
  font-size: var(--text-xs);
  cursor: pointer;
  padding: 2px 0;
  text-decoration: none;
}
.rail-clear:hover { color: var(--text); text-decoration: underline; }
.rail-clear[hidden] { display: none; }

.rail-filter {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.filter-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--muted);
}
.filter-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.filter-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  font-family: inherit;
  font-size: var(--text-base);
  font-weight: 500;
  background: var(--bg-card);
  color: var(--text-soft);
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  cursor: pointer;
  transition: background 0.15s ease-out, border-color 0.15s ease-out, color 0.15s ease-out;
  line-height: 1;
}
.filter-pill:hover {
  background: var(--bg-soft);
  border-color: var(--border-strong);
}
.filter-pill.is-active {
  background: var(--green-soft);
  border-color: var(--green-line);
  color: var(--green-deep);
}
.filter-pill.is-active:focus-visible {
  box-shadow: 0 0 0 2px rgba(0, 229, 160, 0.4);
}

.rail-count {
  font-size: var(--text-sm);
  color: var(--muted);
}

/* The scrollable list itself */
.rail-list {
  list-style: none;
  margin: 0;
  padding: var(--s-4) var(--s-4) var(--s-5);
  overflow-y: auto;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  outline: none;
  min-height: 0;
}
.rail-list::-webkit-scrollbar { width: 8px; }
.rail-list::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: var(--r-xs);
}
.rail-list::-webkit-scrollbar-track { background: transparent; }

.rail-loading,
.rail-empty {
  list-style: none;
  padding: var(--s-5) var(--s-3);
  text-align: center;
  color: var(--muted);
  font-size: var(--text-base);
}

/* ===== Question card ===== */
.rail-item {
  list-style: none;
  position: relative;
  width: 100%;
  font-family: inherit;
  text-align: left;
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-lg);
  padding: var(--s-4) var(--s-4);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
  transition: background 0.15s ease-out, border-color 0.15s ease-out,
              transform 0.15s ease-out, box-shadow 0.15s ease-out;
  color: var(--text);
}
.rail-item:hover {
  background: var(--bg-soft);
  border-color: var(--border-strong);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.05);
}
.rail-item:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 2px;
}
.rail-item.is-active {
  background: rgba(0, 229, 160, 0.04);
  border-color: var(--green-line);
}
.rail-item.is-active::before {
  content: '';
  position: absolute;
  left: 0;
  top: var(--s-2);
  bottom: var(--s-2);
  width: 4px;
  background: var(--green);
  border-radius: 0 4px 4px 0;
}

.rail-item-head {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  flex-wrap: wrap;
}

.rail-item-cat {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-soft);
  line-height: 1;
}
.rail-item-cat .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.cat-behavioral { color: var(--cat-behavioral); }
.cat-system { color: var(--cat-system); }
.cat-coding { color: var(--cat-coding); }
.cat-behavioral .dot { background: var(--cat-behavioral); }
.cat-system .dot { background: var(--cat-system); }
.cat-coding .dot { background: var(--cat-coding); }

.rail-item-diff {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  border-radius: var(--r-pill);
  line-height: 1;
}
.rail-item-diff.diff-easy {
  background: rgba(34, 197, 94, 0.12);
  color: var(--diff-easy);
}
.rail-item-diff.diff-medium {
  background: rgba(245, 158, 11, 0.12);
  color: var(--diff-medium);
}
.rail-item-diff.diff-hard {
  background: rgba(239, 68, 68, 0.12);
  color: var(--diff-hard);
}

.rail-item-text {
  margin: 0;
  font-size: var(--text-md);
  line-height: 1.5;
  font-weight: 500;
  color: var(--text);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.rail-item-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
}
.rail-item-time {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: var(--text-xs);
  color: var(--muted);
}
.rail-item-play {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  color: var(--green-deep);
  background: var(--green-soft);
  border-radius: 50%;
  transition: transform 0.15s ease-out, background 0.15s ease-out;
  flex-shrink: 0;
}
.rail-item:hover .rail-item-play {
  background: var(--green);
  color: #052e1f;
  transform: scale(1.06);
}
.rail-item.is-active .rail-item-play {
  background: var(--green);
  color: #052e1f;
}

.rail-item-tried {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
  font-size: 11px;
  color: var(--green-deep);
  font-weight: 600;
}

/* ======================================================================
   RIGHT STAGE
   ====================================================================== */
.try-stage {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--bg-card);
}

/* sticky toolbar */
.stage-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  padding: var(--s-4) var(--s-5);
  border-bottom: 1px solid var(--border-soft);
  background: var(--bg-card);
  position: sticky;
  top: 0;
  z-index: 2;
}
.stage-back {
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  color: var(--muted-strong);
  border: 1px solid transparent;
  border-radius: 50%;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  flex-shrink: 0;
  padding: 0;
}
.stage-back:hover {
  background: var(--bg-soft);
  border-color: var(--border-strong);
  color: var(--text);
}

.stage-toolbar-center {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  font-size: var(--text-base);
  font-weight: 500;
  color: var(--text-soft);
}
.toolbar-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--green-soft), var(--purple-soft));
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
}
.toolbar-avatar svg {
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
}

.stage-toolbar-right {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* stage body — scrolling area */
.stage-body {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: var(--s-6) var(--s-6) var(--s-8);
  min-height: 0;
}
.stage-body::-webkit-scrollbar { width: 8px; }
.stage-body::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: var(--r-xs);
}

/* ===== Empty state ===== */
.stage-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--s-7) var(--s-5);
  gap: var(--s-3);
  min-height: 380px;
}
.stage-empty[hidden] { display: none; }

.stage-empty-icon {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--green-soft), var(--purple-soft));
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--green-deep);
  margin-bottom: var(--s-2);
}
.stage-empty-icon svg {
  width: 36px;
  height: 36px;
  max-width: 100%;
  max-height: 100%;
}

.stage-empty-title {
  margin: 0;
  font-size: var(--text-2xl);
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text);
}
.stage-empty-body {
  margin: 0;
  color: var(--muted);
  max-width: 520px;
  font-size: var(--text-md);
  line-height: 1.55;
}
.stage-empty-hint {
  margin: var(--s-2) 0 0;
  font-size: var(--text-xs);
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: center;
}

/* ===== Active state ===== */
.stage-active {
  display: flex;
  flex-direction: column;
  gap: var(--s-5);
}
.stage-active[hidden] { display: none; }

/* Avatar + question card */
.qa-card {
  position: relative;
  background: linear-gradient(135deg, rgba(0, 229, 160, 0.04), rgba(124, 92, 252, 0.04));
  border: 1px solid var(--border-soft);
  border-radius: var(--r-xl);
  padding: var(--s-5);
  display: flex;
  align-items: flex-start;
  gap: var(--s-5);
}

.qa-meta {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  margin-bottom: var(--s-3);
  flex-wrap: wrap;
}
.qa-meta .meta-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--text-xs);
  font-weight: 600;
  padding: 4px 10px;
  border-radius: var(--r-pill);
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-soft);
  line-height: 1;
}
.qa-meta .meta-pill .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.qa-meta .meta-cat.cat-behavioral .dot { background: var(--cat-behavioral); }
.qa-meta .meta-cat.cat-system .dot { background: var(--cat-system); }
.qa-meta .meta-cat.cat-coding .dot { background: var(--cat-coding); }
.qa-meta .meta-cat.cat-behavioral { color: var(--cat-behavioral); }
.qa-meta .meta-cat.cat-system { color: var(--cat-system); }
.qa-meta .meta-cat.cat-coding { color: var(--cat-coding); }
.qa-meta .meta-diff.diff-easy {
  background: rgba(34, 197, 94, 0.12);
  color: var(--diff-easy);
  border-color: rgba(34, 197, 94, 0.30);
}
.qa-meta .meta-diff.diff-medium {
  background: rgba(245, 158, 11, 0.12);
  color: var(--diff-medium);
  border-color: rgba(245, 158, 11, 0.30);
}
.qa-meta .meta-diff.diff-hard {
  background: rgba(239, 68, 68, 0.12);
  color: var(--diff-hard);
  border-color: rgba(239, 68, 68, 0.30);
}
.meta-timer {
  background: var(--bg-card);
  color: var(--muted);
  border-color: var(--border);
}
.meta-timer.is-urgent {
  background: rgba(239, 68, 68, 0.12);
  color: var(--diff-hard);
  border-color: rgba(239, 68, 68, 0.30);
  animation: timerPulse 0.8s ease-in-out infinite alternate;
}
@keyframes timerPulse { from { transform: scale(1); } to { transform: scale(1.04); } }

.stage-avatar {
  /* HARD constraint: avatar can never exceed 96 px on desktop / 64 px on mobile,
     regardless of whether Lottie loads. Belt-and-suspenders against the v2
     "giant teal circle fills the viewport" bug. */
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--green-soft), var(--purple-soft));
  border: 1px solid var(--border);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  transition: box-shadow 0.2s ease-out, border-color 0.2s ease-out;
}
.stage-avatar svg {
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  display: block;
}
.stage-avatar.is-speaking {
  border-color: var(--green);
  box-shadow: 0 0 0 4px var(--green-soft);
}
.stage-avatar-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  font-size: 24px;
  font-weight: 800;
  color: var(--green-deep);
}
.stage-avatar.has-lottie .stage-avatar-fallback { display: none; }

.qa-body {
  flex: 1 1 auto;
  min-width: 0;
  position: relative;
}
.qa-body .qa-replay {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--muted-strong);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.qa-body .qa-replay:hover {
  background: var(--bg-soft);
  border-color: var(--border-strong);
  color: var(--green-deep);
}

.stage-question {
  margin: 0;
  font-size: var(--text-xl);
  line-height: 1.45;
  font-weight: 500;
  color: var(--text);
  min-height: 56px;
  padding-right: 36px;
}
.stage-question .caret {
  display: inline-block;
  width: 2px;
  height: 1em;
  background: var(--green);
  margin-left: 2px;
  vertical-align: text-bottom;
  animation: caretBlink 1s steps(2, end) infinite;
}
@keyframes caretBlink { 50% { opacity: 0; } }

.stage-state {
  margin: var(--s-2) 0 0;
  font-size: var(--text-xs);
  color: var(--muted);
  min-height: 16px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* ======================================================================
   v4 - Code block (debug coding questions)
   ----------------------------------------------------------------------
   Dark code surface in BOTH light and dark mode, so the highlight palette
   reads consistently. 12 px radius, 16 px padding, monospace 13 px, line-
   height 1.6, line-numbered gutter, language label + copy button in the
   top-right. Horizontally scrolls on mobile; line numbers stay fixed.
   ====================================================================== */
.qa-code-wrap[hidden] { display: none; }
.qa-code-wrap {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  /* Negative margin pulls the block flush with the stage-active gap. */
}

.qa-code-head {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--s-2);
  /* sits just above the code body — visually anchored */
  margin-bottom: -8px;
  position: relative;
  z-index: 1;
  padding: 0 var(--s-3);
}

.qa-code-lang {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  border-radius: var(--r-pill);
  background: rgba(124, 92, 252, 0.18);
  color: #C7B6FF;
  border: 1px solid rgba(124, 92, 252, 0.32);
  line-height: 1;
  font-family: var(--font-mono);
}

.qa-code-copy {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: inherit;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.3px;
  padding: 4px 10px;
  background: rgba(0, 229, 160, 0.14);
  color: var(--green);
  border: 1px solid rgba(0, 229, 160, 0.30);
  border-radius: var(--r-pill);
  cursor: pointer;
  line-height: 1;
  transition: background 0.15s ease-out, color 0.15s ease-out, transform 0.05s ease-out;
}
.qa-code-copy:hover {
  background: rgba(0, 229, 160, 0.22);
  color: #5BFFC4;
}
.qa-code-copy:active { transform: translateY(1px); }
.qa-code-copy.is-done {
  background: rgba(0, 229, 160, 0.28);
  color: #5BFFC4;
}
.qa-code-copy.is-done .ico-copy { display: none; }
.qa-code-copy.is-done .ico-copy-done { display: inline-block !important; }

/* On desktop the copy button is hover-revealed against the body; on mobile
   it stays visible (touch devices have no hover state). */
@media (hover: hover) and (pointer: fine) {
  .qa-code-copy { opacity: 0.45; }
  .qa-code-wrap:hover .qa-code-copy,
  .qa-code-copy:focus-visible,
  .qa-code-copy.is-done { opacity: 1; }
}

.qa-code-body {
  position: relative;
  display: flex;
  align-items: stretch;
  background: #0F172A;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  overflow: hidden;
  /* Inner scroll wrapper for mobile horizontal overflow */
}

.qa-code-gutter {
  flex-shrink: 0;
  padding: 16px 10px 16px 14px;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.6;
  color: rgba(226, 232, 240, 0.35);
  text-align: right;
  user-select: none;
  border-right: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(255, 255, 255, 0.015);
  font-variant-numeric: tabular-nums;
  position: sticky;
  left: 0;
  z-index: 1;
}
.qa-code-gutter span { display: block; }

pre.qa-code {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  padding: 16px 18px;
  background: transparent;
  color: #E2E8F0;
  font-family: 'SFMono-Regular', Menlo, Consolas, 'Roboto Mono', var(--font-mono);
  font-size: 13px;
  line-height: 1.6;
  overflow-x: auto;
  border-radius: 0;
  text-shadow: none;
}
pre.qa-code code {
  background: transparent;
  padding: 0;
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  text-shadow: none;
  white-space: pre;
}

/* Prism's default theme uses dark backgrounds on code/pre. Force transparency
   so OUR container colours win. The token colours from prism-tomorrow keep. */
pre[class*="language-"],
code[class*="language-"] {
  background: transparent !important;
  text-shadow: none !important;
  font-family: 'SFMono-Regular', Menlo, Consolas, 'Roboto Mono', var(--font-mono) !important;
  font-size: 13px !important;
  line-height: 1.6 !important;
  color: #E2E8F0;
}

.qa-code-hint-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  align-self: flex-start;
  background: transparent;
  border: 0;
  padding: 6px 0;
  font-family: inherit;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 1px solid transparent;
  transition: color 0.15s ease-out, border-color 0.15s ease-out;
}
.qa-code-hint-btn[hidden] { display: none; }
.qa-code-hint-btn:hover {
  color: var(--green-deep);
  border-bottom-color: var(--green-line);
}
.qa-code-hint-btn[aria-expanded="true"] { color: var(--green-deep); }

.qa-code-hint {
  background: rgba(124, 92, 252, 0.08);
  border: 1px solid rgba(124, 92, 252, 0.22);
  border-radius: 10px;
  padding: var(--s-3) var(--s-4);
  font-size: var(--text-sm);
  line-height: 1.5;
  color: var(--text);
  display: flex;
  gap: var(--s-2);
  align-items: flex-start;
}
.qa-code-hint[hidden] { display: none; }
.qa-code-hint::before {
  content: "\1F4A1";
  font-size: 14px;
  line-height: 1;
  flex-shrink: 0;
  margin-top: 2px;
}

/* Code body scrollbars (dark surface) */
pre.qa-code::-webkit-scrollbar { height: 6px; }
pre.qa-code::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.18);
  border-radius: var(--r-pill);
}

/* ======================================================================
   v4 - Attach screenshot
   ----------------------------------------------------------------------
   Ghost-style button + 12 px radius preview card with thumbnail, file name,
   size, and Replace/Remove links. Validation errors render inline.
   ====================================================================== */
.attach-wrap {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  margin: -4px 0 var(--s-1);
}

.attach-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  align-self: flex-start;
  background: var(--bg-card);
  color: var(--text-soft);
  border: 1px dashed var(--border-strong);
  border-radius: var(--r-md);
  font-family: inherit;
  font-size: var(--text-sm);
  font-weight: 500;
  padding: 8px 14px;
  cursor: pointer;
  line-height: 1;
  transition: background 0.15s ease-out, border-color 0.15s ease-out, color 0.15s ease-out;
}
.attach-btn:hover {
  background: var(--bg-soft);
  border-color: var(--green-line);
  color: var(--green-deep);
}
.attach-btn:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 2px;
}
.attach-btn[hidden] { display: none; }

.attach-fine {
  margin: 0;
  font-size: var(--text-xs);
  color: var(--muted);
  line-height: 1.45;
}

.attach-error {
  margin: 0;
  font-size: var(--text-xs);
  color: var(--diff-hard);
  padding: 6px 10px;
  background: rgba(239, 68, 68, 0.10);
  border: 1px solid rgba(239, 68, 68, 0.30);
  border-radius: var(--r-sm);
}
.attach-error[hidden] { display: none; }

.attach-preview {
  display: flex;
  align-items: center;
  gap: var(--s-4);
  padding: var(--s-3);
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-subtle);
}
.attach-preview[hidden] { display: none; }

.attach-preview-thumb {
  display: block;
  width: 240px;
  height: 160px;
  max-width: 100%;
  object-fit: contain;
  background: #0F172A;
  border-radius: var(--r-md);
  flex-shrink: 0;
  border: 1px solid var(--border);
}

.attach-preview-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  flex: 1 1 auto;
}
.attach-preview-name {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.attach-preview-size {
  font-size: var(--text-xs);
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.attach-preview-actions {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  margin-top: 6px;
  flex-wrap: wrap;
}
.attach-link {
  background: transparent;
  border: 0;
  font-family: inherit;
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--green-deep);
  cursor: pointer;
  padding: 2px 0;
  border-bottom: 1px solid transparent;
  transition: border-color 0.15s ease-out, color 0.15s ease-out;
}
.attach-link:hover {
  border-bottom-color: var(--green-line);
}
.attach-link-remove {
  color: var(--diff-hard);
}
.attach-link-remove:hover {
  border-bottom-color: rgba(239, 68, 68, 0.30);
}

/* Critique screenshot badge (v4) */
.critique-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.3px;
  padding: 3px 9px;
  border-radius: var(--r-pill);
  background: rgba(124, 92, 252, 0.12);
  color: var(--purple);
  border: 1px solid rgba(124, 92, 252, 0.30);
  line-height: 1.2;
  align-self: center;
  margin-left: auto;
  margin-right: var(--s-2);
}
.critique-badge[hidden] { display: none; }

/* ===== Audio progress strip ===== */
.audio-strip {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-3) var(--s-4);
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-md);
}
.audio-btn {
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 50%;
  cursor: pointer;
  color: var(--text-soft);
  flex-shrink: 0;
  padding: 0;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.audio-btn:hover {
  background: var(--green-soft);
  color: var(--green-deep);
  border-color: var(--green-line);
}
.audio-progress {
  flex: 1 1 auto;
  height: 4px;
  background: var(--bg-soft);
  border-radius: var(--r-pill);
  overflow: hidden;
  position: relative;
}
.audio-progress-bar {
  position: absolute;
  inset: 0 100% 0 0;
  background: var(--green);
  transition: right 0.1s linear;
}
.audio-cc-badge {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  padding: 2px 8px;
  border-radius: var(--r-pill);
  background: var(--bg-soft);
  border: 1px solid var(--border);
  flex-shrink: 0;
}
.audio-cc-badge.is-on {
  color: var(--green-deep);
  background: var(--green-soft);
  border-color: var(--green-line);
}

/* ===== Answer area ===== */
.answer-wrap {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
}
.stage-textarea {
  width: 100%;
  min-height: 140px;
  padding: var(--s-4);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--bg-card);
  color: var(--text);
  font-family: inherit;
  font-size: var(--text-base);
  line-height: 1.55;
  resize: vertical;
  transition: border-color 0.15s ease-out, box-shadow 0.15s ease-out;
}
.stage-textarea:focus {
  outline: none;
  border-color: var(--green);
  box-shadow: 0 0 0 3px var(--green-soft);
}
.stage-textarea.is-mono {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
}
.answer-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  font-size: var(--text-xs);
  color: var(--muted);
}
.answer-meta-hint { color: var(--muted); }
.answer-meta-count { color: var(--muted); font-variant-numeric: tabular-nums; }

/* Action footer */
.stage-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
}

/* ===== Buttons ===== */
.btn-primary,
.btn-secondary,
.btn-ghost {
  font-family: inherit;
  font-size: var(--text-base);
  font-weight: 600;
  padding: 12px 22px;
  min-height: 44px;
  border-radius: var(--r-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.15s ease-out, color 0.15s ease-out,
              border-color 0.15s ease-out, transform 0.05s ease-out,
              box-shadow 0.15s ease-out;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-decoration: none;
  line-height: 1;
}
.btn-primary {
  background: var(--green);
  color: #052e1f;
  border-color: var(--green-deep);
  box-shadow: 0 1px 2px rgba(0, 181, 130, 0.18);
}
.btn-primary:hover {
  background: var(--green-deep);
  color: #fff;
}
.btn-primary:active { transform: translateY(1px); }
.btn-primary[disabled] {
  background: var(--border-strong);
  color: var(--muted);
  border-color: transparent;
  box-shadow: none;
  cursor: not-allowed;
}
.btn-secondary {
  background: var(--bg-card);
  color: var(--text);
  border-color: var(--border-strong);
}
.btn-secondary:hover {
  background: var(--bg-soft);
  color: var(--text);
}
.btn-ghost {
  background: transparent;
  color: var(--muted-strong);
  border-color: transparent;
  font-weight: 500;
  min-height: 0;
  padding: 8px 14px;
}
.btn-ghost:hover { background: var(--bg-soft); color: var(--text); }
.btn-sm { padding: 7px 14px; font-size: var(--text-sm); min-height: 0; }

/* ===== Critique card ===== */
.critique[hidden] { display: none; }
.critique {
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-xl);
  padding: var(--s-5);
}
.critique-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--s-3);
  margin-bottom: var(--s-4);
}
.critique-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--muted);
}
.critique-score {
  font-size: 28px;
  font-weight: 700;
  color: var(--green-deep);
  line-height: 1;
  display: inline-flex;
  align-items: baseline;
  gap: 2px;
}
.critique-score .score-suffix {
  font-size: 16px;
  font-weight: 500;
  color: var(--muted);
}
.critique-body { font-size: var(--text-base); line-height: 1.55; color: var(--text-soft); }
.critique-section { margin: 0 0 var(--s-3); }
.critique-section h4 {
  margin: 0 0 var(--s-2);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--muted);
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.critique-section ul {
  margin: 0;
  padding-left: var(--s-5);
}
.critique-section li {
  margin-bottom: 4px;
  font-size: var(--text-base);
  color: var(--text);
}
.critique-followup {
  background: var(--bg-soft);
  border-left: 3px solid var(--purple);
  padding: var(--s-3) var(--s-4);
  border-radius: 0 var(--r-md) var(--r-md) 0;
  font-style: italic;
  color: var(--text);
  margin: var(--s-2) 0 var(--s-3);
}
.critique-actions {
  display: flex;
  gap: var(--s-2);
  justify-content: flex-end;
  flex-wrap: wrap;
  margin-top: var(--s-4);
}

/* ===== Error panel ===== */
.error-panel[hidden] { display: none; }
.error-panel {
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.30);
  border-radius: var(--r-xl);
  padding: var(--s-5);
  color: var(--text);
}
.error-panel h3 {
  margin: 0 0 6px;
  font-size: var(--text-lg);
  color: var(--diff-hard);
}
.error-panel p { margin: 0 0 var(--s-3); font-size: var(--text-base); color: var(--text); }
.error-actions { display: flex; gap: var(--s-2); flex-wrap: wrap; }

/* ===== Exit modal ===== */
.modal-overlay[hidden] { display: none; }
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(15, 23, 42, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--s-5);
  animation: fadeIn 0.15s ease-out;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: var(--bg-card);
  border-radius: var(--r-xl);
  padding: var(--s-6);
  max-width: 440px;
  width: 100%;
  box-shadow: var(--shadow-pop);
  border: 1px solid var(--border);
}
.modal h3 {
  margin: 0 0 var(--s-3);
  font-size: var(--text-xl);
  color: var(--text);
  font-weight: 700;
}
.modal p {
  margin: 0 0 var(--s-5);
  color: var(--muted);
  font-size: var(--text-base);
}
.modal-actions {
  display: flex;
  gap: var(--s-2);
  justify-content: flex-end;
  flex-wrap: wrap;
}

/* ======================================================================
   MOBILE  - two-view toggle inside the same demo card
   ====================================================================== */
@media (max-width: 979px) {
  .try-nav { padding: 12px 16px; }
  .try-logo span { font-size: 16px; }
  .try-header { padding: var(--s-7) var(--s-4) var(--s-5); }
  .try-main { padding: 0 var(--s-3); }

  .demo-card {
    grid-template-columns: 1fr;
    height: clamp(540px, calc(100vh - 180px), 900px);
  }
  .try-rail { border-right: 0; border-bottom: 1px solid var(--border-soft); }

  /* Two-view toggle */
  body.try-mode-list .try-stage { display: none; }
  body.try-mode-stage .try-rail { display: none; }

  .stage-avatar { width: 64px; height: 64px; }
  .stage-question { font-size: var(--text-lg); padding-right: 32px; }
  .qa-card { gap: var(--s-3); padding: var(--s-4); }

  .stage-actions {
    flex-direction: column-reverse;
    align-items: stretch;
  }
  .stage-actions .btn-primary,
  .stage-actions .btn-secondary,
  .stage-actions .btn-ghost { width: 100%; }
}

@media (max-width: 480px) {
  .try-header h1 { font-size: 28px; }
  .filter-pill { padding: 7px 11px; font-size: 13px; }
  .rail-item { padding: var(--s-3); }
}

/* v4 mobile tweaks for the code block + attach preview */
@media (max-width: 979px) {
  .qa-code-head { padding: 0 var(--s-2); }
  .qa-code-gutter { padding: 14px 8px 14px 12px; font-size: 12px; }
  pre.qa-code { padding: 14px 14px; font-size: 12px; }
  pre[class*="language-"],
  code[class*="language-"] { font-size: 12px !important; }

  /* Stack the preview vertically so the thumbnail can go full-width */
  .attach-preview {
    flex-direction: column;
    align-items: stretch;
    gap: var(--s-3);
  }
  .attach-preview-thumb {
    width: 100%;
    max-width: 320px;
    height: auto;
    max-height: 180px;
    align-self: center;
  }
  .attach-preview-meta { align-items: center; text-align: center; }
  .attach-preview-name { white-space: normal; word-break: break-all; }
  .attach-preview-actions { justify-content: center; }

  /* Critique badge: keep its own row above the score on mobile */
  .critique-head { flex-wrap: wrap; }
  .critique-badge { order: -1; margin-left: 0; margin-right: 0; width: max-content; }
}

/* ======================================================================
   REDUCED MOTION
   ====================================================================== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
  .stage-question .caret { animation: none; opacity: 1; }
  .rail-item:hover { transform: none; }
  /* No copy-button micro-animation when motion is reduced. */
  .qa-code-copy:active { transform: none; }
}
