:root {
  --font-sans: "DM Sans", "Inter", sans-serif;
  --font-mono: "DM Mono", "JetBrains Mono", monospace;
  --v3-bg: #10130f;
  --v3-surface: #171b15;
  --v3-surface-2: #1f251c;
  --v3-panel: #f6f0df;
  --v3-ink: #f7f0df;
  --v3-muted: #b9b198;
  --v3-faint: #7f765f;
  --v3-line: rgba(246, 240, 223, 0.14);
  --v3-line-strong: rgba(246, 240, 223, 0.24);
  --v3-gold: #c8922a;
  --v3-gold-2: #f0c86b;
  --v3-green: #77a56d;
  --v3-red: #bf604f;
  --v3-radius: 22px;
  --v3-radius-sm: 12px;
  --v3-shadow: 0 24px 80px rgba(0, 0, 0, 0.24);
  /* v0.3.1: single source of truth for the home search column width. The
     search bar, results meta, answer stack, and each answer card all read
     from this token so their visible left/right edges always match. */
  --v3-search-col: 900px;
}

html,
body {
  font-family: var(--font-sans);
  background:
    radial-gradient(circle at 18% 10%, rgba(200, 146, 42, 0.15), transparent 30rem),
    radial-gradient(circle at 88% 0%, rgba(119, 165, 109, 0.12), transparent 28rem),
    var(--v3-bg);
  color: var(--v3-ink);
}

body {
  min-height: 100vh;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(246, 240, 223, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(246, 240, 223, 0.035) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: linear-gradient(to bottom, #000, transparent 76%);
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(18px);
  background: rgba(16, 19, 15, 0.82);
  border-bottom: 1px solid var(--v3-line);
}

.brand-link {
  color: var(--v3-ink);
}

.brand-title {
  letter-spacing: -0.025em;
}

.brand-sub {
  font-family: var(--font-mono);
  color: var(--v3-muted);
}

.brand-logo-inline {
  color: var(--v3-gold-2);
  flex: 0 0 auto;
}

/* v0.4.1 — Selected silhouette logo (raster mark)
   Light mode: dark-green silhouette PNG, no effects.
   Dark mode: the SAME silhouette recoloured flat white (separate PNG asset).
   No glow, no shadow, no gradient, no outline, no filter — just a swap. */
.brand-logo-picture {
  display: inline-flex;
  flex: 0 0 auto;
}
.brand-logo-img {
  width: 36px;
  height: 36px;
  display: block;
  object-fit: contain;
  border-radius: 0;
  border: 0;
  filter: none;
  -webkit-user-drag: none;
  user-select: none;
}

.logo2-mark {
  width: 48px;
  height: 48px;
  fill: none;
  stroke: currentColor;
  stroke-width: 3.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.logo2-bg {
  fill: #2d4032;
  stroke: none;
}

.logo2-frame,
.logo2-book,
.logo2-candle path {
  stroke: #f2f2f2;
}

.logo2-frame,
.logo2-candle rect {
  fill: none;
}

.logo2-candle rect {
  stroke: #f2f2f2;
}

.app-nav {
  gap: 0.25rem;
  align-items: center;
  overflow: visible;
  flex-wrap: nowrap;
}

.nav-link,
.more-summary,
.more-link {
  border-radius: 999px;
  color: var(--v3-muted);
  font-weight: 700;
}

.nav-link:hover,
.nav-link.active,
.nav-more.active .more-summary,
.more-summary:hover,
.more-link:hover,
.more-link.active {
  background: rgba(246, 240, 223, 0.08);
  color: var(--v3-ink);
  text-decoration: none;
}

.nav-more {
  position: relative;
  z-index: 30;
}

.more-summary {
  list-style: none;
  padding: 7px 12px;
  font-size: 13.5px;
  cursor: pointer;
  user-select: none;
  transition: color 0.15s, background 0.15s;
}

.more-summary::-webkit-details-marker {
  display: none;
}

.more-summary::after {
  content: "⌄";
  display: inline-block;
  margin-left: 0.35rem;
  font-size: 0.78em;
  transform: translateY(-1px);
}

.nav-more[open] .more-summary::after {
  transform: rotate(180deg) translateY(1px);
}

.more-menu {
  position: absolute;
  top: calc(100% + 0.5rem);
  right: 0;
  min-width: 180px;
  display: grid;
  gap: 0.25rem;
  padding: 0.5rem;
  border: 1px solid var(--v3-line-strong);
  border-radius: 18px;
  background: var(--v3-surface);
  box-shadow: var(--v3-shadow);
}

.more-link {
  display: block;
  padding: 0.65rem 0.8rem;
  font-size: 0.88rem;
}

.nav-nudge,
.settings-toggle {
  min-height: 40px;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--v3-line-strong);
  border-radius: 999px;
  background: var(--v3-field-bg);
  color: var(--v3-ink);
  font-weight: 800;
}

.nav-nudge {
  display: none;
  width: 40px;
  padding-inline: 0;
  font-size: 1.15rem;
}

.settings-toggle:hover,
.nav-nudge:hover {
  border-color: var(--v3-gold);
  color: var(--v3-gold-2);
}

.settings-popover {
  position: absolute;
  top: calc(100% + 0.65rem);
  right: 1.5rem;
  z-index: 60;
  width: min(390px, calc(100vw - 2rem));
  /* A6: Panel is internally scrollable so bottom never clips on short viewports */
  max-height: calc(100vh - 96px);
  overflow-y: auto;
  display: grid;
  gap: 0.85rem;
  padding: 1rem;
  border: 1px solid var(--v3-line-strong);
  border-radius: 22px;
  background: var(--v3-surface);
  color: var(--v3-ink);
  box-shadow: var(--v3-shadow);
}

/* v0.3.2 P0-6: explicit dark-mode override — ensure the panel sits on a dark surface
   with bright readable text and a clearly visible segmented active state. */
html[data-theme="dark"] .settings-popover {
  background: #1f241b;
  color: var(--v3-ink);
  border-color: rgba(244, 236, 216, 0.28);
  box-shadow: 0 22px 70px rgba(0, 0, 0, 0.55);
}

html[data-theme="dark"] .settings-popover strong,
html[data-theme="dark"] .settings-popover a {
  color: var(--v3-ink);
}

html[data-theme="dark"] .settings-popover span {
  color: var(--v3-muted);
}

.settings-head,
.settings-row {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
}

.settings-head span,
.settings-row span {
  display: block;
  margin-top: 0.2rem;
  color: var(--v3-muted);
  font-size: 0.88rem;
}

.segmented {
  display: inline-flex;
  padding: 0.25rem;
  border: 1px solid var(--v3-line);
  border-radius: 999px;
  background: var(--v3-field-bg);
}

.segmented button {
  min-height: 34px;
  padding: 0.35rem 0.85rem;
  border-radius: 999px;
  border: 0;
  background: transparent;
  color: var(--v3-muted);
  font-weight: 800;
  transition: background 0.15s, color 0.15s;
}

.segmented button:hover {
  color: var(--v3-ink);
}

/* v0.3.2 P1-8: clear filled active state (light + dark). */
.segmented button.active {
  background: var(--v3-gold);
  color: var(--v3-button-text);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.12) inset;
}

html[data-theme="dark"] .segmented button.active {
  background: var(--v3-gold-2);
  color: #17130b;
}

.muted-row {
  padding-top: 0.75rem;
  border-top: 1px solid var(--v3-line);
}

.app {
  max-width: 1240px;
  margin-inline: auto;
  padding: clamp(1.25rem, 2vw, 2rem);
}

.v3-hero {
  min-height: calc(100vh - 180px);
  display: grid;
  align-content: center;
  gap: 1.5rem;
  padding: clamp(2rem, 6vw, 5rem) 0;
}

.clean-home {
  /* v0.3.3: vertically center the home composition inside the viewport.
     - In idle state the search composition sits in the middle of the screen.
     - When the user submits a query, the composition anchors to the top so
       results render directly beneath without leaving a tall gap. */
  min-height: calc(100vh - 220px);
  max-width: 980px;
  margin-inline: auto;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 1.1rem;
  padding-block: clamp(2rem, 5vh, 4rem);
  transition: none;
  text-align: center;
}

/* The home-stage groups ticker + search + quotes + results so the centered
   block stays compact and balanced. */
.clean-home .home-stage {
  width: 100%;
  display: grid;
  justify-items: center;
  gap: 1.1rem;
  max-width: 900px;
}

.clean-home .home-tagline,
.clean-home .home-source-note {
  text-align: center;
  margin-inline: auto;
}

.clean-home.home-idle {
  align-content: center;
}

.clean-home.home-has-results {
  /* Anchor to top once a query is entered — prevents a tall gap above
     the results stack. */
  align-content: start;
  padding-block: clamp(1.5rem, 4vh, 3rem) clamp(2rem, 5vh, 3.5rem);
}

.clean-home.home-static {
  max-width: 980px;
  gap: 1.1rem;
}

.clean-home h1 {
  max-width: 760px;
  font-size: clamp(2rem, 4vw, 3rem);
  line-height: 1.02;
}

/* v0.3.4 — Inner Archive home title.
   Spans the same column width as the search bar / ticker / quote strip
   (--v3-search-col) and sits centered above the stats rail. The font size
   is clamped to fluidly fill the column from small mobile to wide desktop
   without causing horizontal overflow. */
.home-product-title {
  display: block;
  width: 100%;
  max-width: var(--v3-search-col);
  margin: 0 auto 0.35rem;
  padding: 0;
  font-family: var(--font-display, var(--font-sans, inherit));
  font-weight: 800;
  /* Fluid size: small enough on phones, large enough to read as a hero on
     desktop. The upper bound (~9rem) corresponds to the v0.3 reference. */
  font-size: clamp(2.4rem, 11.95vw, 8.35rem);
  line-height: 0.92;
  letter-spacing: -0.025em;
  text-transform: uppercase;
  text-align: center;
  color: var(--v3-ink, currentColor);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: clip;
  /* Optical alignment: pull the wordmark flush with the column edges. */
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  box-sizing: border-box;
}

.clean-home .home-product-title,
.home-idle .home-product-title,
.home-has-results .home-product-title,
.home-static .home-product-title,
.v3-hero .home-product-title {
  /* Higher specificity than .clean-home h1 / .v3-hero h1 so the
     hero title scale is not clobbered by upstream typography rules. */
  width: 100%;
  max-width: var(--v3-search-col);
  margin: 0 auto 0.4rem;
  font-size: clamp(2.4rem, 11.95vw, 8.35rem);
  line-height: 0.92;
  letter-spacing: -0.025em;
  font-weight: 800;
  text-transform: uppercase;
  text-align: center;
  color: var(--v3-ink, currentColor);
  white-space: nowrap;
}

/* Hide the hero title once the user is in results mode so it doesn't push the
   answer stack down. Keeps the layout compact, matching the existing
   .home-source-note / .quote-strip suppression. */
.home-has-results .home-product-title {
  display: none !important;
}

.clean-home .home-tagline {
  max-width: 760px;
}

.clean-home .v3-search {
  max-width: var(--v3-search-col);
  width: 100%;
  margin-top: 0.35rem;
}

.market-ticker {
  /* v0.3.6 — 3-stat row with gentle left-right drift. Single line on desktop,
     graceful wrap only if viewport forces it. Overflow hidden with fade edges. */
  /* C1 v0.8: widened to match search bar (var(--v3-search-col) = 900px) */
  max-width: var(--v3-search-col);
  width: 100%;
  border-block: 1px solid var(--v3-line);
  color: var(--v3-faint);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  overflow: hidden;
  /* Fade mask on both horizontal edges so content doesn't hard-clip */
  /* C1 v0.8: tightened fade stops to reduce visual narrowing */
  -webkit-mask-image: linear-gradient(to right, transparent 0%, #000 2%, #000 98%, transparent 100%);
  mask-image: linear-gradient(to right, transparent 0%, #000 2%, #000 98%, transparent 100%);
}

.market-ticker-track {
  /* Centred, single-line layout with a slow left-right drift */
  display: flex;
  flex-wrap: nowrap;
  justify-content: center;
  align-items: center;
  gap: 0.25rem 2rem;
  padding-block: 0.65rem;
  padding-inline: 1rem;
  white-space: nowrap;
  animation: stats-drift 12s ease-in-out infinite;
}

.market-ticker span {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  flex-shrink: 0;
}

.market-ticker span::before {
  content: "·";
  color: var(--v3-gold-2);
}

.quote-strip {
  /* v0.3.6 — continuous trading-floor ticker. One line only, slow and readable.
     v0.5.3 — replaced mask-image fade with solid background-colored edge
     wedges (::before / ::after) so partial words at the wrap-point are fully
     covered. The earlier mask-only approach only dimmed dark glyphs over the
     cream background, leaving fragments like 'ay comes.' legible at the left
     edge. The wedge gradients cover ~110px of solid background on each side
     and then fade out, so the ticker still feels like a continuous trading
     floor scroll with soft edges.
     v0.10 PATCH-07: extend to full hero/title width (1200px) */
  max-width: min(95vw, 1200px);
  width: 100%;
  border-block: 1px solid var(--v3-line);
  color: var(--v3-muted);
  font-size: 0.82rem;
  line-height: 1.35;
  overflow: hidden;
  position: relative;
  isolation: isolate;
}

.quote-strip::before,
.quote-strip::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  /* v0.5.4: widened wedge so an item's leading bold label can never appear
     alone (e.g. a partial "ICT" frame) before the quote text begins to
     reveal alongside it. The wedge fully masks ~180px of the leading edge,
     which is wider than the longest label glyph block plus its right-side
     gap. Items therefore enter the visible band already paired with quote
     text, eliminating the orphan-label OCR artefact flagged in v0.5.4
     visual validation. */
  width: max(28%, 180px);
  pointer-events: none;
  z-index: 2;
}
/* v0.11 PATCH-16: Tighten fade mask to 1%/99% so text doesn't truncate at edges.
   Preserves the soft entry/exit effect while maximising visible ticker width. */
.quote-strip::before {
  left: 0;
  background: linear-gradient(to right,
    var(--v3-bg, #f4efe3) 0%,
    var(--v3-bg, #f4efe3) 1%,
    rgba(244, 239, 227, 0) 99%);
}
.quote-strip::after {
  right: 0;
  background: linear-gradient(to left,
    var(--v3-bg, #f4efe3) 0%,
    var(--v3-bg, #f4efe3) 1%,
    rgba(244, 239, 227, 0) 99%);
}
html[data-theme="dark"] .quote-strip::before {
  background: linear-gradient(to right,
    var(--v3-bg, #0f1418) 0%,
    var(--v3-bg, #0f1418) 1%,
    rgba(15, 20, 24, 0) 99%);
}
html[data-theme="dark"] .quote-strip::after {
  background: linear-gradient(to left,
    var(--v3-bg, #0f1418) 0%,
    var(--v3-bg, #0f1418) 1%,
    rgba(15, 20, 24, 0) 99%);
}

.home-idle .market-ticker,
.home-idle .v3-search,
.home-has-results .market-ticker,
.home-has-results .v3-search,
.home-static .market-ticker,
.home-static .v3-search {
  max-width: 900px;
}
/* v0.10 PATCH-07: quote-strip keeps 1200px wide in all home states */
.home-idle .quote-strip,
.home-has-results .quote-strip,
.home-static .quote-strip {
  max-width: min(95vw, 1200px);
}

/* v0.3.1: remove quote strip from layout after search so results sit tightly under the bar */
.home-has-results .quote-strip {
  display: none;
  pointer-events: none;
}

.quote-strip-track {
  /* Continuous marquee scroll — single line, no wrap, seamless loop.
     Content is duplicated in JS for seamless looping. */
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0;
  padding-block: 0.72rem;
  white-space: nowrap;
  /* Width auto so the track can extend beyond the masked container */
  width: max-content;
  /* v0.10 PATCH-07: extended duration for wider 1200px strip */
  animation: quote-ticker-scroll 50s linear infinite;
}

/* Pause on hover for readability */
.quote-strip:hover .quote-strip-track {
  animation-play-state: paused;
}

.quote-strip a {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  color: inherit;
  text-decoration: none;
  white-space: nowrap;
  /* v0.5.4: leading pad widened slightly so the bold label glyphs are
     never the only character cluster peeking past the wedge. The trailing
     pad is unchanged — preserving the approved spacing rhythm. */
  padding-inline: 2.8rem 2.2rem;
  flex-shrink: 0;
}

.quote-strip a::before {
  content: "◇";
  color: var(--v3-gold-2);
  font-size: 0.75rem;
  flex-shrink: 0;
}

.quote-strip strong {
  color: var(--v3-gold-2);
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  flex-shrink: 0;
}

.quote-strip span {
  white-space: nowrap;
}

/* v0.3.6 keyframes */
@keyframes quote-ticker-scroll {
  0%   { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}

/* Stats row: slow left-right drift — not a full marquee, just a gentle sway */
@keyframes stats-drift {
  0%   { transform: translateX(0px); }
  25%  { transform: translateX(-8px); }
  75%  { transform: translateX(8px); }
  100% { transform: translateX(0px); }
}

/* Respect reduced-motion: freeze both animations */
@media (prefers-reduced-motion: reduce) {
  .quote-strip-track {
    animation: none;
    width: auto;
    flex-wrap: wrap;
    justify-content: center;
    white-space: normal;
  }
  .market-ticker-track {
    animation: none;
  }
}

.home-results {
  width: 100%;
  max-width: 900px;
  display: grid;
  gap: 0.9rem;
}

.home-results:empty {
  display: none;
}

.home-results-meta {
  color: var(--v3-muted);
  font-size: 0.92rem;
}

.clean-answer-stack {
  width: 100%;
  gap: 0.8rem;
}

.home-answer {
  width: 100%;
  padding: 1rem;
}

.home-answer h2 {
  margin: 0.25rem 0 0.45rem;
  font-size: 1.08rem;
  line-height: 1.22;
  letter-spacing: -0.02em;
}

.home-answer p {
  margin: 0;
  line-height: 1.55;
}

.home-result-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.8rem;
}
/* v0.10 PATCH-08: uniform button sizing in search result cards */
.home-result-actions .btn,
.home-result-actions a.btn {
  min-width: 140px;
  padding: 0.5rem 1rem;
  font-size: 0.82rem;
  line-height: 1.4;
  text-align: center;
  white-space: nowrap;
}

.home-load-more {
  justify-self: center;
  min-width: 140px;
}

.compact-empty {
  padding: 1rem;
}

.scope-chip {
  width: fit-content;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.45rem 0.75rem;
  border: 1px solid rgba(200, 146, 42, 0.28);
  border-radius: 999px;
  background: rgba(200, 146, 42, 0.10);
  color: var(--v3-gold-2);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.02em;
}

.scope-chip.small {
  padding: 0.3rem 0.55rem;
  font-size: 0.68rem;
}

.hero-lockup {
  width: 86px;
  height: 86px;
  display: grid;
  place-items: center;
  border: 1px solid var(--v3-line);
  border-radius: 28px;
  background: linear-gradient(145deg, rgba(246, 240, 223, 0.10), rgba(246, 240, 223, 0.03));
  color: var(--v3-gold-2);
  box-shadow: var(--v3-shadow);
}

.hero-lockup .logo2-mark {
  width: 62px;
  height: 62px;
}

.v3-hero h1:not(.home-product-title),
.page-title {
  max-width: 980px;
  margin: 0;
  font-size: clamp(2rem, 5vw, 3.5rem);
  line-height: 0.98;
  letter-spacing: -0.035em;
  color: var(--v3-ink);
}

.page-title {
  font-size: clamp(1.9rem, 3vw, 2.75rem);
  line-height: 1.04;
}

.home-tagline,
.page-sub {
  max-width: 860px;
  margin: 0;
  color: var(--v3-muted);
  font-size: clamp(1rem, 1.2vw, 1.2rem);
}

.page-kicker,
.answer-label,
.card-meta,
.label {
  font-family: var(--font-mono);
  color: var(--v3-faint);
  font-size: 0.78rem;
  letter-spacing: 0.015em;
}

.v3-search,
.search-header {
  max-width: 980px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem;
  border: 1px solid var(--v3-line-strong);
  border-radius: 24px;
  background: rgba(246, 240, 223, 0.08);
  box-shadow: var(--v3-shadow);
}

.search-icon {
  width: 2.75rem;
  height: 2.75rem;
  display: grid;
  place-items: center;
  color: var(--v3-gold-2);
  font-size: 1.35rem;
}

.hero-input,
.search-header input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--v3-ink);
  font-size: 1rem;
}

.hero-input::placeholder,
.search-header input::placeholder {
  color: var(--v3-faint);
}

.hero-search-btn,
.btn {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.72rem 1rem;
  border: 1px solid transparent;
  border-radius: 999px;
  text-decoration: none;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
}

.hero-search-btn,
.btn-primary {
  background: var(--v3-gold);
  color: #15130d;
}

.hero-search-btn:hover,
.btn-primary:hover {
  background: var(--v3-gold-2);
  color: #15130d;
}

.btn-ghost {
  border-color: var(--v3-line-strong);
  background: rgba(246, 240, 223, 0.05);
  color: var(--v3-ink);
}

.btn-ghost:hover {
  background: rgba(246, 240, 223, 0.10);
}

.home-stats,
.study-dashboard {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.8rem;
}

.lesson-overview,
.study-compact-grid,
.model-summary-strip,
.lesson-study-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.8rem;
}

/* v0.3.2 P1-1/P1-2: slim horizontal stats ticker — not stacked KPI cards. */
.stats-ticker {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 1.1rem;
  padding: 0.55rem 0.85rem;
  border-block: 1px solid var(--v3-line);
  color: var(--v3-muted);
  font-family: var(--font-mono);
  font-size: 0.74rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  background: transparent;
}

.stats-ticker span {
  display: inline-flex;
  align-items: baseline;
  gap: 0.4rem;
}

.stats-ticker span + span::before {
  content: "·";
  margin-right: 0.5rem;
  color: var(--v3-gold-2);
}

.stats-ticker strong {
  color: var(--v3-ink);
  font-family: var(--font-sans, inherit);
  font-weight: 800;
  font-size: 0.85rem;
  letter-spacing: -0.01em;
  text-transform: none;
}

.model-stats-ticker {
  justify-content: flex-end;
}

@media (max-width: 720px) {
  .stats-ticker {
    font-size: 0.7rem;
    padding: 0.5rem 0;
  }
  .model-stats-ticker {
    justify-content: flex-start;
  }
}

.lesson-continue,
.study-control {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 1rem;
  align-items: center;
  padding: 1rem;
  border: 1px solid var(--v3-line);
  border-radius: var(--v3-radius);
  background: var(--v3-card-bg);
  box-shadow: var(--v3-shadow);
}

.lesson-study-control {
  grid-template-columns: minmax(0, 1fr) auto;
}

.lesson-progress-card {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto auto auto;
  gap: 0.85rem;
  align-items: center;
  padding: 1rem;
  border: 1px solid var(--v3-line);
  border-radius: var(--v3-radius);
  background: var(--v3-card-bg);
  box-shadow: var(--v3-shadow);
}

.lesson-more-btn {
  width: 100%;
  justify-content: center;
  margin-top: 0.35rem;
}

.lesson-continue h2,
.study-control strong,
.lesson-progress-card strong {
  display: block;
  margin: 0.2rem 0 0.45rem;
  color: var(--v3-ink);
  font-size: 1.15rem;
  letter-spacing: -0.03em;
}

.lesson-continue p {
  max-width: 760px;
  margin: 0 0 0.7rem;
  color: var(--v3-muted);
}

.progress-track {
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: color-mix(in srgb, var(--v3-muted) 18%, transparent);
}

.progress-track.large {
  height: 11px;
}

.progress-track span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--v3-gold), var(--v3-green));
}

.lesson-table {
  display: grid;
  gap: 0.55rem;
}

.lesson-row {
  display: grid;
  grid-template-columns: 2.4rem minmax(0, 1fr) auto;
  gap: 0.85rem;
  align-items: center;
  padding: 0.85rem;
  border: 1px solid var(--v3-line);
  border-radius: 18px;
  background: var(--v3-card-bg);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.08);
}

.lesson-row.done {
  border-color: color-mix(in srgb, var(--v3-green) 45%, var(--v3-line));
}

.lesson-num {
  width: 2.1rem;
  height: 2.1rem;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: var(--v3-chip-bg);
  color: var(--v3-gold-2);
  font-family: var(--font-mono);
  font-weight: 800;
}

.lesson-main h2 {
  margin: 0;
  font-size: 1rem;
  line-height: 1.2;
  color: var(--v3-ink);
}

.lesson-main p {
  margin: 0.35rem 0;
  color: var(--v3-muted);
  font-size: 0.92rem;
}

.lesson-actions,
.lesson-nav {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  justify-content: flex-end;
}

.heart-btn {
  width: 2.15rem;
  height: 2.15rem;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--v3-line);
  border-radius: 999px;
  background: var(--v3-field-bg);
  color: var(--v3-muted);
  font-size: 1.1rem;
  font-weight: 900;
  line-height: 1;
  cursor: pointer;
  transition: transform 160ms ease, color 160ms ease, border-color 160ms ease, background 160ms ease;
}

.heart-btn:hover {
  transform: translateY(-1px);
  border-color: color-mix(in srgb, var(--v3-gold) 55%, var(--v3-line));
  color: var(--v3-gold-2);
}

.heart-btn.active {
  border-color: color-mix(in srgb, var(--v3-gold) 72%, var(--v3-line));
  background: color-mix(in srgb, var(--v3-gold) 18%, var(--v3-card-bg));
  color: var(--v3-gold-2);
}

.inline-nav {
  padding-inline: 0.35rem;
  border-inline: 1px solid var(--v3-line);
}

.btn.disabled,
.btn.disabled:hover {
  opacity: 0.45;
  pointer-events: none;
  background: var(--v3-field-bg);
  color: var(--v3-muted);
  border-color: var(--v3-line);
}

.lesson-study-grid {
  grid-template-columns: minmax(0, 1fr) minmax(300px, 0.75fr);
}

.compact-panel {
  padding: 1rem;
}

.practice-mini-list {
  display: grid;
  gap: 0.6rem;
}

.practice-mini {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.65rem;
  align-items: start;
  padding: 0.75rem;
  border: 1px solid var(--v3-line);
  border-radius: 14px;
  color: var(--v3-muted);
  background: var(--v3-field-bg);
}

.reflection-box {
  width: 100%;
  min-height: 160px;
  resize: vertical;
  border: 1px solid var(--v3-line-strong);
  border-radius: 16px;
  padding: 0.9rem;
  background: var(--v3-field-bg);
  color: var(--v3-ink);
  font: inherit;
  line-height: 1.5;
}

.reflection-box::placeholder {
  color: var(--v3-faint);
}

.study-progress-main {
  min-width: 0;
}

.model-summary-strip {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.models-page {
  /* v0.10 PATCH-05: center models page content */
  min-height: calc(100vh - 168px);
  align-content: center;
  gap: 0.9rem;
  max-width: var(--v3-search-col, 900px);
  margin-inline: auto;
  width: 100%;
}

.models-head {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(360px, 0.9fr);
  gap: 1rem;
  align-items: end;
}

.models-page .page-title {
  max-width: 760px;
  font-size: clamp(1.85rem, 3vw, 2.65rem);
}

.models-page .page-sub {
  max-width: 720px;
  margin-bottom: 0;
}

.model-summary-strip > div {
  padding: 0.9rem;
  border: 1px solid var(--v3-line);
  border-radius: 18px;
  background: var(--v3-field-bg);
}

.model-summary-strip span {
  display: block;
  color: var(--v3-faint);
  font-family: var(--font-mono);
  font-size: 0.72rem;
}

.model-summary-strip strong {
  display: block;
  margin-top: 0.2rem;
  color: var(--v3-ink);
}

.model-layout.compact-models {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.75rem;
}

/* v0.3.2 P0-3: tablet — prevent 4-up squeeze. */
@media (max-width: 1080px) {
  .model-layout.compact-models {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .model-folder-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* v0.3.2 P0-3: small tablet — 2-up. */
@media (max-width: 840px) {
  .model-layout.compact-models {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* v0.3.2 P0-3: phone — force single column, readable text. */
@media (max-width: 600px) {
  .model-layout.compact-models,
  .model-folder-row {
    grid-template-columns: 1fr;
  }
  .models-page .model-card {
    min-height: 0;
  }
}

.model-folder-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.75rem;
}

.model-folder {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: center;
  min-height: 58px;
  padding: 0.75rem 0.85rem;
  border: 1px solid var(--v3-line);
  border-radius: 18px;
  background: var(--v3-field-bg);
  color: var(--v3-ink);
  text-align: left;
}

.model-folder.active {
  border-color: color-mix(in srgb, var(--v3-gold) 62%, var(--v3-line));
  background: color-mix(in srgb, var(--v3-gold) 14%, var(--v3-card-bg));
}

.model-folder span {
  font-weight: 800;
}

.model-folder strong {
  color: var(--v3-muted);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  text-transform: uppercase;
}

.model-notes-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.model-notes-strip span {
  padding: 0.45rem 0.65rem;
  border: 1px solid var(--v3-line);
  border-radius: 999px;
  background: var(--v3-field-bg);
  color: var(--v3-muted);
  font-size: 0.82rem;
}

.models-page .model-card {
  min-height: 168px;
  padding: 0.9rem;
  border-radius: 20px;
}

.models-page .model-card h2 {
  margin-top: 0.55rem;
  font-size: 1rem;
  line-height: 1.15;
}

.models-page .model-card p {
  margin: 0.55rem 0 0;
  font-size: 0.86rem;
  line-height: 1.45;
}

.models-page .stage-num {
  width: 1.85rem;
  height: 1.85rem;
  border-radius: 10px;
  font-size: 0.82rem;
}

.models-page details {
  margin-top: 0.45rem;
  font-size: 0.8rem;
}

.models-page summary {
  width: fit-content;
}

.home-stat,
.kpi {
  padding: 1rem;
  border: 1px solid var(--v3-line);
  border-radius: var(--v3-radius-sm);
  background: rgba(246, 240, 223, 0.055);
}

.kpi span {
  display: block;
  margin-top: 0.25rem;
  overflow: hidden;
  color: var(--v3-muted);
  font-size: 0.82rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.home-stat .v,
.kpi .value {
  display: block;
  font-size: 1.55rem;
  font-weight: 800;
  letter-spacing: -0.04em;
  color: var(--v3-ink);
}

.home-stat .l {
  display: block;
  color: var(--v3-muted);
  font-size: 0.85rem;
}

.amber {
  color: var(--v3-gold-2) !important;
}

.v3-actions,
.ote-video-grid,
.model-layout,
.practice-grid,
.saved-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.action-card,
.ote-card,
.answer-card,
.panel,
.v3-panel,
.model-card,
.saved-note,
.state-card,
.key-note,
.mini-video,
.practice-row {
  border: 1px solid var(--v3-line);
  border-radius: var(--v3-radius);
  background: linear-gradient(145deg, rgba(246, 240, 223, 0.10), rgba(246, 240, 223, 0.045));
  color: var(--v3-ink);
  box-shadow: 0 14px 42px rgba(0, 0, 0, 0.16);
}

.action-card,
.mini-video {
  padding: 1.05rem;
  text-decoration: none;
}

.action-card:hover,
.mini-video:hover,
.ote-card:hover {
  border-color: rgba(200, 146, 42, 0.42);
  transform: translateY(-1px);
}

.action-card .ic {
  color: var(--v3-gold-2);
  font-family: var(--font-mono);
}

.action-title,
.action-sub,
.model-card h2,
.practice-row h2,
.ote-card h2 {
  margin: 0;
}

.action-title,
.model-card h2,
.practice-row h2,
.ote-card h2,
.panel h2 {
  letter-spacing: -0.03em;
}

.action-sub,
.ote-card p,
.model-card p,
.practice-row p,
.saved-note p,
.answer-card p,
.key-note p,
.panel p,
.mini-video span,
.muted {
  color: var(--v3-muted);
}

.page.v3-page {
  display: grid;
  gap: 1.35rem;
  padding-block: clamp(1.5rem, 4vw, 4rem);
}

.answer-stack {
  display: grid;
  gap: 1rem;
}

.answer-card,
.ote-card,
.model-card,
.panel,
.v3-panel,
.saved-note {
  padding: 1.25rem;
}

.answer-card h2 {
  margin: 0.35rem 0 0.65rem;
  font-size: 1.25rem;
}

.timestamp-row,
.card-actions,
.chip-row,
.library-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  align-items: center;
}

/* v0.3.1 time-link pill: neutral surface, gold as small accent.
   Goal: clearly clickable, soft medium weight, WCAG-AA readable in both modes. */
.time-link,
.note-time {
  width: fit-content;
  max-width: 100%;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.34rem 0.72rem;
  border-radius: 999px;
  border: 1px solid var(--v3-line-strong);
  background: var(--v3-field-bg);
  color: var(--v3-ink);
  font-family: var(--font-sans, inherit);
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.005em;
  text-decoration: none;
  transition: background 160ms ease, border-color 160ms ease, color 160ms ease;
}

.time-link .time-link-tc,
.note-time .time-link-tc {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  font-size: 0.76rem;
  color: var(--v3-ink);
  letter-spacing: 0.02em;
}

.time-link .time-link-sep,
.note-time .time-link-sep {
  color: var(--v3-faint);
  font-weight: 400;
}

.time-link .time-link-label,
.note-time .time-link-label {
  color: var(--v3-ink);
  font-weight: 500;
  font-size: 0.76rem;
  letter-spacing: 0.005em;
}

.time-link .time-link-title,
.note-time .time-link-title {
  max-width: 22rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--v3-muted);
  font-weight: 400;
  font-size: 0.76rem;
}

.time-link .time-link-arrow,
.note-time .time-link-arrow {
  color: var(--v3-gold-2);
  font-size: 0.78rem;
  opacity: 0.95;
}

.time-link:hover,
.note-time:hover {
  background: color-mix(in srgb, var(--v3-gold) 8%, var(--v3-field-bg) 92%);
  border-color: color-mix(in srgb, var(--v3-gold) 55%, var(--v3-line-strong));
  color: var(--v3-ink);
  text-decoration: none;
}

.time-link:hover .time-link-arrow,
.note-time:hover .time-link-arrow {
  opacity: 1;
}

.time-link:focus-visible,
.note-time:focus-visible {
  outline: 2px solid var(--v3-gold-2);
  outline-offset: 2px;
}

.note-title:hover,
.back-link:hover {
  text-decoration: underline;
}

.split-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(280px, 0.65fr);
  gap: 1rem;
}

.split-layout.wide-left {
  grid-template-columns: minmax(0, 1.1fr) minmax(320px, 0.9fr);
}

.section-title {
  margin: 0 0 0.75rem;
  font-size: 1rem;
  color: var(--v3-ink);
}

.note-list,
.mini-list,
.transcript-list,
.study-path {
  display: grid;
  gap: 0.75rem;
}

/* v0.3.1: pill on its own row so the wider Watch-on-YouTube pill never overlaps text */
.key-note {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.5rem;
  padding: 0.9rem;
}

.key-note > .note-time,
.key-note > .time-link {
  justify-self: start;
}

.key-note.compact {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.45rem;
}

.note-title {
  color: var(--v3-ink);
  font-weight: 800;
  text-decoration: none;
}

.tiny-btn {
  min-height: 34px;
  margin-top: 0.35rem;
  padding: 0.35rem 0.6rem;
  border: 1px solid var(--v3-line-strong);
  border-radius: 999px;
  background: rgba(246, 240, 223, 0.05);
  color: var(--v3-ink);
  font-family: var(--font-mono);
  font-size: 0.75rem;
}

.tiny-btn:hover {
  background: rgba(246, 240, 223, 0.12);
}

/* v0.3.1 readability pass: subtle search-term highlight.
   Keep body text in its normal ink color; mark uses a very low-opacity
   tint and a thin underline-style accent rather than a heavy fill. */
mark {
  padding: 0 0.12rem;
  border-radius: 3px;
  background: color-mix(in srgb, var(--v3-gold) 14%, transparent);
  color: inherit;
  font-weight: inherit;
  box-shadow: inset 0 -1px 0 color-mix(in srgb, var(--v3-gold) 45%, transparent);
}

html[data-theme="dark"] mark {
  background: color-mix(in srgb, var(--v3-gold) 18%, transparent);
  box-shadow: inset 0 -1px 0 color-mix(in srgb, var(--v3-gold) 55%, transparent);
}

.callout {
  padding: 1rem;
  border: 1px solid rgba(119, 165, 109, 0.32);
  border-radius: var(--v3-radius-sm);
  background: rgba(119, 165, 109, 0.08);
  color: var(--v3-muted);
}

.ote-video-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.compact-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.ote-card {
  display: grid;
  gap: 0.9rem;
}

.ote-card.done {
  border-color: rgba(119, 165, 109, 0.38);
  background: linear-gradient(145deg, rgba(119, 165, 109, 0.12), rgba(246, 240, 223, 0.045));
}

.card-head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
}

.watch-check,
.practice-row label,
.practice-row {
  color: var(--v3-muted);
  font-size: 0.9rem;
}

input[type="checkbox"] {
  accent-color: var(--v3-gold);
}

.video-hero {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
}

.back-link {
  width: fit-content;
  color: var(--v3-gold-2);
  text-decoration: none;
  font-weight: 800;
}

.tabs {
  width: fit-content;
  display: inline-flex;
  gap: 0.25rem;
  padding: 0.25rem;
  border: 1px solid var(--v3-line);
  border-radius: 999px;
  background: var(--v3-field-bg);
}

.tabs button {
  min-height: 40px;
  padding: 0.55rem 0.85rem;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  color: var(--v3-muted);
  font-weight: 800;
}

.tabs button.active {
  border: 1px solid var(--v3-line-strong);
  background: var(--v3-chip-bg);
  color: var(--v3-ink);
  box-shadow: 0 1px 3px color-mix(in srgb, var(--v3-ink) 15%, transparent);
}

.learning-list,
.takeaway-list {
  display: grid;
  gap: 0.65rem;
}

.learning-list {
  padding-left: 1.2rem;
  color: var(--v3-muted);
}

/* v0.3.1: takeaway item now wraps the wider time-link pill onto its own row. */
.takeaway-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas:
    "pill pill"
    "reason action"
    "text action";
  gap: 0.35rem 0.75rem;
  align-items: start;
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--v3-line);
}

.takeaway-item > .note-time,
.takeaway-item > .time-link {
  grid-area: pill;
  justify-self: start;
}

.takeaway-item > p.auto-reason {
  grid-area: reason;
  margin: 0;
}

.takeaway-item > p.snippet-quote,
.takeaway-item > p {
  grid-area: text;
  margin: 0;
  color: var(--v3-ink);
  line-height: 1.5;
}

.takeaway-item .tiny-btn,
.takeaway-item .heart-btn {
  grid-area: action;
  align-self: start;
}

.takeaway-item .heart-btn {
  min-width: 40px;
  min-height: 40px;
  border: 1px solid var(--v3-line);
  background: var(--v3-field-bg);
}

.takeaway-item .heart-btn.active {
  border-color: color-mix(in srgb, var(--v3-gold) 55%, var(--v3-line));
  color: var(--v3-gold-2);
  background: var(--v3-chip-bg);
}

.transcript-line {
  display: grid;
  grid-template-columns: 90px 1fr auto;
  gap: 0.85rem;
  align-items: start;
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--v3-line);
}

