/* ============================================================
   marina method — MAR-50 design tokens (shared)
   Verified at 375px and 430px in browser; pending Primo on-device review.

   Intent: all 7 screens import this file for shared tokens.
   baal: import this as the SPA's single token source.
   Do NOT duplicate these in individual screen files.
   ============================================================ */

/* ── Self-hosted IBM Plex fonts ──
   Relative path from web/design/MAR-50/ → ../../assets/fonts/fonts.css
   Relocated from web/prototype/fonts/ in MAR-58 so the SPA build does not
   couple to the prototype directory (which MAR-53 retires). The dist build
   rewrites this @import to a sibling 'fonts/fonts.css' path. */
@import url('fonts/fonts.css');

/* ============================================================
   DESIGN TOKENS — Día theme (light / warm paper) — :root default
   MAR-609 (ADR-025 D3): the four-theme model. Día's values live in :root, so
   an explicit `[data-theme="dia"]` selection and the unstyled default both
   resolve to this paper palette via the base cascade. The concrete dark themes
   override below: `[data-theme="original"]` (purple) and `[data-theme="estudio"]`
   (brass). Hex values transcribed verbatim from docs/design/theme-tokens.md
   (the canonical parity source iOS MAR-608 also transcribes). Día's accent /
   success / regress carry the F2/F3/F4 AA lifts from the token doc.
   ============================================================ */
:root {
  /* Backgrounds */
  --bg-base:           #F7F5F2;
  --bg-surface:        #EFECE8;
  --bg-surface-raised: #E8E4DF;

  /* Text */
  --text-primary:   #1A1714;
  --text-secondary: #5C5449;
  --text-tertiary:  #6B6259;   /* WCAG AA 5.49:1 on --bg-base */

  /* Accent — F2: AA-lifted from #7B5EA7 (was 4.46:1 on surface) to #785AA5
     (4.69:1 on surface, 4.59:1 on accent-subtle) per theme-tokens.md. */
  --accent:        #785AA5;
  --accent-subtle: #EDE8F5;
  --accent-fg:     #FFFFFF;    /* 5.52:1 on the F2-corrected --accent light */

  /* MAR-578 — the prominent-question surface gradient (Estudio restyle). A very
     subtle wash from --accent-subtle into the card surface so the question card
     reads as the protagonist without a flat fill. Composed from existing accent
     tokens — no NEW colour is introduced; the gradient just blends two tokens. */
  --question-surface: linear-gradient(
    160deg,
    var(--accent-subtle) 0%,
    var(--bg-surface) 58%
  );

  /* Button edge shadows — new for MAR-517 tactile button system.
     The 3-tier buttons (components/buttons.css) consume these. Light values. */
  --accent-edge:      #5E4683;   /* 3px relief shadow below .btn-primary */
  --accent-hover:     #876AA6;   /* hover tint for .btn-primary */
  --secondary-fill:   #F4F1F9;   /* background fill for .btn-secondary */
  --secondary-border: #C9B9E0;   /* border for .btn-secondary */
  --secondary-edge:   #D8CDEC;   /* 2px relief shadow below .btn-secondary */

  /* Borders */
  --border: #D4CFC9;

  /* States */
  --success:        #377759;   /* F3: AA-lifted from #3A7D5C per theme-tokens.md */
  --success-subtle: #E8F2EC;
  --regress:        #6F6A65;   /* F4: AA-lifted from #7A7570 per theme-tokens.md */
  --regress-subtle: #EEECEB;

  /* Pipeline/status colours (MAR-76 — promoted from web/design/M4/library.html).
     --processing: in-progress ingest step; --error: hard failure. The library
     view's regressing progress segment uses --regress (above), NOT --error —
     regression is a first-class pedagogical state, not an error. */
  --processing:        #B45309;   /* amber-700 */
  --processing-subtle: #FEF3C7;   /* amber-50 */
  --error:             #DC2626;   /* red-600 */
  --error-subtle:      #FEE2E2;   /* red-50 */

  /* Bloom badge fills — WCAG AA ≥4.5:1 at 11px/600 */
  --bloom-badge-remember-bg:   #C8E8D6;  --bloom-badge-remember-fg:   #2A5C43;
  --bloom-badge-understand-bg: #C1DDE8;  --bloom-badge-understand-fg: #1D4D63;
  --bloom-badge-apply-bg:      #D5D6F0;  --bloom-badge-apply-fg:      #3A3C70;
  --bloom-badge-analyze-bg:    #E0D4F0;  --bloom-badge-analyze-fg:    #5A3D7A;
  --bloom-badge-evaluate-bg:   #F0D9C8;  --bloom-badge-evaluate-fg:   #6B3A18;
  --bloom-badge-create-bg:     #C5DDD7;  --bloom-badge-create-fg:     #2E5549;

  /* Typography */
  --font-serif: 'IBM Plex Serif', Georgia, 'Times New Roman', serif;
  --font-sans:  'IBM Plex Sans', system-ui, -apple-system, sans-serif;
  /* MAR-493 / ADR-018 — monospace family for verbatim code blocks in the Liquid
     reader. System mono fallback chain; no bundled mono font is required. */
  --font-mono:  ui-monospace, 'SF Mono', Menlo, Consolas, 'DejaVu Sans Mono', monospace;

  /* Spacing (4pt base) */
  --sp-1:  4px;  --sp-2:  8px;  --sp-3:  12px;  --sp-4:  16px;
  --sp-5:  20px; --sp-6:  24px; --sp-8:  32px;  --sp-10: 40px;
  --sp-12: 48px; --sp-16: 64px;

  /* Layout */
  --content-max: 640px;

  /* ── NAV TOKENS (new in MAR-50) ──
     baal: these are the canonical nav metrics. Do not hardcode pixel values
     in the SPA — reference these variables everywhere nav sizing appears. */
  --nav-bar-height: 56px;           /* fixed bottom tab bar height (excluding safe-area-inset) */
  --nav-tab-min-height: 44px;       /* WCAG / HIG minimum touch target */
  --nav-top-height: 48px;           /* top bar: wordmark + theme toggle */
  --session-header-height: 52px;    /* Estudio sticky Bloom-Position Map height; the filter bar's sticky top offset depends on it (MAR-180, repurposed MAR-218) */
  --nav-content-top-pad: 56px;      /* main content must clear the top bar */
  --nav-content-bottom-pad: 80px;   /* main content must clear nav-bar + safe area */
  --nav-safe-area-bottom: env(safe-area-inset-bottom, 0px); /* iPhone home indicator */

  /* Radius */
  --radius-sm: 4px; --radius-md: 6px; --radius-lg: 8px;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(26,23,20,0.08);
  --shadow-md: 0 2px 8px rgba(26,23,20,0.10);
  /* ── Nav bar shadow: casts upward to separate tab bar from content ── */
  --shadow-nav: 0 -1px 0 var(--border), 0 -4px 16px rgba(26,23,20,0.06);

  /* Transitions */
  --transition-fast: 150ms ease-out;
  --transition-base: 200ms ease-out;
  --transition-slow: 300ms ease-out;

  /* ── Segment control — App Theme settings (MAR-552, extended MAR-609) ──
     Semantic aliases ONLY: every value points at an existing token, so each
     theme's mapping is inherited from that theme's --accent / --accent-subtle /
     --text-* overrides below. No new hex is introduced. In the dark themes
     (Original, Estudio) --accent-subtle == --secondary-fill (the MAR-545
     collision): the fill change is near-invisible there, so the --accent BORDER
     carries the selection signal — the ✓ glyph reinforces it without relying on
     colour at all. See web/src/components/settings.css. */
  --seg-track-bg:            var(--bg-surface);
  --seg-track-border:        var(--border);
  --seg-tile-inactive-label: var(--text-secondary);
  --seg-tile-active-bg:      var(--accent-subtle);
  --seg-tile-active-border:  var(--accent);
  --seg-tile-active-label:   var(--text-primary);
  --seg-tile-active-glyph:   var(--accent);
}

