@font-face {
  font-family: 'Heron Wordmark';   /* Bitsumishi — used ONLY for the brand wordmark/logo */
  src: url('heron-wordmark.ttf') format('truetype');
  font-display: swap;
}

:root {
  --bg-primary: #000000;   /* transparent on additive display — real world shows through */
  --bg-surface: #141418;   /* cards, panels — visible on the see-through canvas */
  --bg-elev: #1d1d24;      /* buttons, chips */
  --bg-elev-2: #2a2a32;    /* tracks, borders */
  --text-primary: #ffffff;
  --text-secondary: #a0a0a8;
  --text-muted: #6a6a72;
  --accent: #ff4f3a;       /* coral red — reserved for the FOCUSED element */
  --accent-bright: #ff6a57;
  --accent-ink: #1a0805;   /* text/icons on a coral fill */
  --accent-ink-dim: rgba(26, 8, 5, 0.66);
  --accent-edge: rgba(255, 79, 58, 0.55); /* idle outline hint for primary actions */
  --pivot: #ff4f3a;        /* matches the coral UI accent */
  --success: #36d399;
  --danger: #ff4466;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  width: 600px;
  height: 600px;
  overflow: hidden;
}

#app { width: 100%; height: 100%; position: relative; }

/* --- Screens --- */
.screen {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  position: absolute;
  top: 0;
  left: 0;
}
.screen.hidden { display: none; }

/* --- Header --- */
.header {
  display: flex;
  align-items: center;
  padding: 16px 20px;
  gap: 12px;
  flex-shrink: 0;
}
.header h1 { font-size: 22px; font-weight: 700; flex: 1; }
.back-btn {
  background: transparent;
  color: var(--text-primary);
  font-size: 30px;
  line-height: 1;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}
.icon-btn {
  background: transparent;
  color: var(--text-secondary);
  font-size: 22px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  flex-shrink: 0;
}
/* Gear is last in the home DOM (so it's not the default selection); pin it top-right visually. */
/* Labeled settings pill (top-right) — more discoverable than a bare gear */
.home-settings {
  position: absolute; top: 14px; right: 18px; z-index: 5;
  width: auto; height: 34px; padding: 0 14px;
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--bg-elev); color: var(--text-secondary);
  border-radius: 18px; font-size: 14px; font-weight: 600;
}
.ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }

/* --- Content --- */
.content {
  flex: 1;
  padding: 8px 20px 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
}

/* Scrim: fade the bottom of long scrolling lists into the (transparent) background as a "more below" cue */
#home::after, #chapters::after {
  content: '';
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 40px;
  background: linear-gradient(to top, var(--bg-primary), transparent);
  pointer-events: none;
  z-index: 4;
}

/* =======================================================
   FOCUS MODEL  (manual: idle 80–90% / targeted 100% + scale)
   One consistent "hot" cue: the FOCUSED element fills coral,
   brightens to full opacity, and lifts slightly. Idle elements
   are neutral and slightly recessed. Color never means "active"
   on anything that isn't focused.
   ======================================================= */