.transcript-line:last-child {
  border-bottom: 0;
}

.chip {
  padding: 0.35rem 0.55rem;
  border: 1px solid var(--v3-line);
  border-radius: 999px;
  background: rgba(246, 240, 223, 0.045);
  color: var(--v3-muted);
  font-family: var(--font-mono);
  font-size: 0.75rem;
}

.practice-row {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 1rem;
  align-items: start;
  padding: 1rem;
}

.practice-grid .practice-row {
  grid-template-columns: auto 1fr;
}

.stage-num {
  width: 2.25rem;
  height: 2.25rem;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: rgba(200, 146, 42, 0.16);
  color: var(--v3-gold-2);
  font-family: var(--font-mono);
  font-weight: 700;
}

details {
  margin-top: 0.75rem;
  color: var(--v3-muted);
}

summary {
  cursor: pointer;
  color: var(--v3-gold-2);
  font-weight: 800;
}

.saved-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.saved-categories {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.85rem;
  align-items: start;
}

.saved-column {
  min-height: 18rem;
  padding: 0.85rem;
  border: 1px solid var(--v3-line);
  border-radius: 22px;
  background: var(--v3-card-bg);
  box-shadow: var(--v3-shadow);
  max-height: 36rem;
  overflow-y: auto;
}

.saved-section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.65rem;
  margin-bottom: 0.7rem;
  color: var(--v3-muted);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.saved-section-head strong {
  min-width: 1.8rem;
  height: 1.8rem;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  background: var(--v3-chip-bg);
  color: var(--v3-gold-2);
  letter-spacing: 0;
}

.saved-stack {
  display: grid;
  gap: 0.65rem;
}

.saved-column .saved-note {
  padding: 0.85rem;
  border-radius: 16px;
  box-shadow: none;
  border: 1px solid var(--v3-line);
  background: var(--v3-field-bg);
}

.saved-lesson h2 {
  margin: 0.4rem 0 0.8rem;
  color: var(--v3-ink);
  font-size: 0.96rem;
  line-height: 1.25;
  letter-spacing: -0.025em;
}

.mini-empty {
  min-height: 8rem;
  display: grid;
  place-items: center;
  padding: 0.85rem;
  border: 1px dashed var(--v3-line);
  border-radius: 16px;
  text-align: center;
  font-size: 0.9rem;
}

.empty.state-card,
.empty {
  padding: 1.5rem;
  color: var(--v3-muted);
}

.empty .big {
  margin-bottom: 0.35rem;
  color: var(--v3-ink);
  font-weight: 800;
}

.app-footer {
  max-width: none;
  width: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  border-top: 1px solid var(--v3-line);
  border-radius: 0;
  background: var(--v3-surface);
  color: var(--v3-faint);
  font-size: 0.68rem;
  line-height: 1.25;
}

.app-footer strong {
  color: var(--v3-ink);
}

.footer-tab-content {
  max-width: none;
  margin: 0 auto;
  padding: 0.35rem clamp(1rem, 2vw, 2rem);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.18rem 0.55rem;
  flex-wrap: wrap;
  text-align: center;
}

@media (max-width: 980px) {
  .app-header {
    position: static;
    flex-wrap: wrap;
    row-gap: 8px;
    padding: 12px 16px;
  }

  .brand {
    flex: 1 1 auto;
  }

  .app-nav {
    order: 3;
    flex-basis: 100%;
    overflow-x: auto;
    overflow-y: visible;
    padding-bottom: 0.25rem;
    max-width: 100%;
    scrollbar-width: none;
    flex-wrap: nowrap;
    justify-content: flex-start;
    gap: 0.1rem;
  }

  .app-nav::-webkit-scrollbar {
    display: none;
  }

  .app-nav .nav-link {
    padding: 6px 10px;
    font-size: 13px;
    white-space: nowrap;
  }

  .app-nav .settings-toggle {
    padding: 0.35rem 0.65rem;
    font-size: 13px;
    min-height: 34px;
    margin-left: auto;
  }

  .nav-nudge {
    display: none;
  }

  .home-stats,
  .study-dashboard,
  .lesson-overview,
  .models-head,
  .model-folder-row,
  .lesson-study-grid,
  .study-compact-grid,
  .model-summary-strip,
  .ote-video-grid,
  .compact-grid,
  .model-layout,
  .compact-models,
  .practice-grid,
  .saved-grid,
  .saved-categories,
  .v3-actions,
  .split-layout,
  .split-layout.wide-left {
    grid-template-columns: 1fr;
  }

  .lesson-continue,
  .study-control,
  .lesson-progress-card,
  .lesson-row {
    grid-template-columns: 1fr;
  }

  .inline-nav {
    width: 100%;
    padding-inline: 0;
    border-inline: 0;
    border-block: 1px solid var(--v3-line);
    padding-block: 0.65rem;
  }

  .lesson-actions,
  .lesson-nav {
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .video-hero,
  .card-head {
    flex-direction: column;
  }
}

@media (max-width: 620px) {
  .app {
    padding-inline: 1rem;
  }

  /* v0.3.2 P0-4 / P2-6: keep brand title on one line. */
  .brand-title {
    white-space: nowrap;
    font-size: 15px;
  }
  .brand-logo-img {
    width: 30px;
    height: 30px;
  }

  .v3-search,
  .search-header {
    grid-template-columns: 1fr;
    border-radius: 18px;
  }

  .search-icon {
    display: none;
  }

  .hero-search-btn {
    width: 100%;
  }

  .v3-hero h1,
  .page-title {
    letter-spacing: -0.025em;
  }

  .clean-home {
    min-height: auto;
    align-content: start;
    padding-block: 2rem;
  }

  .home-product-title {
    font-size: clamp(2.8rem, 15vw, 4.8rem);
    line-height: 0.88;
    text-align: left;
    text-align-last: auto;
    letter-spacing: -0.07em;
  }

  .transcript-line,
  .key-note,
  .takeaway-item {
    grid-template-columns: 1fr;
  }
}

/* v0.3 readability pass: premium light/dark palettes with explicit contrast. */
:root,
html[data-theme="light"] {
  --v3-bg: #f4efe3;
  --v3-surface: #fffaf0;
  --v3-surface-2: #f8efd9;
  --v3-ink: #181a15;
  --v3-muted: #4f5148;
  --v3-faint: #777265;
  --v3-line: rgba(45, 43, 34, 0.14);
  --v3-line-strong: rgba(45, 43, 34, 0.24);
  --v3-gold: #b97b16;
  --v3-gold-2: #7b4f09;
  --v3-green: #496f4e;
  --v3-red: #9b4f3f;
  --v3-header-bg: rgba(250, 246, 236, 0.90);
  --v3-card-bg: linear-gradient(145deg, rgba(255, 252, 244, 0.96), rgba(246, 238, 220, 0.96));
  --v3-field-bg: rgba(255, 252, 244, 0.88);
  --v3-chip-bg: rgba(185, 123, 22, 0.10);
  --v3-icon-bg: rgba(185, 123, 22, 0.08);
  --v3-grid-line: rgba(45, 43, 34, 0.045);
  --v3-shadow: 0 18px 50px rgba(58, 49, 30, 0.14);
  --v3-button-text: #18130a;
  --v3-title-ink: #2f312a;
}

html[data-theme="dark"] {
  --v3-bg: #11140f;
  --v3-surface: #1b2018;
  --v3-surface-2: #242a20;
  --v3-ink: #f4ecd8;
  --v3-muted: #d0c5a9;
  --v3-faint: #a79b82;
  --v3-line: rgba(244, 236, 216, 0.18);
  --v3-line-strong: rgba(244, 236, 216, 0.30);
  --v3-gold: #d19a2e;
  --v3-gold-2: #f0c15d;
  --v3-green: #8ab47e;
  --v3-red: #d27b67;
  --v3-header-bg: rgba(17, 20, 15, 0.92);
  --v3-card-bg: linear-gradient(145deg, rgba(35, 41, 31, 0.96), rgba(25, 30, 23, 0.96));
  --v3-field-bg: rgba(244, 236, 216, 0.09);
  --v3-chip-bg: rgba(209, 154, 46, 0.14);
  --v3-icon-bg: rgba(244, 236, 216, 0.08);
  --v3-grid-line: rgba(244, 236, 216, 0.045);
  --v3-shadow: 0 22px 70px rgba(0, 0, 0, 0.30);
  --v3-button-text: #17130b;
  --v3-title-ink: #ded3b8;
}

html,
body {
  background:
    radial-gradient(circle at 18% 10%, color-mix(in srgb, var(--v3-gold) 18%, transparent), transparent 30rem),
    radial-gradient(circle at 88% 0%, color-mix(in srgb, var(--v3-green) 14%, transparent), transparent 28rem),
    var(--v3-bg);
  color: var(--v3-ink);
}

body::before {
  background-image:
    linear-gradient(var(--v3-grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--v3-grid-line) 1px, transparent 1px);
}

.app-header {
  background: var(--v3-header-bg);
}

.theme-toggle {
  min-height: 40px;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--v3-line-strong);
  border-radius: 999px;
  background: var(--v3-field-bg);
  color: var(--v3-ink);
  font-weight: 800;
}

.theme-toggle:hover {
  border-color: var(--v3-gold);
  color: var(--v3-gold-2);
}

.nav-link:hover,
.nav-link.active,
.nav-more.active .more-summary,
.more-summary:hover,
.more-link:hover,
.more-link.active,
.tabs button.active {
  background: var(--v3-chip-bg);
  color: var(--v3-ink);
}

.scope-chip {
  background: var(--v3-chip-bg);
  color: var(--v3-gold-2);
}

.hero-lockup,
.v3-search,
.search-header,
.home-stat,
.kpi,
.tabs,
.chip,
.tiny-btn,
.btn-ghost {
  background: var(--v3-field-bg);
}

.hero-lockup,
.action-card,
.ote-card,
.answer-card,
.panel,
.v3-panel,
.model-card,
.saved-note,
.state-card,
.key-note,
.mini-video,
.practice-row {
  background: var(--v3-card-bg);
  box-shadow: var(--v3-shadow);
}

.hero-search-btn,
.btn-primary {
  background: var(--v3-gold);
  color: var(--v3-button-text);
}

.hero-search-btn:hover,
.btn-primary:hover {
  background: var(--v3-gold-2);
  color: var(--v3-button-text);
}

.hero-input,
.search-header input {
  color: var(--v3-ink);
}

.hero-input::placeholder,
.search-header input::placeholder {
  color: var(--v3-faint);
  opacity: 1;
}

.panel p,
.v3-panel p,
.learning-list,
.learning-list li,
.transcript-line p,
.key-note p,
.answer-card p,
.ote-card p,
.model-card p,
.practice-row p,
.saved-note p,
.mini-video span,
.action-sub,
.page-sub,
.home-tagline {
  color: var(--v3-muted);
}

.panel h2,
.panel h3,
.v3-panel h2,
.v3-panel h3,
.ote-card h2,
.model-card h2,
.practice-row h2,
.answer-card h2,
.note-title,
.home-stat .v,
.kpi .value,
.brand-title {
  color: var(--v3-ink);
}

.learning-list li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.75rem;
  align-items: start;
  line-height: 1.55;
}

/* v0.3.1: .time-link / .note-time keep their own neutral ink color
   (defined above). Only the arrow + timestamp accents pick up gold. */
.back-link,
summary,
.search-icon,
.brand-logo-inline,
.hero-lockup,
.action-card .ic {
  color: var(--v3-gold-2);
}

html[data-theme="dark"] .back-link,
html[data-theme="dark"] summary,
html[data-theme="dark"] .search-icon,
html[data-theme="dark"] .brand-logo-inline,
html[data-theme="dark"] .hero-lockup,
html[data-theme="dark"] .action-card .ic {
  color: var(--v3-gold-2);
}

.page-kicker,
.answer-label,
.card-meta,
.label,
.brand-sub,
.home-stat .l {
  color: var(--v3-faint);
}

/* ===================================================================
   v0.3.1 — Legal-Safe Demo additions
   Components for non-affiliation framing, attribution, source snippets,
   raw-excerpt disclosure, About page, and footer disclaimer copy.
   =================================================================== */

.home-tagline {
  max-width: 760px;
  margin: 0;
  color: var(--v3-muted);
  font-size: 0.78rem;
  line-height: 1.45;
  letter-spacing: 0.005em;
}

.home-source-note {
  max-width: 760px;
  margin: 0;
  color: var(--v3-faint);
  font-size: 0.78rem;
  line-height: 1.5;
}