/* ============================================================
   DESIGN TOKENS — Original theme (dark / purple) — the product DEFAULT
   MAR-609 (ADR-025 D1/D6): restored verbatim from the pre-MAR-605 purple
   palette (git cc3b348~1), AA already verified (token-doc Original column).
   Every existing/new user lands here unless they pick another theme.
   --accent-fg is #F0EDE8 (token-doc / iOS MAR-608 value), the textPrimary
   override the filled accent button uses in practice.
   ============================================================ */
[data-theme="original"] {
  --bg-base:           #141210;
  --bg-surface:        #1C1917;
  --bg-surface-raised: #252220;
  --text-primary:   #F0EDE8;
  --text-secondary: #A39B90;     /* 6.81:1 on --bg-base */
  --text-tertiary:  #9B9087;     /* WCAG AA 5.99:1 on --bg-base */
  --accent:        #9B7EC8;       /* 5.53/5.17/4.68:1 as text on base/surface/raised */
  --accent-subtle: #2A2340;
  --accent-fg:     #F0EDE8;

  /* MAR-578 — prominent-question surface. Same two-token blend; in Original the
     --accent-subtle (#2A2340) reads as a deep violet wash into the card. */
  --question-surface: linear-gradient(
    160deg,
    var(--accent-subtle) 0%,
    var(--bg-surface) 58%
  );

  /* Button edge shadows — MAR-517 tactile button system, Original purple. */
  --accent-edge:      #6E5499;
  --accent-hover:     #A98FD0;
  --secondary-fill:   #2A2340;
  --secondary-border: #3A3458;
  --secondary-edge:   #221C36;

  --border: #2E2B28;
  --success:        #4FA87A;
  --success-subtle: #1A2E23;
  --regress:        #8A8480;
  --regress-subtle: #252220;

  /* Pipeline/status colours — dark (MAR-76, from web/design/M4/library.html). */
  --processing:        #D97706;
  --processing-subtle: #1C1505;
  --error:             #EF4444;
  --error-subtle:      #1F0606;

  /* --bloom-badge-* ramp is theme-invariant (ADR-025 INV-3 / D9): all dark
     themes share ONE dark ramp, never re-coloured to the theme accent. */
  --bloom-badge-remember-bg:   #1E3D2E;  --bloom-badge-remember-fg:   #F0EDE8;
  --bloom-badge-understand-bg: #162F40;  --bloom-badge-understand-fg: #F0EDE8;
  --bloom-badge-apply-bg:      #22244A;  --bloom-badge-apply-fg:      #F0EDE8;
  --bloom-badge-analyze-bg:    #2D1D42;  --bloom-badge-analyze-fg:    #F0EDE8;
  --bloom-badge-evaluate-bg:   #3A1C08;  --bloom-badge-evaluate-fg:   #F0EDE8;
  --bloom-badge-create-bg:     #1C3530;  --bloom-badge-create-fg:     #F0EDE8;

  --shadow-nav: 0 -1px 0 var(--border), 0 -4px 16px rgba(0,0,0,0.25);
}

