/*!
 * HiverGo HiverApps (Project Flint) [26.11.29.05.55]
 * style.css - Dream Scar reader styles. Pairs with index.html + script.js (same stamp, format [YY.MM.DD.HH.mm]).
 */
:root { --app-version: "26.11.29.05.55"; }

:root {
  --bg: #f3ecdc;
  --paper: #f7f1e3;
  --paper-edge: #e7dec9;
  --ink: #221d17;
  --ink-soft: #5f5548;
  --ink-faint: #948774;
  --accent: #9f3c26;
  --accent-glow: rgba(159, 60, 38, 0.25);
  --surface: rgba(251, 247, 238, 0.96);
  --border: rgba(58, 44, 28, 0.13);
  --shadow: 0 18px 48px rgba(32, 22, 12, 0.16);
  --font-body: 'Literata', Georgia, serif;
  --font-display: 'Cormorant Garamond', Georgia, serif;
  --font-ui: 'Inter', system-ui, -apple-system, sans-serif;
  --reader-size: 18px;
  --reader-leading: 1.66;
  --gutter: clamp(10px, 3.125vw, 24px);
  --page-w: 100vw;
  --hl-amber: rgba(235, 183, 58, 0.36);
  --hl-sage: rgba(94, 158, 118, 0.28);
  --hl-crimson: rgba(189, 72, 66, 0.26);
  --hl-slate: rgba(88, 127, 178, 0.28);
}

html[data-theme="ivory"] {
  --bg: #faf7f0;
  --paper: #fdfbf7;
  --paper-edge: #eae4d7;
  --ink: #1e1c19;
  --ink-soft: #635d53;
  --ink-faint: #9a9286;
  --surface: rgba(253, 251, 247, 0.97);
}

html[data-theme="dusk"] {
  --bg: #181a1f;
  --paper: #1e2026;
  --paper-edge: #2c2f38;
  --ink: #dedbd2;
  --ink-soft: #a09b90;
  --ink-faint: #6b6860;
  --accent: #d46a4e;
  --accent-glow: rgba(212, 106, 78, 0.28);
  --surface: rgba(30, 32, 38, 0.96);
  --border: rgba(255, 255, 255, 0.1);
  --shadow: 0 22px 54px rgba(0, 0, 0, 0.55);
}

html[data-theme="pine"] {
  --bg: #0e1312;
  --paper: #131a18;
  --paper-edge: #1f2a26;
  --ink: #d5ded9;
  --ink-soft: #8fa399;
  --ink-faint: #576961;
  --accent: #c98648;
  --accent-glow: rgba(201, 134, 72, 0.28);
  --surface: rgba(19, 26, 24, 0.96);
  --border: rgba(213, 222, 217, 0.11);
  --shadow: 0 22px 54px rgba(0, 0, 0, 0.65);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100dvh;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-ui);
  transition: background 0.35s ease, color 0.35s ease;
}

.ms {
  font-family: 'Material Symbols Rounded', 'Material Symbols Outlined';
  font-weight: normal;
  font-style: normal;
  font-size: 20px;
  line-height: 1;
  letter-spacing: normal;
  text-transform: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  user-select: none;
  font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
}
.ms.filled { font-variation-settings: 'FILL' 1, 'wght' 400, 'GRAD' 0, 'opsz' 24; }

/* Tactile Paper Surface Grain */
#app {
  position: relative;
  width: 100%;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(120% 80% at 50% 0%, rgba(255,255,255,0.08), transparent 60%),
    linear-gradient(90deg, rgba(0,0,0,0.03) 0%, transparent 4%, transparent 96%, rgba(0,0,0,0.03) 100%),
    var(--paper);
  overflow: hidden;
}

#app::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.045;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='1'/%3E%3C/svg%3E");
  z-index: 1;
}

/* Top Minimal HUD */
#top-hud {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: max(8px, env(safe-area-inset-top)) var(--gutter) 8px;
  background: linear-gradient(to bottom, var(--paper) 65%, transparent);
  transform: translateY(-100%);
  opacity: 0;
  transition: transform 0.34s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.26s ease;
  pointer-events: none;
}
#top-hud.visible {
  transform: translateY(0);
  opacity: 1;
  pointer-events: auto;
}