.home-source-note a {
  color: var(--v3-gold-2);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.home-has-results .home-source-note {
  display: none;
}

/* Footer disclaimers */
.footer-line {
  margin: 0;
  color: var(--v3-muted);
  font-size: 0.68rem;
  line-height: 1.25;
  max-width: none;
}

.footer-line::after {
  content: "•";
  margin-left: 0.55rem;
  color: var(--v3-faint);
}

.footer-line:last-child::after,
.footer-meta::after {
  content: "";
  margin: 0;
}

.footer-muted {
  color: var(--v3-faint);
}

.footer-meta {
  margin: 0;
  padding-top: 0;
  border-top: 0;
  color: var(--v3-faint);
  font-size: 0.68rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.footer-meta a {
  color: var(--v3-gold-2);
  text-decoration: underline;
  text-underline-offset: 2px;
  margin-inline: 0.35rem;
}

/* "Watch on YouTube" CTA — prominent button for detail pages */
.watch-on-youtube {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 0.95rem;
  border-radius: 999px;
  border: 1px solid var(--v3-gold);
  background: var(--v3-gold);
  color: var(--v3-button-text, #18130a);
  font-weight: 700;
  font-size: 0.82rem;
  text-decoration: none;
  letter-spacing: 0.01em;
  transition: filter 160ms ease, transform 160ms ease;
}

.watch-on-youtube:hover {
  filter: brightness(1.05);
  transform: translateY(-1px);
  text-decoration: none;
}

.watch-on-youtube:focus-visible {
  outline: 2px solid var(--v3-gold-2);
  outline-offset: 2px;
}

.watch-on-youtube .yt-arrow {
  font-size: 0.78rem;
  opacity: 0.85;
}

/* Attribution block: video / channel / source rows */
.attribution-block {
  display: grid;
  gap: 0.4rem;
  margin: 1rem 0;
  padding: 0.9rem 1rem;
  border: 1px solid var(--v3-line);
  border-left: 3px solid var(--v3-gold);
  border-radius: 8px;
  background: var(--v3-surface-2);
}

.attribution-block .attrib-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 0.6rem;
  align-items: baseline;
  font-size: 0.83rem;
  line-height: 1.4;
}

.attribution-block .attrib-label {
  color: var(--v3-faint);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  min-width: 4.5rem;
}

.attribution-block .attrib-value {
  color: var(--v3-ink);
  font-weight: 500;
}

.attrib-link {
  color: var(--v3-gold-2);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.attrib-note {
  margin: 0.4rem 0 0;
  padding-top: 0.4rem;
  border-top: 1px dashed var(--v3-line);
  color: var(--v3-faint);
  font-size: 0.75rem;
  line-height: 1.5;
}

/* Source snippet block (quoted, attributed) */
.snippet-quote {
  margin: 0 0 0.35rem;
  padding-left: 0.7rem;
  border-left: 2px solid color-mix(in srgb, var(--v3-gold) 50%, transparent);
  color: var(--v3-muted);
  font-size: 0.88rem;
  line-height: 1.55;
  font-style: italic;
}

.snippet-attrib {
  margin: 0;
  color: var(--v3-faint);
  font-size: 0.74rem;
  line-height: 1.5;
}

.snippet-attrib em {
  font-style: italic;
  color: var(--v3-muted);
}

/* Raw transcript disclosure — gated behind details/summary */
.raw-disclosure {
  margin: 0.75rem 0;
  padding: 0.6rem 0.8rem;
  border: 1px dashed var(--v3-line-strong);
  border-radius: 8px;
  background: color-mix(in srgb, var(--v3-faint) 6%, transparent);
}

.raw-disclosure > summary {
  cursor: pointer;
  color: var(--v3-gold-2);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  list-style: none;
}

.raw-disclosure > summary::-webkit-details-marker {
  display: none;
}

.raw-disclosure > summary::before {
  content: "▸ ";
  display: inline-block;
  transition: transform 160ms ease;
}

.raw-disclosure[open] > summary::before {
  content: "▾ ";
}

.raw-disclosure-warning,
.raw-corruption-warning {
  margin: 0.5rem 0;
  padding: 0.55rem 0.7rem;
  border-left: 3px solid var(--v3-red);
  background: color-mix(in srgb, var(--v3-red) 8%, transparent);
  color: var(--v3-muted);
  font-size: 0.78rem;
  line-height: 1.5;
}

.raw-excerpt-list {
  margin: 0.5rem 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 0.4rem;
}

.raw-excerpt-list li {
  padding: 0.4rem 0.55rem;
  border-left: 2px solid var(--v3-line-strong);
  color: var(--v3-muted);
  font-family: var(--font-mono);
  font-size: 0.76rem;
  line-height: 1.5;
  white-space: pre-wrap;
}

/* About page */
.about-page {
  display: grid;
  gap: 1.25rem;
  max-width: 900px;
  margin: 0 auto;
}

.about-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
}

.about-grid .panel {
  padding: 1.1rem 1.15rem;
  border: 1px solid var(--v3-line);
  border-radius: 10px;
  background: var(--v3-card-bg);
}

.about-grid .panel h2 {
  margin: 0 0 0.45rem;
  font-size: 1.02rem;
  font-weight: 700;
  letter-spacing: -0.005em;
  color: var(--v3-ink);
}

.about-grid .panel p {
  margin: 0 0 0.5rem;
  color: var(--v3-muted);
  font-size: 0.88rem;
  line-height: 1.55;
}

.about-grid .panel a {
  color: var(--v3-gold-2);
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* Settings: non-affiliation row */
.settings-non-affiliation {
  margin-top: 0.7rem;
  padding-top: 0.7rem;
  border-top: 1px solid var(--v3-line);
  color: var(--v3-muted);
  font-size: 0.78rem;
  line-height: 1.5;
}

.settings-non-affiliation strong {
  display: block;
  margin-bottom: 0.3rem;
  color: var(--v3-ink);
  font-size: 0.78rem;
  font-weight: 700;
}

.settings-non-affiliation a {
  color: var(--v3-gold-2);
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* Generic small-muted helper */
.small-muted {
  color: var(--v3-faint);
  font-size: 0.78rem;
  line-height: 1.5;
}

/* Original-content note (study-summary kicker) */
.original-content-note {
  margin: 0 0 0.6rem;
  padding: 0.45rem 0.7rem;
  border-left: 3px solid var(--v3-gold);
  background: color-mix(in srgb, var(--v3-gold) 8%, transparent);
  color: var(--v3-muted);
  font-size: 0.78rem;
  line-height: 1.5;
}

/* Mobile: shrink the home title and stack attribution rows */
@media (max-width: 720px) {
  .clean-home,
  .clean-home.home-idle,
  .clean-home.home-has-results,
  .clean-home.home-static {
    max-width: 100%;
    align-content: start;
  }

  .home-product-title,
  .home-idle .home-product-title,
  .home-static .home-product-title {
    /* On phones the column collapses to 100%, so let the title fill it. */
    width: 100%;
    max-width: 100%;
    font-size: clamp(2.2rem, 14.5vw, 4.6rem);
    line-height: 0.9;
    letter-spacing: -0.05em;
  }

  .attribution-block .attrib-row {
    flex-direction: column;
    gap: 0.1rem;
  }

  .time-link .time-link-title,
  .note-time .time-link-title {
    display: none;
  }
}

/* v0.3.1 width-alignment lock — last in cascade.
   Forces the searched-home column (search bar + results meta + answer stack +
   each answer card) to share one max-width token and identical horizontal
   placement (justify-self: stretch, no auto margins). Ensures visual
   continuity between the search bar and the results below it. */
.clean-home .v3-search,
.clean-home .home-results,
.clean-home .home-results-meta,
.clean-home .clean-answer-stack,
.clean-home .answer-stack,
.clean-home .answer-card,
.clean-home .home-answer,
.home-idle .v3-search,
.home-has-results .v3-search,
.home-static .v3-search,
.home-has-results .home-results,
.home-has-results .home-results-meta,
.home-has-results .clean-answer-stack,
.home-has-results .answer-card,
.home-has-results .home-answer {
  width: 100%;
  max-width: var(--v3-search-col);
  margin-inline: 0;
  justify-self: stretch;
  box-sizing: border-box;
}

/* Keep the post-search source note suppressed (preserves prior v0.3.1 fix). */
.home-has-results .home-source-note,
.home-has-results .quote-strip {
  display: none !important;
}

@media (max-width: 720px) {
  :root,
  html[data-theme="light"],
  html[data-theme="dark"] {
    --v3-search-col: 100%;
  }
}

/* ============================================================
   v0.3.2 Library Lane — full archive lessons UI
   ============================================================ */

.lib-page {
  display: grid;
  gap: 1rem;
}

/* Compact Library index — fit on one screen on desktop. */
.lib-page-compact {
  gap: 0.75rem;
}

.lib-page-compact .page-kicker { margin: 0; }
.lib-page-compact .page-title {
  font-size: 1.85rem;
  line-height: 1.1;
  margin: 0;
}
.lib-page-compact .lib-sub {
  margin: 0.15rem 0 0;
  color: var(--v3-muted);
  font-size: 0.92rem;
}

.lib-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1.5rem;
  flex-wrap: wrap;
}
.lib-header-text { min-width: 0; }

/* Detail page compaction */
.lib-detail-page { gap: 0.7rem; }
.lib-detail-page .page-title {
  font-size: 1.6rem;
  margin: 0.05rem 0 0;
  line-height: 1.15;
  /* v0.4.1 — long folder names should wrap, not overflow into chips row. */
  word-break: break-word;
  overflow-wrap: anywhere;
  hyphens: auto;
}
.lib-detail-page .lib-folder-title {
  max-width: 100%;
}
.lib-detail-page .page-kicker { margin: 0; }
.lib-detail-head-row {
  display: grid;
  gap: 0.3rem;
}

/* Library meta strip retained for legacy use (no longer rendered on the Library index page). */
.lib-meta-strip {
  display: none;
}

.lib-meta-kpi {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}

.lib-meta-kpi .label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--v3-muted);
  font-weight: 600;
}

.lib-meta-kpi strong {
  font-size: 1.05rem;
  color: var(--v3-ink);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}

.lib-legend {
  display: inline-flex;
  gap: 0.4rem;
  align-items: center;
  justify-self: end;
}

.lib-tabs {
  display: inline-flex;
  gap: 0.35rem;
  padding: 0.25rem;
  border: 1px solid var(--v3-line);
  border-radius: 999px;
  background: var(--v3-field-bg);
  width: max-content;
}

.lib-tab {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--v3-muted);
  font: inherit;
  font-weight: 600;
  letter-spacing: 0;
  padding: 0.45rem 0.95rem;
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex;
  gap: 0.45rem;
  align-items: center;
}

.lib-tab:hover {
  color: var(--v3-ink);
}

.lib-tab.active {
  background: var(--v3-card-bg);
  color: var(--v3-ink);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.lib-tab-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.4rem;
  height: 1.1rem;
  padding: 0 0.35rem;
  font-size: 0.7rem;
  font-weight: 700;
  border-radius: 999px;
  background: var(--v3-chip-bg);
  color: var(--v3-muted);
}

.lib-tab.active .lib-tab-count {
  color: var(--v3-gold-2);
}

.lib-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 0.7rem;
}

/* Compact grid for the Library index — denser, four columns on wide desktops. */
.lib-grid-compact {
  grid-template-columns: repeat(auto-fill, minmax(248px, 1fr));
  gap: 0.6rem;
  /* v0.10 PATCH-04 / v0.11 PATCH-09: uniform row height so all tiles in a row stretch equally */
  grid-auto-rows: 1fr;
  align-items: stretch;
}
/* v0.11 PATCH-09: lib-tile min-height + flex column for uniform height */
.lib-grid-compact .lib-card,
.lib-grid-compact .ia-lock-tile {
  min-height: 118px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: 100%;
}

@media (min-width: 1180px) {
  .lib-grid-compact { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (min-width: 1500px) {
  .lib-grid-compact { grid-template-columns: repeat(5, minmax(0, 1fr)); }
}

.lib-card {
  display: grid;
  gap: 0.45rem;
  padding: 0.85rem 0.95rem;
  border: 1px solid var(--v3-line);
  border-radius: 16px;
  /* Same playlist gradient applied to all library cards. */
  background:
    linear-gradient(145deg, color-mix(in srgb, var(--v3-gold) 9%, var(--v3-card-bg)) 0%, var(--v3-card-bg) 60%, color-mix(in srgb, var(--v3-green) 5%, var(--v3-card-bg)) 100%);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.05);
  text-decoration: none;
  color: inherit;
  transition: transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
  min-height: 118px;
  /* v0.3.6 enrichment-parity fix: keep all children inside the card boundary
     in the dense 4-/5-column grid where the OTE title is long. */
  box-sizing: border-box;
  min-width: 0;
  overflow: hidden;
}

.lib-card > * { min-width: 0; }

.lib-card:hover {
  transform: translateY(-2px);
  border-color: color-mix(in srgb, var(--v3-gold) 45%, var(--v3-line));
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.09);
}

.lib-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
  /* Allow the pill to wrap below the title on narrow card widths
     (e.g. 4-/5-column dense grid) instead of forcing horizontal overflow. */
  flex-wrap: wrap;
  min-width: 0;
}

.lib-card-name {
  font-weight: 700;
  font-size: 0.98rem;
  color: var(--v3-ink);
  letter-spacing: -0.01em;
  line-height: 1.25;
  /* Let the title shrink and wrap so the right-hand pill never pushes past
     the card edge. flex: 1 1 ... gives the title room, min-width: 0 lets it
     wrap normally, overflow-wrap: anywhere handles very long single words. */
  flex: 1 1 9rem;
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
  hyphens: auto;
}

.lib-card-sub {
  margin: 0;
  font-size: 0.85rem;
  color: var(--v3-muted);
  line-height: 1.4;
}

.lib-card-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.lib-card-meta {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  color: var(--v3-muted);
  font-size: 0.85rem;
  margin-top: auto;
  /* Stay inside the card if both values are long; right-side duration
     was overflowing the box on the OTE card at desktop width. */
  gap: 0.5rem;
  flex-wrap: wrap;
  min-width: 0;
}

.lib-card-meta > span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.lib-card-meta strong {
  color: var(--v3-ink);
  font-variant-numeric: tabular-nums;
}

/* Topic cards now share the playlist gradient; only a small accent shift differentiates them. */
.lib-card-topic {
  background:
    linear-gradient(145deg, color-mix(in srgb, var(--v3-green) 10%, var(--v3-card-bg)) 0%, var(--v3-card-bg) 55%, color-mix(in srgb, var(--v3-gold) 6%, var(--v3-card-bg)) 100%);
}

/* v0.3.9 sprint-2 fix #5 — Topics tab grid uses a coarser column count so
   the ~12 topic cards fill the canvas with similar visual weight to the ~20
   playlist cards. Title and padding are nudged up only inside Topics. */
.lib-grid.lib-grid-topics {
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 0.7rem;
}
@media (min-width: 900px) {
  .lib-grid.lib-grid-topics { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (min-width: 1500px) {
  .lib-grid.lib-grid-topics { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
.lib-page-v038 .lib-grid.lib-grid-topics {
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  /* v0.11 PATCH-09: uniform row height for topics too */
  grid-auto-rows: 1fr;
  align-items: stretch;
}
.lib-page-v038 .lib-grid.lib-grid-topics .lib-card,
.lib-page-v038 .lib-grid.lib-grid-topics .ia-lock-tile {
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
@media (min-width: 900px) {
  .lib-page-v038 .lib-grid.lib-grid-topics { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (min-width: 1500px) {
  .lib-page-v038 .lib-grid.lib-grid-topics { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
.lib-card.lib-card-topic-lg {
  padding: 0.85rem 1rem;
  gap: 0.45rem;
}
.lib-card.lib-card-topic-lg .lib-card-name {
  font-size: 1.02rem;
  line-height: 1.25;
  font-weight: 700;
}
.lib-card.lib-card-topic-lg .lib-card-meta {
  font-size: 0.82rem;
  margin-top: 0.15rem;
}
.lib-card.lib-card-topic-lg .status-pill {
  font-size: 0.72rem;
  padding: 0.18rem 0.55rem;
}
/* On dense (short viewport) pages, drop the bigger topic-lg padding back
   down so the one-page-compactness goal still holds. */
.lib-page-dense .lib-card.lib-card-topic-lg { padding: 0.55rem 0.7rem; }
.lib-page-dense .lib-card.lib-card-topic-lg .lib-card-name { font-size: 0.92rem; }

/* Filter bar (year + concept) appears on lists with >20 videos.
   v0.4.2 redesign: every filter row uses the same two-column grid layout
   (fixed-width label column + chips area). Labels align in a clean vertical
   stack on the left and chip rows share identical height/spacing so each
   filter category looks visually equal. Uses existing v0.4.1 tokens only. */
.lib-filters {
  display: grid;
  gap: 0.5rem;
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--v3-line-strong);
  border-radius: 14px;
  background: var(--v3-field-bg);
  position: sticky;
  top: calc(var(--header-h, 64px) + 8px);
  z-index: 10;
  backdrop-filter: blur(20px);
}
.lib-filter-row {
  display: grid;
  grid-template-columns: 84px 1fr;
  align-items: start;
  column-gap: 0.85rem;
  row-gap: 0.35rem;
  min-width: 0;
}
.lib-filter-row + .lib-filter-row {
  border-top: 1px dashed var(--v3-line);
  padding-top: 0.5rem;
}
.lib-filter-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  font-weight: 700;
  color: var(--v3-muted);
  padding-top: 0.3rem; /* vertical-center against first chip row */
  white-space: nowrap;
}
.lib-filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  min-width: 0;
  align-items: center;
}
.lib-filter-chip {
  appearance: none;
  border: 1px solid var(--v3-line);
  background: var(--v3-card-bg);
  color: var(--v3-muted);
  padding: 0 0.7rem;
  height: 28px;
  border-radius: 999px;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  line-height: 1;
  white-space: nowrap;
  transition: border-color 140ms ease, color 140ms ease, background 140ms ease;
}
.lib-filter-chip:hover {
  color: var(--v3-ink);
  border-color: color-mix(in srgb, var(--v3-gold) 40%, var(--v3-line));
}
.lib-filter-chip:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--v3-gold) 65%, transparent);
  outline-offset: 2px;
}
.lib-filter-chip.active {
  background: color-mix(in srgb, var(--v3-gold) 18%, var(--v3-card-bg));
  border-color: color-mix(in srgb, var(--v3-gold) 55%, var(--v3-line));
  color: var(--v3-ink);
}

html[data-theme="dark"] .tabs {
  border-color: var(--v3-line-strong);
  background: color-mix(in srgb, var(--v3-surface-2) 78%, transparent);
}

html[data-theme="dark"] .tabs button {
  color: var(--v3-muted);
}

html[data-theme="dark"] .tabs button.active {
  border-color: var(--v3-line-strong);
  background: var(--v3-surface-2);
  color: var(--v3-gold-2);
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.32);
}

html[data-theme="dark"] .lib-filters {
  border-color: var(--v3-line-strong);
  background: color-mix(in srgb, var(--v3-surface-2) 92%, transparent);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.28);
}

html[data-theme="dark"] .lib-filter-chip {
  border-color: var(--v3-line-strong);
  background: var(--v3-surface-2);
  color: var(--v3-faint);
}

html[data-theme="dark"] .lib-filter-chip.active,
html[data-theme="dark"] .lib-filter-chip:hover {
  border-color: color-mix(in srgb, var(--v3-gold) 64%, var(--v3-line-strong));
  background: var(--v3-chip-bg);
  color: var(--v3-gold-2);
}

html[data-theme="dark"] .saved-column {
  border-color: var(--v3-line-strong);
  background: var(--v3-card-bg);
}

html[data-theme="dark"] .saved-section-head {
  border-bottom: 1px solid var(--v3-line);
  padding-bottom: 0.55rem;
}

html[data-theme="dark"] .saved-column .saved-note {
  border-color: var(--v3-line-strong);
  background: color-mix(in srgb, var(--v3-surface-2) 72%, transparent);
}

@media (max-width: 640px) {
  .lib-filters {
    padding: 0.65rem 0.7rem;
    gap: 0.45rem;
  }
  .lib-filter-row {
    grid-template-columns: 1fr;
    row-gap: 0.3rem;
  }
  .lib-filter-label {
    padding-top: 0;
  }
  .lib-filter-row + .lib-filter-row {
    padding-top: 0.45rem;
  }
}
@media (max-width: 480px) {
  .lib-filter-chips {
    max-height: 5.4rem;
    overflow-y: auto;
    padding-right: 0.25rem;
    -webkit-mask-image: linear-gradient(to bottom, #000 70%, transparent 100%);
    mask-image: linear-gradient(to bottom, #000 70%, transparent 100%);
  }
}
.lib-filter-count {
  font-variant-numeric: tabular-nums;
  color: var(--v3-muted);
  font-weight: 600;
  font-size: 0.7rem;
  opacity: 0.85;
}

.lib-note {
  margin: 0 0 0.5rem;
  color: var(--v3-muted);
  font-size: 0.88rem;
}

/* Status pills */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.18rem 0.55rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  border: 1px solid transparent;
  white-space: nowrap;
  /* Inside a library card, allow the pill to shrink against the title
     so it can never push past the card's right edge. flex-wrap on the
     head row will drop it to its own line before it overflows. */
  flex: 0 1 auto;
  max-width: 100%;
}

.lib-card .status-pill {
  /* Slightly tighter so 'Enriched · 27/27' fits in a 4-/5-col grid cell. */
  padding: 0.16rem 0.5rem;
  font-size: 0.68rem;
}

.status-pill.mini {
  font-size: 0.65rem;
  padding: 0.1rem 0.4rem;
}

.status-pill.status-enriched {
  background: color-mix(in srgb, var(--v3-green) 18%, var(--v3-card-bg));
  color: var(--v3-green);
  border-color: color-mix(in srgb, var(--v3-green) 35%, transparent);
}

.status-pill.status-index {
  background: color-mix(in srgb, var(--v3-muted) 14%, var(--v3-card-bg));
  color: var(--v3-muted);
  border-color: color-mix(in srgb, var(--v3-muted) 28%, transparent);
}

.status-pill.status-neutral {
  background: var(--v3-chip-bg);
  color: var(--v3-muted);
  border-color: var(--v3-line);
}

/* v0.3.6 enrichment-parity: tier-aware pills.
   - status-hand  = OTE Pilot only. Hand-written summary + 8-step model. Green accent.
   - status-auto  = Auto-extracted highlights. Gold accent. Clearly different from hand. */
.status-pill.status-hand {
  background: color-mix(in srgb, var(--v3-green) 18%, var(--v3-card-bg));
  color: var(--v3-green);
  border-color: color-mix(in srgb, var(--v3-green) 38%, transparent);
}

.status-pill.status-auto {
  background: color-mix(in srgb, var(--v3-gold) 16%, var(--v3-card-bg));
  color: var(--v3-gold);
  border-color: color-mix(in srgb, var(--v3-gold) 42%, transparent);
}

/* Mix chip shown next to status pill when folder has multiple tiers (e.g. "+12 indexed"). */
.status-mix-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  margin-left: 0.35rem;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  font-size: 0.66rem;
  font-weight: 600;
  color: var(--v3-muted);
  background: var(--v3-chip-bg);
  border: 1px solid var(--v3-line);
  letter-spacing: 0.01em;
  white-space: nowrap;
}

/* Reason line under auto-extracted highlights: clearly marked as automated. */
.auto-reason {
  margin: 0.2rem 0 0.35rem;
  font-size: 0.78rem;
  color: var(--v3-muted);
  line-height: 1.4;
}

.auto-reason-label {
  display: inline-block;
  margin-right: 0.3rem;
  font-weight: 700;
  color: var(--v3-faint);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 0.66rem;
}

/* Topic-level Q&A list shown on non-OTE video detail pages. */
.topic-qa-list {
  display: grid;
  gap: 0.6rem;
  margin-top: 0.65rem;
}

.topic-qa-item {
  border: 1px solid var(--v3-line);
  border-radius: 12px;
  padding: 0.55rem 0.75rem;
  background: color-mix(in srgb, var(--v3-gold) 4%, var(--v3-card-bg, transparent));
}

.topic-qa-item > summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--v3-ink);
  list-style: none;
  position: relative;
  padding-right: 1.25rem;
}

/* v0.10 PATCH-12: removed + / − expand icon from Q&A items.
   Disclosure handled by \25b8 arrow in summary::before below. */
.topic-qa-item > summary::after { content: none; display: none; }
.topic-qa-item[open] > summary::after { content: none; display: none; }

.topic-qa-item > p {
  margin: 0.45rem 0 0.25rem;
  color: var(--v3-ink);
  line-height: 1.55;
  font-size: 0.93rem;
}

.topic-qa-item > p.muted {
  color: var(--v3-muted);
  font-size: 0.78rem;
}

/* Chips */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.16rem 0.5rem;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  border: 1px solid var(--v3-line);
  color: var(--v3-muted);
  background: var(--v3-chip-bg);
  text-decoration: none;
}

.chip.chip-soft {
  background: var(--v3-chip-bg);
  color: var(--v3-ink);
}

.chip.chip-quiet {
  background: transparent;
  color: var(--v3-muted);
}

.chip.chip-muted {
  background: transparent;
  color: var(--v3-muted);
  border-style: dashed;
}

.chip.chip-warn {
  background: color-mix(in srgb, var(--v3-gold) 14%, var(--v3-card-bg));
  color: var(--v3-gold-2);
  border-color: color-mix(in srgb, var(--v3-gold) 40%, transparent);
}

a.chip:hover {
  border-color: color-mix(in srgb, var(--v3-gold) 55%, var(--v3-line));
  color: var(--v3-gold-2);
}

/* Detail head row */
.lib-detail-head {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
  margin: 0.1rem 0 0.2rem;
}

.lib-topic-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin: 0.3rem 0 0.4rem;
}

/* Compact archive row table — v0.4.1 lesson-row cleanup.
   The row is now a 2-column grid: a clickable title-link (which itself uses
   a CSS grid to put title/meta on the left and numeric date/duration on the
   right) and a small actions cluster (heart + YouTube). All text wraps or
   clamps cleanly — no overflow. Duration is right-aligned and tabular. */
.lib-row-table {
  display: grid;
  gap: 0.4rem;
}

.lib-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.5rem;
  align-items: stretch;
  padding: 0;
  border: 1px solid var(--v3-line);
  border-radius: 12px;
  background: var(--v3-card-bg);
  transition: border-color 0.15s ease, background 0.15s ease;
  min-width: 0;
}

.lib-row:hover {
  border-color: color-mix(in srgb, var(--v3-gold) 35%, var(--v3-line));
  background: color-mix(in srgb, var(--v3-card-bg) 92%, var(--v3-gold) 8%);
}

.lib-row-titlelink {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.85rem;
  padding: 0.55rem 0.85rem;
  text-decoration: none;
  color: inherit;
  min-width: 0;
  border-radius: 12px 0 0 12px;
}
.lib-row-titlelink:hover .lib-row-title,
.lib-row-titlelink:focus-visible .lib-row-title {
  color: var(--v3-gold-2);
}
.lib-row-titlelink:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--v3-gold) 55%, transparent);
  outline-offset: -2px;
}

.lib-row-titleblock {
  display: grid;
  gap: 0.25rem;
  min-width: 0;
}

.lib-row-title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1.3;
  color: var(--v3-ink);
  letter-spacing: -0.01em;
  /* Clamp to two lines max so cards stay compact and never overflow. */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  line-clamp: 2;
  overflow: hidden;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.lib-row-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.45rem;
  align-items: center;
  color: var(--v3-muted);
  font-size: 0.78rem;
  min-width: 0;
}

.lib-row-numeric {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: center;
  gap: 0.1rem;
  flex: 0 0 auto;
  color: var(--v3-faint);
  font-family: var(--font-mono, ui-monospace, SFMono-Regular, Menlo, monospace);
  font-variant-numeric: tabular-nums lining-nums;
  font-size: 0.74rem;
  line-height: 1.2;
  letter-spacing: 0.01em;
  white-space: nowrap;
}
.lib-row-date {
  color: var(--v3-faint);
}
.lib-row-dur {
  color: var(--v3-muted);
  font-weight: 500;
}

.lib-row-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0 0.55rem 0 0.1rem;
  flex: 0 0 auto;
}

.lib-row-actions .heart-btn {
  width: 2.1rem;
  height: 2.1rem;
  font-size: 1rem;
}

.lib-row-icon-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.1rem;
  height: 2.1rem;
  min-width: 2.6rem;
  padding: 0 0.55rem;
  border-radius: 999px;
  border: 1px solid var(--v3-line);
  background: transparent;
  color: var(--v3-muted);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-decoration: none;
  white-space: nowrap;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}
.lib-row-icon-link:hover,
.lib-row-icon-link:focus-visible {
  color: var(--v3-gold-2);
  border-color: color-mix(in srgb, var(--v3-gold) 45%, var(--v3-line));
  background: color-mix(in srgb, var(--v3-gold) 10%, transparent);
  outline: none;
}