/* ============================================================
   DESIGN TOKENS — Estudio theme (dark / brass · "Sala de lectura")
   MAR-609: the post-MAR-602/605 brass palette, renamed from the old
   single dark block. Token-for-token identical to iOS MAR-608
   (MarinaPalette.estudio). --regress carries the F5 AA lift (#8A8480 → #938E8A).
   The --bloom-badge-* ramp is the shared dark ramp (INV-3), not re-coloured.
   ============================================================ */
[data-theme="estudio"] {
  --bg-base:           #17120D;  /* espresso screen bg */
  --bg-surface:        #241E18;
  --bg-surface-raised: #2D2620;
  --text-primary:   #F1EADD;     /* cream — 15.55:1 on --bg-base */
  --text-secondary: #ADA294;     /* 7.42:1 on --bg-base */
  --text-tertiary:  #9C9384;     /* WCAG AA on all dark bgs: 4.91 raised / 5.43 surface / 6.13 base */
  --accent:        #D6A65C;      /* brass — 8.39/7.43/6.72:1 as text on base/surface/raised */
  --accent-subtle: #322716;      /* brass wash */
  --accent-fg:     #17120D;      /* 8.39:1 on dark brass accent */

  /* MAR-578 — prominent-question surface. Same two-token blend; in Estudio the
     --accent-subtle (#322716) reads as a warm brass wash into the card. */
  --question-surface: linear-gradient(
    160deg,
    var(--accent-subtle) 0%,
    var(--bg-surface) 58%
  );

  /* Button edge shadows — MAR-517 tactile button system, Estudio brass. */
  --accent-edge:      #A0732F;   /* pressable brass relief */
  --accent-hover:     #E0B978;   /* lighter brass hover tint */
  --secondary-fill:   #322716;
  --secondary-border: #6E5A3A;
  --secondary-edge:   #251B0E;

  --border: #352C23;
  --success:        #84A86C;     /* 6.91:1 on --bg-base */
  --success-subtle: #1F2615;
  --regress:        #938E8A;     /* F5: AA-lifted from #8A8480 per theme-tokens.md */
  --regress-subtle: #252220;

  /* Pipeline/status colours — dark (MAR-76, from web/design/M4/library.html). */
  --processing:        #D97706;
  --processing-subtle: #1C1505;
  --error:             #EF4444;
  --error-subtle:      #1F0606;

  /* --bloom-badge-* ramp is theme-invariant (ADR-025 INV-3 / D9): shared dark ramp. */
  --bloom-badge-remember-bg:   #1E3D2E;  --bloom-badge-remember-fg:   #F0EDE8;
  --bloom-badge-understand-bg: #162F40;  --bloom-badge-understand-fg: #F0EDE8;
  --bloom-badge-apply-bg:      #22244A;  --bloom-badge-apply-fg:      #F0EDE8;
  --bloom-badge-analyze-bg:    #2D1D42;  --bloom-badge-analyze-fg:    #F0EDE8;
  --bloom-badge-evaluate-bg:   #3A1C08;  --bloom-badge-evaluate-fg:   #F0EDE8;
  --bloom-badge-create-bg:     #1C3530;  --bloom-badge-create-fg:     #F0EDE8;

  --shadow-nav: 0 -1px 0 var(--border), 0 -4px 16px rgba(0,0,0,0.25);
}

/* ============================================================
   RESET + BASE
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 16px;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* ── iOS WebKit: suppress grey tap highlight; interactive elements use branded focus/active ── */
a, button, input, textarea, [role="button"] {
  -webkit-tap-highlight-color: transparent;
}

/* ── Remove 300ms tap delay on older iOS WebKit ── */
a, button, [role="button"] {
  touch-action: manipulation;
}