.hud-group { display: flex; align-items: center; gap: 6px; }
.hud-title {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--ink-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 44vw;
}

.icon-btn {
  appearance: none;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink);
  width: 38px;
  height: 38px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.16s cubic-bezier(0.22, 1, 0.36, 1), background 0.2s ease;
}
.icon-btn:hover { background: rgba(128,128,128,0.1); }
.icon-btn:active { transform: scale(0.9); background: rgba(128,128,128,0.16); }
.icon-btn.active { color: var(--accent); background: var(--accent-glow); }

/* Subtle always-available top corner triggers */
#corner-triggers {
  position: fixed;
  top: max(6px, env(safe-area-inset-top));
  left: var(--gutter);
  right: var(--gutter);
  z-index: 25;
  display: flex;
  justify-content: space-between;
  pointer-events: none;
}
.ghost-pill {
  pointer-events: auto;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink-soft);
  height: 32px;
  padding: 0 10px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.03em;
  cursor: pointer;
  opacity: 0.55;
  transition: opacity 0.25s ease, transform 0.18s cubic-bezier(0.22, 1, 0.36, 1);
}
.ghost-pill:hover, .ghost-pill:active { opacity: 1; transform: scale(0.95); }
.ghost-pill .ms { font-size: 16px; }

/* Paginated Stage */
#stage-wrap {
  position: relative;
  z-index: 2;
  flex: 1 1 auto;
  width: 100%;
  min-height: 0;
  padding-top: max(38px, calc(env(safe-area-inset-top) + 28px));
  padding-bottom: max(26px, calc(env(safe-area-inset-bottom) + 18px));
  overflow: hidden;
}

#stage-clip {
  width: 100%;
  height: 100%;
  overflow: hidden;
  position: relative;
}

#pages-track {
  height: 100%;
  width: 100%;
  column-width: var(--page-w);
  column-gap: 0;
  column-fill: auto;
  transform: translateX(0px);
  transition: transform 0.38s cubic-bezier(0.22, 1, 0.36, 1);
  will-change: transform;
}
#pages-track.no-anim { transition: none; }

/* Cover Page (Column 0) */
.cover-page {
  height: 100%;
  break-after: column;
  page-break-after: always;
  padding: 10px max(var(--gutter), calc((100% - 58ch) / 2));
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  text-align: center;
  position: relative;
}

.cover-card {
  width: 100%;
  max-width: 440px;
  flex: 1;
  max-height: 82vh;
  margin: auto 0;
  padding: clamp(22px, 5vw, 40px) clamp(18px, 4vw, 32px);
  border-radius: 8px 16px 16px 8px;
  border: 1px solid rgba(159, 60, 38, 0.25);
  background:
    radial-gradient(circle at 50% 24%, rgba(159, 60, 38, 0.16), transparent 62%),
    linear-gradient(165deg, #171d1b 0%, #101413 55%, #1d1512 100%);
  color: #eee6d8;
  box-shadow:
    -6px 0 0 rgba(255,255,255,0.06) inset,
    0 20px 50px rgba(0, 0, 0, 0.34);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
}

.cover-card::after {
  content: "";
  position: absolute;
  inset: 10px;
  border: 1px solid rgba(238, 230, 216, 0.14);
  border-radius: 4px 12px 12px 4px;
  pointer-events: none;
}

.cover-series {
  font-family: var(--font-ui);
  font-size: 10.5px;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: #c79a6b;
  z-index: 2;
}

.cover-art {
  margin: 12px auto;
  width: min(170px, 38vw);
  height: min(170px, 38vw);
  z-index: 2;
  opacity: 0.92;
}

.cover-title {
  font-family: var(--font-display);
  font-size: clamp(36px, 9vw, 54px);
  font-weight: 700;
  letter-spacing: 0.08em;
  line-height: 1.02;
  margin: 4px 0 8px;
  color: #f6efe2;
  z-index: 2;
}

.cover-sub {
  font-family: var(--font-body);
  font-style: italic;
  font-size: 13.5px;
  color: #b7b0a3;
  line-height: 1.45;
  max-width: 30ch;
  margin: 0 auto 14px;
  z-index: 2;
}

.cover-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  z-index: 2;
}

