/* Read to Me — School in 90 brand (navy, pink, white) with an iPhone-style layout. See DESIGN.md. */
:root {
  color-scheme: dark;
  --bg: #0F2244;           /* School in 90 navy */
  --cell: #17315F;         /* School in 90 panel */
  --cell-2: #1F3D72;
  --fill: rgba(255, 255, 255, 0.14);
  --sep: rgba(255, 255, 255, 0.16);
  --label: #ffffff;
  --label-2: rgba(255, 255, 255, 0.68);
  --label-3: rgba(255, 255, 255, 0.34);
  --accent: #F9A8D4;       /* School in 90 pink */
  --accent-ink: #0F2244;
  --accent-soft: rgba(249, 168, 212, 0.2);
  --red: #FF6B6B;
  --yellow: #ffd60a;
  --read-ink: #FFFFFF;
  --display: "Exo 2", "Trebuchet MS", Arial, sans-serif;
  --tap: 44px;
  --r: 12px;
  --read-size: 26px;
  --safe-b: env(safe-area-inset-bottom);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, system-ui, 'Segoe UI', Roboto, sans-serif;
  color: var(--label);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); }
body { font-size: 17px; line-height: 1.35; -webkit-tap-highlight-color: transparent; -webkit-text-size-adjust: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { -webkit-user-select: none; user-select: none; }
.ic { display: block; flex: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- navigation bar (one line, translucent) ---------- */
.nav {
  position: sticky; top: 0; z-index: 10;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  min-height: 44px; padding: 0 8px; padding-top: env(safe-area-inset-top);
  background: rgba(15, 34, 68, 0.82);
  -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 0.5px solid var(--sep);
}
.nav-title { margin: 0; font-size: 17px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 56vw; text-align: center; }
.nav-side { display: flex; align-items: center; min-height: 44px; }
.nav-side.right { justify-content: flex-end; }
.nav-back, .nav-icon {
  display: inline-flex; align-items: center; gap: 2px; min-height: var(--tap); min-width: var(--tap);
  padding: 0 6px; border: 0; background: none; color: var(--accent); font-size: 17px; cursor: pointer;
}
.nav-back .ic { width: 22px; height: 22px; stroke-width: 2.6; margin-left: -4px; }
.nav-icon { justify-content: center; }
.nav-back:active, .nav-icon:active { opacity: 0.4; }

/* ---------- screens ---------- */
.screen { max-width: 700px; margin: 0 auto; padding: 0 16px calc(40px + var(--safe-b)); display: grid; gap: 14px; }
.large-title { margin: 6px 0 4px; font-size: 34px; font-weight: 700; letter-spacing: 0.01em; }
.section-head { margin: 10px 16px -8px; font-size: 13px; text-transform: uppercase; color: var(--label-2); letter-spacing: 0.02em; }
.footnote { margin: -4px 16px 0; font-size: 13px; color: var(--label-2); }
.center { text-align: center; }
.empty { text-align: center; color: var(--label-2); padding: 40px 16px; }
.empty .ic { width: 56px; height: 56px; margin: 0 auto 10px; color: var(--label-3); }
.empty h2 { margin: 0 0 6px; color: var(--label); font-size: 22px; }
.empty p { margin: 0; }

/* ---------- welcome ---------- */
.welcome { min-height: 100vh; display: grid; place-content: center; justify-items: center; text-align: center; gap: 14px; padding: 24px; }
.brand-mark { width: 96px; height: auto; filter: drop-shadow(0 10px 26px rgba(249, 168, 212, 0.25)); }
.brand-line { margin: -4px 0 0; font-family: var(--display); font-style: italic; font-weight: 800; font-size: 18px; letter-spacing: 0.02em; }
.brand-line b { color: var(--accent); font-weight: 800; }
.nav-brand { display: inline-flex; align-items: center; gap: 6px; padding-left: 6px; font-family: var(--display); font-style: italic; font-weight: 800; font-size: 15px; }
.nav-brand img { width: 24px; height: auto; }
.nav-brand b { color: var(--accent); }
.welcome h1 { margin: 6px 0 0; font-size: 34px; font-weight: 700; }
.welcome p { margin: 0 0 10px; color: var(--label-2); font-size: 19px; }

/* ---------- buttons ---------- */
.ios-fill {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 50px; padding: 0 22px; border: 0; border-radius: var(--r);
  background: var(--accent); color: var(--accent-ink); font-size: 17px; font-weight: 600; cursor: pointer;
}
.ios-fill .ic { width: 20px; height: 20px; }
.ios-fill.big { min-height: 56px; font-size: 19px; }
.ios-fill.wide { width: 100%; }
.ios-fill:active, .tile:active, .pill:active, .cell:active { opacity: 0.7; }
.pill {
  display: inline-flex; align-items: center; gap: 5px; min-height: 34px; padding: 0 14px;
  border: 0; border-radius: 999px; background: var(--accent); color: var(--accent-ink);
  font-size: 15px; font-weight: 600; cursor: pointer; position: relative;
}
.pill::after { content: ''; position: absolute; inset: -5px -2px; } /* 44px touch area */
.pill .ic { width: 14px; height: 14px; }
.pill.gray { background: var(--fill); color: var(--accent); }
.tool { width: var(--tap); height: var(--tap); border: 0; border-radius: 10px; background: none; color: var(--accent); display: grid; place-items: center; cursor: pointer; }
.tool .ic { width: 22px; height: 22px; }
.tool.red { color: var(--red); }
.tool:disabled { color: var(--label-3); }
.add-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 8px; }
.tile {
  display: grid; justify-items: center; gap: 8px; padding: 18px 8px;
  border-radius: 16px; background: var(--cell); color: var(--accent); font-weight: 600; cursor: pointer;
}
.tile .ic { width: 34px; height: 34px; }
.tile.main { background: var(--accent); color: var(--accent-ink); }

/* ---------- grouped inset lists ---------- */
.group { list-style: none; margin: 0; padding: 0; background: var(--cell); border-radius: var(--r); overflow: hidden; }
.cell { display: flex; align-items: center; gap: 12px; min-height: 60px; padding: 10px 14px; position: relative; cursor: pointer; }
.cell + .cell::before { content: ''; position: absolute; top: 0; right: 0; left: 62px; border-top: 0.5px solid var(--sep); }
.page-cell + .page-cell::before { left: 100px; }
.cell-icon { width: 36px; height: 36px; border-radius: 9px; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; flex: none; }
.cell-icon .ic { width: 22px; height: 22px; }
.cell-text { flex: 1; min-width: 0; display: grid; gap: 2px; }
.cell-title { font-size: 17px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cell-sub { font-size: 14px; color: var(--label-2); }
.chev { color: var(--label-3); }
.page-cell { cursor: default; align-items: flex-start; }
.thumb { width: 72px; height: 94px; flex: none; border-radius: 8px; background: var(--cell-2); display: grid; place-items: center; color: var(--label-3); overflow: hidden; }
.thumb .ic { width: 32px; height: 32px; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.page-actions { display: flex; flex-wrap: wrap; gap: 2px; align-items: center; margin-top: 4px; margin-left: -6px; }
.page-actions .pill { margin: 0 6px; }
.status { font-size: 14px; display: inline-flex; gap: 6px; align-items: center; color: var(--label-2); }
.status.ok { color: var(--accent); }
.status.warn { color: var(--yellow); }
.status.bad { color: var(--red); }
.spinner { width: 14px; height: 14px; border: 2px solid var(--label-3); border-top-color: var(--accent); border-radius: 50%; display: inline-block; animation: spin 0.8s linear infinite; vertical-align: -2px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- reader ---------- */
.reader {
  max-width: 760px; margin: 0 auto; padding: 22px 22px calc(190px + var(--safe-b));
  font-size: var(--read-size); line-height: 1.75; color: var(--read-ink); letter-spacing: 0.01em;
}
.reader p { margin: 0 0 0.9em; }
.sent { cursor: pointer; border-radius: 8px; transition: background 0.2s, color 0.2s; }
.sent.now { background: var(--accent-soft); box-shadow: 0 0 0 5px var(--accent-soft); color: #fff; }
.w { border-radius: 6px; transition: background 0.08s, color 0.08s; }
.sent.now .w.done { color: var(--label-2); }
.w.now { background: var(--accent); color: var(--accent-ink); box-shadow: 0 0 0 3px var(--accent); font-weight: 600; }

/* ---------- player bar (like Music) ---------- */
.player {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  padding: 0 16px calc(14px + var(--safe-b));
  background: rgba(23, 49, 95, 0.9);
  -webkit-backdrop-filter: saturate(180%) blur(24px); backdrop-filter: saturate(180%) blur(24px);
  border-top: 0.5px solid var(--sep);
}
.progress { height: 3px; margin: 0 -16px 12px; background: var(--fill); }
.progress-bar { height: 100%; width: 0; background: var(--accent); transition: width 0.3s; }
.player-row { max-width: 520px; margin: 0 auto; display: grid; grid-template-columns: 1fr auto auto auto 1fr; align-items: center; gap: 18px; }
.ctl { width: 56px; height: 56px; border: 0; border-radius: 50%; background: none; color: #fff; display: grid; place-items: center; cursor: pointer; }
.ctl .ic { width: 34px; height: 34px; }
.ctl.play { width: 76px; height: 76px; background: var(--accent); color: var(--accent-ink); }
.ctl.play .ic { width: 36px; height: 36px; }
.ctl:active { transform: scale(0.92); }
.speed { justify-self: start; min-height: var(--tap); padding: 0 12px; border: 0; border-radius: 999px; background: var(--fill); color: var(--accent); font-size: 15px; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; }
.speed.ghost { justify-self: end; background: none; color: var(--label-2); cursor: default; }

/* ---------- alerts and action sheets ---------- */
dialog { border: 0; padding: 0; background: transparent; color: var(--label); max-width: none; max-height: none; }
dialog::backdrop { background: rgba(0, 0, 0, 0.5); }
dialog form { display: grid; gap: 8px; }
.modal-group { background: rgba(23, 49, 95, 0.97); -webkit-backdrop-filter: blur(30px); backdrop-filter: blur(30px); border-radius: 14px; overflow: hidden; }
.modal-head { padding: 18px 16px 14px; text-align: center; }
.modal-head h2 { margin: 0; font-size: 17px; font-weight: 600; }
.modal-head p { margin: 4px 0 0; font-size: 13px; color: var(--label-2); }
.modal-body { margin-top: 12px; text-align: left; display: grid; gap: 10px; }
.modal-body input:not([type]), .modal-body input[name=v], .modal-body textarea, .modal-body select {
  width: 100%; min-height: 40px; padding: 8px 10px; border: 0.5px solid var(--sep); border-radius: 8px; background: #0F2244; font-size: 17px;
}
.modal-body textarea { line-height: 1.45; font-size: 16px; }
.modal-actions { display: grid; }
.modal-actions.row { grid-template-columns: 1fr 1fr; }
.ios-btn { min-height: 44px; border: 0; border-top: 0.5px solid var(--sep); background: none; color: var(--accent); font-size: 17px; cursor: pointer; }
.modal-actions.row .ios-btn + .ios-btn { border-left: 0.5px solid var(--sep); }
.ios-btn.bold { font-weight: 600; }
.ios-btn.destructive { color: var(--red); }
.ios-btn:active { background: rgba(255, 255, 255, 0.08); }
dialog.alert { width: 290px; margin: auto; }
dialog.sheet { width: min(520px, calc(100vw - 16px)); margin: auto auto calc(8px + var(--safe-b)); }
dialog.sheet .ios-btn { min-height: 57px; font-size: 20px; }
dialog.sheet .modal-group:last-child .ios-btn { border-top: 0; font-weight: 600; }
dialog.sheet .modal-head { max-height: 70vh; overflow-y: auto; }
dialog.sheet .modal-head:has(.modal-body:empty), dialog.sheet .modal-head:not(:has(.modal-body)) h2 { font-size: 13px; font-weight: 600; color: var(--label-2); }
dialog[open] { animation: rise 0.28s cubic-bezier(0.2, 0.9, 0.3, 1); }
@keyframes rise { from { transform: translateY(30px); opacity: 0; } }

/* settings form bits */
.modal-body .section-head { margin: 6px 4px -4px; }
.modal-body .group.form { background: #0F2244; }
.form-row { display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 0 14px; width: 100%; border: 0; background: none; text-align: left; }
.form-row + .form-row { border-top: 0.5px solid var(--sep); }
.form-row select { border: 0 !important; background: none !important; padding: 0 !important; color: var(--accent); }
.form-row.link { color: var(--accent); cursor: pointer; }
.form-row.link .ic { width: 20px; height: 20px; }
.form-row input[type=range] { flex: 1; accent-color: var(--accent); }
.small-a { font-size: 13px; } .big-a { font-size: 22px; }
.toggle-row { justify-content: space-between; cursor: pointer; }
.switch { appearance: none; -webkit-appearance: none; width: 51px; height: 31px; border-radius: 999px; background: var(--fill); position: relative; cursor: pointer; transition: background 0.2s; flex: none; margin: 0; }
.switch::after { content: ''; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%; background: #fff; box-shadow: 0 2px 6px rgba(0,0,0,0.3); transition: transform 0.2s; }
.switch:checked { background: var(--accent); }
.switch:checked::after { transform: translateX(20px); }
.segmented { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; padding: 2px; border-radius: 9px; background: var(--fill); }
.segmented label { position: relative; }
.segmented input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.segmented span { display: block; text-align: center; padding: 7px 4px; border-radius: 7px; font-size: 14px; font-weight: 500; }
.segmented input:checked + span { background: var(--accent); color: var(--accent-ink); font-weight: 600; box-shadow: 0 2px 6px rgba(0,0,0,0.25); }
.sample { margin: 4px; color: var(--read-ink); line-height: 1.6; }

/* ---------- banner ---------- */
#toast {
  position: fixed; left: 50%; top: calc(56px + env(safe-area-inset-top)); transform: translateX(-50%); z-index: 30;
  background: rgba(23, 49, 95, 0.97); -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px);
  color: #fff; padding: 12px 18px; border-radius: 16px; width: max-content; max-width: 90vw; text-align: center; font-size: 15px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.5);
}

@media (max-width: 380px) {
  .player-row { gap: 10px; }
  .ctl { width: 48px; height: 48px; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* fit-and-finish */
.modal-group > .ios-btn { width: 100%; }
.speed.ghost { white-space: nowrap; }
.thumb { width: 60px; height: 80px; }
.page-cell + .page-cell::before { left: 86px; }
.page-actions { gap: 0; flex-wrap: nowrap; }
.page-actions .pill { margin: 0 4px 0 6px; padding: 0 12px; }
@media (max-width: 360px) { .page-actions { flex-wrap: wrap; } }

/* School in 90 display type: Exo 2 italic for titles */
.large-title, .welcome h1, .empty h2, .modal-head h2, .nav-title, .cell-title, .ios-fill, .tile span, .pill span {
  font-family: var(--display); font-style: italic;
}
.large-title, .welcome h1 { font-weight: 900; letter-spacing: 0; }
.nav-title, .modal-head h2, .empty h2 { font-weight: 800; }
.ios-fill, .tile span, .pill span { font-weight: 800; letter-spacing: 0.01em; }
.cell-title { font-weight: 700; }
.section-head { color: var(--accent); }
/* thin pink stripe under the bars, like the brand's accent bar */
.nav { box-shadow: inset 0 -2px 0 var(--accent); border-bottom: 0; }
.player { border-top: 2px solid var(--accent); }