body {
  font-family: var(--font-serif);
  font-size: 16px;
  font-weight: 400;
  line-height: 1.7;
  color: var(--text-primary);
  overflow-x: hidden;
  /* ── Atmospheric background: warm paper with radial depth ── */
  background-color: var(--bg-base);
  background-image:
    radial-gradient(ellipse 70% 60% at 80% -10%, rgba(123,94,167,0.04) 0%, transparent 70%),
    radial-gradient(ellipse 50% 40% at 10% 90%, rgba(58,125,92,0.03) 0%, transparent 60%);
  transition: background-color var(--transition-slow), color var(--transition-slow);
  /* ── 100dvh: tracks visible viewport; avoids iOS URL-bar layout shifts ── */
  min-height: 100vh;
  min-height: 100dvh;
}

/* MAR-609 (ADR-025 D3, F1): re-targeted off the retired `dark` value to fire
   under BOTH dark themes. A theme-invariant dark affordance — the deeper body
   glow reads correctly on Original (violet) and Estudio (brass) alike. */
:is([data-theme="original"], [data-theme="estudio"]) body {
  background-image:
    radial-gradient(ellipse 70% 60% at 80% -10%, rgba(155,126,200,0.06) 0%, transparent 70%),
    radial-gradient(ellipse 50% 40% at 10% 90%, rgba(79,168,122,0.04) 0%, transparent 60%);
}

/* ============================================================
   TOP BAR (persistent chrome — appears on every app screen)

   Intent: wordmark for orientation + theme toggle.
   Height: 48px. NOT a navigation element — zero interactive nav here.
   Position: fixed top. Content scrolls beneath it.
   baal: this is the <header role="banner"> in the SPA shell.
   ============================================================ */
.top-bar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--nav-top-height);
  /* ── Safe area: notch protection on iPhone with Dynamic Island / Face ID ── */
  padding-top: env(safe-area-inset-top, 0px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-left: var(--sp-5);
  padding-right: var(--sp-4);
  background-color: var(--bg-base);
  border-bottom: 1px solid var(--border);
  /* ── Slightly higher than content for visual separation ── */
  background-image: linear-gradient(180deg, var(--bg-surface) 0%, var(--bg-base) 100%);
  z-index: 100;
}

.top-bar-wordmark {
  font-family: var(--font-serif);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text-primary);
}

.top-bar-wordmark span { color: var(--accent); }

/* ── Settings entry in top bar: compact icon-only ⚙ button (MAR-552).
   Replaces the old binary theme toggle (◑/☀); the theme choice now lives on
   #/ajustes. Same compact 36px icon footprint as the logout button beside it
   so the top-bar actions group stays visually balanced. ── */
.top-bar-settings-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 16px;
  transition: background-color var(--transition-fast), color var(--transition-fast);
}

/* ── hover-fix: wrapped in (hover: hover) — iPhone Safari skips this block ── */
@media (hover: hover) {
  .top-bar-settings-btn:hover {
    background-color: var(--bg-surface-raised);
    color: var(--text-primary);
  }
}

/* ============================================================
   BOTTOM TAB BAR (persistent nav — the fix for MAR-30 failure)

   Pattern chosen: bottom tab bar, 4 tabs, position:fixed.

   Rationale vs. alternatives:
   A. Top sticky header with back button — requires thumb stretch to top
      80px. At 375px width single-handed, that means hand reposition.
      Acceptable for a back gesture, expensive for repeated section switching.
   B. Hamburger / slide-out drawer — Primo explicitly rejected (MAR-30 failure
      notes). Adds an extra tap layer on every navigation action. Hides
      nav affordance entirely — violates "persistent back affordance" AC.
   C. Bottom tab bar (chosen) — thumb sits naturally in the bottom 20% of the
      screen. At 375x667 (iPhone SE), the bottom 134px is thumb-reachable
      without reposition. Four tabs map 1:1 to the four screens (Inicio, Estudio,
      Mapa, Regreso). No extra tap. Nav is always visible. No hamburger.

   baal: this element is <nav aria-label="Navegación principal"> in the SPA.
   The active tab is driven by router state, not by .active class toggling.
   ============================================================ */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  /* ── Safe area padding for home indicator on notchless and notched iPhones ── */
  padding-bottom: var(--nav-safe-area-bottom);
  height: calc(var(--nav-bar-height) + var(--nav-safe-area-bottom));
  display: flex;
  align-items: stretch;
  background-color: var(--bg-surface);
  /* ── Shadow casts upward — distinguishes nav bar from scrolled content ── */
  box-shadow: var(--shadow-nav);
  z-index: 100;
}

/* ── Each tab is a flex column: icon + label ──
   Touch target: 44px minimum achieved by full bar height (56px) and
   flex:1 width ensuring each third of 375px = 125px, well above 44px. */