.btn-primary {
  appearance: none;
  border: none;
  background: var(--accent);
  color: #fff8f0;
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 600;
  padding: 10px 18px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  box-shadow: 0 8px 22px var(--accent-glow);
  transition: transform 0.16s cubic-bezier(0.22, 1, 0.36, 1), filter 0.2s;
}
.btn-primary:active { transform: scale(0.94); }

.btn-ghost {
  appearance: none;
  border: 1px solid rgba(255,255,255,0.22);
  background: rgba(255,255,255,0.06);
  color: #efe8da;
  font-family: var(--font-ui);
  font-size: 12.5px;
  font-weight: 500;
  padding: 9px 15px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: transform 0.16s cubic-bezier(0.22, 1, 0.36, 1), background 0.2s;
}
.btn-ghost:active { transform: scale(0.94); }

.btn-subtle {
  appearance: none;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 12.5px;
  font-weight: 500;
  padding: 8px 13px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.2s;
}
.btn-subtle:hover { background: rgba(128,128,128,0.08); }
.btn-subtle:active { transform: scale(0.95); }

/* Paperback Chapter Typesetting */
.chapter-block {
  break-before: column;
  page-break-before: always;
  padding-inline: max(var(--gutter), calc((100% - 62ch) / 2));
}

.chapter-head {
  padding-top: 1.4em;
  padding-bottom: 1.5em;
  text-align: center;
  break-inside: avoid;
}

.chapter-kicker {
  font-family: var(--font-ui);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 6px;
}

.chapter-title {
  font-family: var(--font-display);
  font-size: clamp(28px, 6.5vw, 38px);
  font-weight: 700;
  line-height: 1.08;
  margin: 0 0 8px;
  color: var(--ink);
}

.chapter-meta {
  font-family: var(--font-body);
  font-style: italic;
  font-size: 12.5px;
  color: var(--ink-soft);
  line-height: 1.4;
}

.chapter-ornament {
  margin: 14px auto 0;
  width: 64px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--ink-faint), transparent);
}

.para-wrap {
  position: relative;
}

.story-p {
  font-family: var(--font-body);
  font-size: var(--reader-size);
  line-height: var(--reader-leading);
  font-optical-sizing: auto;
  color: var(--ink);
  margin: 0;
  text-align: justify;
  hyphens: auto;
  -webkit-hyphens: auto;
  text-indent: 1.45em;
  orphans: 2;
  widows: 2;
  position: relative;
  cursor: text;
}

.story-p.lead-para {
  text-indent: 0;
}
.story-p.lead-para::first-letter {
  font-family: var(--font-display);
  float: left;
  font-size: 3.35em;
  line-height: 0.78;
  padding: 0.08em 0.11em 0 0;
  font-weight: 700;
  color: var(--accent);
}

.scene-break {
  text-align: center;
  font-family: var(--font-display);
  letter-spacing: 0.55em;
  color: var(--ink-faint);
  padding: 1.15em 0;
  user-select: none;
  break-inside: avoid;
}

/* Paragraph Badges (Illustrations / Audio / Edits) */
.para-badges {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  margin-left: 6px;
  vertical-align: middle;
  user-select: none;
}

.p-badge {
  border: none;
  background: var(--accent-glow);
  color: var(--accent);
  width: 22px;
  height: 22px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  transition: transform 0.15s ease;
}
.p-badge:active { transform: scale(0.88); }
.p-badge .ms { font-size: 14px; }
.p-badge.playing {
  background: var(--accent);
  color: #fff;
  animation: pulseGlow 1.3s infinite ease-in-out;
}
@keyframes pulseGlow {
  0%, 100% { box-shadow: 0 0 0 0 var(--accent-glow); }
  50% { box-shadow: 0 0 0 5px transparent; }
}

