/* ============================================================
   Devotional Bible — Megastore76
   Warm paper, reverent typography, quiet interface.
   ============================================================ */

:root {
  --paper:      #faf7f1;
  --surface:    #fffdf8;
  --surface-2:  #f3ede2;
  --ink:        #241f19;
  --ink-2:      #5f564a;
  --ink-3:      #8d8172;
  --line:       #e7ddcc;
  --line-soft:  #f0e8db;
  --accent:     #b45309;
  --accent-ink: #8a3f06;
  --accent-wash:#fdf1e0;
  --gold:       #c9973c;
  --gold-wash:  #fdf6e3;
  --green:      #3f7d5a;
  --green-wash: #eaf4ee;
  --blue:       #3c6e91;
  --blue-wash:  #e9f2f8;
  --pink:       #a8436b;
  --pink-wash:  #fbeaf1;

  --shadow-sm: 0 1px 2px rgba(36,31,25,.06), 0 1px 3px rgba(36,31,25,.04);
  --shadow-md: 0 4px 12px rgba(36,31,25,.08), 0 2px 4px rgba(36,31,25,.04);
  --shadow-lg: 0 24px 60px rgba(36,31,25,.18), 0 8px 20px rgba(36,31,25,.08);

  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

  --read-size: 19px;
  --read-leading: 1.75;
  --radius: 14px;
  --sidebar-w: 254px;
}

:root[data-theme="dark"] {
  --paper:      #12100e;
  --surface:    #1a1714;
  --surface-2:  #221d19;
  --ink:        #f2ece1;
  --ink-2:      #b6aa9a;
  --ink-3:      #8a7e6f;
  --line:       #2e2822;
  --line-soft:  #241f1a;
  --accent:     #e8a33d;
  --accent-ink: #f0b661;
  --accent-wash:#2a2016;
  --gold:       #e0b45c;
  --gold-wash:  #2a2418;
  --green:      #74b892;
  --green-wash: #1a2620;
  --blue:       #7fb0d0;
  --blue-wash:  #16232c;
  --pink:       #e08bab;
  --pink-wash:  #2a1a22;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.4);
  --shadow-md: 0 4px 14px rgba(0,0,0,.5);
  --shadow-lg: 0 24px 60px rgba(0,0,0,.65);
}

* { box-sizing: border-box; }

/* The hidden attribute must always win over layout display rules below. */
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior-y: none;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; }

svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Shell ---------- */

.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 26px 18px 20px;
  background: var(--surface);
  border-right: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 12px; padding: 0 8px 18px; }

.brand-mark {
  width: 42px; height: 42px;
  display: grid; place-items: center;
  border-radius: 12px;
  background: linear-gradient(145deg, var(--accent) 0%, var(--accent-ink) 100%);
  color: #fff;
  font-family: var(--serif);
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -.5px;
  box-shadow: var(--shadow-sm);
}

.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-text strong { font-family: var(--serif); font-size: 16px; letter-spacing: -.2px; }
.brand-text span { font-size: 11.5px; color: var(--ink-3); letter-spacing: .04em; text-transform: uppercase; }

.nav { display: flex; flex-direction: column; gap: 2px; }

.nav a {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--ink-2);
  font-size: 14.5px;
  font-weight: 500;
  transition: background .15s, color .15s;
}

.nav a svg { width: 18px; height: 18px; opacity: .85; }
.nav a:hover { background: var(--surface-2); color: var(--ink); }
.nav a.active { background: var(--accent-wash); color: var(--accent-ink); font-weight: 600; }
.nav a.active svg { opacity: 1; }
:root[data-theme="dark"] .nav a.active { color: var(--accent); }