/* Hide redundant playlist chip on a playlist folder page — every row is from
   the same playlist already. Keep it on topic folders where rows span
   multiple playlists. */
.lib-page-playlist .lib-row-playlist-chip {
  display: none;
}

/* v0.4.1 — collapsible folder groupings (year / concept). */
.lib-row-groups {
  display: grid;
  gap: 0.55rem;
}
.lib-row-group {
  border: 1px solid var(--v3-line);
  border-radius: 14px;
  background: color-mix(in srgb, var(--v3-card-bg) 60%, transparent);
  overflow: hidden;
}
.lib-row-group[open] {
  background: var(--v3-card-bg);
}
.lib-row-group > .lib-row-table {
  padding: 0.4rem 0.55rem 0.55rem;
  border-top: 1px solid var(--v3-line);
  background: color-mix(in srgb, var(--v3-card-bg) 50%, transparent);
}
.lib-row-group-summary {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.55rem 0.85rem;
  cursor: pointer;
  list-style: none;
  color: var(--v3-ink);
  font-weight: 700;
  font-size: 0.82rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  user-select: none;
}
.lib-row-group-summary::-webkit-details-marker { display: none; }
.lib-row-group-summary::before {
  content: "›";
  display: inline-block;
  width: 0.85rem;
  text-align: center;
  color: var(--v3-faint);
  transition: transform 0.18s ease;
  font-size: 1rem;
  line-height: 1;
}
.lib-row-group[open] > .lib-row-group-summary::before {
  transform: rotate(90deg);
}
.lib-row-group-label {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.lib-row-group-count {
  flex: 0 0 auto;
  font-family: var(--font-mono, ui-monospace, SFMono-Regular, Menlo, monospace);
  font-variant-numeric: tabular-nums lining-nums;
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--v3-faint);
  background: color-mix(in srgb, var(--v3-ink) 6%, transparent);
  border-radius: 999px;
  padding: 0.1rem 0.55rem;
  letter-spacing: 0;
  text-transform: none;
}

/* v0.4.1 — the chip-set inside each row meta line uses a smaller variant so
   two pills + a playlist chip fit on one line without wrapping on desktop. */
.lib-row-meta .chip,
.lib-row-meta .status-pill {
  padding: 0.15rem 0.55rem;
  font-size: 0.7rem;
  letter-spacing: 0.02em;
  line-height: 1.4;
  border-radius: 999px;
}
.lib-row-meta .status-pill.mini { font-size: 0.7rem; }

/* Archive video detail page */
.lib-archive-video .lib-detail-head .heart-btn {
  height: 2.4rem;
  width: 2.4rem;
}

/* v0.3.9 sprint-2 fix #3 — uniform pill row on every lesson page.
   Previously the Watch CTA, heart button, Study-ready pill, and timestamps
   chip rendered at four different heights, making the row look uneven.
   These rules normalise box height, vertical padding, line-height, and
   font-size so all four sit on the same baseline regardless of label
   length. Scoped to .lib-archive-video so other surfaces are unaffected. */
.lib-archive-video .lib-detail-head {
  gap: 0.5rem;
  align-items: center;
}
.lib-archive-video .lib-detail-head .watch-on-youtube,
.lib-archive-video .lib-detail-head .heart-btn,
.lib-archive-video .lib-detail-head .status-pill,
.lib-archive-video .lib-detail-head .chip {
  height: 2.4rem;
  min-height: 2.4rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  box-sizing: border-box;
}
.lib-archive-video .lib-detail-head .watch-on-youtube {
  padding-top: 0;
  padding-bottom: 0;
  font-size: 0.85rem;
}
.lib-archive-video .lib-detail-head .status-pill {
  padding: 0 0.75rem;
  font-size: 0.78rem;
}
.lib-archive-video .lib-detail-head .chip {
  padding: 0 0.75rem;
  font-size: 0.78rem;
}

.lib-segment-preview {
  margin-top: 0.6rem;
  padding: 1rem;
  border: 1px solid var(--v3-line);
  border-radius: var(--v3-radius);
  background: var(--v3-card-bg);
}

.lib-segment-list {
  list-style: none;
  margin: 0.6rem 0 0;
  padding: 0;
  display: grid;
  gap: 0.6rem;
}

.lib-segment-item {
  padding: 0.7rem 0.85rem;
  border: 1px solid var(--v3-line);
  border-radius: 12px;
  background: var(--v3-field-bg);
  display: grid;
  gap: 0.35rem;
}

.lib-segment-item .snippet-quote {
  margin: 0;
  color: var(--v3-ink);
  font-size: 0.9rem;
  line-height: 1.4;
}

/* Responsive */
@media (max-width: 900px) {
  .lib-meta-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .lib-legend {
    grid-column: 1 / -1;
    justify-self: start;
  }
}

@media (max-width: 720px) {
  .lib-row {
    grid-template-columns: minmax(0, 1fr);
  }
  /* On mobile, collapse numeric column under the title so the row stays */
  /* readable. Heart + YT icon link drop to a bottom-aligned strip. */
  .lib-row-titlelink {
    grid-template-columns: minmax(0, 1fr);
    gap: 0.3rem;
    padding: 0.6rem 0.8rem 0.5rem;
  }
  .lib-row-numeric {
    flex-direction: row;
    align-items: center;
    gap: 0.55rem;
    justify-content: flex-start;
  }
  .lib-row-actions {
    justify-content: flex-end;
    flex-wrap: wrap;
    padding: 0 0.7rem 0.55rem;
  }
  .lib-grid {
    grid-template-columns: 1fr;
  }
}

/* ============================================================
   v0.3.2 — Archive lane search result hint
   ============================================================ */

/* Archive-result card kind hint on the home search results.
   Marks results that come from the full 659-video archive index
   (distinct from OTE Q&A / notes / videos). */
.answer-card[data-result-kind="archive"] .answer-label::before {
  content: "Archive · ";
  opacity: 0.75;
}


/* ============================================================
   v0.3.3 — Agent D: Design Consistency Patch
   Goals:
   1. Replace disruptive DM Mono numerical/timestamp styling with a
      calmer body-sans treatment that still aligns numerically.
   2. Align answer-card content consistently to the LEFT instead of
      mixing centered headline/body with left-aligned timestamp pills.
   3. Push timestamp pills to the RIGHT inside answer cards on
      desktop where appropriate. Stack left on narrow viewports.
   4. Keep legal-safe YouTube link structure intact (a.time-link,
      span.time-link-tc, etc. — only typography/layout changed).
   ============================================================ */

/* 1. Calmer numeric typography ---------------------------------- */

/* Timestamp code (e.g. 00:09:10) — drop heavy mono, use body sans
   with tabular figures so digits still align column-by-column. */
.time-link .time-link-tc,
.note-time .time-link-tc {
  font-family: var(--font-sans, inherit);
  font-feature-settings: "tnum" 1, "lnum" 1;
  font-variant-numeric: tabular-nums lining-nums;
  font-weight: 500;
  font-size: 0.78rem;
  letter-spacing: 0.01em;
  color: var(--v3-muted);
}

/* Hero stats ticker — 3-stat drift strip (v0.3.6). */
.market-ticker {
  font-family: var(--font-sans, inherit);
  font-feature-settings: "tnum" 1, "lnum" 1;
  font-variant-numeric: tabular-nums lining-nums;
  font-size: 0.74rem;
  letter-spacing: 0.01em;
  text-transform: none;
  color: var(--v3-muted);
}

.market-ticker span {
  font-weight: 500;
  /* Keep single-line for drift layout */
  white-space: nowrap;
  flex-shrink: 0;
}

/* "Original study answer" kicker / .answer-label / .page-kicker —
   keep the small-caps style but switch off the monospace so it stops
   competing with the H2 below it. */
.page-kicker,
.answer-label,
.card-meta,
.label {
  font-family: var(--font-sans, inherit);
  font-weight: 600;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* 2. Left-align answer card content (kill mixed centering) ------ */

/* The home shell uses text-align:center and justify-items:center to
   center the search bar and tagline. Re-anchor anything *inside* an
   answer card back to the left so the kicker, title, body, and
   timestamp pills share one consistent left edge. */
.clean-home .answer-card,
.home-has-results .answer-card,
.home-static .answer-card,
.answer-card,
.answer-card .answer-label,
.answer-card h2,
.answer-card p,
.answer-card .home-result-actions,
.answer-card .timestamp-row {
  text-align: left;
  justify-self: stretch;
}

.answer-card h2 {
  /* slight tightening so the left edge reads cleanly */
  letter-spacing: -0.01em;
  line-height: 1.25;
}

.answer-card p {
  line-height: 1.55;
}

/* 3. Right-align timestamp pills inside answer cards on desktop -- */
/* The action row mixes time-link pills with a Save/Open button.
   Push the time-link pills to the right edge of the card so they
   sit cleanly under the answer text and feel like metadata, not
   like the next heading. */
.answer-card .home-result-actions,
.answer-card .timestamp-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.85rem;
  justify-content: flex-end;
  align-items: center;
}

/* If there is a ghost button (Save / Open) plus time-link pills,
   keep the button on the LEFT and float the time-link pills RIGHT
   inside the action row. */
.answer-card .home-result-actions > .btn-ghost,
.answer-card .timestamp-row > .btn-ghost {
  margin-right: auto;
}

/* Make individual time-link pills calmer too: thinner border,
   lighter ink weight. Preserves the legal-safe anchor structure. */
.answer-card .time-link,
.answer-card .note-time {
  font-weight: 400;
  color: var(--v3-muted);
  border-color: var(--v3-line);
}

.answer-card .time-link:hover,
.answer-card .note-time:hover {
  color: var(--v3-ink);
}

.answer-card .time-link .time-link-label,
.answer-card .note-time .time-link-label {
  color: var(--v3-muted);
  font-weight: 500;
}

/* 4. Mobile — stack timestamp pills left under the body so they
      don't fight a narrow column. ------------------------------- */
@media (max-width: 720px) {
  .answer-card .home-result-actions,
  .answer-card .timestamp-row {
    justify-content: flex-start;
  }
  .answer-card .home-result-actions > .btn-ghost,
  .answer-card .timestamp-row > .btn-ghost {
    margin-right: 0;
  }
  /* Mobile timestamp pills get a touch more room */
  .answer-card .time-link,
  .answer-card .note-time {
    width: 100%;
    justify-content: flex-start;
  }
}

/* 5. Detail-page evidence cards (.key-note) and result snippet
      cards — match the same calmer numerical treatment. */
.key-note .time-link-tc,
.takeaway-item .time-link-tc {
  font-family: var(--font-sans, inherit);
  font-feature-settings: "tnum" 1, "lnum" 1;
  font-variant-numeric: tabular-nums lining-nums;
  font-weight: 500;
}

/* Library / KPI numeric strips — keep tabular-nums alignment, but
   stop using the heavy mono inside small KPI values. */
.lib-meta-kpi strong {
  font-family: var(--font-sans, inherit);
  font-feature-settings: "tnum" 1, "lnum" 1;
}

/* end v0.3.3 design consistency patch */

/* v0.3.3 — Library chip typography (e.g. "27 timestamped", "70 pending")
   Match calmer numeric treatment. Keep status pills small but readable. */
.chip,
.scope-chip {
  font-family: var(--font-sans, inherit);
  font-feature-settings: "tnum" 1, "lnum" 1;
  font-variant-numeric: tabular-nums lining-nums;
  font-weight: 500;
}

/* Stats ticker on Models page and saved sections — same softening */
.stats-ticker,
.stats-ticker span {
  font-family: var(--font-sans, inherit);
  font-feature-settings: "tnum" 1, "lnum" 1;
  font-variant-numeric: tabular-nums lining-nums;
  text-transform: none;
  letter-spacing: 0.01em;
}

.saved-section-head {
  font-family: var(--font-sans, inherit);
  font-weight: 600;
  letter-spacing: 0.08em;
}

/* ──────────────────────────────────────────────────────────────────────────
   Models Page v0.3.6 — Enrichment Parity — Concept Cards
   New CSS for models-page-v2, model-concept-card, status badges
   ────────────────────────────────────────────────────────────────────────── */

/* --- Source-backed and draft status pills --------------------------------- */
.status-pill.status-source-backed {
  background: color-mix(in srgb, var(--v3-gold) 16%, var(--v3-card-bg));
  color: color-mix(in srgb, var(--v3-gold-2) 100%, transparent);
  border-color: color-mix(in srgb, var(--v3-gold) 35%, transparent);
}

.status-pill.status-draft {
  background: color-mix(in srgb, var(--v3-muted) 10%, var(--v3-card-bg));
  color: var(--v3-muted);
  border-color: color-mix(in srgb, var(--v3-muted) 22%, transparent);
  border-style: dashed;
}

/* --- Folder status badges inside model-folder button --------------------- */
.model-folder-status {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
  flex-shrink: 0;
}

.model-folder-status--hand-authored {
  color: var(--v3-green);
}
.model-folder-status--source-backed {
  color: var(--v3-gold-2, var(--v3-gold));
}
.model-folder-status--draft-model-path {
  color: var(--v3-muted);
}

/* Ensure folder name text doesn't overflow button */
.model-folder-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1 1 0;
  min-width: 0;
}

/* --- Folder description row ---------------------------------------------- */
.model-folder-desc {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--v3-line);
}

.model-folder-desc-text {
  color: var(--v3-muted);
  font-size: 0.86rem;
  line-height: 1.4;
}

.model-folder-count {
  flex-shrink: 0;
  color: var(--v3-faint);
  font-family: var(--font-mono);
  font-size: 0.74rem;
}

/* --- Concept card grid — wider than the OTE step grid -------------------- */
.model-layout.models-concept-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.85rem;
}

@media (max-width: 1200px) {
  .model-layout.models-concept-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 600px) {
  .model-layout.models-concept-grid {
    grid-template-columns: 1fr;
  }
}

/* --- Concept card --------------------------------------------------------- */
.model-concept-card {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 1rem;
  border: 1px solid var(--v3-line);
  border-radius: 20px;
  background: var(--v3-card-bg);
}

.model-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.55rem;
}

.model-archive-count {
  color: var(--v3-faint);
  font-family: var(--font-mono);
  font-size: 0.68rem;
  flex-shrink: 0;
}

.model-card-title {
  margin: 0 0 0.3rem;
  font-size: 1.05rem;
  font-weight: 800;
  line-height: 1.15;
  color: var(--v3-ink);
}

.model-card-tagline {
  margin: 0 0 0.5rem;
  font-size: 0.8rem;
  color: var(--v3-muted);
  line-height: 1.4;
  font-style: italic;
}

.model-card-summary {
  margin: 0 0 0.6rem;
  font-size: 0.86rem;
  color: var(--v3-text);
  line-height: 1.5;
}

.model-keypoints,
.model-steps-detail,
.model-evidence {
  margin: 0.4rem 0;
  font-size: 0.82rem;
}

.model-keypoints summary,
.model-steps-detail summary,
.model-evidence summary {
  cursor: pointer;
  /* v0.4.1 fix: use brand gold accent, not blue */
  color: var(--v3-gold-2, var(--v3-ink));
  font-weight: 600;
  font-size: 0.78rem;
  width: fit-content;
  list-style: none;
  padding: 0.2rem 0;
}

.model-keypoints summary::before,
.model-steps-detail summary::before,
.model-evidence summary::before {
  content: "▸ ";
  font-size: 0.7rem;
}

.model-keypoints[open] summary::before,
.model-steps-detail[open] summary::before,
.model-evidence[open] summary::before {
  content: "▾ ";
}

.model-keypoints ul {
  margin: 0.4rem 0 0 1rem;
  padding: 0;
  list-style: disc;
}

.model-keypoints li {
  margin-bottom: 0.2rem;
  color: var(--v3-text);
  font-size: 0.8rem;
  line-height: 1.4;
}

.model-steps-list {
  margin: 0.4rem 0 0 1.2rem;
  padding: 0;
}

.model-steps-list li {
  margin-bottom: 0.35rem;
  font-size: 0.8rem;
  line-height: 1.45;
  color: var(--v3-text);
}

.model-evidence-links {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-top: 0.4rem;
}

.model-evidence-link {
  /* v0.4.1 fix: brand gold, not blue */
  color: var(--v3-gold-2, var(--v3-ink));
  font-size: 0.78rem;
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.model-evidence-link:hover {
  text-decoration: underline;
}

/* --- Card action row ------------------------------------------------------ */
.model-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: auto;
  padding-top: 0.65rem;
}

.model-search-link,
.model-lib-link,
.model-yt-link {
  display: inline-flex;
  align-items: center;
  padding: 0.3rem 0.7rem;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 600;
  text-decoration: none;
  border: 1px solid var(--v3-line);
  background: var(--v3-field-bg);
  color: var(--v3-ink);
  transition: background 0.12s, border-color 0.12s;
}

.model-search-link:hover,
.model-lib-link:hover,
.model-yt-link:hover {
  /* v0.4.1 fix: brand gold hover, not blue */
  background: color-mix(in srgb, var(--v3-gold) 10%, var(--v3-field-bg));
  border-color: color-mix(in srgb, var(--v3-gold) 40%, var(--v3-line));
}

/* --- Provenance / disclaimer micro text ----------------------------------- */
.model-card-provenance {
  margin: 0.55rem 0 0;
  font-size: 0.7rem;
  color: var(--v3-faint);
  line-height: 1.4;
  border-top: 1px solid var(--v3-line);
  padding-top: 0.45rem;
}

html[data-theme="dark"] .model-card-summary,
html[data-theme="dark"] .model-keypoints li,
html[data-theme="dark"] .model-steps-list li {
  color: var(--v3-ink);
}

html[data-theme="dark"] .model-keypoints summary,
html[data-theme="dark"] .model-steps-detail summary,
html[data-theme="dark"] .model-evidence summary,
html[data-theme="dark"] .model-evidence-link,
html[data-theme="dark"] .inline-link {
  color: var(--v3-gold-2);
}

html[data-theme="dark"] .model-search-link,
html[data-theme="dark"] .model-lib-link,
html[data-theme="dark"] .model-yt-link {
  background: var(--v3-field-bg);
  border-color: var(--v3-line-strong);
  color: var(--v3-ink);
}

html[data-theme="dark"] .model-search-link:hover,
html[data-theme="dark"] .model-lib-link:hover,
html[data-theme="dark"] .model-yt-link:hover {
  background: var(--v3-chip-bg);
  border-color: color-mix(in srgb, var(--v3-gold) 55%, var(--v3-line-strong));
}

/* --- Legal strip at the bottom ------------------------------------------- */
.models-legal-strip {
  margin-top: 0.75rem;
}

/* v0.4.1 — single merged disclaimer line, same text size as page disclaimer.
   Replaces the previous three-pill stack. We keep the .model-notes-strip
   span rule below it but override here so the legal line reads as a sentence,
   not a pill row. */
.models-legal-strip .models-legal-line {
  display: block;
  padding: 0.5rem 0;
  border: 0;
  background: transparent;
  color: var(--v3-faint);
  font-size: 0.78rem;
  line-height: 1.5;
  max-width: 80ch;
}

/* --- inline-link for page-sub prose -------------------------------------- */
.inline-link {
  /* v0.4.1 fix: brand gold, not blue. Underlined so it reads as a link. */
  color: var(--v3-gold-2, var(--v3-ink));
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-thickness: 1px;
}
html[data-theme="dark"] .inline-link {
  color: var(--v3-gold-2);
}
.inline-link:hover {
  text-decoration-thickness: 2px;
}

/* --- Model status badge in card header ------------------------------------ */
.model-status-badge {
  font-size: 0.68rem;
}

/* =========================================================================
   v0.3.7 — Universal lesson framework
   Styling for captured notes panel, honest light states, study tips, and
   the small heart toggle used on per-note "like" controls. All playlists
   and topics share these treatments — no OTE-specific exception.
   ========================================================================= */

/* --- Captured notes panel ----------------------------------------------- */
.captured-notes-panel {
  margin-bottom: 1rem;
}
.captured-notes-panel h2 {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
}
.captured-notes-empty {
  border-style: dashed;
}
.captured-notes-toggle {
  display: inline-flex;
  gap: 0.25rem;
  margin: 0.5rem 0 0.75rem;
  padding: 0.25rem;
  background: rgba(0, 0, 0, 0.04);
  border-radius: 999px;
  border: 1px solid var(--v3-line);
}
.captured-notes-toggle-btn {
  appearance: none;
  background: transparent;
  border: 0;
  color: inherit;
  padding: 0.35rem 0.85rem;
  border-radius: 999px;
  font: inherit;
  font-size: 0.82rem;
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease;
}
.captured-notes-toggle-btn:hover {
  background: rgba(0, 0, 0, 0.05);
}
.captured-notes-toggle-btn.active {
  background: var(--v3-gold, #c8922a);
  color: #1a160c;
  font-weight: 600;
}

/* --- Captured note list --------------------------------------------------- */
.captured-note-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}
.captured-note-item {
  padding: 0.75rem 0.9rem;
  background: rgba(0, 0, 0, 0.025);
  border: 1px solid var(--v3-line);
  border-radius: 10px;
  transition: background 120ms ease, border-color 120ms ease;
}
.captured-note-item.liked {
  background: rgba(200, 146, 42, 0.08);
  border-color: rgba(200, 146, 42, 0.32);
}
.captured-note-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.4rem;
}
.captured-note-text {
  margin: 0 0 0.5rem;
  font-size: 0.92rem;
  line-height: 1.55;
}
.captured-note-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* --- Small heart button (per-note like) ---------------------------------- */
.heart-btn.small {
  font-size: 1rem;
  padding: 0.15rem 0.4rem;
  min-width: auto;
  height: auto;
  line-height: 1;
  border-radius: 999px;
}

/* --- Q&A heart button (v0.9 PATCH-04) ------------------------------------ */
/* v0.10 PATCH-12: key-moment hearts absolute top-right on their container */
.heart-btn.key-moment-heart {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  width: 1.75rem;
  height: 1.75rem;
  font-size: 0.9rem;
  flex-shrink: 0;
}
/* v0.10 PATCH-12: hearts right-aligned in Q&A summaries */
.heart-btn.qa-heart {
  width: 1.75rem;
  height: 1.75rem;
  font-size: 0.9rem;
  margin-left: auto; /* push to right side */
  vertical-align: middle;
  flex-shrink: 0;
}
.topic-qa-item summary {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  flex-wrap: wrap;
  cursor: pointer;
  list-style: none;
}
.topic-qa-item summary::-webkit-details-marker { display: none; }
.topic-qa-item summary::before {
  content: '▸';
  font-size: 0.7rem;
  color: var(--v3-muted);
  flex-shrink: 0;
  transition: transform 160ms ease;
}
.topic-qa-item[open] summary::before { transform: rotate(90deg); }