/* Inline Illustration Plate */
.para-illustration {
  margin: 0.9em 0;
  padding: 8px;
  border: 1px solid var(--border);
  background: rgba(128,128,128,0.04);
  border-radius: 10px;
  break-inside: avoid;
  text-align: center;
}
.para-illustration img {
  display: block;
  max-width: 100%;
  max-height: 36vh;
  margin: 0 auto;
  border-radius: 6px;
  object-fit: contain;
  cursor: zoom-in;
}
.para-illustration figcaption {
  margin-top: 6px;
  font-family: var(--font-body);
  font-style: italic;
  font-size: 12px;
  color: var(--ink-soft);
}

/* Flat Non-Nested Highlights */
mark.hl {
  color: inherit;
  border-radius: 3px;
  padding: 0.04em 0;
  cursor: pointer;
  transition: filter 0.15s ease;
}
mark.hl[data-color="amber"] { background: var(--hl-amber); }
mark.hl[data-color="sage"] { background: var(--hl-sage); }
mark.hl[data-color="crimson"] { background: var(--hl-crimson); }
mark.hl[data-color="slate"] { background: var(--hl-slate); }
mark.hl.has-note {
  border-bottom: 1.5px dashed var(--accent);
}

/* CSS Custom Highlight for tapped word */
::highlight(word-tap) {
  background-color: var(--accent-glow);
  color: var(--ink);
}

#tap-word-pill {
  position: fixed;
  pointer-events: none;
  z-index: 30;
  border-radius: 4px;
  background: var(--accent-glow);
  box-shadow: 0 0 0 2px var(--accent-glow);
  opacity: 0;
  transition: opacity 0.2s ease;
}
#tap-word-pill.show { opacity: 1; }

/* Bottom Progress Bar & Minimal Footer */
#bottom-chrome {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 25;
  padding: 4px var(--gutter) max(6px, env(safe-area-inset-bottom));
  pointer-events: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: linear-gradient(to top, var(--paper) 55%, transparent);
}

.page-footer-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--font-ui);
  font-size: 10.5px;
  color: var(--ink-faint);
  letter-spacing: 0.04em;
}

.progress-track {
  position: relative;
  width: 100%;
  height: 2.5px;
  border-radius: 999px;
  background: var(--border);
  overflow: visible;
}
.progress-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(159, 60, 38, 0.45), var(--accent));
  position: relative;
  transition: width 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}
.progress-fill::after {
  content: "";
  position: absolute;
  right: -3px;
  top: 50%;
  transform: translateY(-50%);
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
}

/* Drawer & Modals */
.scrim {
  position: fixed;
  inset: 0;
  z-index: 55;
  background: rgba(12, 10, 8, 0.44);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.28s ease;
}
.scrim.open { opacity: 1; pointer-events: auto; }

#toc-drawer {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 60;
  width: min(88vw, 390px);
  background: var(--surface);
  border-right: 1px solid var(--border);
  box-shadow: var(--shadow);
  transform: translateX(-104%);
  transition: transform 0.38s cubic-bezier(0.22, 1, 0.36, 1);
  display: flex;
  flex-direction: column;
  padding-top: max(12px, env(safe-area-inset-top));
  padding-bottom: max(12px, env(safe-area-inset-bottom));
}
#toc-drawer.open { transform: translateX(0); }

.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 16px 12px;
  border-bottom: 1px solid var(--border);
}
.drawer-brand {
  display: flex;
  flex-direction: column;
}
.drawer-brand small {
  font-size: 10px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 600;
}
.drawer-brand strong {
  font-family: var(--font-display);
  font-size: 22px;
  line-height: 1.1;
}

.drawer-tabs {
  display: flex;
  gap: 4px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
}
.tab-btn {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--ink-soft);
  font-size: 11.5px;
  font-weight: 600;
  padding: 8px 6px;
  border-radius: 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease, transform 0.15s ease;
}
.tab-btn .ms { font-size: 16px; }
.tab-btn.active {
  background: var(--accent-glow);
  color: var(--accent);
}
.tab-btn:active { transform: scale(0.95); }

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px 14px;
}