.side-plan {
  margin-top: auto;
  padding: 14px;
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px solid var(--line-soft);
}
.side-plan h4 { margin: 0 0 4px; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); font-weight: 600; }
.side-plan p { margin: 0 0 10px; font-size: 13px; color: var(--ink-2); }
.side-plan .bar { height: 5px; border-radius: 3px; background: var(--line); overflow: hidden; }
.side-plan .bar i { display: block; height: 100%; background: var(--accent); border-radius: 3px; transition: width .4s; }

.main {
  min-width: 0;
  padding: 40px 40px 96px;
  outline: none;
}

.wrap { max-width: 780px; margin: 0 auto; }
.wrap.wide { max-width: 940px; }

.loading { display: grid; place-items: center; gap: 16px; min-height: 60vh; color: var(--ink-3); font-size: 14px; }
.spinner { width: 26px; height: 26px; border: 2.5px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Typography ---------- */

.page-head { margin-bottom: 26px; position: relative; }

/* Settings lives in the sidebar on desktop; on a phone the sidebar is gone, so
   the home screen carries a gear button instead. */
.gear-link { display: none; }
@media (max-width: 860px) {
  .gear-link {
    display: grid;
    place-items: center;
    position: absolute;
    top: 0;
    right: 0;
    width: 40px;
    height: 40px;
    border-radius: 11px;
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--ink-2);
    box-shadow: var(--shadow-sm);
  }
  .gear-link svg { width: 19px; height: 19px; }
  .gear-link:active { background: var(--surface-2); }
}
.eyebrow {
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--accent-ink);
  margin: 0 0 8px;
}
:root[data-theme="dark"] .eyebrow { color: var(--accent); }

h1.display {
  font-family: var(--serif);
  font-size: clamp(28px, 4vw, 38px);
  line-height: 1.18;
  letter-spacing: -.02em;
  margin: 0 0 10px;
  font-weight: 600;
}
.lede { font-size: 16.5px; color: var(--ink-2); margin: 0; max-width: 62ch; }

h2.section {
  font-family: var(--serif);
  font-size: 21px;
  font-weight: 600;
  margin: 40px 0 14px;
  letter-spacing: -.01em;
}

/* ---------- Cards ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow-sm);
}

.hero-card {
  background: linear-gradient(160deg, var(--surface) 0%, var(--accent-wash) 140%);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 30px 32px;
  box-shadow: var(--shadow-md);
  position: relative;
  overflow: hidden;
}
.hero-card::after {
  content: "";
  position: absolute;
  inset: auto -60px -80px auto;
  width: 240px; height: 240px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--accent) 0%, transparent 70%);
  opacity: .04;
  pointer-events: none;
}
.hero-card h2 {
  font-family: var(--serif);
  font-size: clamp(24px, 3.4vw, 31px);
  line-height: 1.2;
  margin: 6px 0 12px;
  letter-spacing: -.015em;
  font-weight: 600;
}

.chip-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 18px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 11px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-2);
  letter-spacing: .01em;
}
.chip.accent { background: var(--accent-wash); border-color: transparent; color: var(--accent-ink); }
:root[data-theme="dark"] .chip.accent { color: var(--accent); }

/* ---------- Scripture block ---------- */

.scripture {
  font-family: var(--serif);
  font-size: var(--read-size);
  line-height: var(--read-leading);
  color: var(--ink);
}

.verse-block {
  padding: 6px 10px;
  margin: 0 -10px;
  border-radius: 8px;
  transition: background .15s;
  cursor: pointer;
}
.verse-block:hover { background: var(--surface-2); }
.verse-block:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; background: var(--surface-2); }
.vnum {
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 700;
  color: var(--ink-3);
  vertical-align: super;
  margin-right: 5px;
  letter-spacing: .02em;
  user-select: none;
}
.verse-block.is-target { background: var(--gold-wash); box-shadow: inset 3px 0 0 var(--gold); }
.verse-omitted { color: var(--ink-3); }
.verse-omitted .omitted-dash { font-style: normal; opacity: .6; }

