/* ---------- Fonts (bundled, so the app works offline) ---------- */
@font-face { font-family: "Fraunces"; font-weight: 600; font-style: normal; font-display: swap;
  src: url(../fonts/fraunces-latin-600-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Fraunces"; font-weight: 600; font-style: normal; font-display: swap;
  src: url(../fonts/fraunces-latin-ext-600-normal.woff2) format("woff2"); unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Fraunces"; font-weight: 400; font-style: italic; font-display: swap;
  src: url(../fonts/fraunces-latin-400-italic.woff2) format("woff2"); }
@font-face { font-family: "Literata"; font-weight: 400; font-style: normal; font-display: swap;
  src: url(../fonts/literata-latin-400-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Literata"; font-weight: 400; font-style: normal; font-display: swap;
  src: url(../fonts/literata-latin-ext-400-normal.woff2) format("woff2"); unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Literata"; font-weight: 400; font-style: italic; font-display: swap;
  src: url(../fonts/literata-latin-400-italic.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Literata"; font-weight: 400; font-style: italic; font-display: swap;
  src: url(../fonts/literata-latin-ext-400-italic.woff2) format("woff2"); unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Literata"; font-weight: 700; font-style: normal; font-display: swap;
  src: url(../fonts/literata-latin-700-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Literata"; font-weight: 700; font-style: normal; font-display: swap;
  src: url(../fonts/literata-latin-ext-700-normal.woff2) format("woff2"); unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }

@font-face { font-family: "Fredoka"; font-weight: 600; font-style: normal; font-display: swap;
  src: url(../fonts/fredoka-latin-600-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Fredoka"; font-weight: 600; font-style: normal; font-display: swap;
  src: url(../fonts/fredoka-latin-ext-600-normal.woff2) format("woff2"); unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Nunito"; font-weight: 400; font-style: normal; font-display: swap;
  src: url(../fonts/nunito-latin-400-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Nunito"; font-weight: 400; font-style: normal; font-display: swap;
  src: url(../fonts/nunito-latin-ext-400-normal.woff2) format("woff2"); unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Nunito"; font-weight: 700; font-style: normal; font-display: swap;
  src: url(../fonts/nunito-latin-700-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Nunito"; font-weight: 700; font-style: normal; font-display: swap;
  src: url(../fonts/nunito-latin-ext-700-normal.woff2) format("woff2"); unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Nunito"; font-weight: 400; font-style: italic; font-display: swap;
  src: url(../fonts/nunito-latin-400-italic.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Nunito"; font-weight: 400; font-style: italic; font-display: swap;
  src: url(../fonts/nunito-latin-ext-400-italic.woff2) format("woff2"); unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Atkinson Hyperlegible"; font-weight: 400; font-style: normal; font-display: swap;
  src: url(../fonts/atkinson-hyperlegible-latin-400-normal.woff2) format("woff2"); unicode-range: U+0000-024F, U+1E00-1EFF, U+2000-206F, U+20AC, U+2122, U+2212; }
@font-face { font-family: "Atkinson Hyperlegible"; font-weight: 700; font-style: normal; font-display: swap;
  src: url(../fonts/atkinson-hyperlegible-latin-700-normal.woff2) format("woff2"); unicode-range: U+0000-024F, U+1E00-1EFF, U+2000-206F, U+20AC, U+2122, U+2212; }
@font-face { font-family: "Atkinson Hyperlegible"; font-weight: 400; font-style: italic; font-display: swap;
  src: url(../fonts/atkinson-hyperlegible-latin-400-italic.woff2) format("woff2"); unicode-range: U+0000-024F, U+1E00-1EFF, U+2000-206F, U+20AC, U+2122, U+2212; }

/* ---------- Colors ---------- */
:root {
  --paper: #f5eee1;
  --paper-2: #ece2cf;
  --card: #fffaf0;
  --ink: #2b2118;
  --ink-2: #6b5a48;
  --ink-3: #9a8771;
  --line: #ddcfb8;
  --accent: #b5532e;          /* set per book */
  --accent-soft: #f3dccf;
  --done: #4f7a52;
  --shadow: 0 1px 2px rgba(60, 40, 20, .08), 0 6px 18px rgba(60, 40, 20, .10);
  --radius: 16px;
  --display: "Fraunces", Georgia, "Times New Roman", serif;
  --text: "Literata", Georgia, "Times New Roman", serif;
  --read-size: 19px;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --paper: #191512;
  --paper-2: #231d18;
  --card: #26201b;
  --ink: #efe5d6;
  --ink-2: #bfae98;
  --ink-3: #8c7c69;
  --line: #3a3029;
  --accent-soft: #3b2a22;
  --done: #8cbf8f;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 6px 18px rgba(0,0,0,.35);
  color-scheme: dark;
}

:root[data-theme="dark"] .chapter .kicker, :root[data-theme="dark"] .ch-tile .num,
:root[data-theme="dark"] .ch-tile.tale .badge, :root[data-theme="dark"] .chapter blockquote.moral strong,
:root[data-theme="dark"] .chapter .story > p:first-child::first-letter { color: color-mix(in srgb, var(--book) 55%, #fff); }
:root[data-theme="dark"] .ch-tile.read .num { color: var(--ink-3); }

/* ---------- Font styles (Options menu) ---------- */
:root[data-font="fun"] { --display: "Fredoka", "Nunito", system-ui, sans-serif; --text: "Nunito", system-ui, sans-serif; }
:root[data-font="easy"] { --display: "Atkinson Hyperlegible", system-ui, sans-serif; --text: "Atkinson Hyperlegible", system-ui, sans-serif; }
:root[data-font="fun"] .chapter { line-height: 1.7; }
:root[data-font="fun"] .chapter .kicker, :root[data-font="fun"] .continue small { font-weight: 700; }

/* ---------- Looks (colour themes) ---------- */
:root[data-look="candy"] {
  --paper: #fff2f7; --paper-2: #ffe0ec; --card: #ffffff; --ink: #3b2340; --ink-2: #7b5a80; --ink-3: #ad8db0;
  --line: #f6cfe0; --accent-soft: #ffe3ef; --done: #2fa98a; --shadow: 0 1px 2px rgba(190, 70, 130, .08), 0 6px 18px rgba(190, 70, 130, .12);
  --pattern: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cg stroke-linecap='round' stroke-width='4' opacity='.35'%3E%3Cpath d='M14 18l9 5' stroke='%23ff7eb6'/%3E%3Cpath d='M70 12l-4 9' stroke='%2365d3c4'/%3E%3Cpath d='M100 50l9 3' stroke='%23ffc857'/%3E%3Cpath d='M38 64l-6 7' stroke='%23a98bff'/%3E%3Cpath d='M86 96l8-5' stroke='%23ff7eb6'/%3E%3Cpath d='M18 100l3 9' stroke='%2365d3c4'/%3E%3C/g%3E%3C/svg%3E");
}
:root[data-look="floral"] {
  --paper: #f3f6ee; --paper-2: #e4ecdc; --card: #fffefa; --ink: #2d3a2b; --ink-2: #5d6e57; --ink-3: #8f9f88;
  --line: #d5e0cc; --accent-soft: #f6e3e8; --done: #5b8a4c; --shadow: 0 1px 2px rgba(60, 90, 50, .08), 0 6px 18px rgba(60, 90, 50, .10);
  --pattern: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cg opacity='.28'%3E%3Cg fill='%23e7a3b5' transform='translate(30 34)'%3E%3Ccircle cx='0' cy='-6' r='5'/%3E%3Ccircle cx='6' cy='0' r='5'/%3E%3Ccircle cx='0' cy='6' r='5'/%3E%3Ccircle cx='-6' cy='0' r='5'/%3E%3Ccircle r='3' fill='%23f2c45a'/%3E%3C/g%3E%3Cg fill='%23b9a5e0' transform='translate(104 98) scale(.75)'%3E%3Ccircle cx='0' cy='-6' r='5'/%3E%3Ccircle cx='6' cy='0' r='5'/%3E%3Ccircle cx='0' cy='6' r='5'/%3E%3Ccircle cx='-6' cy='0' r='5'/%3E%3Ccircle r='3' fill='%23f2c45a'/%3E%3C/g%3E%3Cpath d='M96 30c8-6 16-4 20 2c-8 4-14 4-20-2z M54 112c6-8 14-8 19-4c-6 6-12 7-19 4z' fill='%238fb37a'/%3E%3C/g%3E%3C/svg%3E");
}
:root[data-look="ocean"] {
  --paper: #eef6f9; --paper-2: #d9eaf0; --card: #ffffff; --ink: #14303b; --ink-2: #4d6e7a; --ink-3: #87a4af;
  --line: #c9dfe7; --accent-soft: #dcedf4; --done: #2f8f6f; --shadow: 0 1px 2px rgba(20, 70, 100, .08), 0 6px 18px rgba(20, 70, 100, .10);
  --pattern: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='60'%3E%3Cpath d='M0 30c20-12 40-12 60 0s40 12 60 0s30-10 40-6' fill='none' stroke='%2373b5cc' stroke-width='2' opacity='.25' stroke-linecap='round'/%3E%3C/svg%3E");
}
:root[data-look="night"] {
  --pattern: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='150' height='150'%3E%3Cg fill='%23f2d36b'%3E%3Ccircle cx='20' cy='30' r='1.2' opacity='.5'/%3E%3Ccircle cx='90' cy='14' r='1' opacity='.35'/%3E%3Ccircle cx='128' cy='70' r='1.4' opacity='.45'/%3E%3Ccircle cx='60' cy='96' r='1' opacity='.3'/%3E%3Ccircle cx='16' cy='128' r='1.3' opacity='.4'/%3E%3Ccircle cx='110' cy='132' r='.9' opacity='.3'/%3E%3C/g%3E%3C/svg%3E");
}
body { background-image: var(--pattern, none); background-attachment: fixed; }

/* ---------- Base ---------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--text);
  line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
  min-height: 100vh;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; }
a { color: inherit; }
img { display: block; max-width: 100%; }
.screen { max-width: 720px; margin: 0 auto; padding: 0 16px calc(40px + env(safe-area-inset-bottom)); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 8px; }

/* ---------- Home ---------- */
.home-head { padding: calc(28px + env(safe-area-inset-top)) 4px 18px; display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; }
.home-head h1 { font-family: var(--display); font-weight: 600; font-size: 38px; line-height: 1.05; margin: 0; letter-spacing: -.01em; }
.menu-btn { color: var(--ink); background: var(--card); box-shadow: var(--shadow); }
.menu-btn svg { width: 22px; height: 22px; }
.home-head p { margin: 6px 0 0; color: var(--ink-2); font-size: 15px; }
.icon-btn { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; color: var(--ink-2); flex: none; }
.icon-btn:active { background: var(--paper-2); }
.icon-btn svg { width: 22px; height: 22px; }

.book-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.shelf-head { margin: 28px 0 12px; font-size: 20px; color: var(--ink); }
.book-card {
  position: relative; display: flex; flex-direction: column; text-align: left;
  background: var(--card); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow);
  transition: transform .15s ease;
}
.book-card:active { transform: scale(.98); }
.book-card .cover { position: relative; aspect-ratio: 3 / 4; background: var(--book) ; overflow: hidden; }
.book-card .cover img { position: relative; z-index: 1; width: 100%; height: 100%; object-fit: cover; object-position: var(--focus, 50% 30%); }
.book-card .cover::after { content: ""; position: absolute; inset: 0; box-shadow: inset 0 0 0 1px rgba(0,0,0,.06); }
.cover-fallback { position: absolute; inset: 0; display: grid; place-items: center; color: rgba(255,255,255,.9); font-family: var(--display); font-size: 44px; }
.book-card .meta { flex: 1; display: flex; flex-direction: column; padding: 10px 12px 12px; border-top: 4px solid var(--book); }
.book-card .meta .sub { margin-top: auto; padding-top: 4px; }
.book-card h2 { font-family: var(--display); font-weight: 600; font-size: 18px; line-height: 1.15; margin: 0; }
.book-card .sub { margin-top: 4px; font-size: 12.5px; color: var(--ink-2); display: flex; justify-content: space-between; gap: 6px; }
.progress-bar { height: 4px; border-radius: 2px; background: var(--paper-2); margin-top: 8px; overflow: hidden; }
.progress-bar span { display: block; height: 100%; background: var(--book); border-radius: 2px; }

.continue {
  position: relative; display: flex; align-items: center; gap: 4px; margin: 2px 0 6px;
  background: var(--card); border-radius: var(--radius); padding: 10px 12px 10px 10px; box-shadow: var(--shadow); overflow: hidden;
}
.continue::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--book); }
.cont-open { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; text-align: left; }
.continue .thumb { width: 54px; aspect-ratio: 2 / 3; border-radius: 8px; overflow: hidden; flex: none; background: var(--book); box-shadow: 0 2px 6px rgba(0,0,0,.15); }
.continue .thumb img { width: 100%; height: 100%; object-fit: cover; object-position: var(--focus, 50% 30%); }
.cont-text { min-width: 0; }
.continue small { display: block; color: var(--book); font-size: 11.5px; text-transform: uppercase; letter-spacing: .08em; font-weight: 700; }
.continue strong { display: block; font-family: var(--display); font-weight: 600; font-size: 18px; line-height: 1.2; margin: 2px 0 1px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.continue span.of { color: var(--ink-2); font-size: 13px; }
.cont-play { flex: none; width: 50px; height: 50px; border-radius: 50%; display: grid; place-items: center; background: var(--book); color: #fff;
  box-shadow: 0 4px 12px color-mix(in srgb, var(--book) 40%, transparent); transition: transform .15s ease; }
.cont-play svg { width: 22px; height: 22px; }
.cont-play:active { transform: scale(.94); }
:root[data-theme="dark"] .continue small { color: color-mix(in srgb, var(--book) 55%, #fff); }

/* shelves: one sideways row of books each */
.shelf { margin-top: 22px; }
.shelf-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin: 0 2px 10px; }
.shelf-head h2 { margin: 0; font-family: var(--display); font-weight: 600; font-size: 21px; line-height: 1.2; }
.shelf-head span { font-size: 13px; color: var(--ink-3); }
.shelf-row { display: flex; gap: 12px; overflow-x: auto; margin: 0 -16px; padding: 2px 16px 16px; scroll-snap-type: x mandatory; scroll-padding: 0 16px;
  scrollbar-width: none; -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain; }
.shelf-row::-webkit-scrollbar { display: none; }
.shelf-row .book-card { flex: 0 0 41%; max-width: 210px; scroll-snap-align: start; }
.shelf-row .book-card .cover { aspect-ratio: 2 / 3; }
.shelf-row .book-card h2 { font-size: 16px; }
.shelf-row .book-card .meta { padding: 9px 11px 11px; border-top-width: 3px; }
.shelf-row .book-card .sub { font-size: 12px; flex-wrap: wrap; gap: 0 8px; }
.shelf-row .book-card .sub span { white-space: nowrap; }

.credits-link { display: block; margin: 28px auto 0; font-size: 13px; color: var(--ink-3); text-decoration: underline; text-underline-offset: 3px; }

/* ---------- Book (chapter grid) ---------- */
.book-hero { position: relative; margin: 0 -16px; height: 210px; overflow: hidden; background: var(--book); }
.book-hero img { width: 100%; height: 100%; object-fit: cover; object-position: var(--focus, 50% 30%); }
.book-hero::after { content: ""; position: absolute; inset: 0; background: linear-gradient(to bottom, rgba(0,0,0,.35), transparent 35%, transparent 45%, var(--paper) 100%); }
.book-hero .icon-btn { position: absolute; top: calc(8px + env(safe-area-inset-top)); left: 8px; z-index: 2; color: #fff; background: rgba(0,0,0,.28); backdrop-filter: blur(4px); }
.book-title { position: relative; margin-top: -46px; z-index: 1; padding: 0 2px; }
.book-title h1 { font-family: var(--display); font-weight: 600; font-size: 30px; line-height: 1.05; margin: 0; }
.book-title p { margin: 6px 0 0; color: var(--ink-2); font-size: 14.5px; }

.group-head {
  position: sticky; top: 0; z-index: 3; margin: 22px -16px 10px; padding: 10px 18px 8px;
  background: color-mix(in srgb, var(--paper) 92%, transparent); backdrop-filter: blur(6px);
  font-family: var(--display); font-weight: 600; font-size: 17px; line-height: 1.2;
  display: flex; justify-content: space-between; align-items: baseline; gap: 10px;
}
.group-head small { font-family: var(--text); font-weight: 400; font-size: 12.5px; color: var(--ink-3); white-space: nowrap; }
.no-groups { height: 18px; }

.ch-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.ch-tile {
  position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 6px; text-align: left;
  min-height: 104px; padding: 10px 10px 11px; border-radius: 14px;
  background: var(--card); box-shadow: 0 1px 2px rgba(60,40,20,.07); border: 1px solid var(--line);
  transition: transform .12s ease;
}
.ch-tile:active { transform: scale(.97); }
.ch-tile .num { font-family: var(--display); font-weight: 600; font-size: 26px; line-height: 1; color: var(--book); }
.ch-tile .num.word { font-size: 18px; padding-top: 4px; }
.ch-tile .t { font-size: 12.5px; line-height: 1.3; color: var(--ink-2);
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.ch-tile.tale { background: color-mix(in srgb, var(--book) 9%, var(--card)); border-style: dashed; border-color: color-mix(in srgb, var(--book) 45%, var(--line)); }
.ch-tile.tale .badge { position: absolute; top: 9px; right: 9px; font-size: 10px; letter-spacing: .05em; text-transform: uppercase; color: var(--book); }
.ch-tile.read { background: var(--paper-2); box-shadow: none; }
.ch-tile.read .num { color: var(--ink-3); }
.ch-tile .tick { position: absolute; top: 8px; right: 8px; width: 20px; height: 20px; border-radius: 50%; background: var(--done); color: #fff; display: grid; place-items: center; }
.ch-tile .tick svg { width: 12px; height: 12px; }
.ch-tile.current { border: 2px solid var(--book); }
.legend { margin: 14px 2px 0; font-size: 12.5px; color: var(--ink-2); display: flex; gap: 8px; align-items: center; }
.legend i { width: 16px; height: 12px; border-radius: 4px; border: 1px dashed var(--book); background: color-mix(in srgb, var(--book) 9%, var(--card)); }

/* ---------- Reader ---------- */
.reader-bar {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 4px;
  margin: 0 -16px; padding: calc(4px + env(safe-area-inset-top)) 6px 4px;
  background: color-mix(in srgb, var(--paper) 94%, transparent); backdrop-filter: blur(8px);
  border-bottom: 1px solid transparent; transition: border-color .2s;
}
.reader-bar.scrolled { border-bottom-color: var(--line); }
.reader-bar .where { flex: 1; min-width: 0; font-size: 13px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: center; }
.read-progress { position: absolute; left: 0; bottom: -1px; height: 2px; background: var(--book); width: 0; }

.settings { position: sticky; top: calc(56px + env(safe-area-inset-top)); z-index: 6; margin: 6px 0 0; padding: 14px; border-radius: 16px; background: var(--card);
  box-shadow: var(--shadow); display: grid; gap: 12px;
  opacity: 0; transform: translateY(-8px) scale(.98); transform-origin: top right; pointer-events: none; visibility: hidden; max-height: 0; padding-top: 0; padding-bottom: 0;
  transition: opacity .2s ease, transform .25s cubic-bezier(.22, .9, .3, 1), visibility 0s linear .25s, max-height 0s linear .25s, padding 0s linear .25s; }
.settings.open { opacity: 1; transform: none; pointer-events: auto; visibility: visible; max-height: 300px; padding-top: 14px; padding-bottom: 14px;
  transition: opacity .2s ease, transform .25s cubic-bezier(.22, .9, .3, 1); }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.set-row label { font-size: 14px; color: var(--ink-2); }
.settings .seg { display: flex; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--paper); }
.settings .seg button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 14px; min-width: 52px; font-size: 15px; transition: background .15s, color .15s; }
.settings .seg button svg { width: 16px; height: 16px; }
.settings .seg button + button { border-left: 1px solid var(--line); }
.settings .seg button[aria-pressed="true"] { background: var(--book); color: #fff; }

.chapter { max-width: 34em; margin: 0 auto; padding-top: 18px; font-size: var(--read-size); line-height: 1.65; }
.chapter .kicker { font-size: 13px; letter-spacing: .08em; text-transform: uppercase; color: var(--book); margin: 8px 0 6px; }
.chapter h1 { font-family: var(--display); font-weight: 600; font-size: 1.65em; line-height: 1.12; margin: 0 0 6px; letter-spacing: -.01em; }
.chapter .mins { font-size: 14px; color: var(--ink-3); margin-bottom: 26px; }
.chapter p { margin: 0 0 1em; }
.chapter .story > p:first-child::first-letter { font-family: var(--display); font-weight: 600; float: left; font-size: 3.3em; line-height: .85; padding: .08em .1em 0 0; color: var(--book); }
.chapter hr.scene { border: 0; margin: 1.6em 0; text-align: center; height: auto; }
.chapter hr.scene::before { content: "\2726  \2726  \2726"; color: var(--ink-3); font-size: 14px; letter-spacing: .4em; }
.chapter blockquote { margin: 1.4em 0; padding: 14px 18px; border-radius: 14px; background: var(--accent-soft); background: color-mix(in srgb, var(--book) 12%, var(--card)); }
.chapter blockquote p { margin: 0; }
.chapter blockquote.moral { text-align: center; font-style: italic; }
.chapter blockquote.moral strong { font-style: normal; display: block; font-family: var(--display); color: var(--book); font-size: .8em; letter-spacing: .08em; text-transform: uppercase; }
.chapter aside.dyk { margin: 1.6em 0; padding: 14px 16px 14px 16px; border-left: 4px solid var(--book); background: var(--card); border-radius: 0 12px 12px 0; font-size: .88em; line-height: 1.55; color: var(--ink-2); }
.chapter aside.dyk p { margin: 0; }
.chapter aside.dyk strong { color: var(--ink); }
.chapter ol, .chapter ul { padding-left: 1.3em; margin: 0 0 1em; }
.chapter strong { font-weight: 700; }

.end-nav { max-width: 34em; margin: 34px auto 0; display: grid; gap: 10px; }
.end-mark { text-align: center; font-family: var(--display); font-style: italic; color: var(--ink-3); margin: 10px 0 8px; }
.next-btn {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; padding: 16px 18px; border-radius: 16px;
  background: var(--book); color: #fff; box-shadow: var(--shadow);
}
.next-btn small { display: block; opacity: .85; font-size: 12px; text-transform: uppercase; letter-spacing: .07em; }
.next-btn strong { display: block; font-family: var(--display); font-weight: 600; font-size: 18px; line-height: 1.2; }
.next-btn svg { margin-left: auto; width: 24px; height: 24px; flex: none; }
.row-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.row-btns > :only-child { grid-column: 1 / -1; }
.ghost-btn { padding: 13px 14px; border-radius: 14px; border: 1px solid var(--line); background: var(--card); font-size: 15px; text-align: center; }

/* ---------- Credits ---------- */
.plain { padding-top: calc(8px + env(safe-area-inset-top)); }
.plain h1 { font-family: var(--display); font-weight: 600; font-size: 28px; margin: 8px 0 14px; }
.credit { background: var(--card); border-radius: 14px; padding: 14px; margin-bottom: 12px; box-shadow: var(--shadow); font-size: 14.5px; }
.credit strong { font-family: var(--display); font-weight: 600; display: block; font-size: 16px; }
.credit p { margin: 4px 0 0; color: var(--ink-2); }

@media (min-width: 560px) {
  .book-grid { gap: 20px; }
  .shelf-row .book-card { flex-basis: 180px; }
  .ch-grid { gap: 12px; }
  .ch-tile .t { font-size: 13.5px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* ---------- Listen mode: player bar ---------- */
.listen-btn { display: inline-flex; align-items: center; gap: 9px; margin: 2px 0 14px; padding: 11px 22px 11px 16px; border-radius: 999px; background: var(--book); color: #fff;
  font-size: 15.5px; font-weight: 700; border: 1.5px solid var(--book); box-shadow: 0 4px 14px color-mix(in srgb, var(--book) 35%, transparent);
  transition: background .2s, color .2s, box-shadow .2s, transform .15s; }
.listen-btn:active { transform: scale(.97); }
.listen-btn svg { width: 19px; height: 19px; flex: none; }
.listen-btn.playing { background: var(--card); color: var(--book); box-shadow: none; }
.listen-btn .eq { display: none; align-items: flex-end; gap: 2.5px; width: 19px; height: 16px; flex: none; }
.listen-btn .eq b { flex: 1; background: currentColor; border-radius: 1px; height: 30%; animation: eq 1s ease-in-out infinite; }
.listen-btn .eq b:nth-child(2) { animation-delay: -.35s; }
.listen-btn .eq b:nth-child(3) { animation-delay: -.7s; }
.listen-btn.playing .eq { display: inline-flex; }
.listen-btn.playing svg { display: none; }
@keyframes eq { 0%, 100% { height: 25%; } 50% { height: 100%; } }
:root[data-theme="dark"] .listen-btn.playing { color: color-mix(in srgb, var(--book) 55%, #fff); border-color: currentColor; }

.player { position: fixed; left: 8px; right: 8px; bottom: calc(8px + env(safe-area-inset-bottom)); z-index: 50; background: var(--card);
  border: 1px solid var(--line); border-radius: 20px;
  box-shadow: 0 10px 30px rgba(60, 40, 20, .18), 0 2px 6px rgba(60, 40, 20, .08); padding: 10px 12px 10px;
  transform: translateY(calc(100% + 30px)); visibility: hidden; overflow: hidden;
  transition: transform .45s cubic-bezier(.22, .9, .3, 1), visibility 0s linear .45s; }
:root[data-theme="dark"] .player { box-shadow: 0 10px 30px rgba(0,0,0,.5); }
.player.show { transform: none; visibility: visible; transition: transform .45s cubic-bezier(.22, .9, .3, 1), visibility 0s; }
@media (prefers-reduced-motion: reduce) { .player, .player.show { transition: none; } }
.player-inner { max-width: 704px; margin: 0 auto; display: grid; }
.pl-top { display: flex; align-items: center; gap: 8px; }
.pl-thumb { flex: none; width: 42px; height: 42px; border-radius: 10px; overflow: hidden; background: var(--pl-color, var(--accent)); }
.pl-thumb img { width: 100%; height: 100%; object-fit: cover; object-position: var(--focus, 50% 30%); }
.pl-title { flex: 1; min-width: 0; text-align: left; padding: 2px 2px; }
.pl-title small { display: block; font-size: 11px; letter-spacing: .07em; text-transform: uppercase; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pl-title strong { display: block; font-family: var(--display); font-weight: 600; font-size: 15.5px; line-height: 1.25; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pl-speed { flex: none; font-size: 13px; padding: 5px 11px; border: 1px solid var(--line); border-radius: 999px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.pl-fold, .pl-close { flex: none; width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; color: var(--ink-3); }
.pl-fold svg { width: 22px; height: 22px; }
.pl-close svg { width: 18px; height: 18px; }
.pl-fold:active, .pl-close:active, .pl-ctrls button:active { background: var(--paper-2); }
.pl-mini-play { display: none; flex: none; width: 40px; height: 40px; border-radius: 50%; place-items: center; background: var(--pl-color, var(--accent)); color: #fff; }
.pl-mini-play svg { width: 20px; height: 20px; }
.pl-full { display: grid; gap: 2px; max-height: 140px; opacity: 1; transition: max-height .35s cubic-bezier(.22, .9, .3, 1), opacity .25s; }
.pl-seek { display: flex; align-items: center; gap: 8px; margin-top: 6px; font-size: 12px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.pl-seek span { min-width: 38px; }
.pl-seek span:last-child { text-align: right; }
.pl-seek input { flex: 1; min-width: 0; accent-color: var(--pl-color, var(--accent)); height: 22px; }
.pl-ctrls { display: flex; justify-content: space-between; align-items: center; max-width: 340px; width: 100%; margin: 0 auto; }
.pl-ctrls button { width: 44px; height: 44px; display: grid; place-items: center; color: var(--ink-2); border-radius: 50%; }
.pl-ctrls svg { width: 27px; height: 27px; }
.pl-ctrls .pl-skip svg { width: 22px; height: 22px; }
.pl-ctrls .pl-play { width: 58px; height: 58px; background: var(--pl-color, var(--accent)); color: #fff;
  box-shadow: 0 4px 14px color-mix(in srgb, var(--pl-color, var(--accent)) 40%, transparent); }
.pl-ctrls .pl-play svg { width: 26px; height: 26px; }
.pl-ctrls button:disabled, .pl-mini-play:disabled { opacity: .4; cursor: default; }
.pl-msg { font-size: 13px; color: var(--ink-2); text-align: center; padding-top: 4px; }
.pl-line { display: none; position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: color-mix(in srgb, var(--pl-color, var(--accent)) 15%, transparent); }
.pl-line span { display: block; height: 100%; width: 0; background: var(--pl-color, var(--accent)); }

/* the small player: one slim row */
.player.mini { padding: 8px 8px 10px 8px; }
.player.mini .pl-full { max-height: 0; opacity: 0; overflow: hidden; }
.player.mini .pl-speed { display: none; }
.player.mini .pl-mini-play { display: grid; }
.player.mini .pl-line { display: block; }

body.has-player .screen { padding-bottom: calc(190px + env(safe-area-inset-bottom)); transition: padding-bottom .45s; }
body.has-player.player-mini .screen { padding-bottom: calc(100px + env(safe-area-inset-bottom)); }

/* ---------- Read-along highlighting ----------
   Each word fills with yellow from left to right as the narrator says it
   (--p goes from 0% to 100%). Day mode: a yellow highlighter sweeps under the
   text. Night mode: the text itself turns yellow, left to right. */
.story.reading .w {
  --hl: #fbe58b;
  background-image: linear-gradient(var(--hl), var(--hl));
  background-repeat: no-repeat;
  background-size: var(--p, 0%) 100%;
  border-radius: 3px;
  -webkit-box-decoration-break: clone; box-decoration-break: clone;
}
:root[data-theme="dark"] .story.reading .w {
  background-image: linear-gradient(to right, #f2d36b var(--p, 0%), var(--ink) var(--p, 0%));
  background-size: 100% 100%;
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
  border-radius: 0;
}

/* ---------- Downloads ---------- */
.book-hero .hero-dl { left: auto; right: 8px; }
.book-hero .hero-menu { left: auto; right: 60px; }
.book-hero .hero-menu.alone { right: 8px; }
.ch-tile .dl-mark { position: absolute; right: 8px; bottom: 8px; width: 20px; height: 20px; border-radius: 50%;
  display: none; place-items: center; background: color-mix(in srgb, var(--book) 16%, var(--card)); color: var(--book); }
.ch-tile .dl-mark svg { width: 13px; height: 13px; }
.ch-tile.is-dl .dl-mark { display: grid; }
.ch-tile .sel-mark { display: none; }

/* picking chapters */
.selecting .ch-tile { transition: transform .12s ease, box-shadow .12s ease; }
.selecting .ch-tile.no-audio, .selecting .ch-tile.is-dl { opacity: .45; }
.selecting .ch-tile .tick, .selecting .ch-tile .badge { display: none; }
.selecting .ch-tile .sel-mark { position: absolute; top: 8px; right: 8px; width: 22px; height: 22px; border-radius: 50%;
  display: grid; place-items: center; border: 2px solid var(--line); background: var(--card); color: transparent; }
.selecting .ch-tile .sel-mark svg { width: 12px; height: 12px; }
.selecting .ch-tile.selected { border: 2px solid var(--book); box-shadow: 0 0 0 3px color-mix(in srgb, var(--book) 18%, transparent); }
.selecting .ch-tile.selected .sel-mark { background: var(--book); border-color: var(--book); color: #fff; }
.selecting .ch-tile.is-dl .sel-mark, .selecting .ch-tile.no-audio .sel-mark { display: none; }
.selecting .group-head { cursor: pointer; }
.selecting .group-head span { text-decoration: underline dotted; text-underline-offset: 4px; }
.selecting { padding-bottom: calc(150px + env(safe-area-inset-bottom)) !important; }
.ch-tile.no-audio:not(.read) .num { opacity: .7; }

.select-bar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 60; background: var(--card); border-top: 1px solid var(--line);
  box-shadow: 0 -6px 20px rgba(60, 40, 20, .12); padding: 10px 16px calc(12px + env(safe-area-inset-bottom));
  transform: translateY(115%); transition: transform .4s cubic-bezier(.22, .9, .3, 1); }
.select-bar.show { transform: none; }
.sb-hint { max-width: 720px; margin: 0 auto 8px; font-size: 13px; color: var(--ink-2); text-align: center; }
.sb-row { max-width: 720px; margin: 0 auto; display: flex; gap: 10px; }
.sb-cancel { padding: 12px 18px; border-radius: 14px; border: 1px solid var(--line); font-size: 15px; }
.sb-go { flex: 1; display: flex; align-items: center; justify-content: center; gap: 8px; padding: 12px 16px; border-radius: 14px;
  color: #fff; font-size: 15px; font-weight: 700; }
.sb-go svg { width: 19px; height: 19px; }
.sb-go:disabled { opacity: .45; }
.sb-go { background: var(--sb-color, #2f6690); }

/* the sheet */
.sheet-wrap { position: fixed; inset: 0; z-index: 80; }
.sheet-back { position: absolute; inset: 0; background: rgba(20, 12, 6, .45); opacity: 0; transition: opacity .3s; }
.sheet { position: absolute; left: 0; right: 0; bottom: 0; max-width: 560px; margin: 0 auto; max-height: 88vh; overflow: auto;
  background: var(--card); border-radius: 22px 22px 0 0; padding: 8px 20px calc(20px + env(safe-area-inset-bottom));
  transform: translateY(100%); transition: transform .38s cubic-bezier(.22, .9, .3, 1); box-shadow: 0 -10px 30px rgba(0,0,0,.18); }
.sheet-wrap.open .sheet-back { opacity: 1; }
.sheet-wrap.open .sheet { transform: none; }
.sheet-grip { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 2px auto 14px; }
.sheet h2 { font-family: var(--display); font-weight: 600; font-size: 22px; margin: 0; }
.sheet-sub { margin: 2px 0 14px; color: var(--ink-2); font-size: 14px; }
.sheet-status { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 14px; background: var(--paper-2); font-size: 14.5px; color: var(--ink-2); }
.sheet-status svg { width: 20px; height: 20px; flex: none; color: var(--ink-3); }
.sheet-status strong { color: var(--ink); }
.sheet-sec { margin: 18px 0 6px; }
.sheet-sec h3 { margin: 0; font-size: 15px; font-family: var(--display); font-weight: 600; }
.sheet-from { margin: 2px 0 10px; font-size: 13.5px; color: var(--ink-2); }
.sheet-from b { color: var(--ink); font-weight: 700; }
.chips { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.chip { display: grid; gap: 1px; justify-items: center; padding: 10px 4px; border-radius: 14px; border: 1.5px solid var(--line); background: var(--card); }
.chip strong { font-family: var(--display); font-weight: 600; font-size: 22px; line-height: 1.1; }
.chip small { font-size: 11.5px; color: var(--ink-3); }
.chip:active { transform: scale(.97); }
.chip:disabled { opacity: .45; }
.sheet-btn { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; margin-top: 10px; padding: 14px 16px;
  border-radius: 14px; border: 1px solid var(--line); background: var(--card); font-size: 15.5px; }
.sheet-btn.primary { background: var(--ink); color: var(--paper); border-color: transparent; font-weight: 700; }
.sheet-btn svg { width: 18px; height: 18px; }
.sheet-btn:disabled { opacity: .6; }
.sheet-link { display: block; margin: 14px auto 0; font-size: 14px; color: var(--ink-2); text-decoration: underline; text-underline-offset: 3px; }
.sheet-link.danger { color: #a33a2a; }
.sheet-link.danger.sure { font-weight: 700; }
:root[data-theme="dark"] .sheet-link.danger { color: #e58b78; }
.sheet-note { margin: 16px 0 0; font-size: 13px; color: var(--ink-3); text-align: center; line-height: 1.45; }

/* progress / message bar at the top */
.dl-bar { position: fixed; left: 50%; top: calc(10px + env(safe-area-inset-top)); z-index: 90; width: min(92vw, 420px);
  display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 4px 10px; padding: 10px 8px 10px 14px; overflow: hidden;
  border-radius: 16px; background: var(--ink); color: var(--paper); box-shadow: 0 8px 24px rgba(0,0,0,.25);
  transform: translate(-50%, calc(-100% - 30px)); transition: transform .4s cubic-bezier(.22, .9, .3, 1); }
.dl-bar.show { transform: translate(-50%, 0); }
.dl-bar.warn { background: #8a3b22; color: #fff; }
.dl-text { min-width: 0; }
.dl-text strong { display: block; font-size: 14.5px; }
.dl-text small { display: block; font-size: 12.5px; opacity: .8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dl-x { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; opacity: .85; }
.dl-x svg { width: 17px; height: 17px; }
.dl-prog { grid-column: 1 / -1; height: 3px; border-radius: 2px; background: rgba(255,255,255,.18); overflow: hidden; display: none; margin-right: 6px; }
.dl-bar.busy .dl-prog { display: block; }
.dl-prog span { display: block; height: 100%; width: 0; background: #f2d36b; transition: width .25s linear; }

/* reader */
.listen-btn.soon { background: var(--paper-2); color: var(--ink-3); box-shadow: none; cursor: default; }
.saved-note { display: inline-flex; align-items: center; gap: 4px; margin-left: 10px; font-size: 13px; color: var(--ink-3); vertical-align: middle; }
.saved-note svg { width: 15px; height: 15px; }

/* ---------- Options sheet ---------- */
.opt-sec { margin-top: 18px; }
.opt-sec h3 { margin: 0 0 10px; font-family: var(--display); font-weight: 600; font-size: 16px; }
.look-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.look { display: grid; gap: 6px; justify-items: center; padding: 6px 2px 8px; border-radius: 14px; border: 2px solid transparent; }
.look[aria-pressed="true"] { border-color: var(--ink); background: var(--paper-2); }
.look-prev { width: 46px; height: 46px; border-radius: 50%; position: relative; box-shadow: inset 0 0 0 1px rgba(0,0,0,.12); overflow: hidden; }
.look-prev i { position: absolute; width: 18px; height: 18px; border-radius: 50%; }
.look-prev i:first-child { left: 7px; top: 9px; }
.look-prev i:last-child { right: 7px; bottom: 9px; }
.look-name { font-size: 12.5px; color: var(--ink-2); }
.look[aria-pressed="true"] .look-name { color: var(--ink); font-weight: 700; }
.font-list { display: grid; gap: 8px; }
.font-opt { display: flex; align-items: center; gap: 14px; padding: 10px 14px; border-radius: 14px; border: 1.5px solid var(--line); background: var(--card); text-align: left; }
.font-opt[aria-pressed="true"] { border-color: var(--ink); background: var(--paper-2); }
.font-aa { width: 44px; font-size: 28px; line-height: 1; text-align: center; color: var(--ink); }
.font-txt { flex: 1; min-width: 0; }
.font-txt strong { display: block; font-size: 16.5px; font-weight: 600; }
.font-txt small { display: block; font-size: 12.5px; color: var(--ink-3); font-family: var(--text); }
.font-tick { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: var(--ink); color: var(--paper); opacity: 0; }
.font-tick svg { width: 12px; height: 12px; }
.font-opt[aria-pressed="true"] .font-tick { opacity: 1; }
.f-fun { font-family: "Fredoka", "Nunito", system-ui, sans-serif; font-weight: 600; }
.f-classic { font-family: "Fraunces", Georgia, serif; font-weight: 600; }
.f-easy { font-family: "Atkinson Hyperlegible", system-ui, sans-serif; font-weight: 700; }
.size-seg { display: flex; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--paper); }
.size-seg button { flex: 1; padding: 9px 0; transition: background .15s, color .15s; }
.size-seg button + button { border-left: 1px solid var(--line); }
.size-seg button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.size-sample { margin: 10px 2px 0; font-size: var(--read-size); line-height: 1.5; color: var(--ink-2); font-family: var(--text); }
.sheet .sheet-link { text-align: center; }

/* ---------- Profile ---------- */
.profile-row { display: flex; align-items: center; gap: 12px; margin-top: 14px; padding: 12px 14px; border-radius: 16px; background: var(--paper-2); text-decoration: none; }
.pr-avatar { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; background: var(--card); color: var(--ink-2); box-shadow: var(--shadow); flex: none; }
.pr-avatar svg { width: 24px; height: 24px; }
.pr-text { flex: 1; min-width: 0; }
.pr-text strong { display: block; font-family: var(--display); font-weight: 600; font-size: 16.5px; }
.pr-text small { display: block; font-size: 12.5px; color: var(--ink-3); }
.pr-chev svg { width: 20px; height: 20px; color: var(--ink-3); }
.prof-top { display: flex; align-items: center; gap: 6px; margin: 0 0 8px -8px; }
.prof-top h1 { margin: 0; font-family: var(--display); font-weight: 600; font-size: 26px; }
.prof-card { background: var(--card); border-radius: 20px; padding: 16px; margin-top: 14px; box-shadow: var(--shadow); }
.prof-card h2 { margin: 0 0 6px; font-family: var(--display); font-weight: 600; font-size: 18px; }
.prof-id { display: flex; align-items: center; gap: 16px; }
.prof-pic { position: relative; width: 78px; height: 78px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: var(--paper-2); color: var(--ink-3); border: 2px dashed var(--line); }
.prof-pic > svg { width: 38px; height: 38px; }
.prof-cam { position: absolute; right: -2px; bottom: -2px; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--ink); color: var(--paper); border: 2px solid var(--card); }
.prof-cam svg { width: 15px; height: 15px; }
.prof-name strong { display: block; font-family: var(--display); font-weight: 600; font-size: 22px; }
.prof-name small { color: var(--ink-3); font-size: 13.5px; }
.prof-note { margin: 0 0 12px; font-size: 14px; color: var(--ink-2); }
.prof-btn { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; margin-top: 8px; padding: 13px 16px; border-radius: 14px;
  border: 1.5px solid var(--line); font-size: 15.5px; font-weight: 700; }
.prof-btn.primary { background: var(--ink); color: var(--paper); border-color: transparent; }
.soon-tag { font-size: 10.5px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; padding: 3px 7px; border-radius: 999px; background: color-mix(in srgb, currentColor 14%, transparent); opacity: .85; }
.prof-row { display: flex; align-items: center; gap: 10px; width: 100%; padding: 12px 2px; border-top: 1px solid var(--line); text-align: left; font-size: 15px; }
.prof-card h2 + .prof-row { border-top: 0; }
.prof-row span { flex: 1; }
.prof-row em { font-style: normal; color: var(--ink-3); font-size: 14px; }
.prof-row svg { width: 18px; height: 18px; color: var(--ink-3); }
.premium { background: linear-gradient(140deg, #3a2a5c, #7b3f73 55%, #c86b4a); color: #fff; }
.prem-head { display: flex; align-items: center; gap: 12px; }
.prem-head h2 { margin: 0; color: #fff; }
.prem-head small { opacity: .85; font-size: 13px; }
.prem-crown { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; background: rgba(255,255,255,.18); color: #ffd36b; flex: none; }
.prem-crown svg { width: 24px; height: 24px; }
.prem-list { list-style: none; margin: 14px 0; padding: 0; display: grid; gap: 8px; font-size: 14.5px; }
.prem-list li { display: flex; gap: 10px; align-items: center; }
.prem-list svg { width: 16px; height: 16px; color: #ffd36b; flex: none; }
.prem-btn { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; padding: 14px 16px; border-radius: 14px;
  background: #ffd36b; color: #3a2a1c; font-size: 16px; font-weight: 700; box-shadow: 0 6px 18px rgba(0,0,0,.2); }
.home-head .menu-btn { align-self: flex-start; margin-top: -10px; margin-right: -4px; }

/* sign-in */
.pr-avatar img, .prof-pic img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.pr-avatar { overflow: hidden; }
.prof-pic.has-photo { border-style: solid; padding: 0; }
.prof-btn.google { background: var(--card); gap: 10px; }
.g-logo { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-family: Arial, sans-serif; font-weight: 700; font-size: 14px; color: #fff;
  background: conic-gradient(#ea4335 0 25%, #fbbc05 0 50%, #34a853 0 75%, #4285f4 0); }
.or { display: flex; align-items: center; gap: 10px; margin: 14px 0 4px; color: var(--ink-3); font-size: 13px; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.auth-form { display: grid; gap: 10px; margin-top: 6px; }
.auth-form label { display: grid; gap: 4px; font-size: 13.5px; color: var(--ink-2); }
.auth-form input, .name-form input { font: inherit; font-size: 16px; padding: 12px 14px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--paper); color: var(--ink); }
.auth-form input:focus, .name-form input:focus { outline: none; border-color: var(--ink-2); }
.auth-err { margin: 0; padding: 10px 12px; border-radius: 12px; background: #fbe3dd; color: #8a2f1c; font-size: 14px; }
:root[data-theme="dark"] .auth-err { background: #4a2219; color: #f3c2b4; }
.link-btn { color: var(--ink); text-decoration: underline; text-underline-offset: 3px; font-size: 14px; font-weight: 700; }
.prof-card > .link-btn { display: block; margin: 12px auto 0; }
.auth-switch { margin: 12px 0 0; text-align: center; font-size: 14px; color: var(--ink-2); }
.name-row em { margin-right: 6px; }
.name-form { display: flex; gap: 8px; padding: 0 0 12px; }
.name-form input { flex: 1; min-width: 0; padding: 10px 12px; }
.prof-btn.small { width: auto; margin: 0; padding: 10px 16px; }
.prof-card .prof-btn[data-signout] { margin-top: 14px; }
.prof-btn:disabled { opacity: .55; }

/* ---------- Ad break ---------- */
.ad-wrap { position: fixed; inset: 0; z-index: 95; display: grid; place-items: center; padding: 20px;
  background: rgba(20, 12, 6, .55); backdrop-filter: blur(4px); opacity: 0; transition: opacity .25s; }
.ad-wrap.open { opacity: 1; }
.ad-card { width: min(100%, 380px); background: var(--card); border-radius: 24px; padding: 14px 14px 16px; box-shadow: 0 20px 50px rgba(0,0,0,.3);
  transform: translateY(16px) scale(.98); transition: transform .3s cubic-bezier(.22, .9, .3, 1); }
.ad-wrap.open .ad-card { transform: none; }
.ad-label { font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); text-align: center; margin-bottom: 10px; font-weight: 700; }
.ad-slot { border-radius: 18px; padding: 22px 18px 18px; text-align: center; color: #fff;
  background: linear-gradient(140deg, #3a2a5c, #7b3f73 55%, #c86b4a); min-height: 250px; display: grid; align-content: center; justify-items: center; gap: 8px; }
.ad-slot h2 { margin: 4px 0 0; font-family: var(--display); font-weight: 600; font-size: 22px; }
.ad-slot p { margin: 0; font-size: 14.5px; line-height: 1.45; opacity: .9; }
.ad-crown { width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center; background: rgba(255,255,255,.18); color: #ffd36b; }
.ad-crown svg { width: 28px; height: 28px; }
.ad-prem { margin-top: 8px; padding: 11px 22px; border-radius: 999px; background: #ffd36b; color: #3a2a1c; font-weight: 700; font-size: 15px; }
.ad-go { display: block; width: 100%; margin-top: 12px; padding: 13px 16px; border-radius: 14px; background: var(--ink); color: var(--paper); font-weight: 700; font-size: 15.5px; }
.ad-go:disabled { opacity: .5; }

/* The hidden message bar must sit fully above the screen, including under the phone's status bar. */
.dl-bar { transform: translate(-50%, calc(-100% - 40px - env(safe-area-inset-top))); visibility: hidden;
  transition: transform .4s cubic-bezier(.22, .9, .3, 1), visibility 0s linear .4s; }
.dl-bar.show { transform: translate(-50%, 0); visibility: visible; transition: transform .4s cubic-bezier(.22, .9, .3, 1), visibility 0s; }

/* offline screen */
.offline .off-card { margin: 40px auto 0; max-width: 420px; text-align: center; background: var(--card); border-radius: 24px; padding: 28px 22px; box-shadow: var(--shadow); }
.off-icon { width: 64px; height: 64px; margin: 0 auto 10px; border-radius: 50%; display: grid; place-items: center; background: var(--paper-2); color: var(--ink-2); }
.off-icon svg { width: 30px; height: 30px; }
.offline h1 { font-family: var(--display); font-weight: 600; font-size: 24px; margin: 4px 0 8px; }
.offline p { color: var(--ink-2); font-size: 15px; margin: 0 0 16px; }
.offline .off-note { font-size: 13px; color: var(--ink-3); margin: 14px 0 0; }

/* Keep page content out from under the phone's status bar (clock, battery) while scrolling. */
body::before { content: ""; position: fixed; left: 0; right: 0; top: 0; height: env(safe-area-inset-top); background: var(--paper); z-index: 40; pointer-events: none; }
.group-head { top: env(safe-area-inset-top); }

/* Delete account (Profile) */
.prof-card .sheet-link.danger { background: none; border: 0; font: inherit; font-size: 14px; cursor: pointer; }
.del-box { margin-top: 10px; padding: 12px 14px; border: 1px solid #e3b7ad; border-radius: 14px; background: rgba(163, 58, 42, .06); }
.del-box .prof-note { margin: 0 0 6px; }
.prof-btn.danger { background: #a33a2a; color: #fff; border-color: transparent; }
.profile > .sheet-link { margin: 22px auto 8px; text-align: center; }