.toc-item {
  width: 100%;
  text-align: left;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink);
  padding: 11px 12px;
  border-radius: 12px;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  cursor: pointer;
  opacity: 0;
  transform: translateX(-14px);
  transition:
    transform 0.34s cubic-bezier(0.22, 1, 0.36, 1),
    opacity 0.28s ease,
    background 0.2s ease;
}
#toc-drawer.open .toc-item {
  opacity: 1;
  transform: translateX(0);
}
.toc-item:hover { background: rgba(128,128,128,0.07); }
.toc-item.current {
  background: var(--accent-glow);
  border-color: rgba(159, 60, 38, 0.22);
}
.toc-num {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  display: block;
}
.toc-title {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 600;
  display: block;
  line-height: 1.15;
}
.toc-sub {
  font-size: 11px;
  color: var(--ink-soft);
  display: block;
  margin-top: 2px;
}

/* Add Chapter / Form Controls */
.panel-box {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  margin-top: 10px;
  background: rgba(128,128,128,0.03);
}
.panel-box h4 {
  margin: 0 0 10px;
  font-size: 12.5px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 9px;
}
.field label {
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-soft);
}
.field input, .field textarea {
  width: 100%;
  border: 1px solid var(--border);
  background: var(--paper);
  color: var(--ink);
  border-radius: 8px;
  padding: 8px 10px;
  font-family: var(--font-ui);
  font-size: 13px;
}
.field textarea {
  font-family: var(--font-body);
  min-height: 92px;
  resize: vertical;
  line-height: 1.5;
}

/* Settings Controls */
.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 2px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.theme-swatches {
  display: flex;
  gap: 8px;
}
.swatch {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid var(--border);
  cursor: pointer;
  transition: transform 0.15s ease;
}
.swatch.active { border-color: var(--accent); transform: scale(1.12); }

.switch {
  position: relative;
  width: 42px;
  height: 24px;
  border-radius: 999px;
  background: var(--border);
  border: none;
  cursor: pointer;
  transition: background 0.2s ease;
}
.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 5px rgba(0,0,0,0.22);
  transition: transform 0.22s cubic-bezier(0.22, 1, 0.36, 1);
}
.switch.on { background: var(--accent); }
.switch.on::after { transform: translateX(18px); }

/* Bottom Sheets (Dictionary & Paragraph Studio) */
.bottom-sheet {
  position: fixed;
  left: 50%;
  bottom: 0;
  z-index: 65;
  width: min(100vw, 620px);
  max-height: 78dvh;
  background: var(--surface);
  border-top: 1px solid var(--border);
  border-radius: 20px 20px 0 0;
  box-shadow: var(--shadow);
  padding: 10px 18px max(16px, env(safe-area-inset-bottom));
  transform: translate(-50%, 105%);
  transition: transform 0.36s cubic-bezier(0.22, 1, 0.36, 1);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.bottom-sheet.open { transform: translate(-50%, 0); }

.sheet-handle {
  width: 38px;
  height: 4px;
  border-radius: 999px;
  background: var(--ink-faint);
  opacity: 0.45;
  margin: 0 auto 10px;
  flex-shrink: 0;
}
.sheet-scroll { overflow-y: auto; flex: 1; padding-right: 2px; }

.dict-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}
.dict-word {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 700;
  line-height: 1.05;
  margin: 0;
}
.dict-phonetic {
  font-size: 13px;
  color: var(--ink-soft);
  margin-top: 2px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.dict-pos {
  display: inline-block;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent);
  margin: 10px 0 4px;
}
.dict-def {
  font-family: var(--font-body);
  font-size: 14.5px;
  line-height: 1.5;
  margin: 0 0 6px;
}
.dict-ex {
  font-family: var(--font-body);
  font-style: italic;
  font-size: 13px;
  color: var(--ink-soft);
  margin: 0 0 8px;
  padding-left: 10px;
  border-left: 2px solid var(--accent-glow);
}