/* highlights */
.hl-gold  { background: var(--gold-wash);  box-shadow: inset 0 -2px 0 var(--gold); }
.hl-green { background: var(--green-wash); box-shadow: inset 0 -2px 0 var(--green); }
.hl-blue  { background: var(--blue-wash);  box-shadow: inset 0 -2px 0 var(--blue); }
.hl-pink  { background: var(--pink-wash);  box-shadow: inset 0 -2px 0 var(--pink); }

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: transform .12s, background .15s, border-color .15s, box-shadow .15s;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn svg { width: 17px; height: 17px; }

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 1px 2px rgba(0,0,0,.12), 0 4px 14px rgba(180,83,9,.22);
}
.btn.primary:hover { background: var(--accent-ink); border-color: var(--accent-ink); }
:root[data-theme="dark"] .btn.primary { color: #1a1206; font-weight: 700; }
:root[data-theme="dark"] .btn.primary:hover { background: var(--accent-ink); }

.btn.ghost { background: transparent; }
.btn.sm { padding: 7px 13px; font-size: 13px; border-radius: 8px; }
.btn.icon { padding: 9px; border-radius: 9px; }
.btn.icon svg { width: 18px; height: 18px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.icon.speaking { color: var(--accent-ink); border-color: var(--accent); background: var(--accent-wash); }
:root[data-theme="dark"] .btn.icon.speaking { color: var(--accent); }

.btn-row { display: flex; flex-wrap: wrap; gap: 10px; }

/* ---------- Reader ---------- */

.reader-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 22px;
  position: sticky;
  top: 0;
  z-index: 20;
  padding: 14px 0;
  background: linear-gradient(var(--paper) 70%, transparent);
}

.reader-title { display: flex; align-items: baseline; gap: 12px; min-width: 0; }
.reader-title h1 {
  font-family: var(--serif);
  font-size: clamp(22px, 3vw, 30px);
  margin: 0;
  letter-spacing: -.02em;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.reader-title .trad { font-size: 12px; color: var(--ink-3); font-weight: 600; letter-spacing: .06em; text-transform: uppercase; }

.reader-nav { display: flex; gap: 6px; }

.picker {
  display: flex; gap: 8px; flex-wrap: wrap;
  padding: 14px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  margin-bottom: 20px;
}
.picker select {
  flex: 1 1 200px;
  padding: 10px 12px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
}
.picker select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.reader-body {
  font-family: var(--serif);
  font-size: var(--read-size);
  line-height: var(--read-leading);
  max-width: 68ch;
}

.chapter-end {
  margin-top: 40px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

/* Teaching banner */
.teach-banner {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  padding: 16px 18px;
  border-radius: 12px;
  background: var(--accent-wash);
  border: 1px solid transparent;
  margin-bottom: 24px;
}
.teach-banner svg { flex: none; width: 19px; height: 19px; color: var(--accent-ink); margin-top: 2px; }
:root[data-theme="dark"] .teach-banner svg { color: var(--accent); }
.teach-banner strong { display: block; font-size: 14px; margin-bottom: 3px; }
.teach-banner p { margin: 0; font-size: 13.5px; color: var(--ink-2); }
.teach-banner a { color: var(--accent-ink); font-weight: 600; font-size: 13px; display: inline-block; margin-top: 8px; }
:root[data-theme="dark"] .teach-banner a { color: var(--accent); }

/* ---------- Devotional ---------- */

.dev-meta { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }

.dev-body p {
  font-size: 16.5px;
  line-height: 1.72;
  color: var(--ink);
  margin: 0 0 18px;
  max-width: 66ch;
}
.dev-body p:first-child { font-size: 17.5px; }

.dev-passage {
  font-family: var(--serif);
  font-size: 17.5px;
  line-height: 1.72;
  padding: 20px 22px;
  border-left: 3px solid var(--gold);
  background: var(--gold-wash);
  border-radius: 0 10px 10px 0;
  margin: 0 0 24px;
  color: var(--ink);
}
.dev-passage .ref {
  display: block;
  font-family: var(--sans);
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 8px;
}

.reflect-box {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px 24px;
  margin: 28px 0;
}
.reflect-box h3 {
  font-size: 11.5px; text-transform: uppercase; letter-spacing: .09em;
  color: var(--ink-3); margin: 0 0 12px; font-weight: 700;
}
.reflect-box ol { margin: 0; padding-left: 20px; }
.reflect-box li { margin-bottom: 10px; font-size: 15.5px; color: var(--ink-2); line-height: 1.6; }
.reflect-box li:last-child { margin-bottom: 0; }

.prayer-box {
  font-family: var(--serif);
  font-size: 16.5px;
  line-height: 1.7;
  color: var(--ink-2);
  font-style: italic;
  padding: 22px 24px;
  border-radius: var(--radius);
  background: var(--surface-2);
  margin: 0 0 28px;
}
.prayer-box .lbl {
  display: block; font-family: var(--sans); font-style: normal;
  font-size: 11.5px; text-transform: uppercase; letter-spacing: .09em;
  color: var(--ink-3); margin-bottom: 10px; font-weight: 700;
}

/* ---------- Lists ---------- */

.dev-list { display: flex; flex-direction: column; gap: 8px; }

.dev-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 15px 18px;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: var(--surface);
  transition: border-color .15s, transform .12s, box-shadow .15s;
}
.dev-item:hover { border-color: var(--accent); box-shadow: var(--shadow-sm); transform: translateX(2px); }
.dev-item .num {
  flex: none;
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border-radius: 9px;
  background: var(--surface-2);
  font-family: var(--serif);
  font-size: 14px;
  font-weight: 700;
  color: var(--ink-2);
}
.dev-item.done .num { background: var(--green-wash); color: var(--green); }
.dev-item.today { border-color: var(--accent); background: var(--accent-wash); }
.dev-item .body { flex: 1; min-width: 0; }
.dev-item .body strong { display: block; font-size: 15px; font-weight: 600; margin-bottom: 2px; }
.dev-item .body span { font-size: 12.5px; color: var(--ink-3); }
.dev-item .chev { color: var(--ink-3); flex: none; }

/* ---------- Search ---------- */

.search-box {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  margin-bottom: 18px;
}
.search-box svg { color: var(--ink-3); flex: none; }
.search-box input {
  flex: 1;
  border: 0;
  background: transparent;
  font-size: 16px;
  font-family: inherit;
  color: var(--ink);
  outline: none;
  min-width: 0;
}
.search-box input::placeholder { color: var(--ink-3); }

.result {
  display: block;
  padding: 14px 16px;
  border-radius: 10px;
  border-bottom: 1px solid var(--line-soft);
  transition: background .12s;
}
.result:hover { background: var(--surface-2); }
.result .ref {
  font-size: 12px; font-weight: 700; letter-spacing: .04em;
  color: var(--accent-ink); text-transform: uppercase; margin-bottom: 4px;
}
:root[data-theme="dark"] .result .ref { color: var(--accent); }
.result .txt { font-family: var(--serif); font-size: 15.5px; line-height: 1.6; color: var(--ink-2); }
.result .txt mark { background: var(--gold-wash); color: var(--ink); padding: 0 2px; border-radius: 3px; box-shadow: inset 0 -2px 0 var(--gold); }

.empty { text-align: center; padding: 60px 20px; color: var(--ink-3); font-size: 14.5px; }
.empty svg { width: 34px; height: 34px; opacity: .4; margin-bottom: 12px; }

/* ---------- Sheets / modal ---------- */

.sheet-backdrop {
  position: fixed; inset: 0; background: rgba(20,16,12,.42);
  backdrop-filter: blur(2px); z-index: 90;
}
.sheet {
  position: fixed;
  left: 50%; bottom: 0;
  transform: translateX(-50%);
  width: min(520px, 100%);
  background: var(--surface);
  border-radius: 18px 18px 0 0;
  box-shadow: var(--shadow-lg);
  z-index: 91;
  padding: 8px 18px 22px;
  animation: sheetUp .24s cubic-bezier(.2,.9,.3,1);
}
@keyframes sheetUp { from { transform: translate(-50%, 100%); } to { transform: translate(-50%, 0); } }
.sheet .grab { width: 38px; height: 4px; border-radius: 2px; background: var(--line); margin: 8px auto 16px; }
.sheet .vtext {
  font-family: var(--serif); font-size: 16.5px; line-height: 1.65; color: var(--ink);
  margin-bottom: 6px;
}
.sheet .vref { font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); }

.sheet-row { display: flex; gap: 10px; margin-top: 18px; flex-wrap: wrap; }
.swatches { display: flex; gap: 10px; }
.swatch {
  width: 36px; height: 36px; border-radius: 50%;
  border: 2px solid transparent; cursor: pointer;
  display: grid; place-items: center;
  transition: transform .12s, border-color .15s;
}
.swatch:hover { transform: scale(1.08); }
.swatch.active { border-color: var(--ink-2); }
.swatch.g { background: var(--gold-wash); box-shadow: inset 0 0 0 2px var(--gold); }
.swatch.n { background: var(--green-wash); box-shadow: inset 0 0 0 2px var(--green); }
.swatch.b { background: var(--blue-wash);  box-shadow: inset 0 0 0 2px var(--blue); }
.swatch.p { background: var(--pink-wash);  box-shadow: inset 0 0 0 2px var(--pink); }
.swatch.x { background: var(--surface-2); color: var(--ink-3); font-size: 12px; }

.sheet-actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 18px; }
.sheet-actions button {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 12px 8px; border-radius: 11px;
  border: 1px solid var(--line); background: var(--paper);
  color: var(--ink-2); font-size: 12px; font-weight: 600; cursor: pointer;
}
.sheet-actions button:hover { background: var(--surface-2); color: var(--ink); }
.sheet-actions button svg { width: 19px; height: 19px; }