.nav-tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  text-decoration: none;
  color: var(--text-tertiary);
  font-family: var(--font-sans);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.02em;
  padding: var(--sp-2) 0;
  /* ── Minimum touch target: 44px × full-width column ── */
  min-height: var(--nav-tab-min-height);
  transition: color var(--transition-fast);
  /* ── Prevent text selection on repeated taps ── */
  user-select: none;
  -webkit-user-select: none;
  position: relative;
}

/* ── Active tab indicator: top border line instead of filled background.
   Rationale: filled background would read as "selected pill" — a game-
   like affordance. A subtle top line reads as "current location" —
   navigational state, not achievement. Marina design §1.3: no game chrome. ── */
.nav-tab.active {
  color: var(--accent);
}

.nav-tab.active::before {
  content: '';
  position: absolute;
  top: 0; left: 20%; right: 20%;
  height: 2px;
  background-color: var(--accent);
  border-radius: 0 0 2px 2px;
}

/* ── Nav tab icons: inline SVG, 20px, aria-hidden ── */
.nav-tab-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

/* ── hover-fix applied to nav tabs ── */
@media (hover: hover) {
  .nav-tab:hover:not(.active) {
    color: var(--text-secondary);
  }
}

/* ============================================================
   MAIN CONTENT SCROLL AREA

   Must clear both top bar (48px) and bottom nav (56px + safe area).
   baal: the SPA <main> element gets these padding values.
   ============================================================ */
.page-main {
  padding-top: var(--nav-content-top-pad);
  padding-bottom: var(--nav-content-bottom-pad);
  min-height: 100dvh;
  min-height: 100vh;
}

.content-area {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: var(--sp-6) var(--sp-5);
}

/* ============================================================
   PAGE HEADER
   ============================================================ */
.page-header {
  margin-bottom: var(--sp-8);
  padding-bottom: var(--sp-5);
  border-bottom: 1px solid var(--border);
}

.chapter-label {
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  display: block;
  margin-bottom: var(--sp-2);
}

.page-header h1 {
  font-family: var(--font-serif);
  font-size: 26px;
  font-weight: 600;
  line-height: 1.2;
  color: var(--text-primary);
  margin-bottom: var(--sp-2);
}

.page-subtitle {
  font-family: var(--font-sans);
  font-size: 13px;
  color: var(--text-tertiary);
  line-height: 1.5;
}

/* ============================================================
   BLOOM BADGE
   ============================================================ */
.bloom-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 3px;
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  line-height: 1;
}

.bloom-badge.remember   { background: var(--bloom-badge-remember-bg);   color: var(--bloom-badge-remember-fg); }
.bloom-badge.understand { background: var(--bloom-badge-understand-bg); color: var(--bloom-badge-understand-fg); }
.bloom-badge.apply      { background: var(--bloom-badge-apply-bg);      color: var(--bloom-badge-apply-fg); }
.bloom-badge.analyze    { background: var(--bloom-badge-analyze-bg);    color: var(--bloom-badge-analyze-fg); }
.bloom-badge.evaluate   { background: var(--bloom-badge-evaluate-bg);   color: var(--bloom-badge-evaluate-fg); }
.bloom-badge.create     { background: var(--bloom-badge-create-bg);     color: var(--bloom-badge-create-fg); }

/* ============================================================
   BUTTONS — extracted in MAR-517
   The 3-tier tactile button system (.btn-primary / .btn-secondary /
   .btn-tertiary / .btn-full) moved out of this token file into
   web/src/components/buttons.css, imported by main.css after tokens.
   Tokens remain the colour source of truth (see --accent-edge etc. above);
   the button RULES live with the other component CSS. Do not re-add button
   rules here.
   ============================================================ */

/* ============================================================
   LO BLOCK (study card)
   ============================================================ */
.lo-block {
  background-color: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--sp-5);
  margin-bottom: var(--sp-6);
}

.lo-block-header {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  margin-bottom: var(--sp-3);
  flex-wrap: wrap;
}

.lo-block-title {
  font-family: var(--font-serif);
  font-size: 15px;        /* MAR-166: was 18px — smaller for mobile readability */
  font-weight: 500;
  line-height: 1.5;       /* MAR-166: was 1.35 */
  color: var(--text-primary);
  flex: 1;
  min-width: 0;           /* MAR-166: was 200px — let title compress now the badge is gone (MAR-167) */
}

/* MAR-293 — the LO objective is retrospective goal-framing, revealed only
   AFTER the card is answered (the MAR-174 data-answered signal). Hidden by
   default so citation/locate questions never have the answer printed beneath
   them. Reframed copy ("Qué buscaba esta pregunta") + a labelled lead-in;
   visual weight stays subtle (Marina coupled-reward posture). */
.lo-block-objective {
  display: none;
  font-family: var(--font-sans);
  font-size: 12px;
  color: var(--text-tertiary);
  margin-top: var(--sp-4);
  margin-bottom: var(--sp-4);
  line-height: 1.5;
}
.lo-block[data-answered="true"] .lo-block-objective {
  display: block;
}
.lo-block-objective-label {
  font-weight: 600;
  color: var(--text-secondary);
}

