/* =============================================
   p-book v3: Mobile-first adaptive UX
   ============================================= */
:root {
  --bg: #F8F8F5;
  --surface: #FFFFFF;
  --surface-raised: #FFFFFF;
  --text: #1C1917;
  --text-2: #57534E;
  --text-3: #736D68; /* was #A8A29E (2.4:1) — now ≥4.5:1 on --bg and --surface */
  --border: #E7E5E4;
  --border-light: #F5F5F4;
  --accent: #7C3AED;
  --accent-hover: #6D28D9;
  --accent-bg: #EDE9FE;
  --engineer: #2563EB;
  --engineer-bg: #EFF6FF;
  --product: #059669;
  --product-bg: #ECFDF5;
  --business: #D97706;
  --business-bg: #FFFBEB;
  --sidebar-color: #7C3AED;
  --sidebar-bg: #F5F3FF;
  --font-body: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-ui: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-mono: 'SF Mono', Consolas, monospace;
  --content-w: 680px;
  --topbar-h: 52px;
  --bottomnav-h: 56px;
  --fs: 1.1rem;
  --lh: 1.8;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 30px rgba(0,0,0,0.12);
  --transition: 0.2s ease;
  /* Highlight & note colors */
  --hl-bg: #fef08a;
  --hl-bg-hover: #fde047;
  --hl-flash: #fb923c;
  --snote-user-bg: #FEF3C7;
  --snote-user-border: #F59E0B;
  --snote-ai-bg: #FFF7ED;
  --snote-ai-border: #FDBA74;
  --note-bg: #FFFBEB;
  --note-border: #FDE68A;
  --warn: #F59E0B;
  --warn-bg: #FEF3C7;
  --warn-text: #92400E;
  /* --card was referenced as var(--card,#fff) all over the UI but never defined,
     so every such panel stayed a white slab in the dark theme */
  --card: var(--surface);
}
[data-theme="dark"] {
  --bg: #171412; --surface: #231F1C; --surface-raised: #2C2724;
  --text: #F5F5F4; --text-2: #C4BEB9; --text-3: #9C958F;
  --border: #3D3632; --border-light: #2C2724;
  --accent: #9061F9; --accent-hover: #7C3AED; --accent-bg: #2D2060;
  --engineer-bg: #1A2744; --product-bg: #0A3D2E; --business-bg: #3D2600; --sidebar-bg: #261450;
  --shadow: 0 1px 3px rgba(0,0,0,0.3); --shadow-lg: 0 8px 30px rgba(0,0,0,0.4);
  --hl-bg: #854d0e; --hl-bg-hover: #a16207; --hl-flash: #c2410c;
  --snote-user-bg: #3D2600; --snote-user-border: #a16207;
  --snote-ai-bg: #2D1F0A; --snote-ai-border: #92400E;
  --note-bg: #2D2200; --note-border: #5C4A00;
  --warn: #D97706; --warn-bg: #3D2600; --warn-text: #FDE68A;
}
[data-theme="sepia"] {
  --bg: #F5EFE4; --surface: #FAF5EC; --surface-raised: #FFF9F0;
  --text: #3D2E1C; --text-2: #8B7355; --border: #D4C8B0;
}
/* Cosmetic themes (unlocked by level) */
[data-cosmetic="ocean"] { --accent: #0EA5E9; --accent-hover: #0284C7; --accent-bg: #E0F2FE; }
[data-cosmetic="sunset"] { --accent: #F97316; --accent-hover: #EA580C; --accent-bg: #FFF7ED; }
[data-cosmetic="forest"] { --accent: #16A34A; --accent-hover: #15803D; --accent-bg: #F0FDF4; }
[data-cosmetic="galaxy"] { --accent: #8B5CF6; --accent-hover: #7C3AED; --accent-bg: #2D2060; --bg: #0F0B1A; --surface: #1A1528; --surface-raised: #221D30; --text: #E8E0F0; --text-2: #A09CB0; --text-3: #6B6580; --border: #2D2840; --border-light: #221D30; --hl-bg: #854d0e; --hl-bg-hover: #a16207; --hl-flash: #c2410c; --snote-user-bg: #2D2200; --snote-user-border: #a16207; --snote-ai-bg: #1F1A0A; --snote-ai-border: #92400E; --note-bg: #2D2200; --note-border: #5C4A00; --warn-bg: #2D2200; --warn-text: #FDE68A; }
[data-cosmetic="neon"] { --accent: #EC4899; --accent-hover: #DB2777; --accent-bg: #FDF2F8; }
[data-cosmetic="gold"] { --accent: #D97706; --accent-hover: #B45309; --accent-bg: #FFFBEB; }

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
/* overflow-x: clip — body's overflow-x:hidden does not stop the ROOT from widening
   (KaTeX in a table made the whole phone page 484 px wide) */
html { font-size: 16px; -webkit-font-smoothing: antialiased; scroll-behavior: smooth; overflow-x: clip; }
body { font-family: var(--font-body); color: var(--text); background: var(--bg); line-height: var(--lh); overflow-x: hidden; }
button { font-family: var(--font-ui); cursor: pointer; border: none; background: none; color: inherit; }

/* Buttons */
.btn-primary { background: var(--accent); color: #fff; font-weight: 600; padding: .7em 2em; border-radius: var(--radius-sm); font-size: 1rem; transition: background var(--transition); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-large { padding: .9em 2.5em; font-size: 1.1rem; border-radius: var(--radius); }
.btn-ghost { color: var(--text-2); font-size: .9rem; padding: .5em 1em; }
.btn-ghost:hover { color: var(--accent); }

/* =============================================
   ONBOARDING
   ============================================= */
.overlay { position: fixed; inset: 0; background: var(--bg); z-index: 900; display: flex; align-items: flex-start; justify-content: center; overflow-y: auto; scrollbar-width: none; padding: 2em 1em; transition: opacity .4s; }
.overlay::-webkit-scrollbar { display: none; }
.overlay.hidden { opacity: 0; pointer-events: none; }
.onboarding-card { max-width: 480px; width: 90%; text-align: center; }
.onboarding-card h1 { font-family: var(--font-ui); font-size: 2rem; font-weight: 800; letter-spacing: -.03em; margin-bottom: .15em; }
.onboarding-card h2 { font-family: var(--font-ui); font-size: 1.3rem; font-weight: 600; margin-bottom: 1.2em; }
.onboarding-card .author { font-family: var(--font-ui); font-size: .8rem; color: var(--text-3); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 1.5em; }
.onboarding-card .subtitle { font-size: 1.05rem; color: var(--text-2); margin-bottom: 2em; }
.step { display: none; } .step.active { display: block; animation: fadeUp .3s ease; }

/* Intro layout */
.intro-subtitle { font-size: .92rem; color: var(--text-2); margin-bottom: 1.2em; }
.intro-features { display: grid; grid-template-columns: 1fr; gap: .35em; margin-bottom: 1.2em; text-align: left; }
.intro-feature { display: flex; gap: .5em; align-items: flex-start; font-size: .78rem; line-height: 1.4; padding: .45em .6em; background: var(--surface-raised); border-radius: var(--radius-sm); }
.intro-feature span:first-child { font-size: 1.1rem; flex-shrink: 0; }

/* Collapsible details sections */
.intro-details { text-align: left; margin-top: .6em; }
.intro-details summary { font-family: var(--font-ui); font-size: .78rem; font-weight: 600; color: var(--accent); cursor: pointer; padding: .4em .7em; list-style: none; border: 1px solid var(--border); border-radius: var(--radius-sm); transition: all .15s; text-align: center; }
.intro-details summary:hover { border-color: var(--accent); background: var(--accent-bg); }
.intro-details summary::-webkit-details-marker { display: none; }
.intro-details summary::after { content: ' \25BE'; font-size: .7rem; }
.intro-details[open] summary { border-color: var(--accent); background: var(--accent-bg); }
.intro-details[open] summary::after { content: ' \25B4'; }
.intro-details[open] { animation: fadeUp .2s ease; }

.intro-testimonials { display: flex; flex-direction: column; gap: .4em; margin-top: .4em; }
.intro-testimonial { padding: .5em .7em; background: var(--surface-raised); border-radius: var(--radius-sm); border: 1px solid var(--border-light); }
.intro-testimonial p { font-size: .78rem; line-height: 1.4; color: var(--text); font-style: italic; margin-bottom: .15em; }
.testimonial-author { font-family: var(--font-ui); font-size: .7rem; color: var(--text-3); font-style: normal; }

.intro-author-bio { margin-top: .4em; font-size: .8rem; line-height: 1.5; color: var(--text-2); text-align: left; }
.intro-author-bio p { margin-bottom: .5em; }
.intro-author-bio em { color: var(--text); }
.intro-section-title { font-family: var(--font-ui); font-size: .8rem; font-weight: 700; color: var(--text-2); margin: .8em 0 .4em; text-align: left; }

/* Title & tagline */
.intro-title { font-size: 1.8rem; letter-spacing: -.03em; margin-bottom: .2em; }
.intro-tagline { font-family: var(--font-ui); font-size: .88rem; font-weight: 400; color: var(--accent); margin-bottom: .6em; }

/* Hero image */
.intro-hero { width: 100%; max-width: 380px; margin: .3em auto .8em; display: block; border-radius: var(--radius); }

/* Author visible */
.intro-author-visible { text-align: center; margin-bottom: .8em; }
.intro-author-name { font-size: 1.1rem; font-weight: 800; margin-bottom: .1em; }
.intro-author-name a { color: var(--text); text-decoration: none; }
.intro-author-name a:hover { color: var(--accent); }
.intro-author-role { font-family: var(--font-ui); font-size: .72rem; color: var(--text-3); margin-bottom: .4em; }
.intro-author-role a { color: var(--text-2); }
.intro-author-text { font-size: .72rem; color: var(--text-3); line-height: 1.45; }

/* Inline voice selector */
.intro-voices { display: flex; gap: .4em; margin-bottom: .8em; }
.intro-voice { flex: 1; display: flex; align-items: center; justify-content: center; gap: .25em; padding: .45em .3em; border: 1.5px solid var(--border); border-radius: var(--radius-sm); font-family: var(--font-ui); font-size: .72rem; font-weight: 600; background: var(--surface); cursor: pointer; transition: all .15s; }
.intro-voice:hover { border-color: var(--accent); }
.intro-voice.selected { border-color: var(--accent); background: var(--accent-bg); color: var(--accent); }
.intro-voice span:first-child { font-size: .9rem; }

/* Feature toggles */
.intro-toggles { display: flex; flex-direction: column; gap: .4em; padding: .4em 0; }
.intro-toggle { display: flex; align-items: flex-start; gap: .5em; font-size: .76rem; line-height: 1.35; cursor: pointer; }
.intro-toggle input { margin-top: .15em; flex-shrink: 0; }
.toggle-desc { color: var(--text-3); font-size: .7rem; }
.toggle-desc a { color: var(--accent); }
.toggle-hint { font-weight: 400; color: var(--text-3); font-size: .7rem; }

/* Credits */
.intro-credits { margin-top: .8em; text-align: center; font-family: var(--font-ui); font-size: .7rem; color: var(--text-3); line-height: 1.6; }
.intro-credits a { color: var(--text-2); }
.intro-credits p { margin-bottom: .15em; }
.intro-collab-btn { margin-top: .5em; font-family: var(--font-ui); font-size: .78rem; font-weight: 700; color: var(--accent); background: var(--accent-bg); border: 1px solid var(--accent); border-radius: 999px; padding: .45em 1.1em; cursor: pointer; }
.intro-collab-btn:hover { background: var(--accent); color: #fff; }
.contact-hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }
.contact-status { font-family: var(--font-ui); font-size: .8rem; margin-top: .6em; }
.contact-status.ok { color: #15803d; }
.contact-status.err { color: #dc2626; }
.onboard-opts { display: grid; grid-template-columns: 1fr 1fr; gap: .6em; margin: 0 auto; max-width: 360px; }
.opt-card { display: flex; flex-direction: column; align-items: center; gap: .4em; padding: 1.2em .8em; border: 1.5px solid var(--border); border-radius: var(--radius); background: var(--surface); transition: all var(--transition); }
.opt-card:hover, .opt-card.selected { border-color: var(--accent); background: var(--accent-bg); }
.opt-icon { font-size: 1.6rem; }
.opt-label { font-size: .82rem; color: var(--text-2); line-height: 1.3; }

/* =============================================
   TOPBAR
   ============================================= */
.topbar { position: fixed; top: 0; left: 0; right: 0; height: var(--topbar-h); background: var(--bg); border-bottom: 1px solid var(--border); display: flex; align-items: center; padding: 0 .8em; z-index: 200; gap: .6em; backdrop-filter: blur(10px); background: color-mix(in srgb, var(--bg) 90%, transparent); }
[data-theme="dark"] .topbar { background: rgba(23,20,18,.9); }
.topbar-left { flex-shrink: 0; }
.topbar-title { font-family: var(--font-ui); font-size: .85rem; font-weight: 700; color: var(--accent); cursor: pointer; }
.topbar-search { flex: 1; display: flex; align-items: center; gap: .4em; padding: .4em .8em; background: var(--border-light); border-radius: 20px; color: var(--text-3); font-size: .85rem; transition: background var(--transition); }
.topbar-search:hover { background: var(--border); }
.search-placeholder { font-family: var(--font-ui); }
.topbar-right { display: flex; align-items: center; gap: .4em; flex-shrink: 0; }
.topbar-icon { font-size: 1.1rem; padding: .3em; color: var(--text-2); border-radius: 6px; }
.topbar-icon:hover { background: var(--border-light); }
/* XP badge in topbar */
.xp-badge { font-family: var(--font-ui); font-size: .72rem; font-weight: 800; padding: .25em .7em; border-radius: 14px; background: linear-gradient(135deg, var(--accent), #EC4899); color: #fff; cursor: pointer; transition: all var(--transition); box-shadow: 0 2px 8px rgba(124,58,237,.25); }
.xp-badge:hover { transform: scale(1.08); box-shadow: 0 3px 12px rgba(124,58,237,.35); }

/* XP toast notification */
.xp-toast { position: fixed; top: calc(var(--topbar-h) + .5em); right: .8em; font-family: var(--font-ui); font-size: .8rem; font-weight: 700; padding: .4em .8em; border-radius: 10px; color: #fff; z-index: 500; opacity: 0; transform: translateY(-10px); transition: all .3s ease; pointer-events: none; }
.xp-toast.show { opacity: 1; transform: translateY(0); }
.xp-toast.xp { background: linear-gradient(135deg, var(--accent), #EC4899); }
.xp-toast.achievement { background: linear-gradient(135deg, #F59E0B, #EF4444); font-size: .85rem; padding: .5em 1em; }
.xp-toast.levelup { background: linear-gradient(135deg, #10B981, #3B82F6); font-size: .9rem; padding: .6em 1em; }
.xp-toast.info { background: linear-gradient(135deg, #6B7280, #4B5563); }

/* Certificate */
.cert-btn { background: linear-gradient(135deg, var(--accent), #EC4899); color: #fff; border: none; border-radius: 8px; padding: .6em 1.2em; font-size: .85rem; font-weight: 700; cursor: pointer; font-family: var(--font-ui); }
.cert-btn:hover { opacity: .9; transform: translateY(-1px); }
.cert-locked { opacity: .8; }
.cert-progress { height: 6px; background: var(--border); border-radius: 3px; margin-top: .5em; overflow: hidden; }
.cert-progress-fill { height: 100%; background: linear-gradient(90deg, var(--accent), #EC4899); border-radius: 3px; transition: width .5s; }
/* Certificate modal */
.cert-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 999; display: flex; align-items: center; justify-content: center; padding: 1em; animation: fadeIn .2s ease; }
.cert-modal { background: var(--bg); border-radius: 16px; padding: 1.5em; max-width: 480px; width: 100%; max-height: 90vh; overflow-y: auto; position: relative; box-shadow: 0 20px 60px rgba(0,0,0,.2); }
.cert-modal h2 { font-family: var(--font-ui); font-size: 1.2rem; font-weight: 800; margin-bottom: .2em; }
.cert-close { position: absolute; top: .8em; right: .8em; font-size: 1.3rem; color: var(--text-3); width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; border-radius: 50%; }
.cert-close:hover { background: var(--border-light); color: var(--text); }
.cert-label { display: block; font-family: var(--font-ui); font-size: .75rem; font-weight: 600; color: var(--text-2); margin: .8em 0 .3em; }
.cert-input { display: block; width: 100%; border: 1.5px solid var(--border); border-radius: 8px; padding: .5em .7em; font-family: var(--font-ui); font-size: .85rem; background: var(--surface); color: var(--text); outline: none; transition: border-color .15s; }
.cert-input:focus { border-color: var(--accent); }
.cert-input.cert-error { border-color: #dc2626; animation: shake .3s ease; }
textarea.cert-input { resize: vertical; line-height: 1.4; }
.cert-stars { display: flex; gap: .2em; margin: .3em 0; }
.cert-star { font-size: 1.5rem; color: var(--border); cursor: pointer; transition: color .1s, transform .1s; padding: 0 .1em; }
.cert-star:hover, .cert-star.active { color: #f59e0b; transform: scale(1.1); }
.cert-actions { display: flex; gap: .5em; margin-top: 1.2em; }
.cert-btn-primary { flex: 1; }
.cert-btn-share { background: var(--surface); color: var(--accent); border: 1.5px solid var(--accent); flex: 0 0 auto; }
.cert-btn-share:hover { background: var(--accent-bg); }
@keyframes shake { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }

.voice-badge { font-family: var(--font-ui); font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; padding: .2em .5em; border-radius: 4px; color: #fff; }
.voice-badge.engineer, .voice-badge.explorer { background: var(--engineer); }
.voice-badge.product, .voice-badge.creator { background: var(--product); }
.voice-badge.business, .voice-badge.thinker { background: var(--business); }
.voice-badge.universal { background: var(--text-3); }
.voice-badge:empty { display: none; }

/* =============================================
   SEARCH OVERLAY
   ============================================= */
.search-overlay { position: fixed; inset: 0; background: var(--bg); z-index: 300; display: none; flex-direction: column; }
.search-overlay.open { display: flex; }
.search-header { display: flex; align-items: center; gap: .5em; padding: .6em .8em; border-bottom: 1px solid var(--border); }
.search-input-wrap { flex: 1; display: flex; align-items: center; gap: .4em; padding: .4em .6em; background: var(--border-light); border-radius: 10px; }
.search-input-wrap input { flex: 1; border: none; background: none; font-family: var(--font-ui); font-size: 1rem; color: var(--text); outline: none; }
.search-icon { font-size: 1rem; color: var(--text-3); }
.search-results { flex: 1; overflow-y: auto; padding: .5em; }
.search-empty { text-align: center; padding: 3em 1em; color: var(--text-3); font-family: var(--font-ui); font-size: .9rem; }

/* =============================================
   BOTTOM NAV
   ============================================= */
.bottom-nav { position: fixed; bottom: 0; left: 0; right: 0; height: var(--bottomnav-h); background: var(--surface); border-top: 1px solid var(--border); display: flex; z-index: 200; padding-bottom: env(safe-area-inset-bottom); }
.tab { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .15em; color: var(--text-3); transition: color var(--transition); }
.tab.active { color: var(--accent); }
/* fixed icon box: emoji glyphs differ in height (the Map label sat lower than the rest) */
.tab-icon { font-size: 1.2rem; display: block; height: 1.5em; line-height: 1.5em; position: relative; }
.tab-label { font-family: var(--font-ui); font-size: .75rem; font-weight: 600; }

/* =============================================
   VIEWS
   ============================================= */
#appMain { padding-top: var(--topbar-h); padding-bottom: calc(var(--bottomnav-h) + 42px); min-height: 100vh; }
.view { display: none; }
.view.active { display: block; }

/* =============================================
   HOME VIEW
   ============================================= */
/* Hero */
.home-hero { text-align: center; padding: 1.5em 1em 0; }
.home-title { font-family: var(--font-ui); font-size: 1.6rem; font-weight: 800; letter-spacing: -.02em; margin-bottom: .1em; }
.home-author { font-family: var(--font-ui); font-size: .75rem; color: var(--text-3); margin-bottom: .3em; }
.home-slogan { font-size: .85rem; color: var(--text-2); margin-bottom: .6em; }
.home-progress-mini { font-family: var(--font-ui); font-size: .7rem; color: var(--accent); font-weight: 600; margin-bottom: .3em; }

/* Reading modes grid */
.home-modes { display: grid; grid-template-columns: 1fr 1fr; gap: .5em; padding: .5em 1em 1em; max-width: 400px; margin: 0 auto; }
.home-mode { display: flex; flex-direction: column; align-items: center; gap: .2em; padding: .7em .5em; background: var(--surface); border: 1.5px solid var(--border); border-radius: var(--radius); cursor: pointer; transition: all var(--transition); }
.home-mode:hover { border-color: var(--accent); box-shadow: var(--shadow); transform: translateY(-1px); }
.home-mode-icon { font-size: 1.3rem; }
.home-mode-label { font-family: var(--font-ui); font-size: .78rem; font-weight: 700; }
.home-mode-desc { font-family: var(--font-ui); font-size: .7rem; color: var(--text-3); }

/* Mission progress in topbar */
.mission-bar-inline { display: flex; align-items: center; gap: 4px; margin: 0 .3em; }
.mission-bar-back { background: none; border: none; font-size: 1rem; cursor: pointer; padding: 0 2px; line-height: 1; }
.mission-bar-back:hover { transform: scale(1.15); }
.mission-bar-dots { display: flex; gap: 3px; align-items: center; }
.mission-bar-inline .mission-dot { width: 7px; height: 7px; }
.mission-bar-inline .mission-dot.done { background: var(--product); }
.mission-bar-inline .mission-dot.current { background: var(--accent); box-shadow: 0 0 0 2px var(--accent-bg); }


/* Cosmetic theme picker */
.cosmetic-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(80px, 1fr)); gap: .4em; }
.cosmetic-item { display: flex; flex-direction: column; align-items: center; gap: .15em; padding: .5em .3em; border: 1.5px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); cursor: pointer; transition: all .15s; }
.cosmetic-item:hover { border-color: var(--accent); }
.cosmetic-active { border-color: var(--accent); background: var(--accent-bg); box-shadow: 0 0 0 2px var(--accent-bg); }
.cosmetic-locked { opacity: .4; cursor: default; }
.cosmetic-locked:hover { border-color: var(--border); }
.cosmetic-icon { font-size: 1.2rem; }
.cosmetic-name { font-family: var(--font-ui); font-size: .7rem; font-weight: 600; }
.cosmetic-level { font-family: var(--font-ui); font-size: .7rem; color: var(--text-3); }

/* Onboarding tour */
.tour-overlay { position: fixed; inset: 0; z-index: 950; background: rgba(0,0,0,.45); }
.tour-highlight { position: absolute; border: 2px solid var(--accent); border-radius: 8px; box-shadow: 0 0 0 4000px rgba(0,0,0,.4); z-index: 951; pointer-events: none; }
.tour-tip { position: absolute; z-index: 952; background: #fff; border-radius: 12px; padding: .8em 1em; max-width: 250px; box-shadow: 0 8px 30px rgba(0,0,0,.2); animation: fadeUp .25s ease; }
.tour-center { top: 50%; left: 50%; transform: translate(-50%, -50%); text-align: center; max-width: 300px; }
.tour-text { font-family: var(--font-ui); font-size: .82rem; line-height: 1.45; color: #1C1917; margin-bottom: .6em; }
.tour-nav { display: flex; align-items: center; gap: .4em; }
.tour-count { font-family: var(--font-ui); font-size: .7rem; color: #9ca3af; margin-right: auto; }
.tour-btn { font-family: var(--font-ui); font-size: .72rem; font-weight: 600; padding: .3em .7em; border-radius: 6px; border: none; cursor: pointer; color: #6b7280; background: #f3f4f6; }
.tour-btn:hover { background: #e5e7eb; }
.tour-btn-primary { background: #7C3AED; color: #fff; }
.tour-btn-primary:hover { background: #6D28D9; }

/* Preview panel (slides up before navigating) */
.preview-panel { position: fixed; bottom: 0; left: 0; right: 0; z-index: 300; animation: slideUp .25s ease; }
.preview-content { max-width: 500px; margin: 0 auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius) var(--radius) 0 0; box-shadow: 0 -4px 20px rgba(0,0,0,.12); padding: 1em; }
.preview-header { display: flex; align-items: center; gap: .4em; margin-bottom: .4em; }
.preview-ch { font-family: var(--font-ui); font-size: .7rem; font-weight: 700; color: var(--accent); background: var(--accent-bg); padding: .15em .4em; border-radius: 4px; }
.preview-title { font-family: var(--font-ui); font-size: .88rem; font-weight: 700; flex: 1; }
.preview-close { background: none; border: none; font-size: 1.1rem; color: var(--text-3); cursor: pointer; }
.preview-teaser { font-size: .8rem; color: var(--text-2); line-height: 1.45; margin-bottom: .6em; }
.preview-actions { display: flex; gap: .4em; }
.preview-go { flex: 1; background: var(--accent); color: #fff; border: none; border-radius: 6px; padding: .4em; font-family: var(--font-ui); font-size: .82rem; font-weight: 600; cursor: pointer; }
.preview-go:hover { opacity: .9; }
.preview-dismiss { flex: 1; background: var(--border-light); color: var(--text-2); border: none; border-radius: 6px; padding: .4em; font-family: var(--font-ui); font-size: .82rem; font-weight: 600; cursor: pointer; }
.preview-dismiss:hover { background: var(--border); }
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }


/* Inline quiz (between blocks) */
.inline-quiz { display: flex; gap: .6em; margin: 1em 0 1.5em; padding: .8em 1em; background: linear-gradient(135deg, var(--accent-bg), var(--surface)); border: 1px solid var(--accent); border-radius: var(--radius); }
.iq-icon { font-size: 1.2rem; flex-shrink: 0; margin-top: .1em; }
.iq-body { flex: 1; }
.iq-q { font-family: var(--font-ui); font-size: .85rem; font-weight: 600; line-height: 1.4; margin-bottom: .4em; }
.iq-reveal { font-family: var(--font-ui); font-size: .75rem; font-weight: 600; color: var(--accent); background: none; border: 1px solid var(--accent); border-radius: 5px; padding: .25em .6em; cursor: pointer; }
.iq-reveal:hover { background: var(--accent); color: #fff; }
.iq-a { font-size: .82rem; color: var(--text-2); line-height: 1.45; padding-top: .3em; border-top: 1px solid var(--border-light); margin-top: .3em; }

/* Shelves */
.home-inner { padding: 1em 0; }
.shelf { margin-bottom: 1.8em; }
.shelf-head { padding: 0 1em; margin-bottom: .4em; }
.shelf-title { font-family: var(--font-ui); font-size: 1rem; font-weight: 700; }
.shelf-wrap { position: relative; }
.shelf-scroll { display: flex; gap: .6em; overflow-x: auto; padding: 0 1em .5em; scroll-snap-type: x proximity; scroll-padding-inline-start: 1em; -webkit-overflow-scrolling: touch; scrollbar-width: none; scroll-behavior: smooth; }
.shelf-scroll::-webkit-scrollbar { display: none; }
.shelf-btn { position: absolute; top: 0; bottom: .5em; width: 2.8em; z-index: 5; border: none; cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 2rem; font-weight: 300; color: var(--text); transition: opacity var(--transition); opacity: 0; }
.shelf-wrap:hover .shelf-btn:not(.arrow-hidden) { opacity: 1; }
.shelf-btn-left { left: 0; background: linear-gradient(to right, var(--bg) 50%, transparent); border-radius: var(--radius) 0 0 var(--radius); }
.shelf-btn-right { right: 0; background: linear-gradient(to left, var(--bg) 50%, transparent); border-radius: 0 var(--radius) var(--radius) 0; }
.shelf-btn:hover { color: var(--accent); }
.shelf-btn.arrow-hidden { opacity: 0 !important; pointer-events: none !important; }
.shelf-wrap.no-scroll .shelf-btn { display: none; }
.shelf-wrap.no-scroll .shelf-scroll { padding: 0 1em .5em; }
@media (max-width: 600px) { .shelf-btn:not(.arrow-hidden) { opacity: .5; width: 2em; font-size: 1.5rem; } .shelf-scroll { padding: 0 1em .5em; } }

/* Content cards */
.card { flex: 0 0 260px; scroll-snap-align: start; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1em; display: flex; flex-direction: column; gap: .5em; transition: all var(--transition); cursor: pointer; min-height: 140px; }
.card:hover { border-color: var(--accent); box-shadow: var(--shadow); transform: translateY(-2px); }
.card-chapter { font-family: var(--font-ui); font-size: .7rem; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: .04em; }
.card-title { font-family: var(--font-ui); font-size: .9rem; font-weight: 700; line-height: 1.25; flex: 1; }
.card-meta { display: flex; align-items: center; gap: .5em; }
.card-time { font-family: var(--font-ui); font-size: .7rem; color: var(--text-3); }
.card-badge { font-family: var(--font-ui); font-size: .6rem; font-weight: 700; text-transform: uppercase; padding: .15em .4em; border-radius: 3px; color: #fff; }
.card-badge.engineer, .card-badge.explorer { background: var(--engineer); }
.card-badge.product, .card-badge.creator { background: var(--product); }
.card-badge.business, .card-badge.thinker { background: var(--business); }
.card-badge.spine { background: var(--text-3); }
.card-badge.sidebar { background: var(--sidebar-color); }
.card-badge-new { font-family: var(--font-ui); font-size: .7rem; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; padding: .15em .45em; border-radius: 3px; background: #10B981; color: #fff; margin-right: .3em; animation: pulse-new 2s ease-in-out infinite; }
@keyframes pulse-new { 0%, 100% { opacity: 1; } 50% { opacity: .7; } }
.card-teaser { font-size: .8rem; color: var(--text-2); line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-read { position: relative; opacity: .55; border-color: var(--border-light); }
.card-read::after { content: '✓ Read'; position: absolute; top: 6px; right: 8px; font-size: .6rem; font-family: var(--font-ui); font-weight: 700; color: #fff; background: var(--product); padding: .15em .4em; border-radius: 4px; }
.card-read:hover { opacity: .8; }
.card-read .card-title { text-decoration: line-through; text-decoration-color: var(--border); }

/* Card content tags (diagram, math, table, code indicators) */
.card-tags { display: flex; gap: .3em; flex-wrap: wrap; margin-bottom: .3em; }
.card-tag { font-family: var(--font-ui); font-size: .6rem; font-weight: 600; padding: .15em .4em; border-radius: 4px; }
.tag-diagram { background: #DBEAFE; color: #1E40AF; }
.tag-math { background: #FCE7F3; color: #9D174D; }
.tag-table { background: #D1FAE5; color: #065F46; }
.tag-code { background: #E5E7EB; color: #374151; }

/* Recall cards (spaced repetition) */
.recall-card { cursor: default; }
.recall-card .card-title { font-size: .85rem; line-height: 1.4; }
.recall-answer-text { font-size: .8rem; color: var(--text-2); line-height: 1.5; padding: .5em 0; border-top: 1px solid var(--border-light); margin-top: .4em; }
.recall-hint { font-size: .7rem; }
.recall-reveal { background: var(--warn); color: #fff; border: none; border-radius: 6px; padding: .4em .8em; font-size: .75rem; font-weight: 600; cursor: pointer; width: 100%; margin-top: .4em; }
.recall-reveal:hover { background: #D97706; }
.recall-buttons { display: grid; grid-template-columns: 1fr 1fr 1fr 1fr; gap: .3em; margin-top: .4em; }
.recall-btn { border: none; border-radius: 5px; padding: .35em .3em; font-size: .7rem; font-weight: 600; cursor: pointer; }
.recall-forgot { background: #FEE2E2; color: #991B1B; }
.recall-hard { background: var(--warn-bg); color: var(--warn-text); }
.recall-good { background: #D1FAE5; color: #065F46; }
.recall-easy { background: #DBEAFE; color: #1E40AF; }
.recall-btn:hover { opacity: .85; transform: translateY(-1px); }

/* Full-page recall session */
/* Quiz map cells */
#quizMap > div:hover { transform: scale(1.8); z-index: 2; box-shadow: 0 0 0 1px var(--surface); }

.recall-session { max-width: 480px; margin: 0 auto; padding: 1em; text-align: center; }
.recall-session h2 { font-size: 1.2rem; margin-bottom: .5em; }
.recall-summary-icon { font-size: 2.5rem; margin: .3em 0; }
.recall-summary-bar { height: 8px; background: var(--border); border-radius: 4px; overflow: hidden; margin: .5em auto; max-width: 200px; }
.recall-progress-row { display: flex; align-items: center; gap: .5em; margin-bottom: 1em; }
.recall-progress-label { font-family: var(--font-ui); font-size: .75rem; font-weight: 600; color: var(--text-3); white-space: nowrap; }
.recall-progress-bar { flex: 1; height: 5px; background: var(--border); border-radius: 3px; overflow: hidden; }
.recall-due-badge { font-family: var(--font-ui); font-size: .6rem; font-weight: 700; color: #fff; background: var(--warn); padding: .15em .4em; border-radius: 4px; }
.recall-practice-badge { font-family: var(--font-ui); font-size: .6rem; font-weight: 700; color: var(--accent); background: var(--accent-bg); padding: .15em .4em; border-radius: 4px; }
.recall-card-big { padding: 1.5em; background: var(--surface); border: 1.5px solid var(--border); border-radius: var(--radius); }
.recall-card-q { font-size: 1rem; font-weight: 600; line-height: 1.5; margin-bottom: .8em; }
.recall-card-answer { font-size: .88rem; color: var(--text-2); line-height: 1.5; margin-bottom: .5em; padding-top: .5em; border-top: 1px solid var(--border-light); }
.recall-card-source { font-size: .7rem; color: var(--text-3); margin-bottom: .6em; }
.recall-reveal-big { width: 100%; background: var(--warn); color: #fff; border: none; border-radius: 8px; padding: .6em; font-family: var(--font-ui); font-size: .9rem; font-weight: 700; cursor: pointer; }
.recall-reveal-big:hover { opacity: .9; }

/* Inline recall (in read feed) */
.inline-recall { margin: .8em 0 1.5em; padding: 1em; background: var(--warn-bg); border: 1.5px solid var(--warn); border-radius: var(--radius); }
.ir-header { font-family: var(--font-ui); font-size: .75rem; font-weight: 700; color: var(--warn); margin-bottom: .4em; display: flex; align-items: center; gap: .3em; }
.ir-question { font-size: .9rem; font-weight: 600; line-height: 1.4; margin-bottom: .5em; }
.ir-answer-text { font-size: .85rem; color: var(--text-2); line-height: 1.5; margin-bottom: .3em; padding-top: .4em; border-top: 1px solid var(--warn); }
.ir-from { font-size: .7rem; color: var(--text-3); margin-bottom: .5em; }

/* Hero card (continue reading) */
.card-hero { flex: 0 0 calc(100% - 2em); max-width: 500px; background: linear-gradient(135deg, var(--accent-bg), var(--surface)); border-color: var(--accent); min-height: 160px; }
.card-hero .card-title { font-size: 1.05rem; }

/* =============================================
   READ VIEW
   ============================================= */
.read-layout { max-width: 1100px; margin: 0 auto; }
.read-pane { max-width: var(--content-w); margin: 0 auto; padding: 1.5em 1em 3em; }

/* Chapter header */
.ch-head { margin-bottom: 2em; padding-bottom: 1.5em; border-bottom: 1px solid var(--border); }
.ch-label { font-family: var(--font-ui); font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--accent); margin-bottom: .3em; }
.ch-head h2 { font-family: var(--font-ui); font-size: 1.7rem; font-weight: 800; letter-spacing: -.02em; line-height: 1.2; margin-bottom: .3em; }
.ch-sub { font-size: 1rem; color: var(--text-2); }
.ch-path { font-family: var(--font-ui); font-size: .74rem; color: var(--text-3); margin-top: .6em; }
.ch-path a { color: var(--accent); }

/* Essentials flow: the strip to the other tellings of a concept */
.more-ways { display: flex; flex-wrap: wrap; align-items: center; gap: .25em .35em; font-family: var(--font-ui); font-size: .74rem; color: var(--text-3); margin: -.4em 0 1.6em; padding: 0 .2em; }
.mw-lead, .mw-chip { background: none; border: none; padding: .15em .1em; font: inherit; cursor: pointer; color: var(--text-2); }
.mw-lead { color: var(--text-3); }
.mw-chip { color: var(--accent); text-decoration: underline; text-decoration-color: transparent; text-underline-offset: 2px; }
.mw-chip:hover, .mw-chip:focus-visible { text-decoration-color: currentColor; }
.mw-lead:hover { color: var(--text-2); }
.mw-sep { color: var(--text-3); opacity: .6; }

/* Check yourself (concept-contract recall interstitial) */
.check-yourself { background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--accent); }
.check-yourself .ir-header { color: var(--accent); }
.check-yourself .ir-answer-text { border-top-color: var(--border); }
.cy-concept { font-weight: 500; color: var(--text-3); margin-left: .3em; }
.cy-concept::before { content: '\00b7'; margin-right: .35em; }

/* Block articles (each block is a distinct card) */
.block-article { margin-bottom: 1.5em; padding: 1.5em; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); position: relative; overflow: visible; scroll-margin-top: calc(var(--topbar-h) + 10px); }

/* Block-level navigation */
.block-nav { display: flex; align-items: center; gap: .3em; margin-bottom: .5em; font-family: var(--font-ui); font-size: .7rem; color: var(--text-3); }
.bnav-back { background: none; border: none; font-size: .8rem; color: var(--accent); cursor: pointer; padding: 0; font-weight: 700; }
.bnav-back:hover { color: var(--text); }
.bnav-ch { cursor: pointer; font-weight: 600; color: var(--accent); }
.bnav-ch:hover { text-decoration: underline; }
.bnav-sep { color: var(--border); }
.bnav-progress { color: var(--text-3); }
.bnav-core { font-size: .7rem; font-weight: 700; color: var(--accent); background: var(--accent-bg); padding: .1em .35em; border-radius: 3px; }
.block-nav .block-status { margin-left: auto; }

/* Feed chapter divider */
.feed-ch-divider { text-align: center; margin: 1.5em 0 .5em; font-family: var(--font-ui); font-size: .72rem; color: var(--text-3); }
.feed-ch-divider span { background: var(--bg); padding: 0 .8em; position: relative; }
.feed-ch-divider::before { content: ''; display: block; height: 1px; background: var(--border); position: relative; top: .6em; }

/* Block with side notes — margin notes on wide screens */
.block-with-side { position: relative; overflow: visible; }
.block-main { min-width: 0; }
.block-side { position: absolute; right: -190px; top: 0; width: 175px; display: flex; flex-direction: column; gap: .4em; }

/* Unified sticky note style (AI + user) */
.snote { display: flex; gap: .3em; align-items: flex-start; padding: .35em .4em; background: var(--snote-user-bg); border-left: 2px solid var(--snote-user-border); border-radius: 0 4px 4px 0; font-family: var(--font-ui); font-size: .7rem; line-height: 1.3; cursor: pointer; transition: opacity .15s; }
.snote:hover { opacity: .8; }
.snote-ai { background: var(--snote-ai-bg); border-left-color: var(--snote-ai-border); }
.snote-user { background: var(--snote-user-bg); border-left-color: var(--snote-user-border); }
.snote-icon { flex-shrink: 0; font-size: .7rem; }
.snote-body { flex: 1; display: flex; flex-direction: column; gap: .15em; }
.snote-quote { color: var(--accent); font-style: italic; font-size: .6rem; }
.snote-text { color: var(--text-2); flex: 1; }
.snote-user .snote-text { color: var(--text); }
.snote-edit, .snote-del { font-size: .7rem; color: var(--text-3); background: none; border: none; cursor: pointer; padding: 0; flex-shrink: 0; }
.snote-edit:hover { color: var(--accent); }
.snote-del:hover { color: #dc2626; }

/* Narrow screens: notes below content */
@media (max-width: 900px) {
  .block-side { position: static; width: auto; margin-top: .6em; padding-top: .5em; border-top: 1px dashed var(--border-light); flex-direction: row; flex-wrap: wrap; }
  .snote { flex: 1; min-width: 180px; }
}

.block-header { margin-bottom: 1em; }
.block-header h3 { font-family: var(--font-ui); font-size: 1.35rem; font-weight: 800; line-height: 1.25; margin-bottom: .4em; color: var(--text); }
.block-meta { font-family: var(--font-ui); font-size: .72rem; color: var(--text-3); display: flex; gap: .8em; align-items: center; }
.meta-standalone { background: var(--accent-bg); color: var(--accent); padding: .1em .4em; border-radius: 3px; font-weight: 600; }

.block-status { position: absolute; top: 0; left: 0; width: 3px; height: 100%; border-radius: var(--radius) 0 0 var(--radius); background: var(--border); transition: background .3s; }
.block-status.seen { background: #fbbf24; }
.block-status.read { background: var(--product); }
.block-article:has(.block-status.read) { background: var(--border-light); border-color: var(--border-light); }
.block-article:has(.block-status.read) .block-header h3::after { content: ' ✓'; color: var(--product); font-size: .7em; }

/* Spine body */
.spine-body { font-size: var(--fs); line-height: var(--lh); }
.spine-body p { margin-bottom: 1em; }
.spine-body h2 { font-size: 1.1rem; font-weight: 700; margin: 1.5em 0 .5em; color: var(--text); }
.spine-body h3 { font-size: .95rem; font-weight: 700; margin: 1.2em 0 .4em; color: var(--text-2); }
.spine-body h4 { font-size: .88rem; font-weight: 600; margin: 1em 0 .3em; color: var(--text-2); }
.spine-body ul, .spine-body ol { margin-bottom: 1em; padding-left: 1.6em; }
.spine-body ul { list-style-type: disc; }
.spine-body ol { list-style-type: decimal; }
.spine-body li { margin-bottom: .4em; padding-left: .2em; }
.spine-body li::marker { color: var(--accent); }
.spine-body strong { font-weight: 700; color: var(--text); }
.spine-body em { font-style: italic; }
.spine-body code { font-family: var(--font-mono); font-size: .87em; background: var(--border-light); padding: .15em .35em; border-radius: 4px; }
.spine-body img { max-width: 100%; border-radius: var(--radius-sm); margin: 1em 0; }
.spine-body a { color: var(--accent); text-decoration: underline; }
.spine-body hr { border: none; border-top: 2px solid var(--border); margin: 1.5em 0; }
/* Same for depth and sidebar content */

/* Block footer with reactions and actions */
.key-takeaway { margin: 1.5em 0 1em; padding: 1em 1.2em; background: var(--bg-card); border-left: 4px solid var(--accent); border-radius: 0 8px 8px 0; }
.key-takeaway-label { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--accent); margin-bottom: .4em; }
.key-takeaway-text { font-size: .92rem; line-height: 1.5; color: var(--text-1); }
.block-footer { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: .5em; margin-top: 1.2em; padding-top: .8em; border-top: 1px solid var(--border); }
.block-reactions { display: flex; gap: .3em; }
.like-btn { display: flex; align-items: center; gap: .3em; padding: .35em .8em; border-radius: 20px; border: 1.5px solid var(--border); font-size: .82rem; font-family: var(--font-ui); color: var(--text-3); transition: all var(--transition); }
.mark-read-btn { display: flex; align-items: center; gap: .3em; padding: .35em .8em; border-radius: 20px; border: 1.5px solid var(--border); font-size: .82rem; font-family: var(--font-ui); color: var(--text-3); background: none; cursor: pointer; transition: all var(--transition); }
.mark-read-btn:hover { border-color: var(--accent); color: var(--accent); }
.like-btn span { font-size: .72rem; }
.like-btn:hover { border-color: #ef4444; color: #ef4444; background: #fef2f2; }
.like-btn.liked { border-color: #ef4444; color: #ef4444; background: #fef2f2; font-weight: 600; }

.block-actions { display: flex; flex-wrap: wrap; gap: .2em; }
.act-btn { padding: .3em .5em; border-radius: 6px; font-size: .9rem; color: var(--text-3); transition: all var(--transition); }
.act-btn:hover { background: var(--border-light); color: var(--text); }
.act-btn.active { color: var(--accent); }
.flag-btn:hover { color: #dc2626; }

/* Text highlight */
.highlight-popup { position: absolute; z-index: 200; display: flex; gap: .2em; padding: .3em; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow-lg); }
.highlight-popup button { font-size: 1rem; padding: .2em .4em; border-radius: 5px; transition: background var(--transition); }
.highlight-popup button:hover { background: var(--accent-bg); }
.user-highlight { background: var(--hl-bg); border-radius: 2px; padding: 0 .1em; cursor: pointer; transition: background .3s; }
.user-highlight:hover { background: var(--hl-bg-hover); }
.highlight-flash { animation: hlFlash 1.5s ease; }
@keyframes hlFlash { 0% { background: var(--hl-flash); } 30% { background: var(--hl-flash); } 100% { background: var(--hl-bg); } }

/* Notes */
.block-note-display { display: flex; align-items: flex-start; gap: .5em; margin-top: .8em; padding: .6em .8em; background: var(--note-bg); border: 1px solid var(--note-border); border-radius: var(--radius-sm); font-size: .82rem; line-height: 1.4; }
.note-icon { font-size: .9rem; flex-shrink: 0; }
.note-edit { font-size: .7rem; color: var(--accent); margin-left: auto; flex-shrink: 0; }
.note-editor { margin-top: .5em; padding: .8em; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm); animation: fadeUp .2s ease; }
.note-editor textarea { width: 100%; min-height: 60px; border: 1px solid var(--border); border-radius: 6px; padding: .5em; font-family: var(--font-ui); font-size: .82rem; resize: vertical; background: var(--surface); color: var(--text); }
.note-quote-preview { font-size: .78rem; font-style: italic; color: var(--accent); padding: .4em .6em; background: var(--accent-bg); border-left: 2px solid var(--accent); border-radius: 0 4px 4px 0; margin-bottom: .4em; line-height: 1.3; }
.note-actions { display: flex; gap: .4em; margin-top: .4em; }
.note-save { font-size: .75rem; padding: .3em .8em; border-radius: 5px; background: var(--accent); color: #fff; font-weight: 600; }
.note-cancel { font-size: .75rem; padding: .3em .8em; border-radius: 5px; border: 1px solid var(--border); color: var(--text-2); }


/* Read next (inline, appears after reading a block) */
.read-next { margin: .5em 0 1.5em; opacity: 0; max-height: 0; overflow: hidden; transition: all .4s ease; clear: both; position: relative; z-index: 1; }
.read-next.rn-visible { opacity: 1; max-height: none; }
.rn-item { display: flex; flex-wrap: wrap; align-items: baseline; gap: .3em .6em; padding: .6em .8em; margin-bottom: .3em; background: var(--accent-bg); border: 1px solid var(--accent); border-radius: var(--radius-sm); cursor: pointer; transition: all var(--transition); }
.rn-item:hover { background: #fde68a; transform: translateX(3px); }
.rn-label { font-family: var(--font-ui); font-size: .6rem; font-weight: 600; text-transform: uppercase; color: var(--accent); white-space: nowrap; }
.rn-title { font-family: var(--font-ui); font-size: .82rem; font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.rn-time { font-family: var(--font-ui); font-size: .7rem; color: var(--text-3); flex-shrink: 0; }
.rn-rec { background: linear-gradient(135deg, var(--accent-bg), var(--warn-bg)); border-color: var(--warn); }
.rn-rec .rn-label { color: #D97706; }
.rn-skip { font-family: var(--font-ui); font-size: .7rem; color: var(--text-3); text-align: center; padding: .3em; cursor: pointer; }
.rn-skip:hover { color: var(--accent); }

/* Similar items */
.rn-similar { margin-top: .5em; }
.rn-similar-label { font-family: var(--font-ui); font-size: .7rem; font-weight: 700; text-transform: uppercase; color: var(--text-3); margin-bottom: .3em; }
.rn-similar-item { display: flex; align-items: center; gap: .5em; padding: .35em .5em; cursor: pointer; border-radius: var(--radius-sm); transition: background .15s; font-size: .78rem; }
.rn-similar-item:hover { background: var(--accent-bg); }
.rn-read { opacity: .5; }
.rn-similar-title { flex: 1; font-family: var(--font-ui); font-weight: 500; }
.rn-similar-ch { font-family: var(--font-ui); font-size: .7rem; color: var(--text-3); }

/* Share CTA for visitors */
.rn-cta { margin-top: .8em; padding: .8em; background: linear-gradient(135deg, var(--accent-bg), var(--warn-bg)); border-radius: var(--radius); text-align: center; }
.rn-cta-text { font-family: var(--font-ui); font-size: .82rem; color: var(--text-2); margin-bottom: .5em; }
.rn-cta-btn { background: var(--accent); color: #fff; border: none; border-radius: 6px; padding: .4em 1em; font-family: var(--font-ui); font-size: .82rem; font-weight: 600; cursor: pointer; }
.rn-cta-btn:hover { opacity: .9; }

/* Share button */
.share-btn:hover { color: var(--accent); }

/* Flag/report form */
.flag-form { margin-top: .5em; padding: .8em; background: #FEF2F2; border: 1px solid #FECACA; border-radius: var(--radius-sm); animation: fadeUp .2s ease; }
.flag-header { font-family: var(--font-ui); font-size: .8rem; font-weight: 600; color: #991B1B; margin-bottom: .5em; }
.flag-form select { width: 100%; padding: .4em; border: 1px solid #FECACA; border-radius: 5px; font-family: var(--font-ui); font-size: .8rem; margin-bottom: .4em; background: #fff; }
.flag-form textarea { width: 100%; min-height: 50px; border: 1px solid #FECACA; border-radius: 5px; padding: .5em; font-family: var(--font-ui); font-size: .8rem; resize: vertical; }

/* Tables */
/* position: relative — KaTeX's absolutely positioned MathML escaped the scroller and widened the page */
.table-wrap { overflow-x: auto; margin: 1em 0; border-radius: var(--radius-sm); border: 1px solid var(--border); position: relative; }
.table-wrap table { width: 100%; border-collapse: collapse; font-family: var(--font-ui); font-size: .85rem; }
.table-wrap th { background: var(--border-light); font-weight: 600; text-align: left; padding: .6em .8em; border-bottom: 2px solid var(--border); white-space: nowrap; }
.table-wrap td { padding: .5em .8em; border-bottom: 1px solid var(--border); vertical-align: top; }
.table-wrap tr:last-child td { border-bottom: none; }
.table-wrap tr:hover td { background: rgba(0,0,0,.02); }

/* Code blocks */
pre { margin: 1em 0; padding: 1em; background: var(--border-light); border-radius: var(--radius-sm); overflow-x: auto; border: 1px solid var(--border); }
pre code { font-family: var(--font-mono); font-size: .82rem; line-height: 1.5; background: none; padding: 0; }

/* Diagrams */
.diagram-wrap { margin: 1.2em 0; padding: .8em; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow-x: auto; text-align: center; }
.diagram-wrap svg { max-width: 100%; height: auto; }

/* Math (KaTeX) */
.katex-display { margin: 1em 0; overflow-x: auto; overflow-y: hidden; padding: .3em 0; position: relative; }
.katex { font-size: 1.05em; }

/* Depth tabs - adaptive */
/* depth-group, d-tab, d-content, sb-block removed — all content is now spine */

/* Question blocks */
.q-block { margin: 2em 0; padding: 1.2em; border: 1.5px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.q-block h4 { font-family: var(--font-ui); font-size: .95rem; font-weight: 700; margin-bottom: .2em; }
.q-desc { font-size: .85rem; color: var(--text-2); margin-bottom: 1em; }
.q-opts { display: flex; flex-direction: column; gap: .4em; }
.q-opt { display: flex; align-items: flex-start; gap: .6em; padding: .6em .8em; border: 1.5px solid var(--border); border-radius: var(--radius-sm); font-family: var(--font-ui); font-size: .85rem; background: var(--bg); transition: all var(--transition); text-align: left; }
.q-opt:hover { border-color: var(--accent); background: var(--accent-bg); }
.q-opt.selected { border-color: var(--accent); background: var(--accent-bg); font-weight: 600; }
.q-letter { font-weight: 700; color: var(--accent); width: 1.2em; flex-shrink: 0; }

/* Question recommendations (appear after answering) */
.q-recs { margin-top: 1.2em; padding-top: 1em; border-top: 1px solid var(--border); }
.q-feedback { font-size: .9rem; line-height: 1.55; padding: .8em 1em; background: var(--accent-bg); border-left: 3px solid var(--accent); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; margin-bottom: 1em; color: var(--text); }
.q-feedback-note { font-family: var(--font-ui); font-size: .72rem; color: var(--text-3); margin: -.5em 0 1em; }
.q-recs-title { font-family: var(--font-ui); font-size: .8rem; font-weight: 600; color: var(--accent); margin-bottom: .6em; }
.q-rec-item .card { flex: none; width: 100%; margin-bottom: .4em; min-height: auto; }


/* Inline feedback after each spine block */
.block-feedback { display: flex; align-items: center; gap: .3em; margin: .5em 0 1.5em; padding: .4em 0; }
.bf-btn { font-size: 1.1rem; padding: .3em; border-radius: 6px; transition: all var(--transition); opacity: .4; }
.bf-btn:hover { opacity: 1; background: var(--border-light); }
.bf-btn.active { opacity: 1; transform: scale(1.2); }


/* Tutor / Chat view */
.chat-view-inner { display: flex; flex-direction: column; height: calc(100vh - var(--topbar-h) - var(--bottomnav-h) - 38px); padding: 0; }
.chat-view-inner .chat-messages { flex: 1; overflow-y: auto; padding: .8em; display: flex; flex-direction: column; gap: .5em; }
.chat-view-inner .chat-input-wrap { padding: .5em .8em; border-top: 1px solid var(--border); display: flex; gap: .4em; flex-shrink: 0; }

/* Tutor header */
.tutor-header { display: flex; align-items: center; gap: .6em; padding: .5em .8em; border-bottom: 1px solid var(--border); background: var(--surface); flex-shrink: 0; }
.tutor-avatar { font-size: 1.5rem; }
.tutor-info { flex: 1; }
.tutor-name { font-family: var(--font-ui); font-size: .85rem; font-weight: 700; display: block; }
.tutor-status { font-family: var(--font-ui); font-size: .7rem; color: var(--text-3); }
.tutor-author-btn { font-family: var(--font-ui); font-size: .7rem; font-weight: 600; color: var(--accent); background: var(--accent-bg); border: 1px solid var(--accent); border-radius: 6px; padding: .3em .6em; cursor: pointer; white-space: nowrap; }
.tutor-author-btn:hover { background: var(--accent); color: #fff; }

/* Typing indicator */
.tutor-typing { display: flex; gap: 4px; padding: .3em .8em; }
.tutor-typing span { width: 8px; height: 8px; background: var(--text-3); border-radius: 50%; animation: typingDot 1.2s infinite ease-in-out; }
.tutor-typing span:nth-child(2) { animation-delay: .2s; }
.tutor-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes typingDot { 0%, 80%, 100% { transform: scale(.6); opacity: .4; } 40% { transform: scale(1); opacity: 1; } }

/* System messages & escalation */
.chat-msg.system { background: var(--warn-bg); color: var(--warn-text); align-self: center; text-align: center; font-size: .78rem; border-radius: 8px; }
.tutor-escalate-btn { font-family: var(--font-ui); font-size: .72rem; color: var(--accent); background: none; border: 1px solid var(--accent); border-radius: 5px; padding: .25em .5em; cursor: pointer; }
.tutor-escalate-btn:hover { background: var(--accent); color: #fff; }

/* Suggested questions */
.tutor-suggestions { display: flex; flex-direction: column; gap: .3em; padding: .3em 0; }
.tutor-suggest-btn { font-family: var(--font-ui); font-size: .78rem; color: var(--accent); background: var(--accent-bg); border: 1px solid transparent; border-radius: 8px; padding: .4em .7em; cursor: pointer; text-align: left; }
.tutor-suggest-btn:hover { border-color: var(--accent); }

/* Tutor button in block footer */
.tutor-btn:hover { color: var(--accent); }


/* =============================================
   MAP VIEW (redesigned)
   ============================================= */
.map-inner { padding: 1em; max-width: 700px; margin: 0 auto; }

/* Header */
.map-header { text-align: center; margin-bottom: 2em; }
.map-title { font-family: var(--font-ui); font-size: 1.4rem; font-weight: 800; margin-bottom: .6em; }
.map-progress-summary { margin-bottom: 1em; }
.map-progress-bar { height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; margin-bottom: .4em; }
.map-progress-fill { height: 100%; background: var(--accent); border-radius: 3px; transition: width .5s ease; }
.map-progress-text { font-family: var(--font-ui); font-size: .8rem; color: var(--text-2); }

/* Legend */
.map-legend { display: flex; justify-content: center; gap: 1.2em; flex-wrap: wrap; }
.map-legend-item { font-family: var(--font-ui); font-size: .7rem; color: var(--text-3); display: flex; align-items: center; gap: .3em; }
.map-dot-legend { width: 8px; height: 8px; border-radius: 50%; background: var(--border); display: inline-block; }
.map-dot-legend.done { background: var(--product); }
.map-dot-legend.next { background: var(--accent); box-shadow: 0 0 0 3px var(--accent-bg); }
.map-dot-legend.depth-leg { background: transparent; border: 2px solid var(--text-3); }

/* Chapter cards */
.map-chapter { margin-bottom: 1em; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.map-ch-locked { opacity: .6; }
.map-ch-head { display: flex; align-items: center; gap: .8em; padding: .8em 1em; cursor: pointer; transition: background var(--transition); }
.map-ch-head:hover { background: var(--border-light); }
.map-ch-img { width: 48px; height: 48px; object-fit: cover; border-radius: 6px; flex-shrink: 0; opacity: .85; }
.vmap-container { background: var(--surface); border-radius: 10px; overflow: hidden; }
.vmap-toolbar { border-bottom: 1px solid var(--border); background: var(--bg); }
.vmap-filter-btn { padding: .25em .6em; border-radius: 12px; border: 1.5px solid var(--border); font-size: .7rem; font-weight: 600; cursor: pointer; background: var(--bg); color: var(--text-2); transition: all .15s; }
.vmap-filter-btn.active { background: var(--accent); color: white; border-color: var(--accent); }
.vmap-filter-btn:hover:not(.active) { border-color: var(--accent); color: var(--accent); }
.vmap-canvas { height: 450px; }
.vmap-ch-pill { transition: border-color .15s; }
.vmap-ch-pill:hover { background: var(--bg-card); }
.map-ch-ring { position: relative; width: 36px; height: 36px; flex-shrink: 0; }
.map-ch-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.map-ch-ring .map-ch-num { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-family: var(--font-ui); font-size: .75rem; font-weight: 800; color: var(--accent); }
.map-ch-info { flex: 1; min-width: 0; }
.map-ch-title { font-family: var(--font-ui); font-size: .9rem; font-weight: 700; line-height: 1.2; }
.map-ch-sub { font-family: var(--font-ui); font-size: .72rem; color: var(--text-3); margin-top: .1em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.map-ch-stats { font-family: var(--font-ui); font-size: .7rem; color: var(--text-3); margin-top: .2em; }
.map-prereq { color: var(--accent); font-weight: 600; }
.map-ch-arrow { font-size: 1.4rem; color: var(--text-3); }

/* Block list */
.map-blocks { padding: 0 1em .5em; border-top: 1px solid var(--border); }
.map-spine-group { padding: .2em 0; }

/* Spine blocks */
.map-block { display: flex; align-items: center; gap: .5em; padding: .4em .5em; font-family: var(--font-ui); font-size: .82rem; color: var(--text-2); cursor: pointer; transition: all var(--transition); border-radius: 6px; }
.map-block:hover { background: var(--border-light); color: var(--text); }
.map-spine { font-weight: 500; }
.map-block.seen { color: var(--text-2); }
.map-block.seen .map-dot { background: #fbbf24; }
.map-block.read { color: var(--text-3); text-decoration: line-through; text-decoration-color: var(--border); }
.map-block.read .map-dot { background: var(--product); }
.map-block.read .map-block-title::after { content: ' ✓'; color: var(--product); text-decoration: none; font-size: .75em; }
.map-block.suggested { color: var(--accent); font-weight: 600; }
.map-block.suggested .map-dot { background: var(--accent); box-shadow: 0 0 0 3px var(--accent-bg); }
.seen-dot { background: #fbbf24 !important; }
.map-signals { font-size: .7rem; display: flex; gap: .1em; margin-left: auto; flex-shrink: 0; }

/* Dots */
.map-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--border); flex-shrink: 0; transition: all var(--transition); }
.map-dot.done { background: var(--product); }
.map-dot.next { background: var(--accent); box-shadow: 0 0 0 3px var(--accent-bg); }
.depth-dot { background: transparent !important; border: 2px solid var(--text-3); width: 7px; height: 7px; }

.map-block-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.map-block-time { font-size: .7rem; color: var(--text-3); flex-shrink: 0; }
.map-core-badge { font-family: var(--font-ui); font-size: .7rem; font-weight: 700; color: var(--accent); background: var(--accent-bg); padding: .1em .3em; border-radius: 3px; flex-shrink: 0; }
.saved-remove-btn { background: none; border: none; color: var(--text-3); font-size: 1rem; padding: 0 .3em; cursor: pointer; flex-shrink: 0; line-height: 1; }
.saved-remove-btn:hover { color: #dc2626; }
.map-game-tag { font-size: .7rem; flex-shrink: 0; }

/* Knowledge cloud */
.knowledge-cloud { display: flex; flex-wrap: wrap; gap: .25em .5em; justify-content: center; align-items: baseline; padding: .6em; line-height: 1.8; }
.cloud-word { font-family: var(--font-ui); font-weight: 600; color: var(--accent); white-space: nowrap; padding: .1em .3em; border-radius: 4px; transition: all .2s; cursor: default; }
.cloud-word:hover { background: var(--accent-bg); transform: scale(1.05); }

/* Voice tags in map */
.map-voice-tag { font-family: var(--font-ui); font-size: .7rem; font-weight: 700; text-transform: uppercase; padding: .12em .35em; border-radius: 3px; color: #fff; flex-shrink: 0; margin-left: auto; }
.map-voice-tag.engineer, .map-voice-tag.explorer { background: var(--engineer); }
.map-voice-tag.product, .map-voice-tag.creator { background: var(--product); }
.map-voice-tag.business, .map-voice-tag.thinker { background: var(--business); }

/* Children (depth cards indented) */

/* Map signals bar */
.map-signals-bar { display: flex; gap: .8em; justify-content: center; flex-wrap: wrap; margin: .6em 0; font-family: var(--font-ui); font-size: .7rem; color: var(--text-3); }
.map-signals-bar span { display: flex; align-items: center; gap: .2em; }

/* Map data transparency note */
.map-data-note { margin-top: .6em; font-family: var(--font-ui); font-size: .75rem; }
.map-data-note summary { cursor: pointer; color: var(--text-3); font-weight: 500; }
.map-data-note summary:hover { color: var(--accent); }
.map-data-explain { margin-top: .5em; padding: .8em; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: .78rem; line-height: 1.5; color: var(--text-2); }
.map-reset-btn { display: inline-block; margin-top: .5em; font-family: var(--font-ui); font-size: .72rem; padding: .3em .7em; border-radius: 5px; border: 1.5px solid #dc2626; color: #dc2626; background: none; cursor: pointer; }
.map-reset-btn:hover { background: #fef2f2; }

/* Map mode toggle */
.map-mode-toggle { display: flex; gap: .3em; justify-content: center; margin-top: .8em; }
.map-mode-btn { font-family: var(--font-ui); font-size: .75rem; font-weight: 600; padding: .35em .9em; border-radius: 20px; border: 1.5px solid var(--border); color: var(--text-3); transition: all var(--transition); }
.map-mode-btn:hover { border-color: var(--text-2); color: var(--text-2); }
.map-mode-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* Legend (SVG-based) */
.map-legend { display: flex; gap: 1em; justify-content: center; flex-wrap: wrap; margin: .8em 0; }
.ml-item { font-family: var(--font-ui); font-size: .7rem; color: var(--text-3); display: flex; align-items: center; gap: .3em; }

/* ===== VISUAL RPG MAP ===== */
.visual-map-wrap { margin-top: 1em; }
.visual-map { width: 100%; height: auto; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); }
.visual-map .map-node:hover rect:first-of-type { filter: brightness(0.95); }
.visual-map text { user-select: none; }

.vmap-legend { display: flex; gap: 1em; justify-content: center; flex-wrap: wrap; margin: .8em 0; font-family: var(--font-ui); font-size: .7rem; color: var(--text-3); align-items: center; }
.vmap-legend span { display: flex; align-items: center; gap: .25em; }

.vmap-detail { margin-top: 1em; }


/* =============================================
   MISSIONS VIEW
   ============================================= */
.missions-inner { padding: 1em; max-width: 560px; margin: 0 auto; }
.missions-head { margin-bottom: 1.2em; }
.missions-head h2 { font-family: var(--font-ui); font-size: 1.3rem; font-weight: 800; margin-bottom: .2em; }
.missions-head p { font-size: .82rem; color: var(--text-2); }

/* Mission cards (list view) */
.mission-card { display: flex; gap: .8em; padding: .8em; margin-bottom: .6em; background: var(--surface); border: 1.5px solid var(--border); border-radius: var(--radius); cursor: pointer; transition: all var(--transition); }
.mission-card:hover { border-color: var(--accent); box-shadow: var(--shadow); transform: translateY(-1px); }
.mission-complete { border-color: var(--product); background: var(--product-bg); }
.mission-locked { opacity: .5; cursor: default; }
.mission-locked:hover { transform: none; box-shadow: none; border-color: var(--border); }
.mission-active { border-color: var(--accent); }
.mission-icon { font-size: 1.8rem; flex-shrink: 0; display: flex; align-items: center; }
.mission-info { flex: 1; min-width: 0; }
.mission-title-row { display: flex; align-items: center; gap: .4em; margin-bottom: .2em; }
.mission-title { font-family: var(--font-ui); font-size: .88rem; font-weight: 700; }
.mission-diff { font-family: var(--font-ui); font-size: .7rem; font-weight: 700; color: #fff; padding: .15em .4em; border-radius: 4px; text-transform: uppercase; }
.mission-story { font-family: var(--font-ui); font-size: .75rem; color: var(--text-2); line-height: 1.35; margin-bottom: .4em; }
.mission-progress-dots { display: flex; gap: 4px; flex-wrap: wrap; }
.mission-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--border); transition: all .2s; flex-shrink: 0; }
.mission-dot.done { background: var(--product); }
.mission-dot.current { background: var(--accent); box-shadow: 0 0 0 3px var(--accent-bg); }
.mission-dot.branch-dot { border-radius: 3px; }
.mission-meta { display: flex; justify-content: space-between; align-items: center; margin-top: .4em; font-family: var(--font-ui); font-size: .7rem; color: var(--text-3); }
.mission-reward-preview { color: var(--accent); font-weight: 600; }
.mission-complete-badge { color: var(--product); font-weight: 700; }

/* Mission detail view */
.mission-detail-header { display: flex; gap: .8em; align-items: center; margin-bottom: .6em; }
.mission-detail-icon { font-size: 2.5rem; }
.mission-detail-title { font-family: var(--font-ui); font-size: 1.15rem; font-weight: 800; }
.mission-detail-goal { font-family: var(--font-ui); font-size: .8rem; color: var(--accent); font-weight: 600; }
.mission-detail-story { font-size: .85rem; line-height: 1.5; color: var(--text-2); margin-bottom: 1em; padding: .8em; background: var(--surface-raised); border-radius: var(--radius-sm); border-left: 3px solid var(--accent); }
.mission-detail-progress { margin-bottom: 1em; }

/* Steps */
.mission-steps { margin-bottom: 1em; }
.mission-steps-label { font-family: var(--font-ui); font-size: .72rem; font-weight: 700; color: var(--text-3); text-transform: uppercase; letter-spacing: .05em; margin-bottom: .4em; }
.mission-step { display: flex; gap: .6em; padding: .5em .4em; border-bottom: 1px solid var(--border-light); cursor: pointer; transition: background .15s; }
.mission-step:hover { background: var(--accent-bg); }
.mission-step:last-child { border-bottom: none; }
.step-done { opacity: .5; }
.step-done .step-title { text-decoration: line-through; text-decoration-color: var(--border); }
.step-marker { width: 1.6em; height: 1.6em; display: flex; align-items: center; justify-content: center; border-radius: 50%; font-size: .7rem; font-weight: 700; background: var(--accent-bg); color: var(--accent); flex-shrink: 0; margin-top: .1em; }
.step-done .step-marker { background: var(--product-bg); color: var(--product); }
.step-branch .step-marker { border-radius: 4px; }
.step-content { flex: 1; }
.step-title { font-family: var(--font-ui); font-size: .82rem; font-weight: 600; }
.step-meta { font-family: var(--font-ui); font-size: .7rem; color: var(--text-3); }

/* Branch point */
.mission-branch-point { padding: .8em; margin: .5em 0; background: linear-gradient(135deg, var(--accent-bg), var(--surface)); border: 1.5px dashed var(--accent); border-radius: var(--radius); }
.branch-label { font-family: var(--font-ui); font-size: .82rem; font-weight: 700; color: var(--accent); margin-bottom: .2em; }
.branch-desc { font-size: .75rem; color: var(--text-2); margin-bottom: .6em; }
.branch-options { display: flex; flex-direction: column; gap: .4em; }
.branch-option { display: flex; align-items: center; gap: .5em; padding: .5em .7em; background: var(--surface); border: 1.5px solid var(--border); border-radius: var(--radius-sm); cursor: pointer; text-align: left; font-family: var(--font-ui); transition: all .15s; }
.branch-option:hover { border-color: var(--accent); box-shadow: var(--shadow); }
.branch-option.explorer { border-left: 3px solid var(--engineer); }
.branch-option.creator { border-left: 3px solid var(--product); }
.branch-option.thinker { border-left: 3px solid var(--business); }
.branch-icon { font-size: 1.2rem; }
.branch-name { font-size: .78rem; font-weight: 700; min-width: 4em; }
.branch-desc-text { font-size: .72rem; color: var(--text-2); flex: 1; }
.branch-count { font-size: .7rem; color: var(--accent); font-weight: 600; }
.mission-branch-chosen { padding: .5em; margin: .3em 0; background: var(--accent-bg); border-radius: var(--radius-sm); }
.mission-branch-chosen .branch-label { margin: 0; }

/* Rewards */
.mission-reward-earned { text-align: center; padding: 1em; background: linear-gradient(135deg, var(--product-bg), var(--accent-bg)); border-radius: var(--radius); margin-top: .8em; }
.reward-icon { font-size: 2rem; margin-bottom: .3em; }
.reward-text { font-family: var(--font-ui); font-size: .85rem; }
.mission-complete-action { text-align: center; margin-top: .8em; }
.mission-complete-btn { font-family: var(--font-ui); font-size: .9rem; font-weight: 700; color: #fff; background: linear-gradient(135deg, var(--accent), #EC4899); border: none; border-radius: 8px; padding: .6em 1.5em; cursor: pointer; }
.mission-complete-btn:hover { opacity: .9; transform: translateY(-1px); }

/* Mission Wizard Mode */
/* =============================================
   MINI-GAMES
   ============================================= */
.game-block { margin: 1.5em 0; padding: 1em; background: var(--surface); border: 2px solid var(--accent); border-radius: var(--radius); }
.game-header { display: flex; align-items: center; gap: .5em; margin-bottom: .6em; }
.game-icon { font-size: 1.3rem; }
.game-header h4 { flex: 1; font-size: .9rem; }
.game-timer { font-family: var(--font-mono); font-size: .8rem; color: var(--accent); font-weight: 700; }
.game-start-btn { width: 100%; background: var(--accent); color: #fff; border: none; border-radius: 8px; padding: .5em; font-family: var(--font-ui); font-size: .9rem; font-weight: 700; cursor: pointer; }
.game-start-btn:hover { opacity: .9; }
.game-area { min-height: 60px; }
.game-over { text-align: center; padding: .8em; font-size: .85rem; color: var(--text); }
.game-prompt { font-size: .82rem; color: var(--text-2); margin-bottom: .6em; text-align: center; }
.game-score { font-size: .72rem; color: var(--text-3); text-align: center; margin-top: .4em; }

/* Signal Sort */
.game-signal-card { text-align: center; padding: .6em; margin-bottom: .5em; font-size: .88rem; font-weight: 600; background: var(--surface-raised); border-radius: var(--radius-sm); }
.game-buckets { display: grid; grid-template-columns: 1fr 1fr; gap: .4em; }
.game-bucket { padding: .5em; border: 2px solid var(--border); border-radius: var(--radius-sm); font-family: var(--font-ui); font-size: .8rem; font-weight: 600; cursor: pointer; background: var(--surface); }
.game-bucket.strong { border-color: #10B981; color: #065F46; }
.game-bucket.weak { border-color: var(--warn); color: var(--warn-text); }
.game-bucket:hover { opacity: .8; }
.game-correct { background: #D1FAE5 !important; border-color: #10B981 !important; }
.game-wrong { background: #FEE2E2 !important; border-color: #EF4444 !important; }

/* Taste Match */
.game-table { width: 100%; border-collapse: collapse; font-size: .7rem; margin: .4em 0; }
.game-table th, .game-table td { padding: .3em .2em; text-align: center; border-bottom: 1px solid var(--border-light); }
.game-table th { font-weight: 600; color: var(--text-3); font-size: .6rem; }
.game-you td { background: var(--accent-bg); font-weight: 600; }

/* Bubble Pop */
.game-bubble-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: .4em; }
.game-bubble-item { padding: .5em; border: 1.5px solid var(--border); border-radius: var(--radius-sm); font-size: .78rem; cursor: pointer; background: var(--surface); font-family: var(--font-ui); }
.game-bubble-item:hover { border-color: var(--accent); }
.game-bubble-item.in-bubble { background: var(--warn-bg); border-color: var(--warn); }
.game-bubble-item.popped { background: #D1FAE5; border-color: #10B981; opacity: .6; }

/* Pipeline Builder */
.game-pipeline-selected { margin-bottom: .5em; }
.game-pipe-step { padding: .35em .5em; margin-bottom: .2em; background: #D1FAE5; border-radius: var(--radius-sm); font-size: .78rem; font-weight: 500; }
.game-pipeline-options { display: flex; flex-direction: column; gap: .3em; }
.game-pipe-btn { text-align: left; padding: .4em .6em; border: 1.5px solid var(--border); border-radius: var(--radius-sm); font-family: var(--font-ui); font-size: .78rem; cursor: pointer; background: var(--surface); }
.game-pipe-btn:hover { border-color: var(--accent); }

.wizard-container { max-width: 500px; margin: 0 auto; padding: 1em; }
.wizard-progress { height: 6px; background: var(--border); border-radius: 3px; margin-bottom: .3em; overflow: hidden; }
.wizard-progress-fill { height: 100%; background: linear-gradient(90deg, var(--accent), #EC4899); border-radius: 3px; transition: width .4s ease; }
.wizard-progress-label { font-family: var(--font-ui); font-size: .7rem; color: var(--text-3); text-align: center; margin-bottom: 1em; }
.wizard-intro { font-size: .9rem; line-height: 1.55; color: var(--text); padding: .8em; background: linear-gradient(135deg, var(--accent-bg), var(--surface)); border-left: 3px solid var(--accent); border-radius: var(--radius-sm); margin-bottom: 1em; font-style: italic; }
.wizard-block-card { background: var(--surface); border: 1.5px solid var(--border); border-radius: var(--radius); padding: 1.2em; cursor: pointer; transition: all var(--transition); margin-bottom: 1em; }
.wizard-block-card:hover { border-color: var(--accent); box-shadow: var(--shadow); }
.wizard-block-title { font-family: var(--font-ui); font-size: 1rem; font-weight: 700; margin-bottom: .3em; }
.wizard-block-teaser { font-size: .82rem; color: var(--text-2); line-height: 1.45; margin-bottom: .5em; }
.wizard-block-meta { font-family: var(--font-ui); font-size: .7rem; color: var(--text-3); margin-bottom: .6em; }
.wizard-read-btn { width: 100%; background: var(--accent); color: #fff; border: none; border-radius: 8px; padding: .5em; font-family: var(--font-ui); font-size: .85rem; font-weight: 600; cursor: pointer; }
.wizard-read-btn:hover { opacity: .9; }
.wizard-nav { display: flex; justify-content: space-between; align-items: center; margin-top: .5em; }
.wizard-nav-btn { font-family: var(--font-ui); font-size: .8rem; font-weight: 600; color: var(--accent); background: var(--accent-bg); border: 1px solid var(--accent); border-radius: 6px; padding: .35em .8em; cursor: pointer; }
.wizard-nav-btn:hover { background: var(--accent); color: #fff; }
.wizard-nav-next { background: var(--accent); color: #fff; }

/* Boss quiz */
.boss-card { text-align: center; padding: 1.2em; background: var(--surface); border: 2px solid var(--accent); border-radius: var(--radius); }
.boss-icon { font-size: 2.5rem; margin-bottom: .3em; }
.boss-title { font-family: var(--font-ui); font-size: 1rem; font-weight: 800; color: var(--accent); margin-bottom: .5em; }
.boss-question { font-size: .88rem; line-height: 1.5; margin-bottom: .8em; text-align: left; }
.boss-answer { width: 100%; border: 1.5px solid var(--border); border-radius: var(--radius-sm); padding: .6em; font-family: var(--font-body); font-size: .85rem; resize: vertical; background: var(--bg); color: var(--text); }
.boss-answer:focus { border-color: var(--accent); outline: none; }
.boss-actions { margin-top: .6em; }
.boss-submit { background: linear-gradient(135deg, #EF4444, #F59E0B); color: #fff; border: none; border-radius: 8px; padding: .5em 1.5em; font-family: var(--font-ui); font-size: .9rem; font-weight: 700; cursor: pointer; }
.boss-submit:hover { opacity: .9; transform: translateY(-1px); }
.boss-hint { margin-top: .6em; padding: .6em; border-radius: var(--radius-sm); font-size: .82rem; text-align: left; }
.boss-pass { background: #D1FAE5; color: #065F46; border: 1px solid #10B981; }
.boss-retry { background: var(--warn-bg); color: var(--warn-text); border: 1px solid var(--warn); }

/* Mission intro banner in read view */
.mission-intro-banner { display: flex; align-items: flex-start; gap: .5em; padding: .6em .8em; margin-bottom: 1em; background: linear-gradient(135deg, var(--accent-bg), #F5F3FF); border: 1px solid var(--accent); border-radius: var(--radius-sm); font-size: .82rem; line-height: 1.4; color: var(--text); }
.mission-intro-text { flex: 1; font-style: italic; }
.mission-intro-close { background: none; border: none; font-size: 1.1rem; color: var(--text-3); cursor: pointer; padding: 0; line-height: 1; flex-shrink: 0; }

/* Topic tags on cards */
.card-topics { display: flex; gap: .2em; flex-wrap: wrap; }
.card-topic { font-family: var(--font-ui); font-size: .7rem; padding: .15em .4em; border-radius: 3px; background: var(--border-light); color: var(--text-3); cursor: pointer; transition: all var(--transition); }
.card-topic:hover { background: var(--accent-bg); color: var(--accent); }


/* Mobile chat panel (slide-up) */
/* old mobile chat removed — chat is now a tab view */
.chat-head { display: flex; justify-content: space-between; align-items: center; padding: .6em 1em; border-bottom: 1px solid var(--border); font-family: var(--font-ui); font-size: .85rem; font-weight: 700; }
.chat-head button { font-size: 1rem; color: var(--text-3); padding: .2em; }
.chat-messages { flex: 1; overflow-y: auto; padding: .8em; display: flex; flex-direction: column; gap: .5em; }
.chat-msg { font-family: var(--font-ui); font-size: .82rem; line-height: 1.45; padding: .6em .8em; border-radius: 12px; max-width: 85%; }
.chat-msg.bot { background: var(--border-light); color: var(--text); align-self: flex-start; border-bottom-left-radius: 4px; }
.chat-msg.user { background: var(--accent); color: #fff; align-self: flex-end; border-bottom-right-radius: 4px; }
.chat-msg a { color: var(--accent); font-weight: 600; }
.chat-msg.bot a { color: var(--accent); }
.chat-msg i { color: var(--text-2); font-size: .78rem; }
.chat-input-wrap { display: flex; gap: .4em; padding: .5em .8em; border-top: 1px solid var(--border); }
.chat-input-wrap input { flex: 1; border: 1px solid var(--border); border-radius: 8px; padding: .4em .7em; font-family: var(--font-ui); font-size: .82rem; background: var(--bg); color: var(--text); outline: none; }
.chat-input-wrap input:focus { border-color: var(--accent); }
.chat-input-wrap button { background: var(--accent); color: #fff; border-radius: 8px; padding: .4em .7em; font-size: .9rem; }
/* fab-chat removed — chat is a bottom tab now */

@media (min-width: 900px) {
  /* chat is a tab view, no special desktop handling needed */
}
@media (max-width: 500px) {
  .chat-view-inner { height: calc(100vh - var(--topbar-h) - var(--bottomnav-h) - 42px); }
  .topic-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
}

/* Responsive visual map */
@media (max-width: 600px) {
  .visual-map { min-height: 200px; }
}

/* =============================================
   PROFILE VIEW
   ============================================= */
.profile-inner { padding: 1em; max-width: 500px; margin: 0 auto; }
.profile-section { margin-bottom: 1.5em; }
.profile-section h3 { font-family: var(--font-ui); font-size: .9rem; font-weight: 700; margin-bottom: .8em; }
/* Account / Auth */
.auth-card { padding: 1em; background: var(--surface); border: 1.5px solid var(--border); border-radius: var(--radius); }
.auth-card h3 { margin-bottom: .2em; }
.auth-logged-in { display: flex; align-items: center; gap: .8em; flex-wrap: wrap; }
.auth-avatar { width: 40px; height: 40px; border-radius: 50%; background: linear-gradient(135deg, var(--accent), #EC4899); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 1.1rem; flex-shrink: 0; }
.auth-info { flex: 1; min-width: 0; }
.auth-name { font-family: var(--font-ui); font-weight: 700; font-size: .9rem; }
.auth-email { font-family: var(--font-ui); font-size: .7rem; color: var(--text-3); }
.auth-actions { display: flex; gap: .4em; flex-shrink: 0; }
.auth-input { display: block; width: 100%; border: 1.5px solid var(--border); border-radius: 8px; padding: .5em .7em; font-family: var(--font-ui); font-size: .85rem; background: var(--bg); color: var(--text); margin-bottom: .4em; outline: none; }
.auth-input:focus { border-color: var(--accent); }
.auth-btns { display: flex; gap: .4em; margin-top: .3em; }
.auth-primary-btn { flex: 1; padding: .5em; border-radius: 8px; background: var(--accent); color: #fff; font-family: var(--font-ui); font-size: .82rem; font-weight: 700; }
.auth-primary-btn:hover { opacity: .9; }
.auth-secondary-btn { flex: 1; padding: .5em; border-radius: 8px; border: 1.5px solid var(--border); color: var(--text-2); font-family: var(--font-ui); font-size: .82rem; font-weight: 600; }
.auth-secondary-btn:hover { border-color: var(--accent); color: var(--accent); }
.auth-sync-btn { padding: .3em .7em; border-radius: 6px; background: var(--accent); color: #fff; font-family: var(--font-ui); font-size: .72rem; font-weight: 600; }
.auth-logout-btn { padding: .3em .7em; border-radius: 6px; border: 1px solid var(--border); color: var(--text-3); font-family: var(--font-ui); font-size: .72rem; }
.auth-logout-btn:hover { color: #dc2626; border-color: #dc2626; }
.auth-error { font-family: var(--font-ui); font-size: .75rem; color: #dc2626; margin-top: .4em; min-height: 1.2em; }

/* Gamification */
.gami-hero { display: flex; align-items: center; gap: .8em; padding: 1em; background: linear-gradient(135deg, var(--accent-bg), var(--surface)); border: 2px solid var(--accent); border-radius: var(--radius); margin-bottom: 1em; }
.gami-level { font-family: var(--font-ui); font-size: 1.8rem; font-weight: 900; color: var(--accent); flex-shrink: 0; width: 3em; text-align: center; }
.gami-info { flex: 1; }
.gami-title { font-family: var(--font-ui); font-size: 1rem; font-weight: 800; margin-bottom: .3em; }
.gami-xp-bar { height: 8px; background: var(--border); border-radius: 4px; overflow: hidden; margin-bottom: .2em; }
.gami-xp-fill { height: 100%; background: linear-gradient(90deg, var(--accent), #EC4899); border-radius: 4px; transition: width .5s ease; }
.gami-xp-text { font-family: var(--font-ui); font-size: .7rem; color: var(--text-3); }
.gami-streak { font-family: var(--font-ui); font-size: .82rem; font-weight: 700; color: #EF4444; text-align: center; flex-shrink: 0; }

.gami-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: .4em; margin-bottom: 1.2em; }
.gami-stat { text-align: center; padding: .5em; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); }
.gs-num { display: block; font-family: var(--font-ui); font-size: 1.2rem; font-weight: 800; color: var(--accent); }
.gs-label { font-family: var(--font-ui); font-size: .7rem; color: var(--text-3); text-transform: uppercase; letter-spacing: .04em; }

.gami-badges { display: flex; flex-wrap: wrap; gap: .4em; margin-bottom: .8em; }
.gami-badge { display: flex; align-items: center; gap: .3em; padding: .3em .6em; border-radius: 20px; font-family: var(--font-ui); font-size: .72rem; border: 1.5px solid var(--border); transition: all var(--transition); }
.gami-badge.earned { background: var(--accent-bg); border-color: var(--accent); }
.gami-badge.locked { opacity: .4; }
.badge-icon { font-size: .85rem; }
.badge-name { font-weight: 600; }
.stat-row { display: flex; justify-content: space-between; padding: .4em 0; font-family: var(--font-ui); font-size: .85rem; }
.stat-val { font-weight: 600; color: var(--accent); }
.voice-bars { display: flex; flex-direction: column; gap: .4em; }
.voice-bar { display: flex; align-items: center; gap: .6em; font-family: var(--font-ui); font-size: .8rem; }
.voice-bar-fill { height: 6px; border-radius: 3px; transition: width .3s ease; }
.voice-bar-label { min-width: 5em; flex-shrink: 0; font-weight: 600; text-transform: uppercase; font-size: .7rem; }
.saved-list { display: flex; flex-direction: column; gap: .3em; }
.saved-item { font-family: var(--font-ui); font-size: .85rem; padding: .5em .7em; border-radius: var(--radius-sm); background: var(--border-light); cursor: pointer; transition: background var(--transition); }
.saved-item:hover { background: var(--accent-bg); }

/* (the legacy floating .feedback-bar toast was removed: the end-of-block steering
   bar inherited its fixed position/transform and floated over the takeaways —
   the steering bar is .telling-feedback now and sits in normal flow) */

/* =============================================
   SETTINGS DRAWER
   ============================================= */
.settings-drawer { position: fixed; inset: 0; z-index: 400; display: none; }
.settings-drawer.open { display: flex; }
.settings-drawer::before { content: ''; position: absolute; inset: 0; background: rgba(0,0,0,.3); }
.settings-inner { position: absolute; right: 0; top: 0; bottom: 0; width: 280px; background: var(--surface); padding: 1.2em; overflow-y: auto; animation: slideLeft .25s ease; z-index: 1; }
.settings-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5em; }
.settings-head h3 { font-family: var(--font-ui); font-size: .9rem; font-weight: 700; }
.settings-head button { font-size: 1.2rem; color: var(--text-2); }
.sg { margin-bottom: 1.2em; }
.sg > label { font-family: var(--font-ui); font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--text-3); display: block; margin-bottom: .4em; }
.sg-row { display: flex; gap: .3em; flex-wrap: wrap; }
.sg-opt { font-family: var(--font-ui); font-size: .78rem; padding: .35em .7em; border-radius: 6px; border: 1.5px solid var(--border); color: var(--text-2); transition: all var(--transition); }
.sg-opt:hover { border-color: var(--text-2); }
.sg-opt.active { border-color: var(--accent); background: var(--accent-bg); color: var(--accent); font-weight: 600; }
.sg-info { font-family: var(--font-ui); font-size: .8rem; color: var(--text-3); }

/* =============================================
   ANIMATIONS
   ============================================= */
@keyframes fadeUp { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideUp { from { opacity: 0; transform: translate(-50%, 10px); } to { opacity: 1; transform: translate(-50%, 0); } }
@keyframes slideLeft { from { transform: translateX(100%); } to { transform: translateX(0); } }
.fade-up { animation: fadeUp .3s ease; }

/* =============================================
   DESKTOP (> 900px)
   ============================================= */
@media (min-width: 900px) {
  #appMain { padding-bottom: var(--bottomnav-h); }
  .topbar { padding: 0 1.5em; }
  .card { flex: 0 0 280px; }
  .card-hero { flex: 0 0 380px; }
  .shelf-scroll { padding: 0 1.5em .5em; }
  .shelf-head { padding: 0 1.5em; }
  .read-layout { padding: 0 1.5em; }
  .read-pane { padding: 1.5em 0 4em; }
  /* Desktop: show nav links in topbar instead of bottom */
  .topbar::after { content: ''; } /* placeholder */
}

@media (max-width: 500px) {
  :root { --fs: 1rem; }
  .onboarding-card h1 { font-size: 1.6rem; }
  .card { flex: 0 0 220px; min-height: 120px; padding: .8em; }
  .card-hero { flex: 0 0 calc(100% - 2em); }
}
/* Larger screens */
@media (min-width: 600px) {
  .onboarding-card { max-width: 580px; }
  .intro-title { font-size: 2.2rem; }
  .intro-tagline { font-size: .95rem; }
  .intro-author-name { font-size: 1.3rem; }
  .intro-hero { max-width: 520px; }
  .home-modes { max-width: 520px; grid-template-columns: repeat(4, 1fr); }
  .intro-voices { max-width: 420px; margin-left: auto; margin-right: auto; }
}
@media (min-width: 900px) {
  .onboarding-card { max-width: 660px; }
  .intro-title { font-size: 2.5rem; }
  .intro-hero { max-width: 580px; }
  .home-modes { max-width: 580px; gap: .6em; }
  .home-mode { padding: .8em .5em; }
  .home-mode-label { font-size: .82rem; }
}
@media print { .topbar, .bottom-nav, .telling-feedback, .q-block, .settings-drawer, .search-overlay, .game-block { display: none !important; } #appMain { padding: 0; } .read-pane { max-width: 100%; } }

/* ===== Steering knobs + generation (living book) ===== */
.steer-bar { display: flex; align-items: center; gap: .4em; flex-wrap: wrap; margin: .3em 0 .8em; font-size: .72rem; }
.steer-label { opacity: .7; cursor: help; }
.steer-chip { font-size: .7rem; padding: .25em .6em; border-radius: 999px; border: 1px solid var(--border); background: var(--bg-2, var(--bg)); color: var(--text-2); cursor: pointer; transition: all .15s; }
.steer-chip:hover { border-color: var(--accent); color: var(--accent); }
.steer-lens { appearance: none; max-width: 7.5em; }
.steer-variants { font-size: .7rem; color: var(--text-3); margin-left: auto; }
.steer-gen { border-color: var(--accent); color: var(--accent); font-weight: 600; }
.variant-notice { display: flex; align-items: center; justify-content: space-between; gap: .6em; flex-wrap: wrap; font-size: .72rem; color: var(--text-2); background: var(--bg-2, rgba(125,125,125,.06)); border: 1px dashed var(--border); border-radius: 10px; padding: .45em .7em; margin: .6em 0 .4em; }
.gen-badge { font-size: .7rem; color: var(--warn, #D97706); border: 1px solid currentColor; border-radius: 999px; padding: .05em .5em; margin-left: .4em; white-space: nowrap; }
.gen-offer { font-size: .74rem; color: var(--text-2); background: var(--bg-2, rgba(125,125,125,.06)); border: 1px dashed var(--accent); border-radius: 10px; padding: .5em .7em; margin: .3em 0 .7em; display: flex; align-items: center; gap: .6em; flex-wrap: wrap; }
.gen-spinner { animation: genPulse 1.2s ease-in-out infinite; }
@keyframes genPulse { 0%,100% { opacity: .55; } 50% { opacity: 1; } }
.share-consent { border: 1.5px solid var(--accent); border-radius: 12px; padding: .8em; margin: .6em 0; font-size: .78rem; background: var(--bg-2, rgba(125,125,125,.05)); }
.share-consent b { color: var(--accent); }
.share-consent .note-actions { margin-top: .5em; }

/* ===== Tellings panel + end-of-block feedback (living book, iteration 2) ===== */
.tellings-indicator { margin: .2em 0 .6em; }
.tellings-panel { border: 1.5px solid var(--border); border-radius: 12px; padding: .6em .8em; margin-top: .4em; background: var(--bg-2, rgba(125,125,125,.04)); font-size: .75rem; }
.tellings-title { font-weight: 700; font-size: .78rem; margin-bottom: .4em; }
.tellings-miss { color: var(--warn, #D97706); border: 1px dashed currentColor; border-radius: 8px; padding: .35em .6em; margin-bottom: .45em; font-size: .72rem; }
.telling-row { display: flex; align-items: center; gap: .45em; flex-wrap: wrap; padding: .3em 0; border-top: 1px solid var(--border); }
.telling-row:first-of-type { border-top: none; }
.telling-row.current { opacity: .75; }
.telling-title { font-weight: 600; }
.telling-chip { font-size: .7rem; border: 1px solid var(--border); border-radius: 999px; padding: .05em .5em; color: var(--text-2); white-space: nowrap; }
.telling-badge { font-size: .7rem; font-weight: 700; border: 1px solid; border-radius: 4px; padding: .05em .35em; letter-spacing: .5px; white-space: nowrap; }
.tellings-gen { display: flex; align-items: center; gap: .5em; flex-wrap: wrap; margin-top: .5em; padding-top: .5em; border-top: 1px dashed var(--border); font-size: .73rem; color: var(--text-2); }
.telling-feedback { justify-content: flex-start; border-top: 1px dashed var(--border); padding-top: .6em; margin-top: 1em; }
.telling-feedback .steer-label { font-size: .75rem; color: var(--text-2); }

/* Boss AI examiner */
.boss-examiner-note { font-size: .7rem; color: var(--text-3); margin-left: .6em; }
.boss-score-bar { height: 8px; background: var(--border); border-radius: 4px; overflow: hidden; margin: .3em 0 .15em; }
.boss-score-fill { height: 100%; border-radius: 4px; transition: width .6s ease; }

/* Living book coverage map */
.covmap-intro { padding: .4em .2em .8em; }
.covmap { border-collapse: collapse; font-size: .72rem; width: 100%; }
.covmap th { padding: .3em .45em; font-size: .7rem; color: var(--text-2); text-align: center; }
.covmap th div { font-size: .7rem; font-weight: 400; }
.covmap-chapter td { font-weight: 700; font-size: .7rem; color: var(--accent); padding: .7em .3em .2em; }
.covmap-concept { padding: .22em .4em; cursor: pointer; white-space: nowrap; max-width: 16em; overflow: hidden; text-overflow: ellipsis; }
.covmap-concept:hover { color: var(--accent); }
.covmap-cell { text-align: center; padding: .15em .3em; border: 1px solid var(--border); cursor: pointer; min-width: 3em; }
.covmap-cell:hover { background: var(--bg-2, rgba(125,125,125,.07)); }
.covmap-gap button { color: var(--text-3); font-size: .8rem; width: 100%; }
.covmap-gap button:hover { color: var(--accent); }
.covmap-mylens { background: rgba(124, 58, 237, .06); }

/* ===== Remix (reader-tuned passages) ===== */
/* Reader edits: a changed/added REGION (markers on their own lines, so lists and
   tables inside it render normally) and diagrams inserted right where asked. */
.rx-region { position: relative; background: rgba(217, 119, 6, .10); border-left: 3px solid #D97706; border-radius: 0 6px 6px 0; padding: .35em .7em .35em .8em; margin: .8em 0; }
.rx-region::before { content: "your edit"; position: absolute; top: -.62em; left: .7em; font-size: .7rem; letter-spacing: .08em; text-transform: uppercase; color: #B45309; background: var(--card, #fff); padding: 0 .35em; border-radius: 4px; }
.rx-region > :first-child { margin-top: 0; }
.rx-region > :last-child { margin-bottom: 0; }
.md-figure.diagram-inline { margin: .9em 0; }
.md-figure.diagram-inline svg { width: 100%; height: auto; border: 1px solid var(--border); border-radius: 10px; background: #fff; }

/* Point-and-edit affordances: every paragraph offers "rewrite this" and every
   gap between paragraphs offers "add here" — no text selection needed. */
.para-tools { position: absolute; right: .1em; top: -.15em; display: flex; gap: .2em; opacity: 0; transition: opacity .12s; }
.para-host { position: relative; }
.para-host:hover .para-tools, .para-tools:focus-within { opacity: 1; }
.para-tools button { border: 1px solid var(--border); background: var(--card, #fff); color: var(--text-2, #666); border-radius: 6px; font-size: .7rem; line-height: 1; padding: .22em .4em; cursor: pointer; }
.para-tools button:hover { border-color: var(--accent); color: var(--accent); }
.gap-add { display: block; width: 100%; border: 0; background: none; padding: 0; margin: -.35em 0; height: 1.1em; cursor: pointer; opacity: 0; transition: opacity .12s; }
.gap-add:hover, .gap-add:focus { opacity: 1; }
.gap-add span { display: block; border-top: 1.5px dashed var(--accent); position: relative; }
.gap-add span::after { content: "+ add here"; position: absolute; left: 50%; transform: translate(-50%, -50%); background: var(--card, #fff); color: var(--accent); font-size: .6rem; padding: 0 .5em; white-space: nowrap; }

mark.remix-mark { background: rgba(217, 119, 6, .16); border-bottom: 2px solid #D97706; border-radius: 2px; padding: 0 .1em; color: inherit; }
.remix-form textarea:focus { border-color: var(--accent); outline: none; }
.gen-wish { flex: 1 1 220px; min-width: 180px; padding: .3em .55em; border-radius: 999px; border: 1px solid var(--border); background: var(--bg); color: var(--text); font-size: .7rem; }
.gen-wish:focus { border-color: var(--accent); outline: none; }
.highlight-popup button { min-width: 2em; }

/* Diagram remix */
.diagram-wrap { position: relative; }
.diagram-remix-btn { position: absolute; top: .4em; right: .4em; opacity: 0; transition: opacity .15s; font-size: .85rem; background: var(--bg); border: 1.5px solid var(--border); border-radius: 999px; width: 2em; height: 2em; cursor: pointer; z-index: 2; }
.diagram-wrap:hover .diagram-remix-btn { opacity: 1; }
.diagram-remix-btn:hover { border-color: #D97706; }
.diagram-remixed { outline: 2px dashed rgba(217,119,6,.45); outline-offset: 4px; border-radius: 8px; }

/* Onboarding: living-book opt-in + pick hint */
.intro-onboard-hint { font-size: .72rem; color: var(--text-2); margin: .3em auto .8em; max-width: 480px; min-height: 2em; }
.intro-livingbook { display: flex; gap: .5em; align-items: flex-start; max-width: 480px; margin: .4em auto 1em; text-align: left; border: 1.5px dashed #10B981; border-radius: 12px; padding: .55em .7em; }

/* Reading DNA */
.dna-row { display: flex; gap: .7em; align-items: flex-start; margin: .45em 0; }
.dna-label { font-size: .7rem; color: var(--text-2); width: 8.5em; flex-shrink: 0; padding-top: .1em; }
.dna-bars { flex: 1; display: flex; flex-direction: column; gap: .2em; }
.dna-bar-line { display: flex; align-items: center; gap: .5em; }
.dna-val { font-size: .7rem; width: 11em; flex-shrink: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dna-track { flex: 1; height: 6px; background: var(--border); border-radius: 3px; }
.dna-fill { height: 100%; border-radius: 3px; background: var(--accent); }
.dna-pct { font-size: .7rem; color: var(--text-3); width: 2.6em; text-align: right; }
.dna-contrib { font-size: .74rem; margin-top: .7em; padding-top: .6em; border-top: 1px dashed var(--border); }

/* Tellings dimension picker (subspace explorer) */
.tellings-dims { display: flex; gap: .3em; flex-wrap: wrap; margin: .4em 0 .3em; padding-bottom: .35em; border-bottom: 1px dashed var(--border); }
.tellings-dims .dim-active { border-color: var(--accent); color: var(--accent); font-weight: 700; }
/* compose grid (tellings panel v4): selected = filled, current telling = ring + ◉ */
.dimval.dim-active { background: var(--accent) !important; color: #fff !important; border-color: var(--accent) !important; font-weight: 700; }
.dimval.dim-active .dimcount { background: rgba(255,255,255,.25); color: #fff; }
.legend-active { background: var(--accent); color: #fff; border-radius: 4px; padding: 0 .35em; }
.tellings-dimvals { display: flex; gap: .3em; flex-wrap: wrap; margin: .2em 0 .4em; }
.dimval.dim-current { border-color: #10B981; box-shadow: inset 0 0 0 1px #10B981; }
.dimval.dim-empty { border-style: dashed; color: var(--text-3); }
.dimcount { font-size: .7rem; background: var(--border); border-radius: 999px; padding: 0 .4em; }

/* Coverage map v2: chapter sections, per-cell inspector */
.covmap-chapter-sec { margin: .5em 0; }
.covmap-chapter-sec summary { font-size: .74rem; font-weight: 700; color: var(--accent); cursor: pointer; padding: .3em 0; }
.covmap-mini { font-size: .7rem; color: var(--text-3); font-weight: 400; }
.cov-inspector { border: 1.5px solid var(--accent); border-radius: 12px; padding: .6em .8em; margin: .5em 0 .8em; background: var(--bg-2, rgba(124,58,237,.04)); font-size: .75rem; }

/* Feedback bar lifecycle */
.telling-feedback { position: relative; padding-right: 2em; transition: opacity .6s ease, max-height .6s ease .3s, margin .6s ease .3s, padding .6s ease .3s; max-height: 12em; overflow: hidden; }
.telling-feedback.fb-away { opacity: 0; max-height: 0; margin: 0; padding-top: 0; padding-bottom: 0; pointer-events: none; border: none; }
.fb-close { position: absolute; top: .15em; right: .2em; font-size: 1rem; line-height: 1; color: var(--text-3); background: none; border: none; cursor: pointer; padding: .15em .3em; }
.fb-close:hover { color: var(--text); }

/* Coverage map v2.1: count badges + chapter heat strip */
.covcount { display: inline-block; min-width: 1.5em; padding: .05em .3em; border-radius: 999px; color: #fff; font-size: .7rem; font-weight: 700; }
.cov-heatrow { margin-left: .6em; display: inline-flex; gap: 2px; vertical-align: middle; }
.cov-heat { display: inline-flex; align-items: center; justify-content: center; width: 1.5em; height: 1.15em; border-radius: 3px; font-size: .7rem; }

/* Keep inline forms/panels clear of the bottom nav when scrolled into view */
.share-consent, .remix-form, .tellings-panel, .gen-offer, .cov-inspector { scroll-margin-bottom: 110px; }
.share-consent { margin-bottom: .8em; }

/* Editor track */
.editor-badge { display: inline-block; background: linear-gradient(135deg, #7C3AED, #4C1D95); color: #fff; font-size: .7rem; font-weight: 800; letter-spacing: .08em; padding: .18em .55em; border-radius: 999px; vertical-align: middle; }

/* Composed generate target row in the tellings panel */
.tellings-target { display: flex; flex-wrap: wrap; align-items: center; gap: .3em; margin: .5em 0 .2em; padding-top: .45em; border-top: 1px dashed var(--border); }

/* Tellings compose form (panel v3) */
.tellings-compose { border-top: 1px dashed var(--border); margin-top: .5em; padding-top: .2em; }
.tellings-compose .dna-label { min-width: 6.2em; font-size: .7rem; }
.tellings-compose .steer-chip.dimval { font-size: .7rem; padding: .12em .45em; }

/* Remix accept flow */
.remix-decision { display: flex; flex-wrap: wrap; align-items: center; gap: .45em; padding: .5em .7em; margin-bottom: .6em; border: 2px solid var(--accent); border-radius: 10px; background: var(--bg); font-size: .78rem; position: sticky; top: 52px; z-index: 5; }
.override-bar { font-size: .7rem; color: var(--text-3); padding: .3em .55em; border: 1px dashed var(--accent); border-radius: 8px; margin-bottom: .5em; background: color-mix(in srgb, var(--accent) 6%, transparent); }
.override-bar a { color: var(--accent); }

/* Remix preview diff */
.rx-diff { flex-basis: 100%; font-size: .7rem; line-height: 1.45; border-top: 1px dashed var(--border); padding-top: .35em; }
.rx-old { color: #B91C1C; text-decoration: line-through; opacity: .8; }
.rx-new { color: #065F46; font-weight: 600; }

/* Floating remix decision sheet */
.remix-float { position: fixed; left: 50%; transform: translateX(-50%); bottom: 74px; z-index: 300; width: min(560px, calc(100vw - 24px)); background: var(--bg); border: 2px solid var(--accent); border-radius: 14px; padding: .7em .9em; font-size: .8rem; box-shadow: 0 8px 30px rgba(0,0,0,.18); }

/* Improve entry — the one button every editor path starts from */
.improve-btn { border: 1.5px solid var(--accent); color: var(--accent); background: transparent; border-radius: 8px; padding: .25em .6em; font-size: .72rem; font-weight: 700; cursor: pointer; }
.improve-btn:hover { background: color-mix(in srgb, var(--accent) 10%, transparent); }

/* Tile artwork: the item's own visual, translucent behind the text */
.card { position: relative; overflow: hidden; }
.card-art { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: right 30%; opacity: .38; pointer-events: none; user-select: none;
  -webkit-mask-image: linear-gradient(105deg, transparent 8%, rgba(0,0,0,.5) 42%, #000 78%);
  mask-image: linear-gradient(105deg, transparent 8%, rgba(0,0,0,.5) 42%, #000 78%); }
.card-has-art > *:not(.card-art) { position: relative; z-index: 1; }
.card-has-art .card-title, .card-has-art .card-teaser { text-shadow: 0 1px 6px var(--surface), 0 0 2px var(--surface); }
[data-theme="dark"] .card-art { opacity: .30; }

/* Tellings coverage strip */
.tstrip { display: flex; flex-wrap: wrap; align-items: center; gap: .3em; margin: .3em 0 .2em; }
.tstrip-chip { width: 30px; height: 30px; border-radius: 8px; border: 2px solid var(--sc); background: color-mix(in srgb, var(--sc) 10%, transparent); cursor: pointer; font-size: .85rem; line-height: 1; display: inline-flex; align-items: center; justify-content: center; padding: 0; }
.tstrip-chip:hover { background: color-mix(in srgb, var(--sc) 25%, transparent); transform: translateY(-1px); }
.tstrip-current { box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--sc); cursor: default; }
.tstrip-hint { font-size: .7rem; color: var(--text-3); margin-left: .3em; }

/* Recently viewed history */
.history-list { display: flex; flex-direction: column; gap: .25em; }
.hist-row { display: flex; flex-direction: column; align-items: flex-start; gap: .05em; text-align: left; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: .4em .6em; cursor: pointer; }
.hist-row:hover { border-color: var(--accent); }
.hist-title { font-size: .78rem; font-weight: 600; color: var(--text); }
.hist-meta { font-size: .7rem; color: var(--text-3); }
.hist-edit { font-size: .7rem; }

/* Pairs game: 2x2 grid of term choices */
.game-buckets.game-pairs { display: grid; grid-template-columns: 1fr 1fr; gap: .5em; }
.game-buckets.game-pairs .game-bucket { font-size: .82rem; padding: .55em .6em; }

/* Steering bar waits until the section is read; then eases in */
.steer-bar.telling-feedback.fb-waiting { display: none; }
.steer-bar.telling-feedback { animation: fbEase .35s ease; }
@keyframes fbEase { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .steer-bar.telling-feedback { animation: none; } }

/* =============================================
   v2 reader UX (js/ux.js) — door, Ask the book, Why this?, sheets,
   progress moments, reading-progress strip, mini-board pill
   ============================================= */
/* Door: one screen on a phone, one primary action */
.door-hero { display: block; max-width: min(360px, 80%); max-height: 150px; object-fit: contain; margin: .6em auto .4em; border-radius: 14px; }
.door-picks { margin: .6em 0 .4em; }
.door-label { font-family: var(--font-ui); font-size: .78rem; font-weight: 600; color: var(--text-2); margin: .5em 0 .3em; text-align: center; }
.door-chips.intro-voices { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .35em; margin: 0 auto .4em; max-width: 440px; }
#introGoal.door-chips { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.door-chips .intro-voice { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-height: 40px; }
.door-start { display: block; margin: .9em auto .3em; min-width: min(320px, 100%); }
.door-sub { font-family: var(--font-ui); font-size: .78rem; color: var(--text-3); text-align: center; margin-bottom: .8em; }
.door-more { margin-top: .6em; }
.door-more .home-modes { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .4em; }
.door-more .home-mode { font: inherit; color: inherit; }
.door-feat-title { font-family: var(--font-ui); font-size: .78rem; font-weight: 700; color: var(--text-2); margin: .8em 0 .2em; }
.goal-banner { display: flex; align-items: center; justify-content: space-between; gap: .6em; flex-wrap: wrap; font-family: var(--font-ui); font-size: .82rem; background: var(--accent-bg); border: 1px solid var(--border); border-radius: var(--radius); padding: .6em .8em; margin-bottom: 1em; }
.goal-banner-actions { display: flex; align-items: center; gap: .4em; }
.goal-banner-close { font-size: 1.1rem; color: var(--text-2); padding: .1em .35em; }

/* Ask the book */
.ask-card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: .6em .75em; margin: .1em 0 .5em; }
.ask-card-related { opacity: .92; }
.ask-kicker { font-size: .72rem; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: .04em; }
.ask-title { font-weight: 700; font-size: .92rem; margin: .1em 0 .2em; }
.ask-q { font-style: italic; color: var(--text-2); font-size: .8rem; margin-bottom: .2em; }
.ask-a { font-size: .85rem; line-height: 1.5; margin-bottom: .45em; }
.ask-note { display: inline-block; font-size: .75rem; color: var(--text-3); margin-left: .4em; }
.ask-source { font-size: .72rem; color: var(--text-3); margin-top: .2em; }
.ask-actions { display: flex; flex-direction: column; gap: .3em; margin-top: .5em; }

/* Shelf subtitle + async placeholders */
.shelf-sub { font-family: var(--font-ui); font-size: .8rem; color: var(--text-2); margin: -.2em 0 .3em; padding: 0 1rem; }
.card-skeleton { flex: 0 0 240px; min-height: 130px; display: flex; flex-direction: column; gap: .5em; pointer-events: none; }
.card-skeleton div { height: .8em; border-radius: 4px; background: var(--border-light); animation: skel 1.2s ease-in-out infinite alternate; }
.card-skeleton div:nth-child(2) { width: 80%; height: 1.1em; }
.card-skeleton div:nth-child(3) { width: 60%; }
@keyframes skel { from { opacity: .5; } to { opacity: 1; } }
.card-facets { font-family: var(--font-ui); font-size: .75rem; color: var(--text-2); }
.card-community { border-top: 3px solid var(--warn); flex: 0 0 240px; cursor: pointer; }
.card-kicker-warn { color: var(--warn-text) !important; font-weight: 700; }
[data-theme="dark"] .card-kicker-warn { color: var(--warn) !important; }

/* Why this? — every in-app recommendation explains itself */
.why { font-family: var(--font-ui); font-size: .75rem; margin-top: .35em; position: relative; z-index: 2; }
.why summary { cursor: pointer; color: var(--accent); font-weight: 600; list-style: none; display: inline-block; padding: .15em 0; }
.why summary::-webkit-details-marker { display: none; }
.why summary::before { content: 'ⓘ '; }
.why-body { margin-top: .3em; padding: .45em .6em; border-radius: 8px; background: var(--accent-bg); color: var(--text); line-height: 1.4; }
.why-body ul { padding-left: 1.1em; margin: 0 0 .3em; }
.why-math { font-family: var(--font-mono); font-size: .7rem; color: var(--text-2); margin-bottom: .3em; overflow-wrap: anywhere; }
.why-link { color: var(--accent); font-size: .75rem; text-decoration: underline; padding: 0; }

/* Bottom sheet (section menu, mini-board on phones) */
.ux-sheet-wrap { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 400; display: flex; align-items: flex-end; justify-content: center; animation: fbEase .2s ease; }
.ux-sheet { background: var(--surface-raised); color: var(--text); width: 100%; max-width: 520px; max-height: 85vh; overflow-y: auto; border-radius: 16px 16px 0 0; padding: .9em 1em calc(1em + env(safe-area-inset-bottom)); box-shadow: var(--shadow-lg); }
@media (min-width: 700px) { .ux-sheet-wrap { align-items: center; } .ux-sheet { border-radius: 16px; } }
.sheet-title { font-family: var(--font-ui); font-weight: 700; font-size: .95rem; margin-bottom: .5em; }
.sheet-item { display: flex; align-items: center; gap: .75em; width: 100%; text-align: left; padding: .6em .4em; border-radius: 10px; min-height: 48px; }
.sheet-item:hover, .sheet-item:focus-visible { background: var(--border-light); }
.sheet-icon { font-size: 1.2rem; width: 1.6em; text-align: center; flex-shrink: 0; }
.sheet-text { display: flex; flex-direction: column; font-family: var(--font-ui); font-size: .9rem; }
.sheet-text small { color: var(--text-2); font-size: .78rem; font-weight: 400; }
.sheet-cancel { display: block; width: 100%; margin-top: .4em; padding: .7em; font-family: var(--font-ui); font-weight: 600; color: var(--text-2); border-top: 1px solid var(--border); }
.sheet-note { font-family: var(--font-ui); font-size: .8rem; color: var(--text-2); margin: .5em 0; }
.sheet-primary { display: block; width: 100%; margin-top: .4em; }
.mb-sheet-board svg { width: 100%; height: auto; max-height: 55vh; }

/* Reading-progress strip under the top bar */
.read-progress { position: fixed; top: var(--topbar-h); left: 0; right: 0; height: 2px; z-index: 199; pointer-events: none; opacity: 0; transition: opacity .2s; }
.read-progress.on { opacity: 1; }
.read-progress span { display: block; height: 100%; background: var(--accent); transform-origin: 0 50%; transform: scaleX(0); }

/* Progress moments */
.moment-card { background: var(--surface-raised); border: 2px solid var(--accent); border-radius: var(--radius); padding: 1em 1.1em; margin: 0 0 1.5em; font-family: var(--font-ui); }
.moment-kicker { color: var(--accent); font-weight: 700; font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; }
.moment-title { font-size: 1.15rem; margin: .15em 0 .5em; }
.moment-concepts { display: flex; flex-wrap: wrap; gap: .3em; margin-bottom: .6em; }
.moment-chip { font-size: .75rem; background: var(--accent-bg); color: var(--text); border-radius: 999px; padding: .15em .6em; animation: momentPop .5s ease both; }
.moment-chip:nth-child(2) { animation-delay: .08s; } .moment-chip:nth-child(3) { animation-delay: .16s; } .moment-chip:nth-child(4) { animation-delay: .24s; }
@keyframes momentPop { from { opacity: 0; transform: scale(.8); } to { opacity: 1; transform: none; } }
.moment-label { font-size: .8rem; font-weight: 600; color: var(--text-2); margin-bottom: .3em; }
.moment-check { font-size: .85rem; border-top: 1px solid var(--border); padding: .4em 0; }
.moment-check summary { cursor: pointer; }
.moment-check p { color: var(--text-2); margin-top: .3em; }
.moment-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .5em; margin-top: .7em; }
.moment-next-sub { width: 100%; font-size: .78rem; color: var(--text-2); }
@media (prefers-reduced-motion: reduce) { .moment-chip, .card-skeleton div { animation: none; } }

/* Mini-board pill on phones (the fixed board covered the text) */
.mb-pill { position: fixed; right: 12px; bottom: calc(var(--bottomnav-h) + 12px + env(safe-area-inset-bottom)); z-index: 150; display: flex; align-items: center; gap: .35em; height: 40px; padding: 0 .8em 0 .6em; border-radius: 999px; background: var(--surface-raised); color: var(--accent); border: 1px solid var(--border); box-shadow: var(--shadow-lg); font-family: var(--font-ui); font-size: .78rem; font-weight: 700; }
.mb-pill .ring { flex-shrink: 0; }
.mb-pill.pulse { animation: momentPop .6s ease; }
.xp-ring { display: inline-flex; align-items: center; gap: .3em; }

/* Section footer: labelled actions */
.block-more-btn { font-family: var(--font-ui); font-size: .8rem; font-weight: 600; color: var(--text-2); border: 1px solid var(--border); border-radius: 999px; padding: .35em .8em; min-height: 36px; }
.block-more-btn:hover { color: var(--accent); border-color: var(--accent); }

/* Touch: paragraph edit chips and "+ add here" gaps stay hidden while reading
   (sticky :hover showed them after every tap); editing starts from ⋯ More or a selection */
@media (hover: none) { .para-tools, .gap-add { display: none !important; } }

/* Card art: a quiet thumbnail on the right edge, never behind the words */
.card-art { inset: 0 0 0 auto !important; width: 42% !important; opacity: .22 !important; }
[data-theme="dark"] .card-art { opacity: .16 !important; }

/* System dark preference when the reader has not chosen (Settings → Appearance) */
.theme-row .sg-opt.active { border-color: var(--accent); color: var(--accent); }
.mini-board { position: fixed; z-index: 150; }
.mini-board .mb-board { display: block; width: var(--mb-w, 100px); padding: 4px; background: var(--surface-raised); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow); }
.mini-board .mb-board svg { display: block; width: 100%; height: auto; }
.mini-board .mb-pill { position: static; }
@media (max-width: 1099px) {
  .mini-board { right: 12px; bottom: calc(var(--bottomnav-h) + 12px + env(safe-area-inset-bottom)); }
  .mini-board .mb-board { display: none; }
  /* ring only — the count is already in the topbar — and out of the way while
     scrolling, so it does not sit on the right edge of the text being read */
  .mini-board .mb-pill { width: 40px; padding: 0; justify-content: center; }
  .mini-board .mb-pill > span { display: none; }
  .mini-board { transition: opacity .2s, transform .2s; }
  .mini-board.mb-hide { opacity: 0; transform: translateY(8px); pointer-events: none; }
}
@media (min-width: 1100px) {
  .mini-board { left: max(12px, calc(50% - 340px - var(--mb-w, 100px) - 40px)); bottom: calc(var(--bottomnav-h) + 16px); }
  .mini-board .mb-pill { display: none; }
}
.block-nav { font-size: .75rem; }
.bnav-ch { font-size: inherit; padding: 0; }
.bnav-back { min-width: 32px; min-height: 32px; }
.bnav-core { text-transform: none; letter-spacing: 0; }
.bnav-draft { color: var(--warn-text, #92400E); background: var(--warn-bg, #FEF3C7); }
.block-actions { display: flex; flex-wrap: wrap; gap: .4em; }
.block-more-btn.active { color: var(--accent); border-color: var(--accent); }
.tab.has-due .tab-icon::after { content: ''; position: absolute; top: .1em; right: -.35em; width: 8px; height: 8px; border-radius: 50%; background: var(--warn); box-shadow: 0 0 0 2px var(--surface); }
/* progress pill: calm, readable (the gradient + ring in the same purple measured ~1.3:1) */
.xp-badge { background: var(--accent-bg); color: var(--accent); box-shadow: none; }
.xp-badge:hover { transform: none; box-shadow: 0 0 0 2px var(--accent-bg); }
.xp-badge .xp-ring { display: inline-flex; align-items: center; gap: .35em; color: inherit; font-variant-numeric: tabular-nums; }
/* v2 engine-ux: profile folds, chapter-moment checks */
details.profile-fold > summary { cursor: pointer; font-family: var(--font-ui); font-size: .95rem; font-weight: 700; color: var(--text-2); list-style: none; display: flex; align-items: center; gap: .4em; }
details.profile-fold > summary::-webkit-details-marker { display: none; }
details.profile-fold > summary::after { content: '▾'; margin-left: auto; color: var(--text-3); transition: transform var(--transition); }
details.profile-fold[open] > summary { margin-bottom: .6em; }
details.profile-fold[open] > summary::after { transform: rotate(180deg); }
.profile-hint { font-size: .82rem; color: var(--text-2); margin: 0; }
.moment-checks { margin: .8em 0; }