.modal-wrap {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(20,16,12,.45);
  display: grid; place-items: center;
  padding: 20px;
}
.modal {
  width: min(480px, 100%);
  background: var(--surface);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  padding: 24px;
  animation: pop .2s ease-out;
}
@keyframes pop { from { transform: scale(.96); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal h3 { font-family: var(--serif); font-size: 20px; margin: 0 0 4px; font-weight: 600; }
.modal p.sub { margin: 0 0 16px; font-size: 13.5px; color: var(--ink-3); }
.modal textarea {
  width: 100%; min-height: 120px; resize: vertical;
  padding: 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--paper); color: var(--ink);
  font-family: inherit; font-size: 14.5px; line-height: 1.55;
}
.modal textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.modal .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

.toast {
  position: fixed; left: 50%; bottom: 92px; transform: translateX(-50%);
  background: var(--ink); color: var(--paper);
  padding: 10px 18px; border-radius: 999px;
  font-size: 13.5px; font-weight: 600; z-index: 120;
  box-shadow: var(--shadow-md); animation: pop .2s;
}

/* ---------- Settings ---------- */

.set-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 20px; padding: 18px 0; border-bottom: 1px solid var(--line-soft);
}
.set-row:last-child { border-bottom: 0; }
.set-row .label strong { display: block; font-size: 14.5px; margin-bottom: 2px; }
.set-row .label span { font-size: 13px; color: var(--ink-3); }