.focusable {
  border: 2px solid transparent;
  cursor: pointer;
  opacity: 0.9;                 /* idle: gently recessed */
  transition:
    transform 0.18s cubic-bezier(0.6, 0, 0.4, 1),
    background 0.15s ease,
    color 0.15s ease,
    opacity 0.2s ease;
}
.focusable:focus {
  outline: none;
  opacity: 1;                   /* targeted: full brightness */
  transform: scale(1.03);
}
.focusable:active { transform: scale(0.96); }   /* tactile press feedback on activation */
/* The single accent rule: focused control fills coral with dark ink content. */
.btn-primary:focus,
.btn-secondary:focus,
.nav-item:focus,
.list-item:focus,
.step-btn:focus,
.toggle-btn:focus,
.wpm-chip:focus,
.back-btn:focus,
.icon-btn:focus,
.continue-main:focus,
.continue-dismiss:focus {
  background: var(--accent);
  color: var(--accent-ink);
}
.btn-secondary:focus .btn-icon,
.list-item:focus .list-item-meta,
.list-item:focus .list-item-icon { color: var(--accent-ink-dim); }
.list-item:focus .badge { background: rgba(26, 8, 5, 0.18); color: var(--accent-ink); }
/* round transport buttons keep white glyphs on the coral fill */
.t-btn:focus { background: var(--accent); color: #fff; transform: scale(1.08); }
/* destructive action stays red (meaning) rather than turning coral */
.nav-item.danger:focus { background: var(--danger); color: #fff; }

/* ===================== HOME ===================== */
.home-header h1 {
  font-family: 'Heron Wordmark', sans-serif;
  font-weight: 400;            /* Bitsumishi is single-weight — prevents synthesized faux-bold */
  font-size: 26px;
  text-transform: uppercase;   /* render the wordmark as HERON; HTML text stays "Heron" */
  letter-spacing: 2px;
}
.home-content { gap: 12px; }

/* Continue Reading card */
.continue-card {
  display: flex;
  align-items: stretch;
  gap: 6px;
  background: var(--bg-surface);
  border: 1px solid var(--accent-edge);
  border-radius: var(--radius-lg);
  padding: 8px;
}
.continue-main {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 14px;
  background: transparent;
  border-radius: var(--radius-md);
  padding: 10px 12px;
  text-align: left;
  min-width: 0;
  color: var(--text-primary);
}
.continue-play {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--bg-elev);
  color: var(--text-primary);
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding-left: 3px;
}
.continue-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.continue-label { font-size: 13px; font-weight: 700; color: var(--accent); letter-spacing: 0.3px; }
.continue-title { font-size: 18px; font-weight: 600; }
.continue-bar { display: block; width: 100%; height: 5px; background: var(--bg-elev-2); border-radius: 3px; overflow: hidden; }
.continue-fill { display: block; height: 100%; background: var(--accent); border-radius: 3px; }
.continue-pct { flex-shrink: 0; align-self: center; font-size: 14px; color: var(--text-secondary); font-variant-numeric: tabular-nums; }
.continue-dismiss {
  flex-shrink: 0;
  width: 40px;
  background: transparent;
  color: var(--text-muted);
  font-size: 18px;
  border-radius: var(--radius-md);
}
/* card focused → coral fill; recolor its inner content for contrast */
.continue-main:focus .continue-label,
.continue-main:focus .continue-pct { color: var(--accent-ink); }
.continue-main:focus .continue-play { background: var(--accent-ink); color: var(--accent); }
.continue-main:focus .continue-bar { background: rgba(26, 8, 5, 0.25); }
.continue-main:focus .continue-fill { background: var(--accent-ink); }

/* Buttons */
.btn-primary {
  height: 64px;
  background: var(--bg-surface);
  color: var(--accent);
  border: 1px solid var(--accent-edge);   /* idle: outline hint, not a fill */
  border-radius: var(--radius-lg);
  font-size: 20px;
  font-weight: 700;
  flex-shrink: 0;
}
.btn-secondary {
  height: 60px;
  background: var(--bg-surface);
  border: 1px solid var(--bg-elev-2);
  color: var(--text-primary);
  border-radius: var(--radius-md);
  font-size: 17px;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex-shrink: 0;
}
.btn-icon { font-size: 20px; color: var(--text-secondary); }
.section-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.6px;
  text-transform: uppercase;
  margin-top: 6px;
}