/* --- Honest light-state note on Summary tab ------------------------------ */
.lesson-light-note {
  background: rgba(0, 0, 0, 0.03);
  border-left: 3px solid var(--v3-gold, #c8922a);
  padding: 0.75rem 0.9rem;
  border-radius: 4px;
  margin: 0.5rem 0 0.75rem;
  font-size: 0.9rem;
  line-height: 1.55;
}

/* --- Study tip list (used in tape-reading light state) ------------------- */
.study-tip-list {
  margin: 0.5rem 0 0;
  padding-left: 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  font-size: 0.92rem;
  line-height: 1.55;
}
.study-tip-list li {
  padding-left: 0.15rem;
}

/* --- Dark theme corrections for captured notes --------------------------- */
.theme-dark .captured-notes-toggle,
[data-theme="dark"] .captured-notes-toggle {
  background: rgba(255, 255, 255, 0.04);
}
.theme-dark .captured-note-item,
[data-theme="dark"] .captured-note-item {
  background: rgba(255, 255, 255, 0.03);
}
.theme-dark .captured-note-item.liked,
[data-theme="dark"] .captured-note-item.liked {
  background: rgba(240, 200, 107, 0.10);
  border-color: rgba(240, 200, 107, 0.32);
}
.theme-dark .lesson-light-note,
[data-theme="dark"] .lesson-light-note {
  background: rgba(255, 255, 255, 0.03);
}

/* ===========================================================================
   v0.3.8 — Library + Models patch
   Goals:
   - Library landing fits one viewport (Playlists + Topic folders)
   - Models page simplified subheading, removed unequal stats strip
   - Style-consistent SVG folder icons
   - Model detail page (route #/models/:id) with Step Execution Model,
     Concept Reference, Needs review treatments
   - Visual setup diagram placeholder + future-implementation rule
   =========================================================================== */

/* --- Library landing compaction (v0.3.8) ------------------------------------ */
.lib-page-v038 {
  gap: 0.55rem;
  padding-block: 0.5rem;
}
.lib-header-tight {
  margin-bottom: 0.15rem;
  align-items: center;
}
.lib-title-tight {
  font-size: 1.55rem;
  line-height: 1.1;
  margin: 0;
  letter-spacing: -0.015em;
}
/* Library cards: condense vertical rhythm to fit one viewport. */
.lib-card-tight {
  /* v0.10 PATCH-04: uniform height for all playlist/topic tiles */
  min-height: var(--lib-tile-height, 100px);
  padding: 0.6rem 0.75rem;
  gap: 0.35rem;
}
.lib-card-tight .lib-card-name {
  font-size: 0.92rem;
  line-height: 1.2;
}
.lib-card-tight .lib-card-meta {
  font-size: 0.78rem;
  margin-top: 0.1rem;
}
.lib-card-tight .lib-card-cta {
  color: var(--v3-muted);
  font-size: 0.78rem;
}
.lib-card-tight .chip {
  padding: 0.1rem 0.45rem;
  font-size: 0.72rem;
}
.lib-page-v038 .lib-grid-compact {
  gap: 0.5rem;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}
@media (min-width: 1200px) {
  .lib-page-v038 .lib-grid-compact { grid-template-columns: repeat(5, minmax(0, 1fr)); }
}
@media (min-width: 1500px) {
  .lib-page-v038 .lib-grid-compact { grid-template-columns: repeat(6, minmax(0, 1fr)); }
}
/* When viewport is short, shave further. */
.lib-page-dense .lib-title-tight { font-size: 1.35rem; }
.lib-page-dense .lib-card-tight { padding: 0.5rem 0.65rem; }
.lib-page-dense .lib-card-tight .lib-card-name { font-size: 0.88rem; }

/* --- Models page (v0.3.8) -------------------------------------------------- */
.models-page-v038 {
  /* Override prior min-height: calc(100vh - 168px); align-content:center */
  min-height: 0;
  align-content: start;
  gap: 0.75rem;
  padding-block: 0.5rem;
}
.models-head-v038 {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.2rem;
}
.models-title-v038 {
  font-size: clamp(1.5rem, 2vw, 1.85rem);
  margin: 0;
  letter-spacing: -0.02em;
}
.models-sub-v038 {
  margin: 0;
  font-size: 0.86rem;
  line-height: 1.45;
  color: var(--v3-muted);
  max-width: 720px;
}
/* Hide the legacy stats strip on the v0.3.8 page entirely. */
.models-page-v038 .stats-ticker,
.models-page-v038 .model-stats-ticker { display: none !important; }

/* --- Folder tab buttons (v0.3.8) ------------------------------------------ */
.model-folder-row-v038 {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.5rem;
  margin: 0;
}
@media (max-width: 1080px) {
  .model-folder-row-v038 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 700px) {
  .model-folder-row-v038 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.model-folder-v038 {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto;
  gap: 0.15rem 0.55rem;
  align-items: center;
  min-height: 0;
  padding: 0.6rem 0.7rem;
  border: 1px solid var(--v3-line);
  border-radius: 14px;
  background: var(--v3-field-bg);
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}
.model-folder-v038:hover {
  border-color: color-mix(in srgb, var(--v3-gold) 45%, var(--v3-line));
  transform: translateY(-1px);
}
.model-folder-v038.active {
  border-color: color-mix(in srgb, var(--v3-gold) 65%, var(--v3-line));
  background: color-mix(in srgb, var(--v3-gold) 12%, var(--v3-card-bg));
}
.model-folder-v038 .model-folder-icon {
  grid-row: 1 / span 2;
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: color-mix(in srgb, var(--v3-gold) 14%, var(--v3-card-bg));
  color: var(--v3-gold-2, var(--v3-ink));
}
.folder-glyph {
  width: 18px;
  height: 18px;
  display: block;
}
.model-folder-v038 .model-folder-name {
  font-weight: 700;
  font-size: 0.92rem;
  color: var(--v3-ink);
  line-height: 1.15;
  letter-spacing: -0.005em;
  /* Override generic .model-folder span { font-weight: 800; } cascade */
}
.model-folder-v038 .model-folder-kind {
  font-size: 0.7rem;
  color: var(--v3-muted);
  font-family: var(--font-mono);
  text-transform: none;
  letter-spacing: 0.02em;
}

/* --- Models summary grid (v0.3.8) ----------------------------------------- */
.models-summary-grid-v038 {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 0.6rem;
}
.model-summary-card {
  display: grid;
  gap: 0.35rem;
  padding: 0.75rem 0.85rem;
  border: 1px solid var(--v3-line);
  border-radius: 14px;
  background: var(--v3-card-bg);
  text-decoration: none;
  color: inherit;
  min-height: 0;
  box-shadow: 0 4px 12px rgba(0,0,0,0.04);
  transition: transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}
.model-summary-card:hover {
  transform: translateY(-2px);
  border-color: color-mix(in srgb, var(--v3-gold) 45%, var(--v3-line));
  box-shadow: 0 10px 24px rgba(0,0,0,0.08);
}
.model-summary-card .model-card-title {
  margin: 0.1rem 0 0;
  font-size: 0.98rem;
  line-height: 1.2;
  letter-spacing: -0.01em;
  color: var(--v3-ink);
}
.model-summary-card .model-card-tagline {
  margin: 0;
  font-size: 0.82rem;
  line-height: 1.4;
  color: var(--v3-muted);
}
.model-card-actions--compact { margin-top: 0.2rem; }
.model-card-open {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--v3-gold-2, var(--v3-ink));
}

/* --- Equal-tone kind pills (v0.3.8) --------------------------------------- */
.status-pill.kind-study {
  background: color-mix(in srgb, var(--v3-green) 14%, var(--v3-card-bg));
  color: var(--v3-green);
  border-color: color-mix(in srgb, var(--v3-green) 30%, transparent);
}
.status-pill.kind-concept {
  background: color-mix(in srgb, var(--v3-muted) 12%, var(--v3-card-bg));
  color: var(--v3-muted);
  border-color: color-mix(in srgb, var(--v3-muted) 26%, transparent);
}
.status-pill.kind-review {
  background: color-mix(in srgb, var(--v3-gold) 14%, var(--v3-card-bg));
  color: var(--v3-gold-2, var(--v3-ink));
  border-color: color-mix(in srgb, var(--v3-gold) 32%, transparent);
}

/* --- Model detail page (v0.3.8) ------------------------------------------ */
.model-detail-page {
  gap: 1rem;
  padding-block: 0.5rem;
}
.detail-head {
  display: grid;
  gap: 0.45rem;
}
.detail-head-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: center;
  color: var(--v3-muted);
  font-size: 0.82rem;
}
.detail-head-folder {
  display: inline-flex;
  gap: 0.35rem;
  align-items: center;
  padding: 0.15rem 0.55rem;
  border: 1px solid var(--v3-line);
  border-radius: 999px;
  background: var(--v3-field-bg);
  font-size: 0.78rem;
}
.detail-head-folder .folder-glyph {
  width: 14px;
  height: 14px;
}
.detail-head-count {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  color: var(--v3-muted);
}
.detail-title {
  margin: 0.15rem 0 0;
  font-size: clamp(1.6rem, 2.4vw, 2.1rem);
  letter-spacing: -0.02em;
}
.detail-tagline {
  margin: 0;
  font-size: 1rem;
  line-height: 1.45;
  color: var(--v3-muted);
  max-width: 760px;
}
.detail-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.35rem;
  flex-wrap: wrap;
}
.detail-block {
  display: grid;
  gap: 0.5rem;
  padding: 0.95rem 1rem;
  border: 1px solid var(--v3-line);
  border-radius: 18px;
  background: var(--v3-card-bg);
  box-shadow: 0 4px 14px rgba(0,0,0,0.04);
}
.detail-block-title {
  margin: 0;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
  color: var(--v3-ink);
}
.detail-block-sub {
  margin: 0;
  font-size: 0.88rem;
  line-height: 1.5;
  color: var(--v3-muted);
}
.detail-block-note {
  margin: 0;
  font-size: 0.82rem;
  line-height: 1.5;
  color: var(--v3-muted);
  padding: 0.55rem 0.7rem;
  border: 1px dashed var(--v3-line);
  border-radius: 12px;
  background: var(--v3-field-bg);
}
.detail-summary-text {
  margin: 0;
  font-size: 0.95rem;
  line-height: 1.6;
  color: var(--v3-ink);
}
.detail-keypoints,
.detail-evidence-list {
  margin: 0;
  padding-left: 1.1rem;
  line-height: 1.55;
}
.detail-keypoints li { margin-bottom: 0.25rem; }
.detail-evidence-list li { margin-bottom: 0.3rem; }
.detail-evidence-list .model-evidence-link {
  color: var(--v3-gold-2, var(--v3-ink));
  text-decoration: underline;
  text-underline-offset: 2px;
}
.detail-step-list {
  display: grid;
  gap: 0.55rem;
  margin: 0;
  padding: 0;
  list-style: none;
}
.detail-step {
  display: grid;
  grid-template-columns: 2.2rem 1fr;
  gap: 0.65rem;
  padding: 0.7rem 0.8rem;
  border: 1px solid var(--v3-line);
  border-radius: 14px;
  background: var(--v3-field-bg);
}
.detail-step-num {
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  border-radius: 10px;
  background: color-mix(in srgb, var(--v3-gold) 16%, var(--v3-card-bg));
  color: var(--v3-gold-2, var(--v3-ink));
  font-family: var(--font-mono);
  font-weight: 800;
}
.detail-step-body h3 {
  margin: 0 0 0.2rem;
  font-size: 0.98rem;
  line-height: 1.2;
}
.detail-step-body p {
  margin: 0;
  font-size: 0.88rem;
  line-height: 1.5;
  color: var(--v3-ink);
}
.detail-step-evidence {
  margin-top: 0.25rem !important;
  font-size: 0.8rem !important;
  color: var(--v3-muted) !important;
}
.detail-steps-pending,
.detail-needs-review,
.detail-concept-ref {
  background: color-mix(in srgb, var(--v3-muted) 5%, var(--v3-card-bg));
  border-style: dashed;
}

/* --- Visual setup diagram placeholder ------------------------------------- */
/* v0.4.3: Models diagram block removed. Selectors below are kept as defensive
   no-ops so any stale cached markup (e.g. a previously rendered demo DOM)
   collapses cleanly rather than showing an orphan empty frame. A verified
   source-anchored diagram system remains on the post-launch radar; reintroduce
   the block in renderModelDetail (app_v03.js) and re-style these rules then. */
.detail-diagram-block,
.detail-diagram-placeholder,
.detail-diagram-frame,
.detail-diagram-grid,
.detail-diagram-label,
.detail-diagram-note { display: none !important; }

/* --- Detail footer -------------------------------------------------------- */
.detail-foot {
  display: grid;
  gap: 0.35rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--v3-line);
  color: var(--v3-muted);
  font-size: 0.8rem;
}
.detail-provenance,
.detail-legal-line {
  margin: 0;
  line-height: 1.5;
}

html[data-theme="dark"] .model-detail-page .detail-head,
html[data-theme="dark"] .model-detail-page .detail-block,
html[data-theme="dark"] .model-detail-page .detail-foot {
  border-color: var(--v3-line-strong);
  background: var(--v3-card-bg);
  box-shadow: var(--v3-shadow);
}

html[data-theme="dark"] .model-detail-page .detail-head-folder,
html[data-theme="dark"] .model-detail-page .detail-head-count,
html[data-theme="dark"] .model-detail-page .detail-block-note {
  border-color: var(--v3-line-strong);
  background: color-mix(in srgb, var(--v3-surface-2) 72%, transparent);
}
/* v0.4.3: .detail-diagram-placeholder dark override removed alongside the block. */

html[data-theme="dark"] .model-detail-page .detail-step {
  border-color: var(--v3-line-strong);
  background: color-mix(in srgb, var(--v3-surface-2) 76%, transparent);
}

/* v0.4.1 — Light-mode model surfaces. Decoupled from dark overrides.
   The previous default fell back to near-white `--v3-card-bg`, which read as
   a flat "white box overlay" against the warm cream page bg. We tone down
   to a warm parchment surface that matches the rest of the light brand. */
html[data-theme="light"] .model-detail-page .detail-head,
html[data-theme="light"] .model-detail-page .detail-block {
  background: linear-gradient(
    160deg,
    rgba(250, 244, 228, 0.92),
    rgba(244, 234, 211, 0.92)
  );
  border-color: rgba(45, 43, 34, 0.16);
  box-shadow: 0 6px 18px rgba(58, 49, 30, 0.06);
}
html[data-theme="light"] .model-detail-page .detail-step {
  background: rgba(252, 246, 230, 0.78);
  border-color: rgba(45, 43, 34, 0.14);
}
html[data-theme="light"] .model-detail-page .detail-block-note,
html[data-theme="light"] .model-detail-page .detail-head-folder,
html[data-theme="light"] .model-detail-page .detail-head-count {
  background: rgba(248, 240, 220, 0.75);
  border-color: rgba(45, 43, 34, 0.14);
}
/* v0.4.3: .detail-diagram-placeholder light override removed alongside the block. */
html[data-theme="light"] .model-detail-page .detail-step-num {
  background: color-mix(in srgb, var(--v3-gold) 22%, rgba(250, 244, 228, 1));
  color: var(--v3-gold-2);
}
html[data-theme="light"] .model-detail-page .detail-foot {
  background: transparent;
  box-shadow: none;
}

/* v0.4.1 — Light-mode Models index summary cards.
   Same rationale: pull cards onto the warm palette, not pure white. */
html[data-theme="light"] .models-page .model-card,
html[data-theme="light"] .models-page .model-summary-card {
  background: linear-gradient(
    160deg,
    rgba(250, 244, 228, 0.94),
    rgba(244, 234, 211, 0.94)
  );
  border-color: rgba(45, 43, 34, 0.16);
  box-shadow: 0 6px 18px rgba(58, 49, 30, 0.06);
}
html[data-theme="light"] .models-page .model-folder {
  background: rgba(252, 246, 230, 0.86);
  border-color: rgba(45, 43, 34, 0.14);
}
html[data-theme="light"] .models-page .model-folder.active {
  background: color-mix(in srgb, var(--v3-gold) 12%, rgba(250, 244, 228, 1));
  border-color: color-mix(in srgb, var(--v3-gold) 36%, rgba(45, 43, 34, 0.18));
}
/* v0.4.1: merged disclaimer line on Models — no pills, plain sentence. */
html[data-theme="light"] .models-page .models-legal-strip .models-legal-line,
html[data-theme="dark"] .models-page .models-legal-strip .models-legal-line {
  background: transparent;
  border: 0;
}

html[data-theme="dark"] .model-detail-page .detail-step-num {
  border: 1px solid color-mix(in srgb, var(--v3-gold) 42%, var(--v3-line-strong));
  background: color-mix(in srgb, var(--v3-gold) 22%, var(--v3-surface));
  color: var(--v3-gold-2);
}

html[data-theme="dark"] .model-detail-page .detail-steps-pending,
html[data-theme="dark"] .model-detail-page .detail-needs-review,
html[data-theme="dark"] .model-detail-page .detail-concept-ref {
  background: color-mix(in srgb, var(--v3-surface-2) 70%, transparent);
  border-color: var(--v3-line-strong);
}

/* v0.4.3: .detail-diagram-label dark override removed alongside the block. */

html[data-theme="dark"] .model-detail-page .model-card-provenance,
html[data-theme="dark"] .model-detail-page .detail-legal-line,
html[data-theme="dark"] .model-detail-page .detail-step-evidence {
  color: var(--v3-faint) !important;
}

/* v0.4.3 — Compact Browser Extension entry inside the Settings popover.
   Replaces the long YouTube Notes instruction card from v0.4.2. The card is
   now a one-row link that navigates to the dedicated /extension page where
   the full setup, shortcuts, import flow, and future-sync sections live. */
.settings-entry-mark {
  flex: 0 0 32px;
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.settings-entry-mark img {
  width: 28px;
  height: 28px;
  object-fit: contain;
}
.page-kicker-mark-picture {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
}
.settings-row.settings-entry {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 0.85rem;
  border: 1px solid var(--v3-line);
  border-radius: 14px;
  background: var(--v3-field-bg);
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s, background 0.15s, transform 0.1s;
}
.settings-row.settings-entry:hover {
  border-color: var(--v3-line-strong);
  background: color-mix(in srgb, var(--v3-field-bg) 70%, var(--v3-surface) 30%);
}
.settings-row.settings-entry:active { transform: translateY(1px); }
.settings-entry-text {
  flex: 1;
  display: grid;
  gap: 0.15rem;
  min-width: 0;
}
.settings-entry-text strong {
  color: var(--v3-ink);
  font-size: 0.95rem;
  line-height: 1.2;
}
.settings-entry-text span {
  display: block;
  color: var(--v3-muted);
  font-size: 0.82rem;
  line-height: 1.35;
  margin-top: 0;
}
.settings-entry-status {
  color: var(--v3-faint, var(--v3-muted)) !important;
  font-size: 0.72rem !important;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.settings-entry-chevron {
  font-size: 1.2rem;
  color: var(--v3-muted);
  line-height: 1;
  padding-left: 0.25rem;
}
/* The .settings-popover span { display: block } rule above forces every
   span block-level, so we re-flatten the inline beta pill. */
.settings-popover .settings-pill {
  display: inline-block;
  margin: 0 0 0 0.4rem;
  padding: 0.05rem 0.45rem;
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--v3-button-text);
  background: var(--v3-gold);
  border-radius: 999px;
  vertical-align: middle;
  width: auto;
}
html[data-theme="dark"] .settings-popover .settings-pill {
  background: var(--v3-gold-2);
  color: #17130b !important;
}
html[data-theme="dark"] .settings-row.settings-entry {
  background: color-mix(in srgb, var(--v3-surface-2) 80%, transparent);
  border-color: var(--v3-line-strong);
}
html[data-theme="dark"] .settings-row.settings-entry:hover {
  background: var(--v3-surface-2);
}

/* v0.4.3 — Dedicated /extension page.
   Single-column grid of panels; reuses the existing .panel.v3-panel
   treatment so the page reads as a normal Inner Archive content page in
   both light and dark mode. The brand mark sits next to the page title as
   a subtle nod — same proportions as the header logo. */
.extension-page { max-width: 880px; }
.extension-page .page-title { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }
.extension-page .page-title-badge {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--v3-button-text);
  background: var(--v3-gold);
  border-radius: 999px;
  vertical-align: middle;
  line-height: 1.5;
}
html[data-theme="dark"] .extension-page .page-title-badge {
  background: var(--v3-gold-2);
  color: #17130b;
}
.extension-page .page-kicker { display: flex; align-items: center; gap: 0.5rem; }
.extension-page .page-kicker-mark {
  width: 18px;
  height: 18px;
  object-fit: contain;
  opacity: 0.85;
  flex: 0 0 18px;
}
.extension-grid {
  display: grid;
  gap: 1rem;
  margin-top: 1.2rem;
}
.extension-section { padding: 1.1rem 1.2rem; }
.extension-section h2 {
  margin: 0 0 0.5rem;
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: -0.005em;
}
.extension-section p {
  margin: 0.35rem 0;
  font-size: 0.92rem;
  line-height: 1.55;
  color: var(--v3-ink);
}
.extension-section code,
.extension-section kbd {
  font-family: "DM Mono", ui-monospace, SFMono-Regular, monospace;
  font-size: 0.82rem;
  padding: 0.05rem 0.4rem;
  background: var(--v3-field-bg);
  border: 1px solid var(--v3-line);
  border-radius: 6px;
  color: var(--v3-ink);
  white-space: nowrap;
}
/* High-specificity colour bindings: the existing `.panel ul, .panel ol`
   rule earlier in this file sets `color: var(--ink)` (a legacy token from
   styles.css that resolves dark in both themes). We re-bind to the v3 ink
   token using matching specificity (class + element) so list text stays
   legible in dark mode. */
.extension-section ul.extension-bullets,
.extension-section ol.extension-steps {
  margin: 0.45rem 0 0;
  padding-left: 1.25rem;
  display: grid;
  gap: 0.3rem;
  font-size: 0.92rem;
  line-height: 1.55;
  color: var(--v3-ink);
}
.extension-section ul.extension-bullets { gap: 0.25rem; line-height: 1.5; }
.extension-section ul.extension-bullets li { list-style: disc; color: var(--v3-ink); }
.extension-section ol.extension-steps li { list-style: decimal; color: var(--v3-ink); }
.extension-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.85rem;
}
.extension-shortcuts-table {
  width: 100%;
  margin-top: 0.55rem;
  border-collapse: collapse;
  font-size: 0.9rem;
}
.extension-shortcuts-table th,
.extension-shortcuts-table td {
  text-align: left;
  padding: 0.55rem 0.7rem;
  border-bottom: 1px solid var(--v3-line);
  vertical-align: top;
  color: var(--v3-ink);
}
.extension-shortcuts-table th {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--v3-muted);
  font-weight: 700;
  background: var(--v3-field-bg);
}
.extension-shortcuts-table tbody tr:last-child td { border-bottom: 0; }
.extension-status {
  margin: 0.6rem 0 0;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--v3-ink);
}
.extension-legal {
  margin: 0.45rem 0 0;
  font-size: 0.78rem;
  line-height: 1.55;
  color: var(--v3-faint, var(--v3-muted));
}
.extension-future {
  border-color: var(--v3-line-strong);
  background: color-mix(in srgb, var(--v3-field-bg) 60%, var(--v3-surface) 40%);
}
html[data-theme="dark"] .extension-section code,
html[data-theme="dark"] .extension-section kbd {
  background: var(--v3-surface-2);
  border-color: var(--v3-line-strong);
}
html[data-theme="dark"] .extension-shortcuts-table th {
  background: var(--v3-surface-2);
}
html[data-theme="dark"] .extension-future {
  background: color-mix(in srgb, var(--v3-surface-2) 75%, transparent);
  border-color: var(--v3-line-strong);
}
@media (max-width: 640px) {
  .extension-section { padding: 1rem; }
  .extension-shortcuts-table th,
  .extension-shortcuts-table td { padding: 0.45rem 0.5rem; font-size: 0.82rem; }
}

/* =========================================================================
   v0.4.4 — Saved area redesign
   Landing: three entry cards (Lessons / Moments / Key notes) + folder panel.
   Detail:  filter toolbar (search / folder / sort) + priority chips + list.
   Folders: rename / delete / create personal organisation buckets.

   Variables used:
     --v3-ink, --v3-muted, --v3-faint, --v3-surface, --v3-surface-2,
     --v3-line, --v3-line-strong, --v3-field-bg, --v3-accent
   These are the same tokens used across v0.4.1–v0.4.3, so light + dark
   parity is automatic.
   ========================================================================= */

/* ---- Landing: entry cards ---- */
.saved-landing .page-sub { max-width: 64ch; }
.saved-landing .saved-entry-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
  margin: 1.25rem 0 1.75rem;
}
@media (max-width: 900px) {
  .saved-landing .saved-entry-grid { grid-template-columns: 1fr; }
}
.saved-entry-card {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  padding: 1.2rem 1.2rem 1.1rem;
  background: var(--v3-surface);
  border: 1px solid var(--v3-line);
  border-radius: 14px;
  color: var(--v3-ink);
  text-decoration: none;
  transition: border-color 140ms ease, background 140ms ease, transform 140ms ease;
}
.saved-entry-card:hover {
  border-color: var(--v3-line-strong);
  background: color-mix(in srgb, var(--v3-surface) 88%, var(--v3-field-bg) 12%);
  transform: translateY(-1px);
}
.saved-entry-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.saved-entry-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--v3-field-bg);
  color: var(--v3-accent, var(--v3-ink));
  border: 1px solid var(--v3-line);
}
.saved-entry-icon svg { width: 20px; height: 20px; }
.saved-entry-count {
  font-size: 1.35rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--v3-ink);
  letter-spacing: -0.01em;
}
.saved-entry-title {
  margin: 0.1rem 0 0;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.saved-entry-sub {
  margin: 0;
  color: var(--v3-muted);
  font-size: 0.92rem;
  line-height: 1.5;
}
.saved-entry-cta {
  margin-top: auto;
  padding-top: 0.4rem;
  font-size: 0.85rem;
  color: var(--v3-accent, var(--v3-ink));
  font-weight: 600;
}

/* ---- Landing: folders panel + meta row ---- */
.saved-folders-panel {
  margin: 0.25rem 0 1.5rem;
  padding: 1.1rem 1.1rem 1rem;
  background: var(--v3-surface);
  border: 1px solid var(--v3-line);
  border-radius: 14px;
}
.saved-folders-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.6rem;
}
@media (max-width: 640px) {
  .saved-folders-head { flex-direction: column; align-items: stretch; }
}
.saved-folders-title {
  margin: 0 0 0.2rem;
  font-size: 1rem;
  font-weight: 700;
}
.saved-folders-sub {
  margin: 0;
  max-width: 62ch;
}
.saved-folder-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
}
.saved-folder-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.32rem 0.7rem;
  border: 1px solid var(--v3-line);
  border-radius: 999px;
  background: var(--v3-field-bg);
  color: var(--v3-ink);
  font-size: 0.82rem;
  font-weight: 500;
}
.saved-folder-chip-count {
  font-variant-numeric: tabular-nums;
  color: var(--v3-muted);
  font-size: 0.78rem;
}

.saved-meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin: 0.25rem 0 0.5rem;
}
.saved-future-pill {
  display: inline-flex;
  align-items: center;
  padding: 0.28rem 0.65rem;
  border: 1px dashed var(--v3-line-strong);
  border-radius: 999px;
  background: transparent;
  color: var(--v3-muted);
  font-size: 0.76rem;
  letter-spacing: 0.01em;
}

/* ---- Detail: crumbs + toolbar ---- */
.saved-detail-crumbs {
  margin: 0 0 0.5rem;
  font-size: 0.85rem;
}
.saved-detail-crumbs a {
  color: var(--v3-muted);
  text-decoration: none;
}
.saved-detail-crumbs a:hover { color: var(--v3-ink); }

.saved-toolbar {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 0.6rem;
  align-items: center;
  margin: 1rem 0 0.55rem;
}
@media (max-width: 720px) {
  .saved-toolbar { grid-template-columns: 1fr; }
}
.saved-search {
  position: relative;
  display: flex;
  align-items: center;
  padding: 0 0.65rem;
  background: var(--v3-field-bg);
  border: 1px solid var(--v3-line);
  border-radius: 10px;
  transition: border-color 140ms ease;
}
.saved-search:focus-within { border-color: var(--v3-line-strong); }
.saved-search-icon {
  display: inline-flex;
  width: 18px;
  height: 18px;
  color: var(--v3-muted);
  flex-shrink: 0;
}
.saved-search-icon svg { width: 18px; height: 18px; }
.saved-search input {
  flex: 1;
  padding: 0.55rem 0.55rem;
  border: 0;
  background: transparent;
  color: var(--v3-ink);
  font: inherit;
  outline: none;
}
.saved-search input::placeholder { color: var(--v3-faint, var(--v3-muted)); }

.saved-select {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0 0.55rem 0 0.75rem;
  background: var(--v3-field-bg);
  border: 1px solid var(--v3-line);
  border-radius: 10px;
}
.saved-select-label {
  font-size: 0.78rem;
  color: var(--v3-muted);
  white-space: nowrap;
}
.saved-select select {
  flex: 1;
  padding: 0.55rem 0.45rem 0.55rem 0.2rem;
  border: 0;
  background: transparent;
  color: var(--v3-ink);
  font: inherit;
  outline: none;
}

/* v0.11 PATCH-07: uniform height/padding/border-radius for saved controls row siblings */
.saved-search,
.saved-select {
  height: 38px !important;
  padding-top: 0 !important;
  padding-bottom: 0 !important;
  border-radius: 8px !important;
  border: 1px solid var(--v3-line) !important;
  background: var(--v3-field-bg) !important;
  box-sizing: border-box !important;
}
.saved-search input,
.saved-select select {
  padding-top: 0 !important;
  padding-bottom: 0 !important;
  height: 100% !important;
  box-sizing: border-box !important;
}