/* Floating Selection Bar */
#selection-bar {
  position: fixed;
  z-index: 50;
  left: 50%;
  bottom: max(48px, calc(env(safe-area-inset-bottom) + 40px));
  transform: translate(-50%, 18px) scale(0.94);
  opacity: 0;
  pointer-events: none;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  border-radius: 999px;
  padding: 5px 8px;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: transform 0.22s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.2s ease;
}
#selection-bar.open {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, 0) scale(1);
}
.hl-dot {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 1.5px solid rgba(0,0,0,0.18);
  cursor: pointer;
  transition: transform 0.15s ease;
}
.hl-dot:active { transform: scale(0.86); }

/* Fullscreen Modal Overlay (Notes Viewer & Lightbox) */
.full-modal {
  position: fixed;
  inset: 0;
  z-index: 70;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  transform: translateY(100%);
  transition: transform 0.38s cubic-bezier(0.22, 1, 0.36, 1);
  padding-top: max(10px, env(safe-area-inset-top));
  padding-bottom: max(12px, env(safe-area-inset-bottom));
}
.full-modal.open { transform: translateY(0); }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px var(--gutter) 12px;
  border-bottom: 1px solid var(--border);
}
.modal-header h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 24px;
}
.modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px max(var(--gutter), calc((100% - 66ch) / 2));
}

.note-card {
  border: 1px solid var(--border);
  background: var(--paper);
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 10px;
}
.note-quote {
  font-family: var(--font-body);
  font-style: italic;
  font-size: 14px;
  padding-left: 10px;
  border-left: 3px solid var(--accent);
  margin: 6px 0;
}
.note-text {
  font-size: 13.5px;
  line-height: 1.5;
  margin: 6px 0;
}

/* Toast Feedback */
#toast {
  position: fixed;
  left: 50%;
  bottom: 62px;
  transform: translate(-50%, 14px);
  z-index: 90;
  background: #1e1a16;
  color: #f7efe2;
  font-size: 12px;
  font-weight: 500;
  padding: 8px 14px;
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease, transform 0.24s cubic-bezier(0.22, 1, 0.36, 1);
  box-shadow: 0 10px 26px rgba(0,0,0,0.3);
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

.studio-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(135px, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}
.studio-tile {
  border: 1px solid var(--border);
  background: var(--paper);
  border-radius: 12px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  cursor: pointer;
  color: var(--ink);
  font-size: 12.5px;
  font-weight: 500;
  transition: transform 0.15s ease, border-color 0.2s;
}
.studio-tile:active { transform: scale(0.96); }
.studio-tile .ms { color: var(--accent); }

.rec-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(128,128,128,0.05);
  margin-top: 8px;
}
.rec-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #c83e31;
  animation: pulseGlow 1s infinite;
}

.empty-state {
  break-before: column;
  page-break-before: always;
  padding: 32px max(var(--gutter), calc((100% - 54ch) / 2));
  text-align: center;
}

/* ============================================================
   Additions [26.11.29.05.55]
   ============================================================ */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { -webkit-font-smoothing: antialiased; }

/* Icon glyphs: fixed box so the ligature name never flashes or shifts layout; hidden until the icon font is ready */
.ms { width: 1em; height: 1em; flex: none; overflow: hidden; }
html:not(.icons-ready) .ms { visibility: hidden; }

/* Illustrations reserve their space from width/height attributes, so pagination does not jump on load */
.para-illustration img { height: auto; }

/* In-app text prompt (window.prompt is blocked or unreliable in Android WebView) */
.ask-modal {
  position: fixed;
  inset: 0;
  z-index: 95;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 16px 16px max(18px, env(safe-area-inset-bottom));
  background: rgba(12, 10, 8, 0.44);
}
.ask-card {
  width: min(100%, 420px);
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 16px;
}
.ask-card h4 { margin: 0 0 10px; font-family: var(--font-display); font-size: 20px; }
.ask-card input {
  width: 100%;
  border: 1px solid var(--border);
  background: var(--paper);
  color: var(--ink);
  border-radius: 10px;
  padding: 10px 12px;
  font-family: var(--font-ui);
  font-size: 14px;
}
.ask-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