.seg { display: inline-flex; padding: 3px; border-radius: 9px; background: var(--surface-2); border: 1px solid var(--line); }
.seg button {
  border: 0; background: transparent; padding: 7px 13px; border-radius: 7px;
  font-size: 13px; font-weight: 600; color: var(--ink-2); cursor: pointer;
}
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }

input[type="range"] { accent-color: var(--accent); width: 150px; }

.set-row select {
  max-width: 260px;
  width: 100%;
  padding: 9px 12px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  font-family: inherit;
  font-size: 13.5px;
  cursor: pointer;
}
.set-row select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

@media (max-width: 620px) {
  .set-row { flex-wrap: wrap; }
  .set-row select { max-width: none; }
}

/* ---------- Stats ---------- */

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 8px; }
.stat {
  padding: 16px 18px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--line);
}
.stat .n { font-family: var(--serif); font-size: 27px; font-weight: 600; line-height: 1; margin-bottom: 4px; }
.stat .l { font-size: 12px; color: var(--ink-3); text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }

/* ---------- Book index ---------- */

.book-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(172px, 1fr));
  gap: 8px;
}

.book-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  transition: border-color .15s, transform .12s, box-shadow .15s;
}
.book-card:hover { border-color: var(--accent); transform: translateY(-1px); box-shadow: var(--shadow-sm); }