.saved-priority-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0.25rem 0 1rem;
}
.saved-chip {
  padding: 0.34rem 0.78rem;
  border: 1px solid var(--v3-line);
  border-radius: 999px;
  background: var(--v3-surface);
  color: var(--v3-ink);
  font: inherit;
  font-size: 0.82rem;
  cursor: pointer;
  transition: border-color 120ms ease, background 120ms ease;
}
.saved-chip:hover { border-color: var(--v3-line-strong); }
.saved-chip.active {
  background: var(--v3-ink);
  color: var(--v3-surface);
  border-color: var(--v3-ink);
}
html[data-theme="dark"] .saved-chip.active {
  background: var(--v3-ink);
  color: var(--v3-bg, #0f0f0e);
  border-color: var(--v3-ink);
}
.saved-chip-pri-high.active { background: #b34a2a; border-color: #b34a2a; color: #fff; }
.saved-chip-pri-mid.active  { background: #d19900; border-color: #d19900; color: #1a1a18; }
.saved-chip-pri-low.active  { background: #6a8a4f; border-color: #6a8a4f; color: #fff; }

.saved-result-meta {
  margin: 0.1rem 0 0.75rem;
}

/* ---- Detail: item list ---- */
.saved-list {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}
.saved-item {
  padding: 0.9rem 1rem 0.85rem;
  background: var(--v3-surface);
  border: 1px solid var(--v3-line);
  border-radius: 12px;
  transition: border-color 120ms ease;
}
.saved-item:hover { border-color: var(--v3-line-strong); }

.saved-item-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 0.55rem;
  font-size: 0.78rem;
  color: var(--v3-muted);
}
.saved-item-type {
  font-weight: 600;
  color: var(--v3-ink);
  letter-spacing: 0.01em;
  font-size: 0.78rem;
}
.saved-item-time { font-variant-numeric: tabular-nums; }
.saved-item-stamp {
  padding: 0.15rem 0.45rem;
  border: 1px solid var(--v3-line);
  background: var(--v3-field-bg);
  border-radius: 6px;
  font-family: "DM Mono", ui-monospace, monospace;
  font-size: 0.78rem;
  color: var(--v3-ink);
}
.saved-item-title {
  margin: 0.45rem 0 0.4rem;
  font-size: 1.02rem;
  font-weight: 700;
  letter-spacing: -0.005em;
  color: var(--v3-ink);
}
.saved-item-text {
  margin: 0.45rem 0 0.55rem;
  font-size: 0.94rem;
  line-height: 1.55;
  color: var(--v3-ink);
}

.saved-folder-tag {
  display: inline-flex;
  align-items: center;
  padding: 0.18rem 0.55rem;
  border: 1px solid var(--v3-line);
  border-radius: 999px;
  background: var(--v3-field-bg);
  color: var(--v3-ink);
  font-size: 0.74rem;
  font-weight: 500;
}
.saved-folder-tag-empty {
  color: var(--v3-muted);
  font-style: italic;
}

/* Priority pill (read-only, in head row) */
.saved-pri {
  display: inline-flex;
  align-items: center;
  padding: 0.16rem 0.5rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.saved-pri-high { background: rgba(179, 74, 42, 0.14); color: #b34a2a; border: 1px solid rgba(179,74,42,0.3); }
.saved-pri-mid  { background: rgba(209, 153, 0, 0.16); color: #8a6b00; border: 1px solid rgba(209,153,0,0.32); }
.saved-pri-low  { background: rgba(106, 138, 79, 0.16); color: #4f6a3b; border: 1px solid rgba(106,138,79,0.32); }
html[data-theme="dark"] .saved-pri-high { color: #e88863; border-color: rgba(232,136,99,0.38); }
html[data-theme="dark"] .saved-pri-mid  { color: #e8c25e; border-color: rgba(232,194,94,0.38); }
html[data-theme="dark"] .saved-pri-low  { color: #9bbd76; border-color: rgba(155,189,118,0.38); }

/* Priority cycle button (interactive, in controls row) */
.saved-pri-btn {
  padding: 0.28rem 0.7rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  font-family: inherit;
  transition: filter 120ms ease, transform 120ms ease;
}
.saved-pri-btn:hover { filter: brightness(1.05); transform: translateY(-1px); }
.saved-pri-btn.saved-pri-high { background: rgba(179, 74, 42, 0.14); color: #b34a2a; border: 1px solid rgba(179,74,42,0.4); }
.saved-pri-btn.saved-pri-mid  { background: rgba(209, 153, 0, 0.16); color: #8a6b00; border: 1px solid rgba(209,153,0,0.42); }
.saved-pri-btn.saved-pri-low  { background: rgba(106, 138, 79, 0.16); color: #4f6a3b; border: 1px solid rgba(106,138,79,0.4); }
html[data-theme="dark"] .saved-pri-btn.saved-pri-high { color: #e88863; border-color: rgba(232,136,99,0.45); }
html[data-theme="dark"] .saved-pri-btn.saved-pri-mid  { color: #e8c25e; border-color: rgba(232,194,94,0.45); }
html[data-theme="dark"] .saved-pri-btn.saved-pri-low  { color: #9bbd76; border-color: rgba(155,189,118,0.45); }

.saved-item-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.85rem;
  margin: 0.3rem 0 0.6rem;
}
.saved-item-actions .time-link {
  font-size: 0.86rem;
  font-weight: 500;
  color: var(--v3-accent, var(--v3-ink));
  text-decoration: none;
  border-bottom: 1px dotted color-mix(in srgb, var(--v3-accent, var(--v3-ink)) 50%, transparent);
}
.saved-item-actions .time-link:hover { border-bottom-style: solid; }

.saved-item-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.55rem;
  padding-top: 0.55rem;
  border-top: 1px dashed var(--v3-line);
}
.saved-folder-select {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.2rem 0.45rem 0.2rem 0.6rem;
  background: var(--v3-field-bg);
  border: 1px solid var(--v3-line);
  border-radius: 8px;
}
.saved-folder-select-label {
  font-size: 0.72rem;
  color: var(--v3-muted);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.saved-folder-select select {
  border: 0;
  background: transparent;
  color: var(--v3-ink);
  font: inherit;
  font-size: 0.82rem;
  padding: 0.25rem 0.2rem;
  outline: none;
}
.saved-item-controls .tiny-btn {
  padding: 0.32rem 0.65rem;
  font-size: 0.78rem;
  border: 1px solid var(--v3-line);
  background: var(--v3-field-bg);
  color: var(--v3-ink);
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit;
}
.saved-item-controls .tiny-btn:hover { border-color: var(--v3-line-strong); }
.tiny-btn-danger {
  color: #b34a2a !important;
  border-color: rgba(179,74,42,0.35) !important;
  background: transparent !important;
}
.tiny-btn-danger:hover { background: rgba(179,74,42,0.08) !important; }
html[data-theme="dark"] .tiny-btn-danger { color: #e88863 !important; border-color: rgba(232,136,99,0.45) !important; }

/* ---- Empty states ---- */
.saved-empty {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.6rem;
  padding: 1.4rem 1.25rem;
  background: var(--v3-surface);
  border: 1px dashed var(--v3-line-strong);
  border-radius: 12px;
  color: var(--v3-muted);
}
.saved-empty p { margin: 0; max-width: 60ch; line-height: 1.55; }

/* ---- Folders page ---- */
.saved-folders-page .saved-folder-create {
  display: flex;
  gap: 0.55rem;
  margin: 1rem 0 1.25rem;
  align-items: stretch;
}
.saved-folders-page .saved-folder-create .saved-search { flex: 1; }
.saved-folders-page .saved-folder-create .saved-search-icon {
  width: auto;
  height: auto;
  font-weight: 700;
  font-size: 1.1rem;
  padding-right: 0.2rem;
}
.saved-folder-list {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}
.saved-folder-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.7rem;
  padding: 0.7rem 0.9rem;
  background: var(--v3-surface);
  border: 1px solid var(--v3-line);
  border-radius: 10px;
}
.saved-folder-row-name {
  display: flex;
  align-items: baseline;
  gap: 0.55rem;
}
.saved-folder-row-actions { display: flex; gap: 0.4rem; }

/* ---- Compatibility: hide the old horizontal three-column layout if any
        legacy markup leaks in via cache. The new IA replaces it. ---- */
.saved-categories { display: block; }

/* =========================================================================
   v0.4.5 — UI fixes
   1. Browser Extension page redesigned as a centred, single-screen,
      arrowed flow chart with a "Coming soon" sign-in step.
   2. Saved category views gain a "Clear all" affordance (right-aligned
      in the result-meta row).
   3. About / non-affiliation tightened into a one-screen page.
   ========================================================================= */

/* ---- Saved: layout the result-meta row + clear-all ---- */
.saved-result-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  flex-wrap: wrap;
}
.saved-clear-all {
  margin-left: auto;
}
.saved-clear-all[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
}

/* ---- Browser Extension v0.4.5 — centred flow ----
   The page is intentionally narrower and centred so the flow chart
   sits as a single column on desktop and fits a typical viewport
   without scrolling at 1280px+ when the browser chrome is normal.
*/
.extension-page-v045 {
  max-width: 700px;
  margin: 0 auto;
  padding-block: clamp(0.4rem, 1vw, 0.8rem);
  gap: 0.4rem;
}
.extension-page-v045 .ext-head {
  display: grid;
  gap: 0.25rem;
  text-align: center;
  justify-items: center;
}
.extension-page-v045 .ext-kicker {
  justify-content: center;
  margin-bottom: 0;
  font-size: 0.68rem;
  letter-spacing: 0.06em;
}
.extension-page-v045 .ext-kicker .page-kicker-mark { width: 16px; height: 16px; }
.extension-page-v045 .ext-title {
  margin: 0;
  font-size: clamp(1.15rem, 1.5vw, 1.4rem);
  line-height: 1.15;
  justify-content: center;
}
.extension-page-v045 .ext-sub {
  margin: 0;
  font-size: 0.8rem;
  line-height: 1.4;
  color: var(--v3-muted);
  max-width: 600px;
}
.extension-page-v045 .ext-cta-row {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 0.05rem;
}
.extension-page-v045 .ext-cta-row .btn { padding: 0.4rem 0.9rem; font-size: 0.8rem; }

/* The flow itself: 6 numbered steps connected by down-arrows. */
.ext-flow {
  list-style: none;
  margin: 0.15rem 0 0;
  padding: 0;
  display: grid;
  gap: 0.15rem;
  justify-items: stretch;
}
.ext-step {
  display: grid;
  grid-template-columns: 28px 1fr;
  align-items: start;
  gap: 0.55rem;
  padding: 0.35rem 0.7rem;
  border: 1px solid var(--v3-line);
  border-radius: 8px;
  background: var(--v3-card-bg);
}
.ext-step-num {
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: var(--v3-gold);
  color: var(--v3-button-text);
  font-weight: 800;
  font-size: 0.76rem;
  margin-top: 0.1rem;
  flex: 0 0 22px;
}
html[data-theme="dark"] .ext-step-num {
  background: var(--v3-gold-2);
  color: #17130b;
}
.ext-step-body { min-width: 0; }
.ext-step-title {
  margin: 0 0 0.03rem;
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--v3-ink);
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
  line-height: 1.25;
}
.ext-step-text {
  margin: 0;
  font-size: 0.76rem;
  line-height: 1.35;
  color: var(--v3-ink);
}
.ext-step-text code,
.ext-step-text kbd {
  font-family: "DM Mono", ui-monospace, SFMono-Regular, monospace;
  font-size: 0.78rem;
  padding: 0.02rem 0.35rem;
  background: var(--v3-field-bg);
  border: 1px solid var(--v3-line);
  border-radius: 5px;
  color: var(--v3-ink);
  white-space: nowrap;
}
html[data-theme="dark"] .ext-step-text code,
html[data-theme="dark"] .ext-step-text kbd {
  background: var(--v3-surface-2);
  border-color: var(--v3-line-strong);
}
.ext-step-future {
  border-style: dashed;
  background: color-mix(in srgb, var(--v3-field-bg) 55%, var(--v3-surface) 45%);
}
.ext-step-badge {
  display: inline-block;
  padding: 0.05rem 0.45rem;
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: var(--v3-field-bg);
  color: var(--v3-muted);
  border: 1px solid var(--v3-line);
  border-radius: 999px;
}
html[data-theme="dark"] .ext-step-future {
  background: color-mix(in srgb, var(--v3-surface-2) 70%, transparent);
}
.ext-arrow {
  display: flex;
  justify-content: center;
  color: var(--v3-muted);
  margin: -0.15rem 0;
  line-height: 0;
  opacity: 0.7;
}
.ext-arrow svg { width: 14px; height: 14px; }

/* Demo testing strip — secondary, lower visual weight than the flow. */
.ext-testing {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.6rem;
  align-items: center;
  padding: 0.4rem 0.7rem;
  border: 1px solid var(--v3-line);
  border-radius: 8px;
  background: var(--v3-field-bg);
  margin-top: 0.2rem;
}
.ext-testing-title {
  margin: 0;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--v3-ink);
}
.ext-testing-sub {
  margin: 0.1rem 0 0;
  font-size: 0.7rem;
  line-height: 1.35;
  color: var(--v3-muted);
}
.ext-testing-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.35rem;
}
.ext-testing-status {
  font-size: 0.74rem;
  color: var(--v3-muted);
}
.ext-legal {
  margin: 0.15rem auto 0;
  max-width: 640px;
  text-align: center;
  font-size: 0.68rem;
  color: var(--v3-faint, var(--v3-muted));
  line-height: 1.45;
}

@media (max-width: 720px) {
  .ext-testing {
    grid-template-columns: 1fr;
  }
  .ext-testing-actions { align-items: stretch; }
  .extension-page-v045 .ext-title { font-size: 1.35rem; }
}

/* ---- About / Affiliation page v0.4.5 — compact, one-screen ---- */
.about-page-v045 {
  max-width: 1040px;
  margin: 0 auto;
  padding-block: clamp(1rem, 2.5vw, 2rem);
  gap: 0.9rem;
}
.about-page-v045 .about-head {
  display: grid;
  gap: 0.3rem;
  text-align: center;
  justify-items: center;
}
.about-page-v045 .about-title {
  margin: 0;
  font-size: clamp(1.35rem, 2.1vw, 1.75rem);
  line-height: 1.2;
  max-width: 760px;
}
.about-page-v045 .about-sub {
  margin: 0;
  font-size: 0.88rem;
  line-height: 1.5;
  color: var(--v3-muted);
  max-width: 740px;
}
.about-grid-v045 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
  margin-top: 0.4rem;
}
.about-grid-v045 .about-card {
  padding: 0.85rem 1rem;
  border: 1px solid var(--v3-line);
  border-radius: 10px;
  background: var(--v3-card-bg);
}
.about-grid-v045 .about-card h2 {
  margin: 0 0 0.35rem;
  font-size: 0.92rem;
  font-weight: 700;
  letter-spacing: 0;
  color: var(--v3-ink);
}
.about-grid-v045 .about-card p {
  margin: 0;
  font-size: 0.82rem;
  line-height: 1.5;
  color: var(--v3-muted);
}
.about-grid-v045 .about-card a {
  color: var(--v3-gold-2);
  text-decoration: underline;
  text-underline-offset: 2px;
}
@media (max-width: 820px) {
  .about-grid-v045 {
    grid-template-columns: 1fr;
  }
}

/* =====================================================================
   v0.4.6 — Sync & cloud status (Settings popover + Extension page card)
   ===================================================================== */

.sync-row {
  align-items: flex-start;
}
.sync-row strong {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.sync-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 1.4;
  border: 1px solid var(--v3-border, #d8dad8);
  background: var(--v3-surface-soft, #f3f4f1);
  color: var(--v3-fg, #18221c);
  white-space: nowrap;
}
.sync-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #b3b8b3;
  flex: 0 0 8px;
}
.sync-badge-off { background: var(--v3-surface-soft, #f3f4f1); color: var(--v3-fg-muted, #4f594f); }
.sync-badge-off .sync-dot { background: #9aa19a; }
.sync-badge-ok { background: rgba(31, 113, 79, 0.10); color: #1f714f; border-color: rgba(31, 113, 79, 0.30); }
.sync-badge-ok .sync-dot { background: #1f9468; }
.sync-badge-syncing { background: rgba(78, 110, 224, 0.10); color: #3a51b8; border-color: rgba(78, 110, 224, 0.30); }
.sync-badge-syncing .sync-dot { background: #6678d6; animation: ia-sync-pulse 1.2s ease-in-out infinite; }
.sync-badge-error { background: rgba(178, 60, 60, 0.10); color: #a23535; border-color: rgba(178, 60, 60, 0.30); }
.sync-badge-error .sync-dot { background: #c44; }

@keyframes ia-sync-pulse {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}

/* Dark mode parity. The popover already uses a darker surface; just lift
   muted text so the off-state badge is still legible. */
[data-theme="dark"] .sync-badge-off,
@media (prefers-color-scheme: dark) {
  [data-theme="dark"] .sync-badge-off { background: rgba(255,255,255,0.06); color: rgba(255,255,255,0.7); border-color: rgba(255,255,255,0.12); }
}

/* Extension page sync card */
.ext-sync-card {
  max-width: 700px;
  margin: 20px auto 0;
  padding: 14px 18px;
  border: 1px solid var(--v3-border, #d8dad8);
  border-radius: 10px;
  background: var(--v3-surface-soft, #f7f8f5);
  text-align: left;
}
.ext-sync-head { margin-bottom: 6px; }
.ext-sync-body {
  margin: 0;
  font-size: 13px;
  line-height: 1.55;
  color: var(--v3-fg, #18221c);
}
.ext-sync-body code {
  font-family: "DM Mono", ui-monospace, monospace;
  font-size: 12px;
  background: rgba(0,0,0,0.05);
  padding: 1px 5px;
  border-radius: 4px;
}
[data-theme="dark"] .ext-sync-card {
  background: rgba(255,255,255,0.04);
  border-color: rgba(255,255,255,0.10);
}
[data-theme="dark"] .ext-sync-body code {
  background: rgba(255,255,255,0.08);
}

/* Saved item source pill (Cloud / Imported) */
.saved-source-pill {
  display: inline-flex;
  align-items: center;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border: 1px solid transparent;
  line-height: 1.5;
}
.saved-source-cloud {
  background: rgba(31, 113, 79, 0.10);
  color: #1f714f;
  border-color: rgba(31, 113, 79, 0.25);
}
.saved-source-imported {
  background: rgba(78, 110, 224, 0.10);
  color: #3a51b8;
  border-color: rgba(78, 110, 224, 0.25);
}
[data-theme="dark"] .saved-source-cloud { color: #6ed1a1; border-color: rgba(110, 209, 161, 0.30); background: rgba(110, 209, 161, 0.10); }
[data-theme="dark"] .saved-source-imported { color: #97a8ef; border-color: rgba(151, 168, 239, 0.30); background: rgba(151, 168, 239, 0.10); }

/* v0.4.6 dark-mode legibility fix for ext-sync-body */
[data-theme="dark"] .ext-sync-body {
  color: rgba(255,255,255,0.92);
}

/* v0.4.6 user_notes patch — "♥ Liked" chip on cloud-synced moments
   surfaces the boolean `liked` column from public.user_notes. Strictly
   informational; clear / delete / filter behaviour is unchanged. */
.saved-liked-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  line-height: 1.5;
  background: rgba(214, 51, 95, 0.10);
  color: #c4385e;
  border: 1px solid rgba(214, 51, 95, 0.25);
}
[data-theme="dark"] .saved-liked-chip {
  color: #f59ab1;
  background: rgba(245, 154, 177, 0.10);
  border-color: rgba(245, 154, 177, 0.30);
}

/* ===================================================================== */
/* v0.5.4 — Lighter card surfaces matching Home search bar pill style.    */
/* Goal: every card/box that sits on the page background should feel      */
/* one step LIGHTER than the page (cream), with the same hairline +       */
/* subtle shadow language as `.hero-search`. The Home page itself is      */
/* preserved exactly: we override per-component, never the home tokens.   */
/* ===================================================================== */
:root,
html[data-theme="light"] {
  /* A flatter, lighter solid surface, slightly brighter than --v3-card-bg
     gradient and matching the off-white feel of the home search pill. */
  --v3-card-bg-soft: #fffdf5;
  --v3-card-shadow-soft: 0 1px 2px rgba(38, 28, 6, 0.05),
                         0 6px 18px rgba(58, 49, 30, 0.07);
}
html[data-theme="dark"] {
  --v3-card-bg-soft: #1f2418;
  --v3-card-shadow-soft: 0 1px 2px rgba(0, 0, 0, 0.30),
                         0 6px 18px rgba(0, 0, 0, 0.25);
}

/* Apply the lighter pill-surface to non-Home card components. We
   deliberately exclude `.hero-lockup` and Home hero composition because
   the approved Home page must not change. */
.saved-item,
.saved-entry-card,
.action-card,
.ote-card,
.answer-card,
.panel,
.v3-panel,
.model-card,
.saved-note,
.state-card,
.key-note,
.practice-row,
.captured-notes-panel,
.settings-panel,
.settings-card {
  background: var(--v3-card-bg-soft) !important;
  border: 1px solid var(--v3-line-strong);
  box-shadow: var(--v3-card-shadow-soft);
}

/* Saved cards: a touch tighter so they read like pills aligned to the
   hero-search visual rhythm. Radius matches v3-radius (22px). */
.saved-item,
.saved-entry-card {
  border-radius: var(--v3-radius);
}

/* Home page is approved; explicitly do not touch the hero lockup or
   the home search pill, even if a future rule tries to override. */
.hero-search,
.hero-lockup,
.home-hero,
.hero-row,
.home-tagline {
  /* no-op guard */
}

/* ===================================================================== */
/* v0.5.4 — Centered hearts on every page.                                */
/* The `.heart-btn` already uses inline-grid place-items:center for its   */
/* icon. We add a vertical-align baseline override so it sits centered    */
/* relative to neighboring text/buttons regardless of the parent flex.    */
/* ===================================================================== */
.heart-btn {
  vertical-align: middle;
  align-self: center;
  flex: 0 0 auto;
}
.lesson-actions,
.lib-row-actions,
.lib-detail-head,
.saved-item-actions,
.captured-note-head {
  align-items: center;
}

/* ===================================================================== */
/* v0.5.4 — "Routed from" pill in Source notes for orphan extension       */
/* notes whose original video is not in the local archive.                */
/* ===================================================================== */
.captured-note-routed-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  background: color-mix(in srgb, var(--v3-gold) 12%, var(--v3-card-bg-soft, var(--v3-field-bg)));
  color: var(--v3-gold-2);
  border: 1px solid color-mix(in srgb, var(--v3-gold) 30%, var(--v3-line));
  margin-left: 0.5rem;
  cursor: help;
}
.captured-note-item.captured-note-routed {
  border-left: 2px solid color-mix(in srgb, var(--v3-gold) 55%, transparent);
  padding-left: 0.6rem;
}

/* ===================================================================== */
/* v0.5.4 — Bottom-right feedback prompt (20% off first 3 months).        */
/* Disclaimer-sized; shown only after the user has interacted.            */
/* Sticky bottom-right; dismissible.                                      */
/* ===================================================================== */
.ia-feedback-prompt {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 90;
  max-width: 320px;
  padding: 10px 14px 10px 14px;
  background: var(--v3-card-bg-soft, var(--v3-card-bg));
  border: 1px solid var(--v3-line-strong);
  box-shadow: var(--v3-card-shadow-soft, var(--v3-shadow));
  border-radius: 14px;
  font-size: 11.5px;
  line-height: 1.45;
  color: var(--v3-muted);
  display: none;             /* JS sets to grid after interaction */
  grid-template-columns: 1fr auto;
  align-items: start;
  gap: 8px;
}
.ia-feedback-prompt.visible { display: grid; }
.ia-feedback-prompt strong {
  color: var(--v3-ink);
  font-weight: 700;
}
.ia-feedback-prompt a.ia-feedback-link {
  color: var(--v3-gold-2);
  font-weight: 600;
  text-decoration: none;
  border-bottom: 1px dotted color-mix(in srgb, var(--v3-gold) 40%, transparent);
}
.ia-feedback-prompt a.ia-feedback-link:hover {
  border-bottom-color: var(--v3-gold-2);
}
.ia-feedback-prompt .ia-feedback-dismiss {
  width: 22px; height: 22px;
  display: inline-grid; place-items: center;
  border: 1px solid var(--v3-line);
  border-radius: 999px;
  background: transparent;
  color: var(--v3-faint);
  cursor: pointer;
  font-size: 12px;
}
.ia-feedback-prompt .ia-feedback-dismiss:hover {
  color: var(--v3-ink);
  border-color: var(--v3-line-strong);
}
@media (max-width: 540px) {
  .ia-feedback-prompt {
    left: 10px; right: 10px; bottom: 10px; max-width: none;
  }
}

/* ===================================================================== */
/* v0.5.4 — Extension page: tighten to fit a single viewport when the     */
/* browser is reasonably tall. Smaller arrows, condensed step cards.      */
/* The actual classes are .ext-flow, .ext-step, .ext-arrow, .ext-testing  */
/* (see renderExtensionPage in app_v03.js).                               */
/* ===================================================================== */
.extension-page-v045 {
  padding-block: 0.6rem 0.9rem !important;
  max-width: 1100px;
}
.extension-page-v045 .ext-head {
  margin-bottom: 0.35rem !important;
}
.extension-page-v045 .ext-kicker {
  margin-bottom: 0.1rem !important;
  font-size: 0.72rem !important;
}
.extension-page-v045 .ext-title {
  font-size: 1.35rem !important;
  margin: 0.05rem 0 0.15rem 0 !important;
}
.extension-page-v045 .ext-sub {
  font-size: 0.82rem !important;
  margin: 0 0 0.35rem 0 !important;
  line-height: 1.4 !important;
}
.extension-page-v045 .ext-cta-row {
  margin-top: 0.2rem !important;
  gap: 0.6rem !important;
}
.extension-page-v045 .ext-cta-row .btn {
  padding: 0.35rem 0.8rem !important;
  font-size: 0.78rem !important;
}
.extension-page-v045 .ext-flow {
  gap: 0.4rem !important;
  margin: 0.35rem 0 0.45rem 0 !important;
  padding: 0 !important;
  display: grid !important;
  grid-template-columns: repeat(6, minmax(0, 1fr)) !important;
  grid-template-rows: auto !important;
  align-items: stretch;
  list-style: none;
}
.extension-page-v045 .ext-flow .ext-step {
  padding: 0.5rem 0.6rem !important;
  background: var(--v3-card-bg-soft, var(--v3-card-bg)) !important;
  border: 1px solid var(--v3-line) !important;
  border-radius: 10px !important;
  display: grid !important;
  grid-template-columns: auto 1fr !important;
  gap: 0.45rem !important;
  align-items: start;
}
.extension-page-v045 .ext-flow .ext-step .ext-step-num {
  width: 1.4rem !important;
  height: 1.4rem !important;
  font-size: 0.78rem !important;
  min-width: 0 !important;
}
.extension-page-v045 .ext-flow .ext-step-title {
  font-size: 0.8rem !important;
  line-height: 1.2 !important;
  margin: 0 0 0.1rem 0 !important;
  font-weight: 700;
}
.extension-page-v045 .ext-flow .ext-step-text {
  font-size: 0.7rem !important;
  line-height: 1.3 !important;
  margin: 0 !important;
}
.extension-page-v045 .ext-flow .ext-step-text code,
.extension-page-v045 .ext-flow .ext-step-text kbd {
  font-size: 0.65rem !important;
  padding: 0 3px !important;
}
.extension-page-v045 .ext-flow .ext-arrow {
  display: none !important; /* horizontal grid doesn't need vertical arrows */
}
.extension-page-v045 .ext-testing {
  padding: 0.55rem 0.75rem !important;
  font-size: 0.78rem !important;
  margin-top: 0.35rem !important;
}
.extension-page-v045 .ext-testing-title {
  font-size: 0.88rem !important;
  margin: 0 0 0.15rem 0 !important;
}
.extension-page-v045 .ext-testing-sub {
  font-size: 0.72rem !important;
  margin: 0 0 0.2rem 0 !important;
  line-height: 1.35 !important;
}
.extension-page-v045 .ext-testing-actions .btn {
  padding: 0.3rem 0.7rem !important;
  font-size: 0.75rem !important;
}
.extension-page-v045 .ext-legal {
  font-size: 0.66rem !important;
  line-height: 1.4 !important;
  margin-top: 0.35rem !important;
}
/* The sync-status card on Extension page: compact one-line layout. */
.extension-page-v045 .ext-sync-status,
.extension-page-v045 .sync-row {
  padding: 0.5rem 0.7rem !important;
  font-size: 0.78rem !important;
  margin: 0.35rem 0 0 0 !important;
}
.extension-page-v045 .ext-sync-status .sync-badge,
.extension-page-v045 .sync-row .sync-badge {
  font-size: 0.72rem !important;
}
/* Stack to two rows of three on medium screens, one column on small. */
@media (max-width: 980px) {
  .extension-page-v045 .ext-flow {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  }
}
@media (max-width: 640px) {
  .extension-page-v045 .ext-flow {
    grid-template-columns: 1fr !important;
  }
}

/* ===================================================================== */
/* v0.5.4 — Settings popup: clean section grouping (Appearance / Cloud &  */
/* account / About). Cards inside a section share a soft container so     */
/* sync, sign-in, and extension entries read as ONE block visually.       */
/* ===================================================================== */
.settings-popover-v054 .settings-section {
  margin-top: 0.7rem;
  padding: 0.6rem 0.75rem 0.75rem;
  background: var(--v3-card-bg-soft, var(--v3-card-bg));
  border: 1px solid var(--v3-line);
  border-radius: 14px;
}
.settings-popover-v054 .settings-section-title {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--v3-faint);
  margin: 0 0 0.5rem 0;
}
.settings-popover-v054 .settings-section .settings-row {
  background: transparent !important;
  border: 1px solid var(--v3-line);
  border-radius: 10px;
  padding: 0.55rem 0.7rem;
  margin-top: 0.4rem;
  box-shadow: none !important;
}
.settings-popover-v054 .settings-section .settings-row:first-of-type {
  margin-top: 0;
}
.settings-popover-v054 .sync-row {
  border-color: var(--v3-line-strong) !important;
}
.settings-popover-v054 .settings-entry {
  display: grid !important;
  grid-template-columns: auto 1fr auto;
  gap: 0.6rem;
  align-items: center;
}


/* =====================================================================
   STREAM B v0.6 — Design System Pass
   All rules below are additive; no existing rules removed here.
   ===================================================================== */

/* ── B2: Card brightness tokens ────────────────────────────────────── */
:root,
html[data-theme="light"] {
  --bg:       #f4ecdc;
  --surface-1: #fbf6ea;   /* boxed cards: Saved, Models, Settings, Library */
  --surface-2: #ffffff;   /* nested inputs needing extra contrast */
  --border:   rgba(0,0,0,.06);
}
html[data-theme="dark"] {
  --bg:       #1a1814;
  --surface-1: #25221d;
  --surface-2: #2b271f;
  --border:   rgba(255,255,255,.06);
}

/* Apply --surface-1 to all boxed cards */
.saved-item,
.saved-entry-card,
.model-card,
.settings-popover-v054 .settings-section,
.playlist-card,
.detail-block {
  background: var(--surface-1) !important;
}

/* ── B1: Saved card 3-line layout ──────────────────────────────────── */
/* Override the old mixed layout with a strict 3-line grid */
.saved-item {
  border-radius: 16px !important;
  padding: 1rem 1.1rem !important;
  display: grid !important;
  grid-template-rows: auto auto auto !important;
  gap: 0 !important;
  border: 1px solid var(--v3-line) !important;
}

/* Line 1: priority pill + title + duration + date */
.saved-item-line1 {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: nowrap;
  overflow: hidden;
  min-height: 1.6rem;
  margin-bottom: 0.5rem;
}
.saved-item-line1 .saved-pri {
  flex-shrink: 0;
}
.saved-item-line1 .saved-item-title-inline {
  flex: 1;
  font-size: 0.97rem;
  font-weight: 700;
  color: var(--v3-ink);
  letter-spacing: -0.005em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin: 0;
}
.saved-item-line1 .saved-item-meta-right {
  display: flex;
  gap: 0.45rem;
  align-items: center;
  flex-shrink: 0;
  color: var(--v3-muted);
  font-size: 0.78rem;
}

/* Line 2: note preview (max 2 lines, ellipsis, see-more inline) */
.saved-item-line2 {
  font-size: 0.88rem;
  line-height: 1.5;
  color: var(--v3-muted);
  margin-bottom: 0.6rem;
}
.saved-item-preview {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.saved-item-preview.expanded {
  display: block;
  -webkit-line-clamp: unset;
}
.saved-item-see-more {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.82rem;
  color: var(--v3-gold-2, var(--v3-gold));
  font-weight: 600;
  margin-left: 0.25rem;
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* Line 3: priority chip + folder + delete — separated from line 2 by border */
.saved-item-line3 {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex-wrap: wrap;
  padding-top: 0.55rem;
  border-top: 1px dashed var(--v3-line);
}

/* Custom-styled folder dropdown (B4) */
.saved-folder-custom {
  position: relative;
  display: inline-flex;
  align-items: center;
}
.saved-folder-custom-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.6rem;
  border: 1px solid var(--v3-line-strong);
  border-radius: 999px;
  background: var(--surface-1, var(--v3-field-bg));
  color: var(--v3-ink);
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}
.saved-folder-custom-btn:hover,
.saved-folder-custom-btn:focus-visible {
  border-color: var(--v3-gold, var(--brand));
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--v3-gold, #b97b16) 18%, transparent);
  outline: none;
}
.saved-folder-custom-btn .folder-chevron {
  font-size: 0.65em;
  opacity: 0.7;
}
.saved-folder-popover {
  position: absolute;
  bottom: calc(100% + 4px);
  left: 0;
  z-index: 100;
  min-width: 160px;
  background: var(--surface-2, var(--v3-surface));
  border: 1px solid var(--v3-line-strong);
  border-radius: 12px;
  box-shadow: 0 8px 28px rgba(0,0,0,0.13);
  padding: 0.3rem;
  display: none;
  flex-direction: column;
}
.saved-folder-popover.open {
  display: flex;
}
.saved-folder-popover-item {
  padding: 0.35rem 0.65rem;
  border-radius: 8px;
  font-size: 0.82rem;
  color: var(--v3-ink);
  cursor: pointer;
  background: none;
  border: none;
  font-family: inherit;
  text-align: left;
  transition: background 100ms;
}
.saved-folder-popover-item:hover {
  background: var(--v3-chip-bg);
}
.saved-folder-popover-item.selected {
  font-weight: 700;
  color: var(--v3-gold-2, var(--v3-gold));
}

/* ── B4: Custom sort dropdown (toolbar) ─────────────────────────── */
.saved-sort-custom {
  position: relative;
  display: inline-flex;
  align-items: center;
}
.saved-sort-custom-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.75rem;
  border: 1px solid var(--v3-line-strong);
  border-radius: 999px;
  background: var(--surface-1, var(--v3-field-bg));
  color: var(--v3-ink);
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}
.saved-sort-custom-btn:hover,
.saved-sort-custom-btn:focus-visible {
  border-color: var(--v3-gold, var(--brand));
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--v3-gold, #b97b16) 18%, transparent);
  outline: none;
}
.saved-sort-popover {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  z-index: 100;
  min-width: 180px;
  background: var(--surface-2, var(--v3-surface));
  border: 1px solid var(--v3-line-strong);
  border-radius: 12px;
  box-shadow: 0 8px 28px rgba(0,0,0,0.13);
  padding: 0.3rem;
  display: none;
  flex-direction: column;
}
.saved-sort-popover.open {
  display: flex;
}
.saved-sort-popover-item {
  padding: 0.35rem 0.65rem;
  border-radius: 8px;
  font-size: 0.82rem;
  color: var(--v3-ink);
  cursor: pointer;
  background: none;
  border: none;
  font-family: inherit;
  text-align: left;
  transition: background 100ms;
}
.saved-sort-popover-item:hover {
  background: var(--v3-chip-bg);
}
.saved-sort-popover-item.selected {
  font-weight: 700;
  color: var(--v3-gold-2, var(--v3-gold));
}

/* ── B3: Models hero rounded corners ─────────────────────────────── */
.model-detail-page .detail-head {
  border-radius: 16px !important;
  border: 1px solid var(--v3-line);
  padding: 1.1rem 1.2rem;
  background: var(--surface-1) !important;
}
/* Also ensure all detail-block are 16px (was 18px — keep existing or override) */
.detail-block {
  border-radius: 16px !important;
}

/* ── B5: Settings rebuild ─────────────────────────────────────────── */
.settings-popover-b6 {
  /* inherits all from settings-popover-v054 */
}
/* C2 v0.8: Section gaps tightened from 24px → 10px, padding 16px → 12px/14px */
/* v0.11 PATCH-06: density −20% gaps, −10% font, desktop only */
.settings-popover-b6 .settings-section {
  margin-top: 8px !important;   /* was 10px, −20% */
  padding: 10px 12px !important; /* was 12px/14px, −20% */
  border-radius: 14px !important;
  border: 1px solid var(--border, var(--v3-line)) !important;
  background: var(--surface-1) !important;
}
.settings-popover-b6 .settings-section:first-child {
  margin-top: 6px !important;  /* was 8px, −20% */
}
/* v0.11 PATCH-06: font size −10% in settings sections (desktop) */
@media (min-width: 641px) {
  .settings-popover-b6 .settings-section-title { font-size: 0.65rem !important; }  /* was 0.72rem */
  .settings-popover-b6 .settings-colour-label { font-size: 0.81rem !important; }   /* was 0.9rem */
  .settings-popover-b6 .settings-sync-oneline { font-size: 0.79rem !important; }   /* was 0.88rem */
  .settings-popover-b6 .settings-head { font-size: 0.85rem !important; }
  .settings-popover-b6 .settings-founder-note { font-size: 0.72rem !important; }
  .settings-popover-b6 .settings-entry-text span { font-size: 0.74rem !important; }
}
/* Section 1: colour mode — single row */
.settings-colour-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.settings-colour-label {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--v3-ink);
}
/* Section 2: sign-in status */
.settings-sync-oneline {
  font-size: 0.88rem;
  color: var(--v3-ink);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.settings-synced-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.2rem 0.7rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
}
.settings-synced-badge.ok {
  background: rgba(67, 122, 34, 0.14);
  color: #437a22;
  border: 1px solid rgba(67,122,34,0.3);
}
html[data-theme="dark"] .settings-synced-badge.ok {
  background: rgba(94, 168, 50, 0.18);
  color: #7ec84e;
  border-color: rgba(94,168,50,0.35);
}
.settings-synced-badge.error {
  background: rgba(161, 44, 123, 0.14);
  color: #a12c7b;
  border: 1px solid rgba(161,44,123,0.3);
}
html[data-theme="dark"] .settings-synced-badge.error {
  background: rgba(212, 106, 170, 0.18);
  color: #d46aaa;
  border-color: rgba(212,106,170,0.35);
}
/* Profile link row */
.settings-profile-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.88rem;
  color: var(--v3-ink);
  text-decoration: none;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--v3-line);
}
.settings-profile-row:hover { color: var(--v3-gold-2, var(--v3-gold)); text-decoration: none; }
/* C2.1 v0.8 — Settings sign-out button */
.settings-sign-out-btn {
  display: inline-block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--v3-muted);
  background: transparent;
  border: 1px solid var(--v3-line-strong);
  border-radius: 6px;
  padding: 4px 10px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.settings-sign-out-btn:hover {
  color: var(--v3-ink);
  border-color: var(--v3-ink);
}
html[data-theme="dark"] .settings-sign-out-btn {
  color: var(--v3-muted);
  border-color: var(--v3-line-strong);
}
html[data-theme="dark"] .settings-sign-out-btn:hover {
  color: var(--v3-ink);
}
/* Upcoming features founder note */
.settings-founder-note {
  font-size: 0.84rem;
  line-height: 1.55;
  color: var(--v3-muted);
  margin: 0 0 14px;
}
.settings-feedback-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
}
.settings-feedback-form textarea,
.settings-feedback-form input[type="email"] {
  width: 100%;
  border: 1px solid var(--v3-line-strong);
  border-radius: 8px;
  padding: 8px 10px;
  font-family: inherit;
  font-size: 0.85rem;
  background: var(--surface-2, var(--v3-field-bg));
  color: var(--v3-ink);
  resize: vertical;
}
.settings-feedback-form textarea:focus,
.settings-feedback-form input[type="email"]:focus {
  outline: none;
  border-color: var(--v3-gold, var(--brand));
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--v3-gold, #b97b16) 18%, transparent);
}

/* ── B6: Feedback popup — bottom-LEFT repositioned ───────────────── */
.ia-feedback-prompt {
  right: auto !important;
  left: 18px !important;
}
@media (max-width: 540px) {
  .ia-feedback-prompt {
    left: 10px !important;
    right: 10px !important;
  }
}

/* ── B10: Extension landing page full-width redesign ─────────────── */
.extension-page-b10 {
  max-width: 1200px !important;
  width: 100%;
  padding: 0 0 3rem 0 !important;
}
.ext-b10-hero {
  padding: 3rem 0 2.5rem;
  display: grid;
  gap: 1rem;
}
.ext-b10-eyebrow {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--v3-muted);
}
.ext-b10-title {
  font-size: clamp(2rem, 4vw, 3rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 0;
  color: var(--v3-ink);
  line-height: 1.1;
}
.ext-b10-version {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.7rem;
  border: 1px solid var(--v3-line-strong);
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 0.74rem;
  color: var(--v3-muted);
  background: var(--surface-1);
  margin-left: 0.75rem;
  vertical-align: middle;
}
.ext-b10-tagline {
  font-size: 1.15rem;
  color: var(--v3-muted);
  max-width: 680px;
  line-height: 1.5;
  margin: 0;
}
.ext-b10-cta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  margin-top: 0.5rem;
}
/* How it works section */
.ext-b10-section {
  padding: 2rem 0;
  border-top: 1px solid var(--v3-line);
}
.ext-b10-section-title {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0 0 1.5rem;
  color: var(--v3-ink);
}
.ext-b10-steps {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}
.ext-b10-step {
  background: var(--surface-1);
  border: 1px solid var(--v3-line);
  border-radius: 16px;
  padding: 1.25rem 1.1rem;
  display: grid;
  gap: 0.65rem;
}
.ext-b10-step-num {
  width: 2rem;
  height: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: var(--v3-chip-bg);
  color: var(--v3-gold-2, var(--v3-gold));
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 700;
}
.ext-b10-step-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--v3-ink);
  margin: 0;
  letter-spacing: -0.005em;
}
.ext-b10-step-body {
  font-size: 0.88rem;
  line-height: 1.5;
  color: var(--v3-muted);
  margin: 0;
}
.ext-b10-step-body kbd {
  display: inline-block;
  padding: 1px 6px;
  border: 1px solid var(--v3-line-strong);
  border-radius: 5px;
  background: var(--surface-2);
  font-family: var(--font-mono);
  font-size: 0.75em;
  color: var(--v3-ink);
  box-shadow: 0 1px 0 var(--v3-line-strong);
}
/* Install section */
.ext-b10-install {
  background: var(--surface-1);
  border: 1px solid var(--v3-line);
  border-radius: 16px;
  padding: 1.5rem 1.4rem;
}
.ext-b10-install ol {
  margin: 1rem 0 0;
  padding-left: 1.4rem;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}
.ext-b10-install li {
  font-size: 0.95rem;
  line-height: 1.5;
  color: var(--v3-ink);
}
.ext-b10-install li code {
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--surface-2);
  font-family: var(--font-mono);
  font-size: 0.85em;
  border: 1px solid var(--v3-line);
}
/* FAQ section */
.ext-b10-faq {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.ext-b10-faq-item {
  border: 1px solid var(--v3-line);
  border-radius: 16px;
  overflow: hidden;
  background: var(--surface-1);
}
.ext-b10-faq-item summary {
  list-style: none;
  padding: 1rem 1.1rem;
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--v3-ink);
  display: flex;
  justify-content: space-between;
  align-items: center;
  user-select: none;
}
.ext-b10-faq-item summary::-webkit-details-marker { display: none; }
.ext-b10-faq-item summary::after {
  content: "▾";
  font-size: 0.8em;
  color: var(--v3-muted);
  transition: transform 150ms;
}
.ext-b10-faq-item[open] summary::after {
  transform: rotate(180deg);
}
.ext-b10-faq-answer {
  padding: 0 1.1rem 1rem;
  font-size: 0.9rem;
  line-height: 1.55;
  color: var(--v3-muted);
}
/* Channel lock notice */
.ext-b10-channel-notice {
  margin-top: 0.5rem;
  padding: 0.85rem 1.1rem;
  background: var(--surface-1);
  border: 1px solid var(--v3-line);
  border-radius: 12px;
  font-size: 0.85rem;
  color: var(--v3-muted);
  display: flex;
  gap: 0.55rem;
  align-items: flex-start;
}
.ext-b10-channel-notice::before {
  content: "⚠";
  font-size: 1em;
  flex-shrink: 0;
  margin-top: 1px;
}
/* Mobile responsive */
@media (max-width: 768px) {
  .ext-b10-steps {
    grid-template-columns: 1fr;
  }
  .ext-b10-title {
    font-size: 1.8rem;
  }
  .ext-b10-hero {
    padding: 2rem 0 1.5rem;
  }
}

/* ── B9: Save Moment modal — reduced spacing ─────────────────────── */
/* Tighten vertical spacing by ~25% — target content.js injected styles */
/* These override the inline <style> injected by the extension content script */
#ia-overlay #ia-priority-row {
  margin: 5px 0 4px !important;
}
#ia-overlay #ia-note-textarea {
  margin-top: 4px !important;
}
#ia-overlay #ia-overlay-meta,
#ia-overlay #ia-overlay-timestamps {
  margin-bottom: 3px !important;
}
#ia-overlay #ia-overlay-actions {
  margin-top: 7px !important;
}

/* ═══════════════════════════════════════════════════════════════════════════
   STREAM C PHASE 1 — v0.7 additions
   Plans page, modals, showcase blur, soft-clear toast, PDF export button
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Plans page ──────────────────────────────────────────────────────────── */
.plans-page {
  max-width: 960px;
  margin-left: auto;
  margin-right: auto;
}
/* v0.11 PATCH-03: shared centering wrapper for header + cards */
.plans-page-inner {
  max-width: var(--v3-search-col, 740px);
  margin-left: auto;
  margin-right: auto;
}
/* C4.2 v0.8: .plans-pricing-note removed (class no longer used) */
.plans-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.25rem;
  margin-bottom: 2rem;
  margin-left: auto;
  margin-right: auto;
  max-width: var(--v3-search-col);
}
.plans-card {
  background: var(--surface-1);
  border: 1px solid var(--v3-line);
  border-radius: 16px;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  position: relative;
}
.plans-card-featured {
  border-color: var(--brand, #2a6b3f);
  box-shadow: 0 0 0 2px var(--brand, #2a6b3f);
}
.plans-card-badge {
  position: absolute;
  top: -12px;
  left: 1.25rem;
  background: var(--brand, #2a6b3f);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 2px 10px;
  border-radius: 999px;
}
.plans-card-head {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.plans-plan-name {
  font-size: 1rem;
  font-weight: 700;
  color: var(--ink);
}
.plans-price {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--ink);
  line-height: 1.1;
}
.plans-price-period {
  font-size: 1rem;
  font-weight: 400;
  color: var(--v3-muted);
}
.plans-price-note {
  font-size: 0.78rem;
  color: var(--v3-muted);
}
.plans-features {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}
.plans-features li {
  font-size: 0.875rem;
  color: var(--ink-2, var(--v3-muted));
  padding-left: 1.25em;
  position: relative;
}
.plans-features li::before {
  content: "✓";
  position: absolute;
  left: 0;
  color: var(--brand, #2a6b3f);
  font-weight: 700;
}
.plans-lifetime-counter {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--v3-muted);
  min-height: 1.2em;
}
.plans-cta {
  width: 100%;
  margin-top: auto;
}
.plans-coupon-note {
  font-size: 0.85rem;
  color: var(--v3-muted);
  margin-bottom: 0.75rem;
}
.plans-disclaimer {
  font-size: 0.78rem;
  color: var(--v3-muted);
  line-height: 1.5;
  border-top: 1px solid var(--v3-line);
  padding-top: 1rem;
  margin-top: 0.5rem;
}
@media (max-width: 640px) {
  .plans-card-grid {
    grid-template-columns: 1fr;
  }
}

/* v0.11 PATCH-02: /plans dark mode text readability */
[data-theme="dark"] .plans-plan-name { color: var(--v3-fg); }
[data-theme="dark"] .plans-price { color: var(--v3-fg); }
[data-theme="dark"] .plans-price-period { color: var(--v3-muted); }
[data-theme="dark"] .plans-price-note { color: var(--v3-muted); }
[data-theme="dark"] .plans-features li { color: var(--v3-muted); }
[data-theme="dark"] .plans-card-head { color: var(--v3-fg); }
[data-theme="dark"] .plans-card { background: var(--v3-card); border-color: var(--v3-line); color: var(--v3-fg); }
[data-theme="dark"] .plans-card-featured { border-color: var(--brand, #2a6b3f); box-shadow: 0 0 0 2px var(--brand, #2a6b3f); }
[data-theme="dark"] .plans-coupon-note { color: var(--v3-muted); }
[data-theme="dark"] .plans-disclaimer { color: var(--v3-muted); border-color: var(--v3-line); }
[data-theme="dark"] .plans-lifetime-counter { color: var(--v3-muted); }

/* ── Modal overlay (shared: sign-in, waitlist, edit, confirm) ────────────── */
.ia-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: 1rem;
}
.ia-modal-box {
  background: var(--surface-0, #fff);
  border-radius: 16px;
  padding: 2rem;
  max-width: 440px;
  width: 100%;
  position: relative;
  box-shadow: 0 24px 64px rgba(0,0,0,0.2);
}
.ia-modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: none;
  border: none;
  font-size: 1.4rem;
  color: var(--v3-muted);
  cursor: pointer;
  line-height: 1;
  padding: 4px 8px;
  border-radius: 6px;
}
.ia-modal-close:hover {
  background: var(--surface-1);
  color: var(--ink);
}
.ia-modal-title {
  font-size: 1.25rem;
  font-weight: 700;
  margin: 0 0 0.4rem;
}
.ia-modal-sub {
  font-size: 0.875rem;
  color: var(--v3-muted);
  margin: 0 0 1.25rem;
}
.ia-modal-note {
  font-size: 0.8rem;
  color: var(--v3-muted);
  margin-top: 1rem;
}
.ia-modal-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.ia-form-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: -4px;
}
.ia-form-input {
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--v3-line);
  border-radius: 8px;
  font-size: 0.9rem;
  background: var(--surface-0, #fff);
  color: var(--ink);
  width: 100%;
  box-sizing: border-box;
}
.ia-form-input:focus {
  outline: 2px solid var(--brand, #2a6b3f);
  outline-offset: 1px;
}
.ia-form-textarea {
  resize: vertical;
  min-height: 80px;
  font-family: inherit;
}
.ia-form-checkbox-row {
  display: flex;
  gap: 0.5rem;
  align-items: flex-start;
  font-size: 0.85rem;
}
.ia-form-checkbox-row input[type="checkbox"] {
  flex-shrink: 0;
  margin-top: 3px;
  accent-color: var(--brand, #2a6b3f);
}
/* v0.11 PATCH-08: Sign In/Up modal dark mode */
[data-theme="dark"] .ia-modal-box { background: var(--v3-card); color: var(--v3-fg); border: 1px solid var(--v3-line); }
[data-theme="dark"] .ia-form-input { background: var(--v3-bg); color: var(--v3-fg); border-color: var(--v3-line); }
[data-theme="dark"] .ia-form-label { color: var(--v3-muted); }
[data-theme="dark"] .ia-modal-title { color: var(--v3-fg); }
[data-theme="dark"] .ia-modal-sub { color: var(--v3-muted); }
[data-theme="dark"] .ia-modal-note { color: var(--v3-muted); }
[data-theme="dark"] .ia-modal-close { color: var(--v3-muted); }
[data-theme="dark"] .ia-modal-close:hover { background: var(--v3-line); color: var(--v3-fg); }

.ia-form-error {
  font-size: 0.82rem;
  color: #c0392b;
  background: #fdf0ed;
  border: 1px solid #e8b4ad;
  border-radius: 6px;
  padding: 6px 10px;
  margin: 0;
}
.ia-form-success {
  font-size: 0.82rem;
  color: #1a7a3a;
  background: #eef7f0;
  border: 1px solid #a3d4b0;
  border-radius: 6px;
  padding: 6px 10px;
  margin: 0;
}

/* ── Showcase blur overlay ───────────────────────────────────────────────── */
.ia-showcase-blur-wrap {
  position: relative;
  overflow: hidden;
  border-radius: 12px;
}
.ia-showcase-blurred {
  filter: blur(4px);
  pointer-events: none;
  user-select: none;
  -webkit-user-select: none;
}
.ia-showcase-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(var(--surface-0-rgb, 255,255,255), 0.7);
  backdrop-filter: blur(2px);
  gap: 0.75rem;
  padding: 1.5rem;
  text-align: center;
}
.ia-showcase-overlay-label {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--ink);
  margin: 0;
}

/* ── Soft clear toast (C11) ──────────────────────────────────────────────── */
.ia-soft-clear-toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  background: var(--ink, #1a1a1a);
  color: #fff;
  font-size: 0.875rem;
  padding: 0.75rem 1.1rem;
  border-radius: 10px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.18);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  z-index: 1900;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
}
.ia-soft-clear-toast.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
.ia-toast-undo {
  background: rgba(255,255,255,0.18);
  border: 1px solid rgba(255,255,255,0.3);
  color: #fff;
  border-radius: 6px;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 3px 10px;
  cursor: pointer;
  white-space: nowrap;
}
.ia-toast-undo:hover {
  background: rgba(255,255,255,0.28);
}

/* ── btn-danger (confirmation modals) ────────────────────────────────────── */
.btn-danger {
  background: #c0392b;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 0.55rem 1.1rem;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
}
.btn-danger:hover {
  background: #a93226;
}

/* ── Plans nudge (C7) — same shape as ia-feedback-prompt ─────────────────── */
.ia-plans-nudge {
  background: var(--surface-0, #fff);
  border: 1px solid var(--v3-line);
}

/* ── PDF export button (C10) — admin-only ────────────────────────────────── */
.btn-pdf-export {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.82rem;
}

/* Dark mode overrides for new components */
@media (prefers-color-scheme: dark) {
  .ia-modal-box {
    background: var(--surface-0, #161616);
  }
  .ia-form-input {
    background: var(--surface-1, #222);
  }
  .ia-showcase-overlay {
    background: rgba(22,22,22,0.75);
  }
}
.theme-dark .ia-modal-box    { background: var(--surface-0, #161616); }
.theme-dark .ia-form-input   { background: var(--surface-1, #222); }

/* ── C3-P v0.8: Demo saved preview for unsigned-in visitors ──────────────── */
.saved-demo-preview-label {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--v3-faint);
  margin-bottom: 1rem;
}
.saved-demo-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-bottom: 2rem;
}
.saved-demo-column-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--v3-faint);
  margin-bottom: 0.5rem;
}
.saved-item-demo {
  position: relative;
  cursor: pointer;
  opacity: 0.82;
  transition: opacity 0.15s;
}
.saved-item-demo:hover { opacity: 1; }
.saved-item-demo-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: color-mix(in srgb, var(--surface-1) 60%, transparent);
  border-radius: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--v3-ink);
  opacity: 0;
  transition: opacity 0.18s;
}
.saved-item-demo:hover .saved-item-demo-overlay,
.saved-item-demo:focus .saved-item-demo-overlay {
  opacity: 1;
}
.saved-demo-cta {
  margin-top: 1.5rem;
}
@media (max-width: 768px) {
  .saved-demo-grid {
    grid-template-columns: 1fr;
  }
}

/* ── C4 v0.8: LAUNCH10 promo popup — inherits all from ia-feedback-prompt ── */
.ia-launch10-prompt {
  /* No overrides needed; inherits bottom-left position from .ia-feedback-prompt */
  /* Ensure it stacks below the feedback prompt if both are visible simultaneously */
  bottom: calc(18px + 80px);
}
@media (max-width: 540px) {
  .ia-launch10-prompt {
    bottom: calc(10px + 80px);
  }
}

/* ── C6 v0.8: Per-video Q&A items ─────────────────────────────────────────── */
.video-qa-item .qa-timestamp-link {
  font-size: 0.78rem;
  font-family: var(--font-mono);
  color: var(--v3-gold-2, var(--v3-gold));
  text-decoration: none;
  margin-left: 0.5rem;
  border-bottom: 1px dotted color-mix(in srgb, var(--v3-gold) 40%, transparent);
  white-space: nowrap;
}
.video-qa-item .qa-timestamp-link:hover {
  border-bottom-color: var(--v3-gold-2);
}
.video-qa-slot:empty { display: none; }
@media (max-width: 414px) {
  .video-qa-item .qa-timestamp-link {
    display: block;
    margin-left: 0;
    margin-top: 0.25rem;
  }
}

/* =====================================================================
   DEMO PREVIEW MODE — v0.8 demo fresh-account + C8 coachmarks
   All rules additive; no existing rules removed.
   ===================================================================== */

/* ── Demo mode banner (fixed top bar) ─────────────────────────────────────── */
.ia-demo-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 9000;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 0 1rem;
  background: var(--v3-gold, #c8922a);
  color: #18130a;
  font-size: 0.82rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
html[data-theme="dark"] .ia-demo-banner {
  background: var(--v3-gold, #d19a2e);
  color: #17130b;
}
.ia-demo-banner-text {
  flex: 1 1 auto;
  text-align: right;
}
.ia-demo-banner-exit {
  flex: 0 0 auto;
  text-decoration: none;
  background: rgba(0,0,0,0.12);
  border-radius: 4px;
  padding: 2px 10px;
  color: inherit;
  font-weight: 600;
  transition: background 0.15s;
  white-space: nowrap;
}
.ia-demo-banner-exit:hover {
  background: rgba(0,0,0,0.22);
}

/* Push the sticky header below the demo banner */
:root { --ia-demo-banner-h: 0px; }
.app-header {
  top: var(--ia-demo-banner-h, 0px) !important;
}

/* ── Coachmark overlay (non-blocking) ─────────────────────────────────────── */
.ia-cm-overlay {
  position: fixed;
  inset: 0;
  z-index: 9990;
  pointer-events: none;
  background: rgba(0, 0, 0, 0.08);
}
html[data-theme="dark"] .ia-cm-overlay {
  background: rgba(0, 0, 0, 0.20);
}

/* ── Coachmark tooltip bubble ─────────────────────────────────────────────── */
.ia-coachmark-tooltip {
  position: fixed;
  z-index: 9999;
  width: 320px;
  border-radius: 14px;
  background: var(--v3-surface, #1b2018);
  border: 1px solid var(--v3-line-strong);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.28);
  overflow: visible;
  animation: ia-cm-fadein 0.22s ease;
}
html[data-theme="light"] .ia-coachmark-tooltip {
  background: var(--v3-surface, #fffaf0);
}
@keyframes ia-cm-fadein {
  from { opacity: 0; transform: translateY(6px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0)   scale(1);    }
}

/* Arrow */
.ia-cm-arrow {
  position: absolute;
  width: 0;
  height: 0;
  display: none;
}
.ia-cm-arrow-top {
  top: -8px;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-bottom: 8px solid var(--v3-line-strong);
}
.ia-cm-arrow-top::after {
  content: '';
  position: absolute;
  top: 2px;
  left: -7px;
  border-left: 7px solid transparent;
  border-right: 7px solid transparent;
  border-bottom: 7px solid var(--v3-surface, #1b2018);
}
html[data-theme="light"] .ia-cm-arrow-top::after {
  border-bottom-color: var(--v3-surface, #fffaf0);
}
.ia-cm-arrow-bottom {
  bottom: -8px;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-top: 8px solid var(--v3-line-strong);
}
.ia-cm-arrow-bottom::after {
  content: '';
  position: absolute;
  bottom: 2px;
  left: -7px;
  border-left: 7px solid transparent;
  border-right: 7px solid transparent;
  border-top: 7px solid var(--v3-surface, #1b2018);
}
html[data-theme="light"] .ia-cm-arrow-bottom::after {
  border-top-color: var(--v3-surface, #fffaf0);
}

/* Bubble body */
.ia-cm-body {
  padding: 1.1rem 1.25rem 1rem;
}
.ia-cm-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.6rem;
}
.ia-cm-progress {
  font-size: 0.75rem;
  color: var(--v3-faint);
  font-variant-numeric: tabular-nums;
}
.ia-cm-skip {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.75rem;
  color: var(--v3-faint);
  padding: 0;
  line-height: 1;
  transition: color 0.15s;
}
.ia-cm-skip:hover { color: var(--v3-muted); }
.ia-cm-title {
  display: block;
  font-size: 0.97rem;
  font-weight: 600;
  color: var(--v3-ink);
  margin-bottom: 0.35rem;
  line-height: 1.3;
}
.ia-cm-text {
  font-size: 0.87rem;
  color: var(--v3-muted);
  line-height: 1.55;
  margin: 0 0 0.9rem;
}
.ia-cm-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}
.ia-cm-dots {
  display: flex;
  gap: 5px;
  align-items: center;
}
.ia-cm-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--v3-faint);
  display: inline-block;
  transition: background 0.15s;
}
.ia-cm-dot.active {
  background: var(--v3-gold);
}
.ia-cm-next {
  font-size: 0.82rem !important;
  padding: 0.35rem 1rem !important;
  border-radius: 8px !important;
  min-height: unset !important;
}

/* Mobile adjustments ≤414px */
@media (max-width: 414px) {
  .ia-coachmark-tooltip {
    border-radius: 10px;
  }
  .ia-cm-body {
    padding: 0.9rem 1rem 0.85rem;
  }
  .ia-demo-banner {
    font-size: 0.75rem;
    gap: 0.6rem;
    height: 32px;
  }
  :root { --ia-demo-banner-h: 32px; }
}

/* ── Demo fresh-account empty states ──────────────────────────────────────── */
.ia-demo-fresh-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin: 1.5rem 0;
}
.ia-demo-fresh-card {
  background: var(--surface-1, var(--v3-surface));
  border: 1px solid var(--v3-line);
  border-radius: 16px;
  padding: 1.25rem 1.25rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}
.ia-demo-fresh-icon {
  width: 36px;
  height: 36px;
  color: var(--v3-gold);
  flex-shrink: 0;
}
.ia-demo-fresh-icon svg {
  width: 36px;
  height: 36px;
}
.ia-demo-fresh-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--v3-ink);
  margin: 0;
}
.ia-demo-fresh-empty {
  font-size: 0.85rem;
  color: var(--v3-muted);
  line-height: 1.5;
  flex: 1;
  margin: 0;
}
.ia-demo-fresh-cta {
  align-self: flex-start;
  font-size: 0.82rem !important;
  padding: 0.3rem 0.9rem !important;
  border-radius: 8px !important;
  min-height: unset !important;
}
.ia-demo-fresh-notice {
  font-size: 0.8rem;
  color: var(--v3-faint);
  margin-top: 0.75rem;
  text-align: center;
}
.ia-demo-fresh-notice a {
  color: var(--v3-gold);
  text-decoration: underline;
}
.ia-demo-fresh-empty-state {
  padding: 3rem 0 2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.2rem;
  text-align: center;
}
.ia-demo-fresh-empty-text {
  font-size: 0.95rem;
  color: var(--v3-muted);
  max-width: 40ch;
  line-height: 1.6;
}

@media (max-width: 414px) {
  .ia-demo-fresh-grid {
    grid-template-columns: 1fr;
  }
}

/* ── v0.9 PATCH-05.0: Signup overlay ─────────────────────────────────────── */
.ia-signup-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.50);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9000;
  padding: 1rem;
}

.ia-signup-overlay-card {
  background: var(--v3-bg, #fff);
  border: 1px solid var(--v3-line);
  border-radius: 20px;
  padding: 2.5rem 2rem;
  max-width: 420px;
  width: 100%;
  position: relative;
  box-shadow: 0 32px 80px rgba(0, 0, 0, 0.24);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  text-align: center;
}

.ia-signup-overlay-logo {
  width: 72px;
  height: 72px;
  object-fit: contain;
  border-radius: 12px;
}

.ia-signup-overlay-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0;
  color: var(--v3-text, inherit);
}

.ia-signup-overlay-sub {
  font-size: 0.95rem;
  color: var(--v3-muted);
  margin: 0;
  line-height: 1.5;
}

.ia-signup-overlay-actions {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  width: 100%;
  margin-top: 0.25rem;
}

.ia-signup-overlay-actions .btn {
  width: 100%;
  justify-content: center;
}

.ia-signup-overlay-signin-link {
  font-size: 0.88rem;
  color: var(--v3-muted);
  margin: 0;
}

.ia-signup-overlay-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
}

.ia-link-btn {
  background: none;
  border: none;
  padding: 0;
  color: var(--accent, var(--v3-gold-2));
  cursor: pointer;
  font-size: inherit;
  text-decoration: underline;
}

/* Dark mode for signup overlay */
html[data-theme="dark"] .ia-signup-overlay-card,
.theme-dark .ia-signup-overlay-card {
  background: var(--surface-0, #161616);
  border-color: var(--v3-line);
}

/* ── v0.9 PATCH-05.x: Content lock / gating styles ───────────────────────── */
.ia-lock-tile {
  opacity: 0.6;
  position: relative;
  pointer-events: none;
  cursor: not-allowed;
}
.ia-lock-tile-wrap {
  position: relative;
  cursor: pointer;
}
.ia-lock-tile-wrap .ia-lock-icon {
  /* v0.10 PATCH-04.3: lock icon centered in tile (both axes) */
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--v3-bg, #fff);
  border: 1px solid var(--v3-line);
  border-radius: 999px;
  width: 2rem;
  height: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  z-index: 2;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
html[data-theme="dark"] .ia-lock-tile-wrap .ia-lock-icon,
.theme-dark .ia-lock-tile-wrap .ia-lock-icon {
  background: var(--surface-1, #222);
}

/* Blur wrap for search results gating */
.ia-blur-gate-row {
  position: relative;
  overflow: hidden;
}
.ia-blur-gate-row .ia-blur-gate-content {
  filter: blur(4px);
  user-select: none;
  pointer-events: none;
}
.ia-blur-gate-row .ia-blur-gate-cta {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 1rem;
  gap: 0.5rem;
}
/* v0.10 PATCH-01: centered variant for home search results */
.ia-blur-gate-row .ia-blur-gate-cta--center {
  justify-content: center;
  padding-right: 0;
}
.ia-signup-cta-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  background: var(--accent, var(--v3-gold-2));
  color: #fff;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
  border: none;
}
.ia-signup-cta-badge:hover {
  opacity: 0.9;
}

/* v0.10 PATCH-09: saved demo CTA */
.saved-demo-signup-cta {
  display: flex;
  justify-content: center;
  margin-top: 2rem;
  padding-bottom: 2rem;
}
/* v0.10 PATCH-09.1: center saved landing */
.saved-landing {
  max-width: var(--v3-search-col, 900px);
  margin-inline: auto;
  width: 100%;
}
/* demo card style tweaks — slightly muted to signal non-interactive */
.saved-entry-card--demo {
  cursor: default;
  opacity: 0.75;
  pointer-events: none;
}

/* Plan badge in profile section */
.ia-plan-badge {
  display: inline-block;
  background: color-mix(in srgb, var(--accent, var(--v3-gold-2)) 15%, var(--v3-bg));
  border: 1px solid color-mix(in srgb, var(--accent, var(--v3-gold-2)) 40%, transparent);
  color: var(--accent, var(--v3-gold-2));
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  letter-spacing: 0.03em;
}

/* Profile section rows */
.ia-profile-row {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-bottom: 0.75rem;
}
.ia-profile-label {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--v3-faint);
}
.ia-profile-value {
  font-size: 0.9rem;
  color: var(--v3-muted);
}
.ia-profile-input {
  background: var(--v3-field-bg, var(--surface-1));
  border: 1px solid var(--v3-line);
  border-radius: 8px;
  padding: 0.45rem 0.65rem;
  font-size: 0.9rem;
  color: inherit;
  font-family: inherit;
  width: 100%;
  box-sizing: border-box;
  transition: border-color 160ms ease;
}
.ia-profile-input:focus {
  outline: none;
  border-color: var(--accent, var(--v3-gold-2));
}
html[data-theme="dark"] .ia-profile-input,
.theme-dark .ia-profile-input {
  background: var(--surface-1, #222);
}
.ia-profile-link-btn {
  background: none;
  border: none;
  padding: 0;
  color: var(--accent, var(--v3-gold-2));
  cursor: pointer;
  font-size: 0.88rem;
  text-decoration: underline;
  font-family: inherit;
}

/* Onboarding /plans welcome headline */
.plans-onboarding-welcome {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--v3-muted);
  margin-bottom: 0.5rem;
  text-align: center;
}

/* ── PATCH-05.6: Extension page gate (signed-out) ────────────────── */
/* v0.10 PATCH-11: gate card matches how-it-works row width; lighter bg */
.ia-ext-gate-cta {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  padding: 2.5rem 1.5rem;
  border: 1px solid var(--v3-line);
  border-radius: 12px;
  /* v0.10 PATCH-11.1: much lighter background */
  background: #f8f5ee;
  text-align: center;
  max-width: 100%; /* v0.10 PATCH-11: match how-it-works row width */
  margin: 0 auto;
}
html[data-theme="dark"] .ia-ext-gate-cta,
.theme-dark .ia-ext-gate-cta {
  background: #1e1c19; /* v0.10 PATCH-11.1: softer dark neutral */
}
.ia-ext-gate-label {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--v3-muted);
  margin: 0;
}
.ia-ext-gate-sub {
  font-size: 0.9rem;
  color: var(--v3-muted);
  margin: 0;
  opacity: 0.8;
}
.ia-ext-gate-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 0.25rem;
}

/* =====================================================================
   v0.10 PATCH-15: Mobile responsive CSS
   640px  — core layout collapses, sticky header restored
   414px  — small-phone tightening, tap targets, font-size
   Desktop (>640px) is untouched — all rules below are additive.
   ===================================================================== */

@media (max-width: 640px) {
  /* ── Header: restore sticky (980px query set it to static) ──────── */
  .app-header {
    position: sticky;
    top: 0;
    z-index: 20;
  }

  /* ── Settings toggle: ensure 44×44 tap target ───────────────────── */
  .settings-toggle {
    min-width: 44px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  /* ── Nav links: 44px tap targets, horizontal scroll ─────────────── */
  .app-nav .nav-link {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
  }

  /* ── Hero title: responsive clamp ───────────────────────────────── */
  .home-product-title {
    font-size: clamp(2rem, 12vw, 5rem);
  }

  /* ── Search bar: full width ─────────────────────────────────────── */
  .v3-search,
  .search-header,
  .clean-home .v3-search,
  .home-idle .v3-search,
  .home-has-results .v3-search,
  .home-static .v3-search {
    width: 100%;
    max-width: 100%;
  }

  /* ── Library + models grids: single column ──────────────────────── */
  .lib-grid,
  .lib-grid-compact,
  .lib-grid.lib-grid-topics,
  .lib-page-v038 .lib-grid.lib-grid-topics,
  .model-layout,
  .model-layout.compact-models,
  .model-layout.models-concept-grid {
    grid-template-columns: 1fr;
  }

  /* ── Plans: stack vertically (already done at 640px; guard reenforce) */
  .plans-card-grid {
    grid-template-columns: 1fr;
  }

  /* ── Extension how-it-works: 1 column ──────────────────────────── */
  .ext-b10-steps {
    grid-template-columns: 1fr;
  }

  /* ── Signup modal: 90 vw max ────────────────────────────────────── */
  .ia-modal-box {
    max-width: 90vw;
  }

  /* ── Signup overlay card: 90 vw max ─────────────────────────────── */
  .ia-signup-overlay-card {
    max-width: 90vw;
    padding: 2rem 1.25rem;
  }

  /* ── Saved demo landing: single column ──────────────────────────── */
  .saved-landing .saved-entry-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 414px) {
  /* ── Body: 14px base for small phones ──────────────────────────── */
  body {
    font-size: 14px;
  }

  /* ── Hero: tighter clamp for very small screens ─────────────────── */
  .home-product-title {
    font-size: clamp(1.75rem, 10vw, 3rem);
  }

  /* ── Grids: enforce 1 column ────────────────────────────────────── */
  .lib-grid,
  .lib-grid-compact,
  .lib-grid.lib-grid-topics,
  .model-layout,
  .plans-card-grid,
  .ext-b10-steps,
  .ia-demo-fresh-grid,
  .saved-landing .saved-entry-grid {
    grid-template-columns: 1fr;
  }

  /* ── Tap targets: all interactive elements ≥44×44px ─────────────── */
  .btn,
  .heart-btn,
  .nav-link,
  .settings-toggle,
  .app-nav .nav-link {
    min-height: 44px;
  }

  .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  /* ── Settings popover: ensure it fits narrow viewport ───────────── */
  .settings-popover {
    width: min(90vw, 360px);
    right: 0.5rem;
  }

  /* ── Modal: tighter padding on tiny screens ─────────────────────── */
  .ia-modal-box {
    max-width: 95vw;
    padding: 1.25rem 1rem;
  }

  /* ── Signup overlay: tighter ────────────────────────────────────── */
  .ia-signup-overlay-card {
    max-width: 95vw;
    padding: 1.5rem 1rem;
  }
}

/* ======================================================================
   v0.13 PATCH BLOCK — Applied patches F1, F2, L4/L5/L8 new CSS
   ====================================================================== */

/* ── F1: LAUNCH10 banner dark-mode parity ────────────────────────────── */
/* The ia-feedback-prompt / ia-launch10-prompt inherits light styling.
   When the site switches to dark mode, override background/border/text
   using the same CSS vars used everywhere else in the design system.    */
html[data-theme="dark"] .ia-feedback-prompt,
html[data-theme="dark"] .ia-launch10-prompt {
  background: var(--v3-surface-2);
  border-color: var(--v3-line-strong);
  color: var(--v3-muted);
}
html[data-theme="dark"] .ia-feedback-prompt strong,
html[data-theme="dark"] .ia-launch10-prompt strong {
  color: var(--v3-ink);
}
html[data-theme="dark"] .ia-feedback-prompt .ia-feedback-dismiss,
html[data-theme="dark"] .ia-launch10-prompt .ia-feedback-dismiss {
  border-color: var(--v3-line);
  color: var(--v3-faint);
  background: transparent;
}
html[data-theme="dark"] .ia-feedback-prompt .ia-feedback-dismiss:hover,
html[data-theme="dark"] .ia-launch10-prompt .ia-feedback-dismiss:hover {
  color: var(--v3-ink);
  border-color: var(--v3-line-strong);
}

/* ── F2: Modal isolation — solid backdrop + depth ────────────────────── */
/* Increase backdrop opacity and add blur so page text doesn't bleed
   through. Ensure modal box is solid (not translucent) in both modes.  */
.ia-modal-overlay {
  background: rgba(0, 0, 0, 0.70);          /* was 0.55 → 0.70 */
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.ia-modal-box {
  background: var(--v3-card, #fff);         /* solid surface var */
  position: fixed !important;               /* belt-and-suspenders z guarantee */
  box-shadow: 0 32px 96px rgba(0, 0, 0, 0.45), 0 2px 0 rgba(255,255,255,0.04) inset;
}
html[data-theme="dark"] .ia-modal-overlay {
  background: rgba(0, 0, 0, 0.82);
}
html[data-theme="dark"] .ia-modal-box {
  background: var(--v3-surface-2, #1f251c);
  border: 1px solid var(--v3-line-strong);
  box-shadow: 0 32px 96px rgba(0, 0, 0, 0.65);
}

/* ── Legal pages (L4/L5) ─────────────────────────────────────────────── */
.ia-page-center {
  max-width: var(--v3-search-col, 900px);
  margin-inline: auto;
  padding: clamp(1.5rem, 4vw, 3.5rem) clamp(1rem, 2vw, 2rem);
}
.ia-legal-page {
  color: var(--v3-ink);
}
.ia-legal-page h1 {
  font-size: clamp(1.75rem, 3vw, 2.5rem);
  line-height: 1.08;
  letter-spacing: -0.03em;
  margin: 0 0 1.25rem;
  color: var(--v3-ink);
}
.ia-legal-page h2 {
  font-size: 1.2rem;
  letter-spacing: -0.02em;
  margin: 2rem 0 0.65rem;
  color: var(--v3-ink);
  border-bottom: 1px solid var(--v3-line);
  padding-bottom: 0.4rem;
}
.ia-legal-page h3 {
  font-size: 1rem;
  letter-spacing: -0.015em;
  margin: 1.25rem 0 0.4rem;
  color: var(--v3-ink);
}
.ia-legal-page p {
  line-height: 1.65;
  color: var(--v3-muted);
  margin: 0 0 0.85rem;
}
.ia-legal-page strong {
  color: var(--v3-ink);
  font-weight: 700;
}
.ia-legal-page em {
  font-style: italic;
}
.ia-legal-page a {
  color: var(--v3-gold-2);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.ia-legal-page a:hover {
  color: var(--v3-gold);
}
.ia-legal-page ul,
.ia-legal-page ol {
  padding-left: 1.4rem;
  margin: 0 0 0.85rem;
  color: var(--v3-muted);
  line-height: 1.65;
}
.ia-legal-page li {
  margin-bottom: 0.35rem;
}
.ia-legal-page hr {
  border: none;
  border-top: 1px solid var(--v3-line);
  margin: 1.5rem 0;
}
.ia-legal-page table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  margin: 0 0 1rem;
  color: var(--v3-muted);
}
.ia-legal-page th,
.ia-legal-page td {
  text-align: left;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--v3-line);
}
.ia-legal-page th {
  background: rgba(246, 240, 223, 0.06);
  color: var(--v3-ink);
  font-weight: 700;
}
@media (max-width: 640px) {
  .ia-legal-page table {
    display: block;
    overflow-x: auto;
  }
}
.ia-legal-back {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  margin-bottom: 1.5rem;
  color: var(--v3-gold-2);
  text-decoration: none;
  font-weight: 800;
  font-size: 0.9rem;
}
.ia-legal-back:hover {
  text-decoration: underline;
}
.ia-legal-notice {
  padding: 0.85rem 1rem;
  margin-bottom: 1.75rem;
  border: 1px solid var(--v3-line);
  border-radius: var(--v3-radius-sm);
  background: rgba(246, 240, 223, 0.04);
  color: var(--v3-faint);
  font-size: 0.82rem;
  line-height: 1.5;
}

/* ── L8: Cookie consent banner ───────────────────────────────────────── */
#ia-cookie-banner {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  z-index: 1500;
  max-width: 360px;
  width: calc(100vw - 2.5rem);
  padding: 1rem 1.1rem;
  background: var(--v3-surface);
  border: 1px solid var(--v3-line-strong);
  border-radius: 18px;
  box-shadow: 0 16px 52px rgba(0, 0, 0, 0.22);
  font-size: 0.82rem;
  line-height: 1.5;
  color: var(--v3-muted);
  display: none;                             /* shown by JS */
}
#ia-cookie-banner.visible {
  display: block;
}
html[data-theme="dark"] #ia-cookie-banner {
  background: var(--v3-surface-2);
  border-color: var(--v3-line-strong);
  box-shadow: 0 16px 52px rgba(0, 0, 0, 0.5);
}
#ia-cookie-banner p {
  margin: 0 0 0.75rem;
}
#ia-cookie-banner a {
  color: var(--v3-gold-2);
  text-decoration: underline;
  text-underline-offset: 2px;
}
#ia-cookie-banner a:hover {
  color: var(--v3-gold);
}
.ia-cookie-banner-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.ia-cookie-accept {
  padding: 0.45rem 1rem;
  border: none;
  border-radius: 999px;
  background: var(--v3-gold);
  color: #15130d;
  font-weight: 800;
  font-size: 0.82rem;
  cursor: pointer;
  line-height: 1;
}
.ia-cookie-accept:hover {
  background: var(--v3-gold-2);
}
.ia-cookie-settings {
  padding: 0.45rem 0.85rem;
  border: 1px solid var(--v3-line-strong);
  border-radius: 999px;
  background: transparent;
  color: var(--v3-muted);
  font-weight: 700;
  font-size: 0.82rem;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  line-height: 1;
}
.ia-cookie-settings:hover {
  color: var(--v3-ink);
  border-color: var(--v3-ink);
  text-decoration: none;
}
/* Mobile: ensure cookie banner doesn't overlap with LAUNCH10 on /plans */
@media (max-width: 540px) {
  #ia-cookie-banner {
    right: 0.75rem;
    left: 0.75rem;
    bottom: 0.75rem;
    max-width: none;
    width: auto;
  }
}

/* ── L10: ICT video attribution line ─────────────────────────────────── */
.ia-video-attribution {
  display: block;
  margin-top: 0.5rem;
  font-size: 0.8rem;
  font-style: italic;
  color: var(--v3-faint);
  line-height: 1.4;
}
.ia-video-attribution a {
  color: var(--v3-muted);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.ia-video-attribution a:hover {
  color: var(--v3-gold-2);
}