/* MAR-293 — .lo-block-divider removed: it separated the old pre-answer
   objective subtitle from the verb-hint, and both that subtitle's position and
   the divider are gone now the objective is post-answer goal-framing. */

/* ============================================================
   QUESTION + ATTEMPT AREA
   ============================================================ */
.question-label {
  font-family: var(--font-sans);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  margin-bottom: var(--sp-3);
  display: block;
}

.question-text {
  font-family: var(--font-serif);
  font-size: 17px;
  font-weight: 400;
  line-height: 1.65;
  color: var(--text-primary);
  margin-bottom: var(--sp-5);
}

.attempt-label {
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
  margin-bottom: var(--sp-2);
  display: block;
}

/* ── Textarea: large enough for a few sentences at 375px ── */
.attempt-textarea {
  width: 100%;
  min-height: 128px;
  padding: var(--sp-4);
  background-color: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-family: var(--font-serif);
  font-size: 16px;
  font-weight: 400;
  line-height: 1.65;
  color: var(--text-primary);
  resize: vertical;
  outline: none;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  /* ── Prevent iOS font-size auto-zoom: minimum 16px required ── */
  -webkit-text-size-adjust: 100%;
}

.attempt-textarea::placeholder { color: var(--text-tertiary); }

.attempt-textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(123,94,167,0.12);
}

/* MAR-609 (ADR-025 D3): re-targeted off `dark` to both dark themes — the
   focus ring needs the brighter dark-theme alpha under Original and Estudio. */
:is([data-theme="original"], [data-theme="estudio"]) .attempt-textarea:focus {
  box-shadow: 0 0 0 3px rgba(155,126,200,0.15);
}

/* ============================================================
   REVEAL LAYERS (details/summary)
   ============================================================ */
details.reveal-layer {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin-top: var(--sp-4);
  overflow: hidden;
  transition: border-color var(--transition-fast);
}

details.reveal-layer.available { border-color: var(--accent); }

details.reveal-layer summary {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-4);
  cursor: pointer;
  list-style: none;
  background-color: var(--bg-surface-raised);
  user-select: none;
  /* ── Touch target: 52px — above 44px minimum ── */
  min-height: 52px;
  transition: background-color var(--transition-fast);
}

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

@media (hover: hover) {
  details.reveal-layer summary:hover { background-color: var(--bg-surface); }
}

details.reveal-layer.available summary { background-color: var(--accent-subtle); }

.summary-arrow {
  font-size: 11px;
  color: var(--text-tertiary);
  transition: transform var(--transition-base);
  flex-shrink: 0;
}

details[open] .summary-arrow { transform: rotate(90deg); }

.summary-text {
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  flex: 1;
}

details.reveal-layer.available .summary-text { color: var(--accent); }

.reveal-body {
  padding: var(--sp-5) var(--sp-4);
  border-top: 1px solid var(--border);
}

.reveal-body p {
  font-family: var(--font-serif);
  font-size: 16px;
  line-height: 1.7;
  color: var(--text-primary);
  margin-bottom: var(--sp-4);
}

.reveal-body p:last-child { margin-bottom: 0; }

.reveal-body ul {
  margin: var(--sp-3) 0 var(--sp-4) var(--sp-5);
}

.reveal-body li {
  font-family: var(--font-serif);
  font-size: 15px;
  line-height: 1.6;
  color: var(--text-primary);
  margin-bottom: var(--sp-2);
}

/* ── Verified citation block ── */
.verified-citation {
  border-left: 3px solid var(--accent-subtle);
  padding: var(--sp-3) var(--sp-4);
  margin: var(--sp-4) 0;
  background-color: var(--accent-subtle);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

/* MAR-609 (ADR-025 D3): re-targeted off `dark` to both dark themes — under a
   dark theme the citation's left rule uses the full --accent (not the subtle
   wash) for legible separation. */
:is([data-theme="original"], [data-theme="estudio"]) .verified-citation {
  border-left-color: var(--accent);
}

.verified-citation p {
  font-family: var(--font-serif);
  font-size: 15px;
  font-style: italic;
  line-height: 1.6;
  color: var(--text-primary);
  margin: 0;
}

.cita-label {
  font-family: var(--font-sans);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  display: block;
  margin-bottom: var(--sp-2);
}

/* ── Comprensión checklist ── */
.comprension-label {
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  margin: var(--sp-5) 0 var(--sp-3);
  display: block;
}

.comprension-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.comprension-list li {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-2);
  font-family: var(--font-serif);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-secondary);
  margin: 0;
}

.comprension-list li::before {
  content: '◦';
  color: var(--text-tertiary);
  flex-shrink: 0;
  margin-top: 2px;
}

/* ============================================================
   MASTERY ROW (self-report checkbox)

   Intent: student claims mastery after working through both reveal layers.
   Disabled state: before both layers are opened.
   The checkbox is purely self-report — it does not write to the server;
   MAR-34 POST /api/los/{id}/mastery is the server write path.
   baal: wire the onchange event to the MAR-34 endpoint in the SPA.
   ============================================================ */