.book-abbr {
  flex: none;
  width: 36px;
  padding: 4px 0;
  border-radius: 7px;
  background: var(--surface-2);
  color: var(--ink-2);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .02em;
  text-align: center;
}
.book-card:hover .book-abbr { background: var(--accent-wash); color: var(--accent-ink); }
.book-body { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.book-name { font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.book-meta { font-size: 10.5px; color: var(--ink-3); margin-top: 1px; }

/* ---------- Month tabs ---------- */

.months {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 6px;
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px solid var(--line);
}
.months button {
  flex: 1 1 auto;
  min-width: 52px;
  padding: 7px 4px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink-2);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}
.months button:hover { background: var(--surface); color: var(--ink); }
.months button.on { background: var(--accent); color: #fff; box-shadow: var(--shadow-sm); }
:root[data-theme="dark"] .months button.on { color: #1a1206; }

/* ---------- Book introduction ---------- */

.fact-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
  margin: 0 0 26px;
}
.fact {
  padding: 14px 16px;
  border-radius: 11px;
  background: var(--surface);
  border: 1px solid var(--line);
}
.fact span {
  display: block;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--ink-3);
  font-weight: 700;
  margin-bottom: 4px;
}
.fact strong { font-size: 14px; font-weight: 600; }

.intro-text {
  font-size: 16.5px;
  line-height: 1.72;
  color: var(--ink-2);
  margin: 0 0 18px;
  max-width: 68ch;
}

.outline { border-top: 1px solid var(--line-soft); }
.outline-row {
  display: flex;
  gap: 16px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line-soft);
  align-items: baseline;
}
.outline-range {
  flex: none;
  min-width: 62px;
  font-family: var(--serif);
  font-size: 13.5px;
  font-weight: 700;
  color: var(--accent-ink);
}
:root[data-theme="dark"] .outline-range { color: var(--accent); }
.outline-body { display: flex; flex-direction: column; gap: 2px; }
.outline-body strong { font-size: 14.5px; font-weight: 600; }
.outline-body span { font-size: 13px; color: var(--ink-3); }

/* Chapter-1 introduction banner */
.intro-banner {
  display: block;
  padding: 15px 18px;
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  margin-bottom: 16px;
}
.intro-banner .intro-label {
  display: block;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 5px;
}
.intro-banner strong {
  display: block;
  font-family: var(--serif);
  font-size: 16px;
  font-weight: 600;
  line-height: 1.45;
  margin-bottom: 7px;
}
.intro-banner .intro-more { font-size: 13px; font-weight: 600; color: var(--accent-ink); }
:root[data-theme="dark"] .intro-banner .intro-more { color: var(--accent); }
.intro-banner:hover { border-color: var(--accent); }

/* ---------- Book shop ---------- */

.region-note {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 14px 16px;
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  margin-bottom: 24px;
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--ink-2);
}
.region-note svg { width: 18px; height: 18px; flex: none; color: var(--ink-3); margin-top: 1px; }

.ebook-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(330px, 1fr));
  gap: 16px;
}