/* Library list */
.list-container { display: flex; flex-direction: column; gap: 8px; }
.list-item {
  display: flex;
  align-items: center;
  padding: 13px 14px;
  background: var(--bg-surface);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  text-align: left;
  gap: 12px;
}
.list-item-icon { font-size: 22px; flex-shrink: 0; width: 30px; text-align: center; }
.list-item-cover { width: 40px; height: 56px; object-fit: cover; border-radius: 4px; flex-shrink: 0; background: var(--bg-elev); }
.list-row { display: flex; align-items: stretch; gap: 6px; }
.list-row .list-item { flex: 1; min-width: 0; }
.list-del {
  flex-shrink: 0; width: 46px;
  background: var(--bg-surface); color: var(--text-muted);
  border-radius: var(--radius-md); font-size: 18px;
}
.list-del:focus { background: var(--danger); color: #fff; }
.list-item-content { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.list-item-title { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-item-meta { font-size: 13px; color: var(--text-secondary); margin-top: 2px; }
.badge { padding: 4px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; flex-shrink: 0; }
.badge-success { background: rgba(54, 211, 153, 0.2); color: var(--success); }
.badge-info { background: rgba(255, 79, 58, 0.18); color: var(--accent-bright); }
.badge-readd { background: rgba(255, 255, 255, 0.10); color: var(--text-secondary); }

/* ===================== READER ===================== */
.reader-header { gap: 10px; }
.reader-counter { font-size: 15px; color: var(--text-primary); font-variant-numeric: tabular-nums; flex-shrink: 0; }
.reader-counter .slash { color: var(--text-muted); }
/* reserve a fixed slot for the current count (width set in JS to the total's digits)
   so growing 1→2→3 digits never shifts the title or wpm chip */
#counter-cur { display: inline-block; text-align: right; }
.reader-title { flex: 1; text-align: center; font-size: 18px; font-weight: 600; }
.wpm-chip {
  flex-shrink: 0;
  background: var(--bg-elev);
  color: var(--text-primary);
  border-radius: 20px;
  padding: 7px 14px;
  font-size: 14px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.reader-content { position: relative; justify-content: center; align-items: stretch; overflow: hidden; padding: 0 20px; }
/* When paused, the surrounding sentence appears faintly near the bottom so you can re-orient. */
.reader-context {
  position: absolute;
  left: 24px; right: 24px; bottom: 12px;
  text-align: center;
  font-size: 15px;
  line-height: 1.4;
  color: var(--text-secondary);
  opacity: 0.85;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
/* The exact word playback resumes on — coral + bold so it stands out in the faint sentence. */
.ctx-current { color: var(--accent); font-weight: 700; }

.rsvp-stage {
  --fx: 42%;
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.reticle { height: 16px; position: relative; }
.reticle::before {
  content: '';
  position: absolute;
  top: 0; bottom: 0;
  left: var(--fx);
  width: 2px;
  margin-left: -1px;
  background: var(--accent);
  opacity: 0.6;
}
.reticle-top::before { top: 4px; }
.reticle-bottom::before { bottom: 4px; }
.rsvp-stage.no-orp .reticle::before { display: none; }

.rsvp-word {
  position: relative;
  height: 96px;
  line-height: 96px;
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-size: var(--rsvp-size, 56px);
  font-weight: 600;
  letter-spacing: 0.5px;
}
.rsvp-word span { position: absolute; top: 0; white-space: pre; }
.w-left  { right: calc(100% - var(--fx) + 0.5ch); text-align: right; color: var(--text-primary); }
.w-pivot { left: var(--fx); transform: translateX(-50%); color: var(--pivot); }
.w-right { left: calc(var(--fx) + 0.5ch); color: var(--text-primary); }
.w-center { left: 50%; transform: translateX(-50%); color: var(--text-primary); }

/* Chapter chip (current chapter; tap opens the Chapters list) */
.chapter-chip {
  align-self: center;
  max-width: 90%;
  margin: 0 auto 4px;
  padding: 6px 14px;
  background: var(--bg-elev);
  color: var(--text-secondary);
  border-radius: 16px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex-shrink: 0;
}
.chapter-chip:focus { background: var(--accent); color: var(--accent-ink); }

/* Chapters list — current chapter outlined when not focused */
.list-item.current { border-color: var(--accent-edge); }

/* Scrubber (display only — no touch on device) */
.scrubber { flex-shrink: 0; padding: 8px 24px 4px; }
.scrub-times {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
  margin-bottom: 8px;
}
.scrub-track { position: relative; height: 6px; background: var(--bg-elev-2); border-radius: 3px; overflow: hidden; }
.scrub-fill { height: 100%; width: 0%; background: var(--accent); border-radius: 3px; transition: width 0.15s linear; }
.scrub-marks { position: absolute; inset: 0; pointer-events: none; }
.scrub-mark { position: absolute; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: rgba(255, 255, 255, 0.6); }

/* Transport — neutral idle; the focused control is the coral one.
   Play is distinguished by SIZE (not color) when unfocused. */
.transport {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 14px 20px 22px;
  flex-shrink: 0;
}
.t-btn {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: transparent;
  color: var(--text-primary);
  font-size: 22px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  font-variant-numeric: tabular-nums;
}
.t-unit { font-size: 12px; color: var(--text-secondary); margin-left: 1px; }
.t-btn:focus .t-unit { color: rgba(255, 255, 255, 0.85); }
.t-btn.play {
  width: 76px;
  height: 76px;
  background: var(--bg-elev);     /* neutral until focused */
  color: #fff;
  font-size: 30px;
  padding-left: 4px;
}
.t-btn.play.is-playing { padding-left: 0; }
/* More specific than the grey `.t-btn.play` base, so focus still fills coral. */
.t-btn.play:focus { background: var(--accent); transform: scale(1.08); }

/* ===================== SETTINGS ===================== */
.setting-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--bg-surface);
  border-radius: var(--radius-md);
}
.setting-info { flex: 1; min-width: 0; }
.setting-label { font-size: 16px; font-weight: 500; }
.setting-hint { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }
.stepper { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.step-btn {
  width: 48px; height: 48px;
  background: var(--bg-elev);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  font-size: 24px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.step-val { min-width: 56px; text-align: center; font-size: 18px; font-weight: 600; font-variant-numeric: tabular-nums; }
.toggle-btn {
  flex-shrink: 0;
  min-width: 72px; height: 44px;
  padding: 0 16px;
  background: var(--bg-elev);
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  font-size: 15px; font-weight: 600;
}
.toggle-btn.on { background: rgba(255, 79, 58, 0.2); color: var(--accent-bright); }

/* ===================== ADD A DOCUMENT (code entry) ===================== */
.add-content { align-items: center; gap: 10px; }
.add-slots { display: flex; align-items: center; justify-content: center; gap: 9px; font-size: 13px; color: var(--text-secondary); }
.slot-pips { display: inline-flex; gap: 5px; }
.slot-pip { width: 8px; height: 8px; border-radius: 50%; border: 1px solid var(--text-secondary); opacity: 0.45; }
.slot-pip.filled { background: var(--accent); border-color: var(--accent); opacity: 1; }
.add-slots.full .slot-label { color: var(--text-primary); }
.add-step { font-size: 14px; color: var(--text-secondary); text-align: center; margin-top: 4px; }
.add-url { font-size: 17px; font-weight: 700; color: var(--accent); text-align: center; word-break: break-all; }
.code-display { display: flex; gap: 8px; margin: 6px 0 8px; }
.code-slot {
  width: 46px; height: 58px; line-height: 58px; text-align: center;
  font-size: 30px; font-weight: 700; font-variant-numeric: tabular-nums;
  border-radius: 10px; color: var(--text-muted);
  border: 2px solid var(--bg-elev-2);
}
.code-slot.filled { color: var(--text-primary); background: var(--bg-elev); border-color: transparent; }
.keypad { display: grid; grid-template-columns: repeat(3, 74px); gap: 10px; }
.key {
  height: 62px; border-radius: 12px; background: var(--bg-elev);
  color: var(--text-primary); font-size: 26px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.key.key-go { color: var(--accent); }
.key:focus { background: var(--accent); color: var(--accent-ink); }
.add-file-link {
  margin-top: 12px; background: transparent; border: none;
  color: var(--text-secondary); font-size: 14px; text-decoration: underline;
}
.add-file-link:focus { color: var(--accent); }

/* nav-bar (done / paste / settings footer) */
.nav-bar { display: flex; gap: 8px; padding: 12px 20px; flex-shrink: 0; }
.nav-item {
  flex: 1;
  padding: 14px 16px;
  background: var(--bg-surface);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 15px; font-weight: 500;
  text-align: center;
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
.nav-item.primary {                  /* idle: coral outline hint, not a fill */
  background: var(--bg-surface);
  color: var(--accent);
  border: 1px solid var(--accent-edge);
}
.nav-item.danger { background: rgba(255, 68, 102, 0.15); color: var(--danger); }

/* Done */
.done-content { align-items: center; justify-content: center; text-align: center; gap: 16px; }
/* Confirm-remove screen */
.confirm-content { align-items: center; justify-content: center; text-align: center; gap: 12px; }
.confirm-icon { font-size: 52px; line-height: 1; color: var(--danger); }
.confirm-title { font-size: 20px; font-weight: 700; color: var(--text-primary); max-width: 460px; }
.confirm-hint { font-size: 14px; color: var(--text-secondary); max-width: 420px; line-height: 1.5; }
.done-check { font-size: 72px; color: var(--success); line-height: 1; }
.done-summary { font-size: 18px; color: var(--text-secondary); max-width: 440px; line-height: 1.5; }
.done-summary strong { color: var(--text-primary); }
/* Lifetime stats row — the motivation hook shown at finish */
.done-stats { display: flex; justify-content: center; gap: 14px; margin-top: 20px; }
.stat-tile {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  min-width: 92px; padding: 12px 10px;
  background: var(--bg-surface); border-radius: var(--radius-md);
}
.stat-val { font-size: 24px; font-weight: 700; color: var(--accent); font-variant-numeric: tabular-nums; }
.stat-lbl { font-size: 12px; color: var(--text-secondary); }

/* Busy overlay */
.busy {
  position: absolute; inset: 0;
  background: rgba(0, 0, 0, 0.85);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px;
  z-index: 50;
}
.loading-spinner {
  width: 48px; height: 48px;
  border: 4px solid var(--bg-elev-2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.busy-text { font-size: 16px; color: var(--text-secondary); }

/* Toast */
.toast {
  position: fixed;
  top: 20px; left: 50%;
  transform: translateX(-50%) translateY(-8px);
  opacity: 0;                       /* hidden = invisible (not just moved off the 600px screen) */
  background: var(--bg-elev);
  color: var(--text-primary);
  padding: 12px 24px;
  border-radius: var(--radius-md);
  font-size: 14px;
  border: 1px solid var(--accent);
  transition: opacity 0.25s ease, transform 0.25s ease;
  z-index: 100;
  pointer-events: none;
}
.toast.visible { transform: translateX(-50%) translateY(0); opacity: 1; }
.toast.error { border-color: var(--danger); }
.toast.success { border-color: var(--success); }

/* Utility */
.hidden { display: none !important; }
.mt-auto { margin-top: auto; }

/* Respect a reduced-motion preference: keep focus legible (brightness only), drop scale/slide animation */
@media (prefers-reduced-motion: reduce) {
  .focusable, .toast { transition: opacity 0.15s ease, background 0.15s ease, color 0.15s ease; }
  .focusable:focus, .focusable:active { transform: none; }
  .loading-spinner { animation-duration: 1.5s; }
}