.mastery-row {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  margin-top: var(--sp-6);
  padding: var(--sp-4) 0;
  border-top: 1px solid var(--border);
}

/* ── Checkbox: custom appearance for cross-browser consistency ── */
.mastery-checkbox {
  width: 22px;
  height: 22px;
  border: 2px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-color: var(--bg-base);
  flex-shrink: 0;
  transition: border-color var(--transition-fast), background-color var(--transition-fast);
  position: relative;
}

@media (hover: hover) {
  .mastery-checkbox:enabled:hover { border-color: var(--success); }
}

.mastery-checkbox:checked {
  background-color: var(--success);
  border-color: var(--success);
}

.mastery-checkbox:checked::after {
  content: '';
  position: absolute;
  top: 3px; left: 7px;
  width: 5px; height: 9px;
  border: 2px solid #fff;
  border-top: none;
  border-left: none;
  transform: rotate(45deg);
}

.mastery-checkbox:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.mastery-label-text {
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 400;
  color: var(--text-secondary);
  line-height: 1.4;
}

.mastery-label-text.checked { color: var(--success); }

.mastery-note {
  font-family: var(--font-sans);
  font-size: 12px;
  color: var(--text-tertiary);
  margin-top: var(--sp-2);
  margin-left: calc(22px + var(--sp-3));
  line-height: 1.5;
}

/* ============================================================
   PROGRESS MAP SCREEN
   ============================================================ */
.progress-summary {
  display: flex;
  gap: var(--sp-5);
  margin-bottom: var(--sp-6);
  padding: var(--sp-4) var(--sp-5);
  background-color: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  flex-wrap: wrap;
}

.progress-stat { display: flex; flex-direction: column; gap: var(--sp-1); }

.stat-value {
  font-family: var(--font-serif);
  font-size: 28px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1;
}

.stat-label {
  font-family: var(--font-sans);
  font-size: 12px;
  color: var(--text-tertiary);
}

/* State legend */
.state-legend {
  display: flex;
  gap: var(--sp-4);
  margin-bottom: var(--sp-6);
  flex-wrap: wrap;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-family: var(--font-sans);
  font-size: 12px;
  color: var(--text-secondary);
}

.legend-glyph { font-size: 14px; }

/* Bloom section groupings */
.bloom-section { margin-bottom: var(--sp-8); }

.bloom-section-header {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  margin-bottom: var(--sp-4);
  padding-bottom: var(--sp-3);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.bloom-section-title {
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}

.bloom-section-count {
  font-family: var(--font-sans);
  font-size: 12px;
  color: var(--text-tertiary);
  margin-left: auto;
}

/* LO row in progress map */
.lo-map-row {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-4);
  padding: var(--sp-4);
  border-radius: var(--radius-md);
  margin-bottom: 4px;
  text-decoration: none;
  transition: background-color var(--transition-fast);
  /* ── Touch target: min-height 56px, comfortably above 44px ── */
  min-height: 56px;
  border: 1px solid transparent;
}

@media (hover: hover) {
  .lo-map-row:hover {
    background-color: var(--bg-surface);
    border-color: var(--border);
  }
}

.lo-map-row.mastered   { background-color: var(--success-subtle); border-color: rgba(58,125,92,0.15); }
.lo-map-row.in-progress { background-color: var(--accent-subtle); border-color: rgba(123,94,167,0.15); }
.lo-map-row.regressing  { background-color: var(--regress-subtle); border-color: rgba(122,117,112,0.15); }

.lo-map-glyph {
  font-size: 16px;
  line-height: 1;
  margin-top: 2px;
  flex-shrink: 0;
  width: 20px;
  text-align: center;
}

.lo-map-glyph.not-started { color: var(--text-tertiary); }
.lo-map-glyph.in-progress { color: var(--accent); }
.lo-map-glyph.mastered    { color: var(--success); }
.lo-map-glyph.regressing  { color: var(--regress); }

.lo-map-content { flex: 1; }

.lo-map-title {
  font-family: var(--font-serif);
  font-size: 15px;
  font-weight: 500;
  line-height: 1.4;
  color: var(--text-primary);
  margin-bottom: var(--sp-1);
}

.lo-map-meta {
  font-family: var(--font-sans);
  font-size: 12px;
  color: var(--text-tertiary);
}

/* ── State label badge: hidden on phone to reduce crowding.
   Glyph + row tint communicate state; badge is redundant below 430px. ── */
.lo-map-state-label {
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 3px;
  white-space: nowrap;
  align-self: flex-start;
  margin-top: 2px;
}

.lo-map-state-label.mastered   { background: var(--success-subtle); color: var(--success); }
.lo-map-state-label.in-progress { background: var(--accent-subtle); color: var(--accent); }
.lo-map-state-label.regressing  { background: var(--regress-subtle); color: var(--regress); border: 1px solid var(--border); }