.ebook-card {
  display: flex;
  gap: 16px;
  padding: 16px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  transition: border-color .15s, box-shadow .15s;
}
.ebook-card:hover { border-color: var(--accent); box-shadow: var(--shadow-md); }

.ebook-cover {
  flex: none;
  align-self: flex-start;
  width: 92px;
  aspect-ratio: 2 / 3;
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface-2);
  box-shadow: var(--shadow-sm);
  position: relative;
}
.ebook-cover img { width: 100%; height: 100%; object-fit: contain; display: block; }
.ebook-cover.cover-missing img { display: none; }
.ebook-cover.cover-missing::after {
  content: attr(data-title);
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 8px;
  text-align: center;
  font-family: var(--serif);
  font-size: 11px;
  line-height: 1.3;
  color: var(--ink-2);
}

.ebook-body { min-width: 0; display: flex; flex-direction: column; }
.ebook-body h3 { font-family: var(--serif); font-size: 16.5px; margin: 0 0 3px; line-height: 1.3; font-weight: 600; }
.ebook-sub { font-size: 12.5px; color: var(--ink-3); margin: 0 0 8px; line-height: 1.4; font-style: italic; }
.ebook-hook { font-size: 13.5px; color: var(--ink-2); margin: 0 0 12px; line-height: 1.5; }
.ebook-prices { margin: auto 0 12px; display: flex; gap: 9px; align-items: baseline; }
.ebook-prices span:first-child { font-size: 14px; font-weight: 700; color: var(--ink); }
.ebook-prices .dim { font-size: 12px; color: var(--ink-3); font-weight: 500; }
.ebook-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.ebook-teaser {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 18px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--surface);
  margin-top: 22px;
  box-shadow: var(--shadow-sm);
  transition: border-color .15s, transform .12s;
}
.ebook-teaser:hover { border-color: var(--accent); transform: translateY(-1px); }
.ebook-teaser-covers { display: flex; flex: none; }
.ebook-teaser-covers img {
  width: 36px; height: 54px; object-fit: cover;
  border-radius: 5px; border: 2px solid var(--surface);
  box-shadow: var(--shadow-sm);
}
.ebook-teaser-covers img + img { margin-left: -13px; }
.ebook-teaser-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.ebook-teaser-text strong { font-family: var(--serif); font-size: 15px; font-weight: 600; }
.ebook-teaser-text span { font-size: 12.5px; color: var(--ink-3); }
.ebook-teaser > svg { color: var(--ink-3); flex: none; }

/* ---------- Mobile ---------- */

.tabbar { display: none; }

@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .main { padding: 20px 16px 104px; }
  .tabbar {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    position: fixed; bottom: 0; left: 0; right: 0;
    background: color-mix(in srgb, var(--surface) 92%, transparent);
    backdrop-filter: blur(14px);
    border-top: 1px solid var(--line);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
    z-index: 60;
  }
  .tabbar a {
    display: flex; flex-direction: column; align-items: center; gap: 3px;
    padding: 7px 2px; font-size: 10.5px; font-weight: 600;
    color: var(--ink-3); border-radius: 9px;
  }
  .tabbar a.active { color: var(--accent-ink); }
  :root[data-theme="dark"] .tabbar a.active { color: var(--accent); }
  .tabbar svg { width: 21px; height: 21px; }

  .hero-card { padding: 24px 20px; }
  .reader-head { padding: 10px 0; }
  .sheet { width: 100%; }
  .btn-row { width: 100%; }
  .btn-row .btn { flex: 1; }
  .dev-item { padding: 13px 14px; }
  .ebook-grid { grid-template-columns: 1fr; }
  .ebook-cover { width: 76px; }
  .ebook-teaser-covers { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* Print */
@media print {
  .sidebar, .tabbar, .reader-nav, .picker, .btn { display: none !important; }
  .main { padding: 0; }
  body { background: #fff; }
}