@media (max-width: 430px) {
  /* ── Hide state label badge at phone widths — glyph + tint are sufficient ── */
  .lo-map-state-label { display: none; }
  .lo-map-row { padding: var(--sp-3); }
  .bloom-section-count { margin-left: 0; flex-basis: 100%; }
  .bloom-section-header { flex-wrap: wrap; gap: var(--sp-2); }
}

/* ============================================================
   RETURN SCREEN
   ============================================================ */
/* superseded by MAR-521 repaso-anchor — retained for test compatibility until
   MAR-521 follow-up cleanup; regreso.js no longer emits these elements. */
.return-greeting {
  font-family: var(--font-serif);
  font-size: 26px;
  font-weight: 600;
  line-height: 1.2;
  color: var(--text-primary);
  margin-bottom: var(--sp-3);
}

.return-bio-fact {
  font-family: var(--font-serif);
  font-size: 16px;
  font-weight: 400;
  line-height: 1.65;
  color: var(--text-secondary);
  margin-bottom: var(--sp-8);
}

.return-bio-fact em {
  font-style: normal;
  color: var(--text-primary);
}

.section-heading {
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  margin-bottom: var(--sp-4);
  display: block;
}

.due-lo-card {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-4);
  padding: var(--sp-4) var(--sp-4);
  background-color: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin-bottom: var(--sp-3);
  text-decoration: none;
  transition: background-color var(--transition-fast), border-color var(--transition-fast);
  /* ── Touch target: min-height 56px ── */
  min-height: 56px;
}

@media (hover: hover) {
  .due-lo-card:hover {
    background-color: var(--bg-surface-raised);
    border-color: var(--accent);
  }
}

.due-lo-card.regressing {
  border-color: var(--regress);
  background-color: var(--regress-subtle);
}

.due-glyph {
  font-size: 18px;
  line-height: 1;
  margin-top: 2px;
  flex-shrink: 0;
}

.due-glyph.in-progress { color: var(--accent); }
.due-glyph.regressing  { color: var(--regress); }

.due-lo-title {
  font-family: var(--font-serif);
  font-size: 15px;
  font-weight: 500;
  line-height: 1.4;
  color: var(--text-primary);
  margin-bottom: var(--sp-2);
}

.due-lo-meta {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  flex-wrap: wrap;
}

.due-status {
  font-family: var(--font-sans);
  font-size: 11px;
  color: var(--text-tertiary);
}

.due-status.recalibrating { color: var(--regress); }

/* ============================================================
   EVAL FEEDBACK DISPLAY

   Intent: slot for the server's verdict on a submitted attempt.
   baal: the .eval-verdict-slot div is where MAR-36 injects its response.
   The verdict type class (.eval-correct / .eval-partial / .eval-needs-work)
   is added by JS after the response arrives.
   ============================================================ */
.eval-verdict-slot {
  margin-top: var(--sp-5);
  padding: var(--sp-5);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background-color: var(--bg-surface);
  /* ── Loading state: pulse animation shows server is thinking ── */
  transition: border-color var(--transition-base), background-color var(--transition-base);
}

/* intentional: minimal pulse, no spinner. Marina coupled-reward
   posture (reward couples to understanding, not to a theatrical wait).
   Revisit if >3s eval latency causes student confusion. */
.eval-verdict-slot.loading {
  animation: eval-pulse 1.4s ease-in-out infinite;
}

@keyframes eval-pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.6; }
}

.eval-verdict-slot.eval-correct {
  border-color: var(--success);
  background-color: var(--success-subtle);
}

.eval-verdict-slot.eval-partial {
  border-color: var(--accent);
  background-color: var(--accent-subtle);
}

.eval-verdict-slot.eval-needs-work {
  border-color: var(--regress);
  background-color: var(--regress-subtle);
}

.eval-verdict-label {
  font-family: var(--font-sans);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: var(--sp-3);
  display: block;
}

.eval-correct   .eval-verdict-label { color: var(--success); }
.eval-partial   .eval-verdict-label { color: var(--accent); }
.eval-needs-work .eval-verdict-label { color: var(--regress); }

.eval-verdict-text {
  font-family: var(--font-serif);
  font-size: 16px;
  line-height: 1.65;
  color: var(--text-primary);
}

/* ── Loading placeholder text ── */
.eval-loading-text {
  font-family: var(--font-sans);
  font-size: 13px;
  color: var(--text-tertiary);
}

/* ============================================================
   UTILITY
   ============================================================ */
.hidden { display: none !important; }
.text-tertiary  { color: var(--text-tertiary); }
.text-secondary { color: var(--text-secondary); }
.text-accent    { color: var(--accent); }
.text-success   { color: var(--success); }
.text-regress   { color: var(--regress); }

/* ============================================================
   REDUCED MOTION
   All animations suppressed. Transitions reduced to 1ms.
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
