
:root {
  --bg: #F2EFE8; --surface: #FAF9F5; --surface-2: #E7E7EB; --ink: #1F1E1D; --muted: #6B6862;
  --line: #DFDBD2; --accent: #4E5F8C; --accent-ink: #FFFFFF; --accent-soft: #E2E6F0;
  --new: rgba(56,120,240,.16); --new-line: rgba(56,120,240,.55);
  --learn: rgba(240,170,20,.28); --learn-line: rgba(214,140,0,.7);
  --danger: #B3261E;
  --easy: #2E7D4F; --good: #4E5F8C; --stretch: #B26A00; --hard: #B3261E;
  --radius: 14px; --shadow: 0 1px 2px rgba(30,38,64,.06), 0 6px 18px rgba(30,38,64,.07);
  --serif: 'DF-literata', Georgia, serif; --sans: 'DF-inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --nav-h: 64px;
  color-scheme: light;
}
:root[data-theme="sepia"] {
  --bg: #EEE2C8; --surface: #F6EDDA; --surface-2: #E4D6B8; --ink: #3A2E1F; --muted: #7A6A52;
  --line: #DDCFB2; --accent: #7A4B12; --accent-soft: #EBDCC0;
}
:root[data-theme="paper"] {
  --bg: #F4EEDB; --surface: #F9F5E8; --surface-2: #EAE2CC; --ink: #2B2925; --muted: #6F665A;
  --line: #DDD4C2; --accent: #4E5F8C; --accent-ink: #FFFFFF; --accent-soft: #E1E3E8;
  --new: rgba(70,110,190,.13); --new-line: rgba(70,110,190,.5);
}
:root[data-theme="papyrus"] {
  --bg: #FAF5E8; --surface: #FDFAF2; --surface-2: #E8DBBA; --ink: #3A2C17; --muted: #7A6A4E;
  --line: #DCCBA4; --accent: #6E4E1E; --accent-ink: #FFF8EC; --accent-soft: #E8D8B4;
}
:root[data-theme="parchment"] {
  --bg: #F8EBCF; --surface: #FCF3E0; --surface-2: #E6C68C; --ink: #3A200A; --muted: #7A5530;
  --line: #D8B072; --accent: #7A3F10; --accent-ink: #FFF4E0; --accent-soft: #E6C185;
}
:root[data-theme="night"] {
  --bg: #000000; --surface: #121110; --surface-2: #1C1A17; --ink: #C8AE86; --muted: #8C7A5E;
  --line: #2A2622; --accent: #E0A55A; --accent-ink: #1A1206; --accent-soft: #2A2016;
  --new: rgba(120,150,230,.2); --new-line: rgba(120,150,230,.55); --learn: rgba(230,160,50,.22); --learn-line: rgba(230,160,50,.6);
  --danger: #F2A08F; --easy: #9CCB7A; --good: #E0A55A; --stretch: #E8B65A; --hard: #F2A08F;
  --shadow: 0 1px 2px rgba(0,0,0,.6); color-scheme: dark;
}
:root[data-theme="contrast"] {
  --bg: #000000; --surface: #000000; --surface-2: #1A1A1A; --ink: #FFFFFF; --muted: #E0E0E0;
  --line: #FFFFFF; --accent: #FFE14D; --accent-ink: #000000; --accent-soft: #332D00;
  --new: rgba(80,160,255,.38); --new-line: #6FB2FF; --learn: rgba(255,200,0,.4); --learn-line: #FFD400;
  --danger: #FF8A80; --easy: #7CFF9B; --good: #FFE14D; --stretch: #FFD400; --hard: #FF8A80;
  --shadow: none; color-scheme: dark;
}
:root[data-theme="dark"] {
  --bg: #151514; --surface: #1E1E1C; --surface-2: #282826; --ink: #E4DED4; --muted: #9C958A;
  --line: #34332F; --accent: #A3B2DA; --accent-ink: #141A2B; --accent-soft: #262C3C;
  --new: rgba(110,160,255,.22); --new-line: rgba(110,160,255,.6);
  --learn: rgba(255,190,60,.22); --learn-line: rgba(255,190,60,.65);
  --danger: #F2B8B5; --easy: #7BD69B; --good: #A3B2DA; --stretch: #F0B35A; --hard: #F2B8B5;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.35);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
/* no pull-down-to-reload: it clashes with the reader's edge gestures (brightness on the left edge) */
html { overscroll-behavior-y: none; }
body {
  background: var(--bg); color: var(--ink); font: 15px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
button { font: inherit; color: inherit; cursor: pointer; }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; letter-spacing: -.01em; margin: 0; }
h1 { font-size: 28px; }
h2 { font-size: 21px; }
h3 { font-size: 16px; }
p { margin: .4em 0; }
a { color: var(--accent); }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin: 14px 0; }
mark { background: var(--learn); color: inherit; border-radius: 3px; padding: 0 2px; box-shadow: 0 1px 0 var(--learn-line); }

/* layout */
#main { max-width: 860px; margin: 0 auto; padding: calc(env(safe-area-inset-top) + 18px) 16px calc(var(--nav-h) + env(safe-area-inset-bottom) + 24px); }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.page-head p { margin: 2px 0 0; }

/* buttons */
.btn {
  white-space: nowrap; flex: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 0 18px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface); font-weight: 600; font-size: 14px;
}
:root:not([data-theme]) .btn:not(.primary), :root[data-theme="light"] .btn:not(.primary) { background: var(--surface-2); border-color: transparent; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, var(--line)); }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .45; cursor: default; }
.btn:active { transform: translateY(1px); }
.icon-btn { width: 44px; height: 44px; display: grid; place-items: center; border: 0; background: none; border-radius: 50%; color: inherit; }
.icon-btn:active { background: var(--surface-2); }
.link-btn { border: 0; background: none; color: var(--accent); padding: 6px 0; font-weight: 600; }
.chip { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 4px 12px; font-size: 13px; }
.pill { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 7px 12px; font-size: 13px; font-weight: 600; white-space: nowrap; }

/* nav */
#nav {
  position: fixed; inset: auto 0 0 0; height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(12px);
  border-top: 1px solid var(--line); z-index: 10;
}
.nav-btn { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; border: 0; background: none; color: var(--muted); font-size: 11.5px; font-weight: 600; }
.nav-btn.on { color: var(--accent); }
.nav-btn.on svg { stroke-width: 2.2; }
.badge { position: absolute; top: 8px; left: calc(50% + 6px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--danger); color: #fff; font: 700 11px/18px var(--sans); font-style: normal; }
:root[data-theme="dark"] .badge, :root[data-theme="night"] .badge, :root[data-theme="contrast"] .badge { color: #2a0d0b; }
body.reading #nav, body.reading #main { display: none; }

/* shelf */
.shelf { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 26px 18px; }
.book { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.book-open { position: relative; padding: 0 7px 0 0; border: 0; background: none; border-radius: 6px; }
/* 3D book: page block on the right edge */
.book-open::after { content: ''; position: absolute; top: 3px; bottom: 3px; right: 0; width: 8px; border-radius: 0 3px 3px 0; z-index: 0;
  background: repeating-linear-gradient(90deg, #f7f3ea 0 1px, #ddd6c6 1px 2px), #efe9dc;
  box-shadow: inset 1px 0 2px rgba(0,0,0,.25), 2px 3px 6px -2px rgba(0,0,0,.25); }
.cover { aspect-ratio: 2 / 3; border-radius: 3px 5px 5px 3px; overflow: hidden; background: var(--surface-2); position: relative; z-index: 1;
  box-shadow: 0 1px 1px rgba(0,0,0,.10), 0 8px 14px -6px rgba(0,0,0,.45), 0 18px 26px -16px rgba(0,0,0,.40); }
.cover::before { content: ''; position: absolute; inset: 0 auto 0 0; width: 12px; z-index: 1;
  background: linear-gradient(90deg, rgba(0,0,0,.28), rgba(0,0,0,.08) 35%, rgba(255,255,255,.22) 55%, rgba(0,0,0,.14) 70%, transparent); }
/* light from above, slight shade at the foot */
.cover::after { content: ''; position: absolute; inset: 0; z-index: 1; pointer-events: none;
  background: linear-gradient(160deg, rgba(255,255,255,.28), rgba(255,255,255,0) 38%), linear-gradient(0deg, rgba(0,0,0,.10), transparent 25%); }
.cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cover.gen {
  background: linear-gradient(160deg, hsl(var(--hue) 22% 40%), hsl(calc(var(--hue) + 20) 26% 26%));
  color: hsl(var(--hue) 40% 94%); display: flex; flex-direction: column; justify-content: space-between; padding: 18px 14px 16px 18px; text-align: left;
}
.gen-title { font: 600 18px/1.2 var(--serif); overflow-wrap: anywhere; }
/* keep the first title line clear of the ribbon; the lines below use the full width */
.book-open:has(.ribbon) .gen-title::before { content: ''; float: right; width: 28px; height: 20px; }
.gen-author { font-size: 12px; opacity: .8; }
.readbar { position: absolute; left: 8px; right: 15px; bottom: 8px; height: 4px; border-radius: 2px; background: rgba(0,0,0,.35); overflow: hidden; z-index: 2; }
.readbar i { display: block; height: 100%; background: #fff; }
/* bookmark ribbon on books being read; the outer span carries the shadows (a clip-path would cut them off) */
.ribbon { position: absolute; top: -5px; right: 20px; z-index: 3; width: 21px; height: 36px; pointer-events: none;
  filter: drop-shadow(1.2px 2.5px 2px rgba(0,0,0,.38)); transform-origin: 50% 2px; animation: rb-sway 5.5s ease-in-out infinite; will-change: transform; }
.ribbon svg { display: block; overflow: visible; }
@keyframes rb-sway { 0%, 100% { transform: rotate(-1.6deg); } 50% { transform: rotate(1.6deg); } }
@media (prefers-reduced-motion: reduce) { .ribbon { animation: none; } }
.readpct { position: absolute; right: 8px; bottom: 4px; z-index: 2; font: 700 10px/1 var(--sans); color: #fff; background: rgba(0,0,0,.45); padding: 3px 5px; border-radius: 7px; }
.book-open:has(.readpct) .readbar { right: 44px; bottom: 9px; }
/* ribbon colour picker in the book sheet */
.rb-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 12px 0 4px; }
.rb-row > span { font-size: 14px; color: var(--muted); margin-right: 4px; }
.rb-dot { width: 30px; height: 30px; border-radius: 50%; padding: 0; flex: none; border: 2px solid rgba(255,255,255,.85); box-shadow: 0 0 0 1px var(--line); }
.rb-dot.on { outline: 3px solid var(--accent); outline-offset: 2px; }
.book-meta h3 { font-size: 15px; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.book-meta p { margin: 2px 0; }
.fit { display: inline-flex; gap: 4px; align-items: baseline; margin: 6px 0 2px; padding: 3px 10px; border-radius: 999px; border: 0; font-size: 12.5px; font-weight: 600; }
.fit b { font-size: 13.5px; }
.fit-easy { background: color-mix(in srgb, var(--easy) 15%, transparent); color: var(--easy); }
.fit-good { background: color-mix(in srgb, var(--good) 15%, transparent); color: var(--good); }
.fit-stretch { background: color-mix(in srgb, var(--stretch) 16%, transparent); color: var(--stretch); }
.fit-hard { background: color-mix(in srgb, var(--hard) 14%, transparent); color: var(--hard); }

/* empty */
.empty { text-align: center; padding: 30px 8px; display: flex; flex-direction: column; align-items: center; }
.empty .row { justify-content: center; }
.empty-art {
  width: 120px; height: 120px; margin-bottom: 18px; border-radius: 50%;
  background: radial-gradient(circle at 50% 60%, var(--accent-soft) 0 58%, transparent 59%);
  position: relative;
}
.empty-art::after {
  content: ''; position: absolute; inset: 28px 26px 30px; border-radius: 3px 6px 6px 3px;
  background: linear-gradient(90deg, var(--accent) 0 8px, color-mix(in srgb, var(--accent) 75%, #fff) 8px);
  transform: rotate(-8deg); box-shadow: 10px 4px 0 -2px var(--surface), 10px 4px 0 -1px var(--line);
}

/* sheet */
.sheet { position: fixed; inset: 0; z-index: 65; }
#sheet-scrim { position: absolute; inset: 0; background: rgba(20,15,5,.32); opacity: 0; transition: opacity .2s; }
.sheet-panel {
  position: absolute; left: 0; right: 0; bottom: 0; max-height: 72vh; margin: 0 auto; max-width: 640px;
  background: var(--surface); color: var(--ink); border-radius: 22px 22px 0 0; box-shadow: 0 -10px 40px rgba(0,0,0,.18);
  transform: translateY(100%); transition: transform .22s cubic-bezier(.2,.8,.2,1);
  display: flex; flex-direction: column; padding-bottom: env(safe-area-inset-bottom);
}
.sheet.tall .sheet-panel { max-height: 88vh; }
.sheet.open #sheet-scrim { opacity: 1; }
.sheet.open .sheet-panel { transform: none; }
.grip { width: 40px; height: 4px; border-radius: 2px; background: var(--line); margin: 10px auto 4px; flex: none; }
#sheet-body { overflow-y: auto; padding: 8px 20px 22px; overscroll-behavior: contain; }
.sheet-title { margin: 6px 0 10px; }
.sub { margin: 20px 0 8px; font-size: 15px; }

/* word popup */
.wordpop .wp-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.wp-word { font: 600 26px/1.15 var(--serif); }
.wp-lemma { color: var(--muted); font-size: 14px; margin-top: 2px; }
.wp-band { display: inline-block; margin-top: 6px; font-size: 12px; font-weight: 600; color: var(--accent); background: var(--accent-soft); border-radius: 999px; padding: 2px 9px; }
.wp-head .icon-btn { background: var(--surface-2); flex: none; }
.wp-senses { margin: 14px 0 6px; padding-left: 20px; }
.wp-senses li { margin: 0 0 10px; }
.wp-pos { font-style: italic; color: var(--muted); font-size: 13px; }
.wp-ex { color: var(--muted); font-style: italic; font-size: 14px; margin-top: 2px; }
.wp-ex::before { content: '“'; } .wp-ex::after { content: '”'; }
.wp-syn { color: var(--muted); font-size: 13px; margin-top: 2px; }
.wp-sentence { background: var(--surface-2); border-radius: 12px; padding: 10px 14px 4px; margin: 12px 0; font-family: var(--serif); }
.wp-sentence p { margin: 0 0 2px; }
.wp-sentence .link-btn { font-family: var(--sans); font-size: 13px; }
.wp-states { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; position: sticky; bottom: -22px; background: var(--surface); padding: 10px 0 2px; }
.state-btn { min-height: 46px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); font-size: 13px; font-weight: 600; padding: 4px; }
.state-btn.on.st0 { background: var(--new); border-color: var(--new-line); }
.state-btn.on.st1 { background: var(--learn); border-color: var(--learn-line); }
.state-btn.on.st2 { background: color-mix(in srgb, var(--easy) 18%, transparent); border-color: var(--easy); }
.state-btn.on.st3 { background: var(--surface-2); border-color: var(--muted); }

/* lists */
.wordlist { list-style: none; padding: 0; margin: 0; }
.wordlist > li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 9px 2px; border-bottom: 1px solid var(--line); font-family: var(--serif); font-size: 16px; }
.wordlist > li > span:first-child { padding: 0 4px; border-radius: 4px; }
.wordlist > li.st0 > span:first-child { background: var(--new); box-shadow: 0 1px 0 var(--new-line); }
.wordlist > li.st1 > span:first-child { background: var(--learn); box-shadow: 0 1px 0 var(--learn-line); }
.wordlist > li > .muted, .wordlist .chip { font-family: var(--sans); font-size: 13px; }
.wordlist.tap > li:not(.wl-def) { cursor: pointer; }
.wordlist.tap > li.open, .cw-list > li.open { border-bottom-color: transparent; }
.cw-list > li:not(.wl-def) { cursor: pointer; }
.wordlist > li.wl-def, .cw-list > li.wl-def { display: block; border-bottom: 0; padding: 12px 12px 14px; margin: 0 0 6px; background: var(--accent-soft); border-radius: 0 0 10px 10px; font-size: 15px; }
.wl-def .wp-senses { margin: 6px 0 10px; }
.wl-def .row { gap: 8px; align-items: stretch; flex-wrap: nowrap; }
.wl-def .row .btn { flex: 1 1 0; min-width: 0; padding: 8px 10px; font-size: 14px; line-height: 1.25; white-space: normal; font-family: var(--sans); }
.meter { height: 10px; border-radius: 5px; background: var(--new); overflow: hidden; margin: 6px 0 10px; }
.meter i { display: block; height: 100%; background: var(--accent); border-radius: 5px; }
.toc { list-style: none; padding: 0; margin: 0; }
.toc-item { width: 100%; text-align: left; border: 0; background: none; padding: 12px 16px; border-radius: 10px; font-size: 15px; }
.toc-item.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

/* stats */
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 8px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; }
.stat b { font: 600 30px/1.1 var(--serif); }
.stat span { color: var(--muted); font-size: 13px; margin-top: 4px; }

/* review */
.review-start { text-align: center; padding: 24px 0; }
.big-num { font: 600 64px/1 var(--serif); color: var(--accent); margin: 0; }
.card-panel { margin-top: 30px; padding: 16px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.flash { background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 22px 20px; box-shadow: var(--shadow); text-align: center; }
.flash-word { font-size: 34px; margin: 10px 0 12px; }
.flash-sent { font-family: var(--serif); font-size: 17px; line-height: 1.6; text-align: left; }
.flash-back { padding: 18px 6px; font-size: 16px; }
.grade { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 8px; }
.grade .btn { flex-direction: column; gap: 0; min-height: 58px; border-radius: 14px; padding: 4px; }
.grade small { font-weight: 500; color: var(--muted); font-size: 11.5px; }
.grade-again { border-color: color-mix(in srgb, var(--hard) 45%, var(--line)) !important; }
.grade-good { border-color: color-mix(in srgb, var(--good) 55%, var(--line)) !important; }
#view-review > .btn.wide { margin-top: 16px; }

/* settings */
.set { padding: 14px 0; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 10px; }
.set > label { font-weight: 600; }
.set.links { flex-direction: row; gap: 22px; align-items: center; }
.seg { display: flex; background: var(--surface-2); border-radius: 12px; padding: 3px; gap: 3px; flex-wrap: wrap; }
.seg button { flex: 1; min-height: 40px; min-width: 52px; border: 0; background: none; border-radius: 9px; font-size: 14px; font-weight: 600; color: var(--muted); }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.seg.seg-grid { display: grid; grid-template-columns: repeat(4, 1fr); }
.seg.seg-grid button { min-width: 0; font-size: 13px; }
.switch { display: flex; align-items: center; gap: 12px; font-weight: 600; cursor: pointer; }
.switch input { width: 22px; height: 22px; accent-color: var(--accent); }
input[type=range] { width: 100%; accent-color: var(--accent); }
#view-settings > .btn.danger { margin-top: 18px; }
.about ul { padding-left: 18px; font-size: 14px; }

/* onboarding */
.onboard {
  position: fixed; inset: 0; z-index: 60; background: var(--bg); overflow-y: auto;
  padding: calc(env(safe-area-inset-top) + 40px) 22px 32px; display: flex; flex-direction: column; max-width: 560px; margin: 0 auto;
}
.onboard h1 { font-size: 34px; margin-top: 14px; }
.onboard .lead { font: 400 19px/1.45 var(--serif); margin: 8px 0 26px; }
.onboard h2 { font-size: 18px; margin-bottom: 12px; }
.brand-mark { width: 64px; height: 64px; border-radius: 18px; background: url(icons/icon-192.png) center/cover; box-shadow: var(--shadow); }
.levels { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 8px; }
.level { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 12px 14px; border: 1.5px solid var(--line); background: var(--surface); border-radius: 14px; text-align: left; }
.level b { font: 600 18px var(--serif); }
.level span { font-size: 13px; color: var(--muted); }
.level.on { border-color: var(--accent); background: var(--accent-soft); }
.onboard .btn.wide { margin-top: auto; position: sticky; bottom: 0; }
.onboard > p.small { margin-bottom: 22px; }

/* busy / toast */
.busy { text-align: center; padding: 24px 0; }
.spinner { width: 34px; height: 34px; margin: 0 auto 12px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
#toast {
  position: fixed; left: 50%; bottom: calc(var(--nav-h) + 24px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px);
  background: var(--ink); color: var(--bg); padding: 10px 18px; border-radius: 999px; font-size: 14px; font-weight: 500;
  opacity: 0; pointer-events: none; transition: .2s; z-index: 80; max-width: calc(100vw - 32px); text-align: center;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* reader */
#reader { position: fixed; inset: 0; background: var(--page, var(--bg)); color: var(--ink, inherit); z-index: 20; overflow: hidden; }
#r-panes { position: absolute; inset: 0; display: grid; grid-template: 1fr / 1fr; }
#r-panes[data-dir="row"] { grid-template: 1fr / 1fr 1fr; }
#r-panes[data-dir="col"] { grid-template: 1fr 1fr / 1fr; }
#r-panes[data-dir="grid"][data-count="3"] { grid-template: 1fr 1fr / 1fr 1fr; }
#r-panes[data-dir="grid"][data-count="3"] .pane:nth-child(3) { grid-column: 1 / 3; }
#r-panes[data-dir="grid"][data-count="4"] { grid-template: 1fr 1fr / 1fr 1fr; }
.pane { position: relative; min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.pane-view { position: relative; flex: 1; min-height: 0; }
.pane-view foliate-view { position: absolute; inset: 0; }
/* the page bookmark ribbon (see flashMark): over the page for a moment when a book opens or a page is bookmarked */
.page-mark { position: absolute; top: -4px; z-index: 3; cursor: pointer; border-radius: 0 0 1px 1px; background: #EEE3CC 0 0 / 100% 100% no-repeat;
  box-shadow: 0 2px 3px rgba(60,35,10,.3), 0 6px 12px rgba(60,35,10,.16); transition: opacity .18s; -webkit-tap-highlight-color: transparent; }
.page-mark[hidden] { display: none; }
.page-mark { animation: pm-in .3s ease-out; }
.page-mark.gone { opacity: 0; transition: opacity .4s; }
@keyframes pm-in { from { transform: translateY(-14px); opacity: 0; } }
.pm-v { position: absolute; top: 22px; bottom: 44px; left: 0; right: 0; writing-mode: vertical-rl; display: flex; flex-direction: column; align-items: flex-start; justify-content: center; gap: 3px; overflow: hidden; }
.pm-ti, .pm-au, .pm-brand { font-family: 'DF-cinzel', var(--serif); font-weight: 600; color: var(--pm-ink); text-shadow: 0 1px 0 rgba(255,250,240,.7), 0 -1px 0 rgba(80,55,30,.3); }
.pm-ti { font-size: 15px; letter-spacing: .1em; line-height: 1.1; text-transform: uppercase; max-width: 2.3em; overflow: hidden; }   /* at most two lines */
.pm-au { font-size: 10px; letter-spacing: .15em; opacity: .85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-height: 100%; }
.pm-brand { position: absolute; bottom: 14px; left: 0; right: 0; text-align: center; font-size: 7.5px; letter-spacing: .18em; color: var(--pm-brand); }
.turn-curl { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 2; pointer-events: none; opacity: 0; overflow: visible; }
.turn-curl .tc-paper { fill: var(--page, #FBF8F3); }
#reader[data-theme="papyrus"] .turn-curl .tc-paper, #reader[data-theme="parchment"] .turn-curl .tc-paper { fill: var(--sheet-back, #EBD3A2); }
.pane-head { display: none; }
#reader.split .pane { border: 1px solid color-mix(in srgb, var(--ink) 14%, transparent); margin: 2px; border-radius: 10px; overflow: hidden; }
#reader.split .pane.active { border-color: var(--accent, #4E5F8C); box-shadow: inset 0 0 0 1px var(--accent, #4E5F8C); }
#reader.split .pane-head { display: flex; align-items: center; gap: 6px; padding: 2px 4px 2px 12px; font: 600 12px var(--sans); color: var(--ink); opacity: .75; border-bottom: 1px solid color-mix(in srgb, var(--ink) 10%, transparent); }
#reader.split .pane.active .pane-head { opacity: 1; color: var(--accent, #4E5F8C); }
.pane-title { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pane-close { width: 30px; height: 30px; }
.tool:disabled { opacity: .35; }
#r-tools { grid-template-columns: repeat(var(--tools, 6), 1fr) !important; }
/* Discura: the pen's marks on flowing text (underline, ring) - lighter on a dark page */
:root { --pen-black: #1F1E1D; --pen-navy: #2E3F7F; --pen-red: #B3261E; --pen-green: #2E7D32; }
:root[data-theme="dark"] { --pen-black: #E4DED4; --pen-navy: #9DB0F0; --pen-red: #FF8A80; --pen-green: #7FD69A; }
:root[data-theme="night"] { --pen-black: #C8AE86; --pen-navy: #9DB0F0; --pen-red: #FF8A80; --pen-green: #7FD69A; }
:root[data-theme="contrast"] { --pen-black: #FFFFFF; --pen-navy: #9DB0F0; --pen-red: #FF8A80; --pen-green: #7FD69A; }
.wp-actions { display: flex; gap: 6px; flex: none; }
.wp-actions .icon-btn { background: var(--surface-2); }
.wp-sent-actions { display: flex; gap: 18px; flex-wrap: wrap; }
.sheet-book { margin: 0 0 8px; font-weight: 600; }
#r-dim { position: absolute; inset: 0; background: #000; opacity: 0; pointer-events: none; z-index: 3; transition: opacity .08s; }
#r-dimlevel { position: absolute; right: 18px; top: 50%; transform: translateY(-50%); background: rgba(0,0,0,.72); color: #fff; padding: 8px 12px; border-radius: 12px; font: 600 14px var(--sans); opacity: 0; transition: opacity .2s; z-index: 6; pointer-events: none; }
#r-dimlevel.show { opacity: 1; }
.r-top, .r-bottom {
  position: absolute; left: 0; right: 0; z-index: 5; color: var(--ink);
  background: color-mix(in srgb, var(--page) 94%, transparent); backdrop-filter: blur(10px);
  transition: opacity .2s, transform .22s;
}
.r-top { top: 0; display: flex; align-items: center; gap: 2px; padding: env(safe-area-inset-top) 6px 0; height: calc(54px + env(safe-area-inset-top)); border-bottom: 1px solid color-mix(in srgb, var(--ink) 10%, transparent); }
.r-bottom { bottom: 0; padding: 6px 10px env(safe-area-inset-bottom); border-top: 1px solid color-mix(in srgb, var(--ink) 10%, transparent); }
.r-progress-row { display: flex; align-items: center; gap: 10px; padding: 4px 6px 2px; }
#r-tools { display: grid; grid-template-columns: repeat(5, 1fr); }
.tool { display: flex; flex-direction: column; align-items: center; gap: 3px; border: 0; background: none; color: var(--ink); padding: 8px 2px 10px; font-size: 11px; font-weight: 600; border-radius: 12px; }
.tool:active { background: color-mix(in srgb, var(--ink) 8%, transparent); }
.r-titles { flex: 1; min-width: 0; text-align: center; }
#r-title { font: 600 14px var(--serif); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#r-chapter { font-size: 12px; opacity: .65; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#r-progress { flex: 1; min-width: 60px; }
#r-pct { font-size: 12px; opacity: .7; min-width: 34px; text-align: right; font-variant-numeric: tabular-nums; }
#r-bm.on path { fill-opacity: 1; color: var(--accent); }
#reader.chrome-hidden .r-top { opacity: 0; transform: translateY(-100%); pointer-events: none; }
#reader.chrome-hidden .r-bottom { opacity: 0; transform: translateY(100%); pointer-events: none; }
#reader[data-theme="dark"], #reader[data-theme="night"], #reader[data-theme="contrast"] { --surface: #1E1E1C; --line: #34332F; --surface-2: #282826; color-scheme: dark; }
#reader[data-theme="contrast"] .r-top, #reader[data-theme="contrast"] .r-bottom { background: #000; border-color: #fff; }
#selbar {
  position: absolute; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 7;
  display: flex; align-items: center; gap: 6px; padding: 8px 10px; border-radius: 999px;
  background: #222; color: #fff; box-shadow: 0 8px 28px rgba(0,0,0,.35); max-width: calc(100vw - 24px); overflow-x: auto;
}
.hl-dot { width: 28px; height: 28px; border-radius: 50%; border: 2px solid rgba(255,255,255,.85); flex: none; padding: 0; }
.hl-dot.on { outline: 3px solid var(--accent); outline-offset: 2px; }
.sb-btn { border: 0; background: none; color: #fff; font-weight: 600; font-size: 13.5px; padding: 6px 8px; white-space: nowrap; }
.icon-btn.small { width: 36px; height: 36px; }

/* reader sheets */
.theme-swatches { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin: 6px 0 14px; }
.swatch { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 10px 2px; border-radius: 14px; border: 2px solid var(--line); }
.swatch b { font: 600 20px var(--serif); }
.swatch small { font-size: 10.5px; font-weight: 600; opacity: .85; }
.swatch.on { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.display-panel { display: flex; flex-direction: column; gap: 12px; }
.disp-row { display: flex; align-items: center; gap: 12px; }
.disp-row .btn { flex: 1; font-size: 16px; }
.disp-val { min-width: 54px; text-align: center; font-weight: 600; }
.tabs { margin-bottom: 12px; }
.notes-list { list-style: none; padding: 0; margin: 0; }
.notes-list li { display: flex; align-items: flex-start; gap: 4px; border-bottom: 1px solid var(--line); }
.note-item { flex: 1; display: flex; gap: 12px; text-align: left; border: 0; background: none; padding: 12px 2px; min-width: 0; }
.note-bar { width: 4px; border-radius: 2px; align-self: stretch; flex: none; }
.note-bar.bm { background: var(--accent); }
.note-body { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.note-text { font-family: var(--serif); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.note-note { font-size: 14px; background: var(--surface-2); border-radius: 8px; padding: 6px 10px; }
.note-quote { margin: 0 0 12px; padding: 8px 14px; border-left: 4px solid var(--learn-line); font-family: var(--serif); background: var(--surface-2); border-radius: 0 10px 10px 0; max-height: 30vh; overflow: auto; }
.note-input { width: 100%; font: 15px/1.5 var(--sans); padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); margin-top: 12px; resize: vertical; }
.hl-colors { display: flex; gap: 12px; }
.hl-colors .hl-dot { border-color: var(--line); width: 32px; height: 32px; }
.search-row { display: flex; gap: 8px; margin: 4px 0 8px; }
.search-input { flex: 1; min-height: 44px; padding: 0 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); font: 16px var(--sans); }
.search-results { list-style: none; padding: 0; margin: 0; }
.sr-label { font-weight: 700; font-size: 13px; color: var(--muted); padding: 12px 2px 4px; }
.sr-item { width: 100%; text-align: left; border: 0; background: none; padding: 10px 2px; border-bottom: 1px solid var(--line); font-family: var(--serif); font-size: 15px; }
.wp-phrasal { border: 1.5px solid var(--accent); border-radius: 14px; padding: 10px 14px 12px; margin: 14px 0 6px; background: color-mix(in srgb, var(--accent) 6%, transparent); }
.wp-phrasal.maybe { border-style: dashed; border-color: var(--line); background: none; }
.wp-phr-head { display: flex; align-items: center; gap: 8px; }
.wp-phr-head b { font: 600 19px var(--serif); flex: 1; }
.wp-tag { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--accent); }
.wp-phrasal .wp-senses { margin: 8px 0 8px; }

@media (min-width: 700px) {
  .shelf { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
  #main { padding-top: 36px; }
}
body.reading #toast { bottom: auto; top: calc(64px + env(safe-area-inset-top)); transform: translate(-50%, -10px); }
body.reading #toast.show { transform: translate(-50%, 0); }

/* pro, academic, stats */
.pro-badge { display: inline-block; font: 800 11px/1 var(--sans); letter-spacing: .08em; color: var(--accent-ink); background: linear-gradient(135deg, #D9A441, #B97A1E); padding: 5px 8px; border-radius: 6px; }
.pro-card { border: 1.5px solid color-mix(in srgb, #D9A441 55%, var(--line)); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 8px; background: color-mix(in srgb, #D9A441 7%, var(--surface)); }
.pro-card.on { display: flex; align-items: center; gap: 10px; }
.pro-card-head { display: flex; align-items: center; gap: 10px; }
.pro-list { margin: 10px 0 6px; padding-left: 20px; font-size: 14px; }
.pro-list li { margin: 3px 0; }
.paywall { text-align: left; }
.paywall .pro-badge { margin-top: 6px; }
.pw-reason { font-weight: 600; }
.plans { display: grid; gap: 8px; margin: 12px 0 4px; }
.plan { display: grid; gap: 2px; width: 100%; text-align: left; font-family: var(--sans); color: var(--ink); background: var(--surface); border: 1.5px solid var(--line); border-radius: 12px; padding: 11px 14px; cursor: pointer; }
.plan.best { border-color: #C8902F; background: color-mix(in srgb, #D9A441 9%, var(--surface)); }
.plan-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 16px; }
.plan-tag { font: 700 11.5px/1 var(--sans); color: var(--accent-ink); background: linear-gradient(135deg, #D9A441, #B97A1E); padding: 4px 7px; border-radius: 999px; }
.plan-price { font-size: 14px; color: var(--muted); }
.plan-cta { font-size: 14px; font-weight: 600; color: var(--accent); margin-top: 2px; }
.plan-terms { margin: 4px 2px 0; line-height: 1.4; }
.pro-card .plans { margin-top: 10px; }
.pro-teaser { width: 100%; display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px; text-align: left; border: 1px dashed var(--line); background: var(--surface); border-radius: 12px; padding: 12px 14px; margin: 10px 0; color: var(--ink); }
.pro-teaser span { color: var(--muted); font-size: 13px; flex: 1 1 100%; }
sup { font-size: 9px; font-weight: 800; color: #B97A1E; letter-spacing: .05em; margin-left: 2px; }
.profile { margin: 6px 0 4px; }
.prof-row { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.wp-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.wp-tags .wp-band { margin-top: 0; }
.wp-band.alt { background: color-mix(in srgb, #7B3FB8 14%, transparent); color: #7B3FB8; }
:root[data-theme="dark"] .wp-band.alt, :root[data-theme="night"] .wp-band.alt, :root[data-theme="contrast"] .wp-band.alt { color: #C9A6F2; }
.wp-tr { display: flex; gap: 10px; align-items: flex-start; margin: 12px 0 4px; padding: 10px 12px; border-radius: 12px; background: color-mix(in srgb, #C8102E 7%, var(--surface)); border: 1px solid color-mix(in srgb, #C8102E 22%, var(--line)); }
.wp-tr-tag { font: 800 10.5px/1 var(--sans); color: #fff; background: #C8102E; border-radius: 4px; padding: 4px 5px; flex: none; margin-top: 2px; }
.wp-tr-line { font-size: 15px; margin: 1px 0; }
.wp-limit { width: 100%; border: 1px dashed #B97A1E; background: color-mix(in srgb, #D9A441 10%, transparent); color: inherit; border-radius: 10px; padding: 8px 12px; margin: 10px 0 0; font-size: 13px; font-weight: 600; }
.flash-tr { display: flex; gap: 8px; align-items: baseline; font-size: 16px; }
.legend .lg-acad { text-decoration: underline dotted #7B3FB8 2px; text-underline-offset: 4px; }
.legend .lg-disc { text-decoration: underline wavy #2E8B57 1.5px; text-underline-offset: 4px; }
.stats.three { grid-template-columns: repeat(3, 1fr); }
.stats.three .stat b { font-size: 24px; }
.bars { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; height: 110px; align-items: end; margin: 14px 0 6px; }
.bar { display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; justify-content: flex-end; }
.bar i { display: block; width: 100%; max-width: 28px; min-height: 3px; background: var(--accent); border-radius: 6px 6px 2px 2px; }
.bar small { font-size: 11px; color: var(--muted); }

/* tablets, foldables, desktop */
@media (min-width: 600px) {
  #nav { grid-template-columns: repeat(4, minmax(0, 150px)); justify-content: center; }
  #r-tools { max-width: 620px; margin: 0 auto; }
  .r-progress-row { max-width: 720px; margin: 0 auto; }
  .sheet-panel { border-radius: 22px 22px 0 0; }
}
@media (min-width: 1000px) {
  #main { max-width: 1120px; }
  .shelf { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 32px 24px; }
  .stats { max-width: 720px; }
}
@media (min-width: 900px) and (min-height: 700px) {
  .sheet-panel { bottom: 50%; transform: translateY(calc(50% + 100vh)); border-radius: 22px; max-height: 80vh; }
  .sheet.open .sheet-panel { transform: translateY(50%); }
  .wp-states { bottom: -22px; }
}
.add-menu { display: flex; flex-direction: column; gap: 10px; }
.add-opt { display: flex; align-items: center; gap: 14px; text-align: left; padding: 14px 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); color: var(--ink); }
.add-opt svg { color: var(--accent); flex: none; }
.add-opt span { display: flex; flex-direction: column; gap: 2px; }
.add-opt small { color: var(--muted); font-size: 13px; }
.scan-row { display: flex; justify-content: space-between; padding: 9px 0; border-bottom: 1px solid var(--line); }
.scan-row.ok b { color: var(--easy); }
.scan-row.bad b { color: var(--hard); }

/* paper-like (matte) themes: grain texture, no glossy shadows */
:root[data-theme="paper"] body, #reader[data-theme="paper"] { background-image: var(--paper-texture); }
/* papyrus and parchment: a torn sheet lies behind the (transparent) page; around it a tone lighter than the paper */
#reader[data-theme="papyrus"], #reader[data-theme="parchment"] { background: var(--page); }
:root[data-theme="paper"], :root[data-theme="papyrus"], :root[data-theme="parchment"] { --shadow: 0 1px 2px rgba(60,45,20,.08); }
.sheet-bg { position: absolute; inset: 0; pointer-events: none; background: 0 0 / 100% 100% no-repeat; }
.sheet-bg[hidden] { display: none; }
.sheet-bg .sheet-flap { position: absolute; inset: 0; background: 0 0 / 100% 100% no-repeat; transition: opacity .18s; }
#r-warm { position: absolute; inset: 0; background: rgb(255, 150, 50); mix-blend-mode: multiply; opacity: 0; pointer-events: none; z-index: 2; }
.theme-swatches { grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); }
.swatch.tex { background-image: var(--paper-texture) !important; }
.font-pick { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; padding: 12px 14px; border: 0; border-bottom: 1px solid var(--line); background: none; color: var(--ink); font-size: 19px; }
.font-pick.on { background: var(--accent-soft); border-radius: 10px; }
.font-pick small { margin-left: auto; font: 600 11px var(--sans); color: var(--muted); }
.font-group { font: 700 12px var(--sans); text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 16px 2px 4px; }
.font-row-btn { display: flex; justify-content: space-between; align-items: center; width: 100%; min-height: 46px; padding: 0 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--ink); font-size: 16px; }
.src-item { display: grid; grid-template-columns: 1fr auto; grid-template-areas: "n go" "d go"; gap: 2px 10px; }
.src-item b { grid-area: n; font-size: 15px; }
.src-item .muted { grid-area: d; }
.src-go { grid-area: go; align-self: center; color: var(--accent); font-weight: 700; }

/* level test */
.pt { display: flex; flex-direction: column; gap: 12px; padding-bottom: 8px; }
.pt-points { margin: 0; padding-left: 18px; display: grid; gap: 6px; }
.pt-head { display: flex; justify-content: space-between; align-items: center; }
.pt-skill { font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--accent); background: var(--accent-soft); padding: 3px 9px; border-radius: 999px; }
.pt-passage { background: var(--surface-2); border-radius: 12px; padding: 12px 14px; font: 16px/1.55 var(--serif); max-height: 42vh; overflow-y: auto; }
.pt-passage p { margin: 0 0 6px; }
.pt-stem { font: 600 18px/1.45 var(--serif); margin: 4px 0; }
.pt-gap { display: inline-block; min-width: 64px; border-bottom: 2px solid var(--accent); color: transparent; margin: 0 4px; }
.pt-opts { display: grid; gap: 8px; }
.pt-opts.two { grid-template-columns: 1fr 1fr; }
.pt-opt { text-align: left; padding: 13px 16px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); font: 500 16px var(--sans); color: var(--ink); }
.pt-opts.two .pt-opt { text-align: center; }
.pt-opt:active { background: var(--accent-soft); border-color: var(--accent); }
.pt-skip { align-self: center; }
.pt-result { text-align: left; }
.pt-level { font: 600 64px/1 var(--serif); color: var(--accent); margin: 0; }
.pt-bars { display: grid; gap: 6px; margin: 6px 0; }
.pt-bar { display: grid; grid-template-columns: 30px 1fr 40px; align-items: center; gap: 10px; font-size: 13px; font-weight: 600; }
.pt-bar i { display: block; height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.pt-bar b { display: block; height: 100%; background: color-mix(in srgb, var(--accent) 45%, transparent); }
.pt-bar.on b { background: var(--accent); }
.pt-note { background: var(--accent-soft); border-radius: 12px; padding: 10px 14px; }
.pt-note p { margin: 4px 0; } .pt-note ul { margin: 4px 0 0; padding-left: 18px; }
.pt-nudge { display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: center; justify-content: space-between; background: var(--accent-soft); border-radius: var(--radius); padding: 12px 16px; margin: 0 0 18px; }
.pt-nudge p { margin: 2px 0 0; } .pt-nudge .row { margin: 0; }
.onboard .link-btn { display: block; margin: 4px auto 14px; }

/* display tabs, colour legend, single word action, walkthrough */
.disp-tabs { margin-bottom: 4px; }
.lg-card { background: var(--surface-2); border-radius: 14px; padding: 12px 14px; display: grid; gap: 10px; }
.lg-card.off { opacity: .55; }
.lg-row { display: grid; grid-template-columns: 64px 1fr; gap: 12px; align-items: start; }
.lg-row p { margin: 2px 0 0; }
.lg-word { font: 500 17px var(--serif); padding: 1px 4px; border-radius: 3px; text-decoration: underline 2px; text-underline-offset: 3px; justify-self: start; color: var(--ink); }
.lg-word.plain { text-decoration: none; }
.lg-card .link-btn { justify-self: start; }
.r-legend { display: flex; align-items: center; justify-content: center; gap: 6px; margin: 0 auto 4px; border: 0; background: none; color: var(--ink); opacity: .75; font: 600 12px var(--sans); padding: 4px 10px; }
.r-legend .lg-q { width: 16px; height: 16px; border-radius: 50%; border: 1px solid currentColor; font-size: 10px; line-height: 14px; margin-left: 2px; }
.lg-dot { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-left: 6px; vertical-align: -1px; }
.lg-dot.new { background: var(--lg-new, var(--new)); box-shadow: inset 0 -2px 0 var(--lg-new-line, var(--new-line)); }
.lg-dot.learn { background: var(--lg-learn, var(--learn)); box-shadow: inset 0 -2px 0 var(--lg-learn-line, var(--learn-line)); margin-left: 10px; }
.wp-states.one { display: block; }
.wp-states.one .btn { width: 100%; min-height: 48px; font-size: 15px; }
.wp-added { display: flex; gap: 8px; align-items: center; font-size: 13px; color: var(--muted); margin: 0 0 8px; }
.wp-added .lg-dot { margin: 0; flex: none; }
.coach { position: absolute; inset: 0; z-index: 30; }
.coach.dim { background: rgba(0,0,0,.45); }
.coach-ring { position: absolute; border-radius: 8px; box-shadow: 0 0 0 3px #fff, 0 0 0 9999px rgba(0,0,0,.5); pointer-events: none; transition: all .2s; }
.coach-card { position: absolute; left: 16px; right: 16px; bottom: calc(24px + env(safe-area-inset-bottom)); max-width: 520px; margin: 0 auto; background: var(--surface); color: var(--ink); border-radius: 16px; padding: 16px 18px 12px; box-shadow: 0 10px 40px rgba(0,0,0,.3); font: 16px/1.5 var(--sans); }
.coach-card.top { bottom: auto; top: calc(24px + env(safe-area-inset-top)); }
.coach-card p { margin: 0 0 10px; }
.coach-card small { display: block; margin-top: 6px; font-size: 13px; }
.coach-foot { display: flex; justify-content: space-between; align-items: center; }
.coach-foot .row { margin: 0; }

.wp-sense-tr { font-size: 14px; color: var(--accent); margin-top: 2px; }
.wp-tr-line .wp-pos { margin-right: 4px; }

.trust-line { font-size: 13px; font-weight: 600; color: var(--accent); letter-spacing: .01em; margin: 6px 0 14px; }
.wp-tr-rel { font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.wp-parts { font-size: 12.5px; color: var(--ink); margin-top: 3px; line-height: 1.45; }
.wp-parts b { color: var(--accent); }
.wp-en-rel { margin: 4px 0 2px; }

/* read aloud */
#r-tts.on { color: var(--accent); }
.tts-bar {
  position: absolute; left: 50%; bottom: calc(16px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 6;
  display: flex; align-items: center; gap: 4px; padding: 4px 6px 4px 4px; border-radius: 999px;
  background: var(--surface, #FAF9F5); color: var(--ink); border: 1px solid var(--line);
  box-shadow: 0 6px 22px rgba(0,0,0,.18); transition: bottom .2s ease;
}
#reader:not(.chrome-hidden) .tts-bar { bottom: calc(118px + env(safe-area-inset-bottom)); }
.tts-bar .icon-btn { color: var(--ink); }
.tts-label { font-size: 13px; font-weight: 600; padding: 0 4px; white-space: nowrap; }
.tts-speed { border: 1px solid var(--line); background: none; color: var(--ink); border-radius: 999px; font: 600 12.5px var(--sans, inherit); padding: 5px 9px; min-width: 52px; font-variant-numeric: tabular-nums; }

/* chapter words */
.cw-label { font-weight: 700; margin: 12px 0 2px; }
.cw-list { list-style: none; margin: 8px 0 14px; padding: 0; }
.cw-list > li { display: grid; grid-template-columns: minmax(96px, auto) 1fr auto; align-items: center; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--line); }
.cw-word { border: 0; background: none; color: inherit; text-align: left; padding: 0; font-size: 15.5px; }
.cw-mean { font-size: 13.5px; color: var(--muted); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.cw-add { font-size: 20px; font-weight: 600; color: var(--accent); }
.cw-add:disabled { color: var(--muted); }
.cw .seg, .seg + .cw { margin-top: 10px; }

/* chapter-end note, word popup counts */
.cn .note-input { margin: 4px 0 10px; }
.note-bar.sum { background: #C9963A; }
.wp-seen { margin-top: 6px; font-size: 12.5px; color: var(--muted); }

/* selection bar: one narrow see-through column on the right edge, halfway down (on the left when the selection is at
   the right edge); icons only, in the page's own colours so it suits every theme */
#selbar { left: auto; right: max(4px, env(safe-area-inset-right)); top: 50%; bottom: auto; transform: translateY(-50%);
  flex-direction: column; align-items: center; gap: 0; padding: 5px 2px; border-radius: 18px; width: 34px; max-width: none; max-height: calc(100vh - 40px); overflow-y: auto;
  background: color-mix(in srgb, var(--page, var(--bg)) 55%, transparent); color: var(--ink, var(--ink));
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  border: 1px solid color-mix(in srgb, var(--ink) 18%, transparent); box-shadow: 0 2px 10px rgba(0,0,0,.12);
  animation: sb-open .16s ease-out; }
#selbar.left { right: auto; left: max(4px, env(safe-area-inset-left)); }
@keyframes sb-open { from { opacity: 0; transform: translateY(-50%) scaleY(.85); } }
#selbar .sb-dots { display: flex; flex-direction: column; align-items: center; gap: 5px; padding: 2px 0 6px; border-bottom: 1px solid color-mix(in srgb, var(--ink) 18%, transparent); margin-bottom: 2px; }
#selbar .hl-dot { width: 18px; height: 18px; border: 1px solid color-mix(in srgb, var(--ink) 25%, transparent); }
#selbar .sb-btn { display: flex; align-items: center; justify-content: center; width: 30px; height: 32px; padding: 0; border-radius: 9px; color: var(--ink); }
#selbar .sb-btn:active { background: color-mix(in srgb, var(--ink) 12%, transparent); }
#selbar .sb-del { color: #B4473A; border-top: 1px solid color-mix(in srgb, var(--ink) 18%, transparent); border-radius: 0 0 9px 9px; margin-top: 2px; }

/* level hint inside the word popup */
.wp-lvhint { margin: 12px 0 4px; padding: 12px 14px; border-radius: 14px; background: var(--accent-soft); }
.wp-lvhint p { margin: 4px 0 10px; }
.wp-lvhint .row { margin: 0; flex-wrap: wrap; }

/* tab rows (notes: 3 tabs) stay on one line on narrow phones */
.seg.tabs { flex-wrap: nowrap; }
.seg.tabs button { white-space: normal; padding: 2px 6px; font-size: 13.5px; line-height: 1.15; min-width: 0; overflow-wrap: anywhere; }
@media (max-width: 380px) { .seg.tabs button { font-size: 12.5px; padding: 0 4px; } }

/* words read without looking up */
.pk-box { margin: 14px 0 4px; padding: 14px 16px; border-radius: var(--radius); background: var(--accent-soft); }
.pk-box p { margin: 4px 0 6px; }
.pk-list { margin-top: 8px; }

/* language pickers */
.pick { width: 100%; min-height: 44px; padding: 0 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); font: 600 15px var(--sans); }
.seg button { padding: 4px 6px; line-height: 1.2; }

.cw-pick { margin: 10px 0 4px; }
.nc-link { border: 0; background: none; padding: 2px 0; margin: 2px 0; color: var(--muted); font: 13px var(--sans); text-align: left; cursor: pointer; text-decoration: underline; text-decoration-color: var(--line); text-underline-offset: 3px; }

/* review card additions */
.flash-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.card-undo { font-size: 14px; }
.flash-head { display: flex; align-items: center; justify-content: center; gap: 6px; }
.cloze-sent { font-size: 20px; line-height: 1.55; }
.cloze { display: inline-block; color: var(--accent); font-weight: 700; letter-spacing: .08em; }
.flash-extra .wp-parts { margin: 6px 0; font-size: 14px; }
.flash-sent.small { font-size: 15px; }
.flash-more { border-top: 1px solid var(--line); margin-top: 10px; padding-top: 6px; }
.flash-meta { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; margin: 8px 0; }
.card-acts { margin: 6px 0 10px; gap: 8px; }
.card-acts .btn { flex: 1 1 0; font-size: 14px; }
.card-panel .seg { margin: 6px 0 10px; }
.card-panel > label { display: block; font-weight: 600; margin-top: 4px; }
.mcq { display: grid; gap: 8px; margin-top: 14px; }
.mcq-opt { width: 100%; justify-content: flex-start; text-align: left; white-space: normal; line-height: 1.3; font-family: var(--sans); font-size: 15px; padding: 10px 12px; }
:root .mcq .mcq-opt.ok { border-width: 1.5px; background: color-mix(in srgb, #2E9E5B 18%, var(--surface)); border-color: #2E9E5B; color: var(--ink); }
:root .mcq .mcq-opt.bad { border-width: 1.5px; background: color-mix(in srgb, #C2453D 16%, var(--surface)); border-color: #C2453D; color: var(--ink); }
.mcq-opt:disabled { opacity: 1; }
.grade .btn.suggest { outline: 3px solid var(--accent); outline-offset: 1px; }
.mcq-next { margin: 4px 0 8px; }
.review-help-link { margin: 2px 0 6px; font-size: .9rem; }
.review-help p { line-height: 1.5; margin: 0 0 10px; }
.card-exit { margin-left: auto; }
#r-auto.on { color: var(--accent); }
.disp-label { display: block; font-size: .85rem; color: var(--muted, #888); margin: 10px 0 4px; }
#auto-bar { position: fixed; left: 0; right: 0; bottom: 0; height: 2px; background: var(--accent); opacity: .45; transform-origin: left; transform: scaleX(0); z-index: 40; pointer-events: none; display: none; }
body.reading.auto-on #auto-bar { display: block; }
body.auto-wait #auto-bar { opacity: .15; }
.disp-row .disp-val { white-space: nowrap; }

/* start screen: shown at once, before the app has loaded; fades out when the first screen is ready (and after 8 s at the latest) */
#splash { position: fixed; inset: 0; z-index: 9999; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
  background: #ECE4D2; color: var(--ink); text-align: center; padding: 24px; transition: opacity .5s ease;   /* the app icon's own beige: the phone's start screen flows into this one */ animation: splash-off .5s ease 8s forwards; }
#splash .splash-art { width: min(380px, 88vw, 53vh); height: auto; margin-bottom: -6px;   /* 53vh: the picture never taller than half the screen */
  -webkit-mask-image: radial-gradient(ellipse 50% 50% at 50% 50%, #000 55%, transparent 100%); mask-image: radial-gradient(ellipse 50% 50% at 50% 50%, #000 55%, transparent 100%); }
/* the name as if carved in stone: Roman capitals (Cinzel, OFL), warm stone colour, a light edge below and a shadow above */
#splash h1 { font-family: 'DF-cinzel', var(--serif); font-size: 46px; font-weight: 600; letter-spacing: .14em; margin: 0 0 0 .14em; color: #8C7B62;
  text-shadow: 0 1px 0 rgba(255,250,240,.9), 0 -1px 0 rgba(70,55,35,.45), 0 0 1px rgba(70,55,35,.25); }
#splash p { font-family: var(--sans); font-size: 15px; color: #8A7F6E; margin: 0; letter-spacing: .04em; }
#splash.out { opacity: 0; pointer-events: none; }
@keyframes splash-off { to { opacity: 0; visibility: hidden; } }
@media (min-width: 600px) { #splash .splash-art { width: min(440px, 80vw, 53vh); } }   /* tablets: a little larger still */

/* book language row in the book sheet */
.lang-row { margin: 14px 0 4px; }
.lang-row > label { display: block; font-size: 14px; color: var(--muted); margin-bottom: 6px; }
.fit.lang { background: var(--surface-2); color: var(--muted); }

/* "Learn the 20 most frequent": its own full line under Read and Delete, in every language */
.row .btn.learn-top { order: 3; flex: 1 1 100%; }

/* a level between two steps (A2–B1): both neighbours lightly marked */
.seg button.half { background: var(--accent-soft); }

/* book card: title with a "⋯" menu button; the delete note in sheets */
.bm-head { display: flex; align-items: flex-start; gap: 2px; }
.bm-head h3 { flex: 1; min-width: 0; }
.book-more { flex: none; border: 0; background: none; color: var(--muted); font-size: 20px; line-height: 1; padding: 0 4px 6px; min-width: 32px; min-height: 28px; border-radius: 8px; }
.book-more:active { background: var(--surface-2); }
.del-note { margin: -6px 0 10px; }
.book-menu .btn.wide { margin: 4px 0 6px; }

/* the query a look-up will send */
.lookup-q { margin: -4px 0 6px; word-break: break-word; }

/* share as text or as a quote card */
.share-menu .btn.wide { margin: 6px 0; }
.quote-card img { display: block; width: 100%; max-width: 360px; margin: 4px auto 12px; border-radius: 10px; box-shadow: 0 4px 16px rgba(0,0,0,.18); }
.quote-card .row { justify-content: center; }

/* new version notice */
#update-bar { position: fixed; left: 50%; bottom: calc(76px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 9000;
  display: flex; align-items: center; gap: 10px; padding: 8px 8px 8px 16px; border-radius: 999px;
  background: var(--ink); color: var(--surface); font-size: 14px; box-shadow: 0 4px 16px rgba(0,0,0,.25); white-space: nowrap; }
#update-bar button { border: 0; border-radius: 999px; padding: 6px 14px; font: inherit; font-weight: 600; background: var(--accent); color: var(--accent-ink, #fff); cursor: pointer; }
#update-bar .ub-x { background: transparent; color: inherit; padding: 6px 8px; font-weight: 400; }
body.reading #update-bar { bottom: auto; top: calc(64px + env(safe-area-inset-top)); }

/* touch selection handles (the book's own selection on touch screens) */
/* the drop is 20 px; the touch area around it is larger on every side so a finger finds it even at the screen edge */
.pick-h { position: fixed; z-index: 8; width: 60px; height: 60px; margin-top: -10px; touch-action: none; }
.pick-h[hidden] { display: none; }
.pick-h::after { content: ''; position: absolute; top: 10px; width: 20px; height: 20px; background: var(--accent); box-shadow: 0 1px 3px rgba(0,0,0,.25); }
.pick-h.start { transform: translateX(-44px); }
.pick-h.start::after { right: 16px; border-radius: 50% 0 50% 50%; }
.pick-h.end { transform: translateX(-16px); }
.pick-h.end::after { left: 16px; border-radius: 0 50% 50% 50%; }

/* Discura: "Show choices" under a gap card; the other reading of a word like "ground" in the word popup */
.show-choices { display: block; margin: 12px auto 0; font-family: var(--sans); font-size: 14px; }
.wp-alt { margin: 4px 0 8px; line-height: 1.4; }
.wp-alt .wp-tr-tag { margin-right: 2px; }
/* narrow phones: long theme and bookmark names (Pergaminho, Pergamena) fit their buttons */
@media (max-width: 400px) {
  .swatch { padding-inline: 0; }
  .swatch small { font-size: 9.5px; }
  .seg button { font-size: 13px; padding-inline: 2px; }
  .seg.seg-grid button { font-size: 12px; }
}
/* splash: DISCURA a little lower, close to its two lines; the second line carved in stone like the name */
#splash h1 { margin: 20px 0 -34px .14em; }
#splash p { margin-top: 24px; line-height: 1.45; }
#splash .sp-sub { display: inline-block; margin-bottom: 10px; font-size: min(17px, 4.5vw); letter-spacing: .03em; white-space: nowrap; }
#splash .sp-ins { font-family: 'DF-cinzel', var(--serif); font-weight: 600; font-size: min(19px, 5vw); letter-spacing: .22em; white-space: nowrap; color: #8C7B62;
  text-shadow: 0 1px 0 rgba(255,250,240,.9), 0 -1px 0 rgba(70,55,35,.45), 0 0 1px rgba(70,55,35,.25); }
/* Discura: the guide's map of the reading screen (step 4) */
.coach.mapped { background: rgba(22,19,14,.82); }
.gm-zone { position: absolute; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; text-align: center;
  border: 1.5px dashed rgba(255,255,255,.5); border-radius: 14px; color: #fff; font-family: var(--sans); pointer-events: none; }
.gm-zone i { font-style: normal; font-size: 30px; line-height: 1; }
.gm-zone b { font-size: 14px; font-weight: 600; line-height: 1.25; background: rgba(255,255,255,.14); border-radius: 10px; padding: 6px 8px; max-width: 92%; }
.gm-line { display: block; margin: 0 0 4px; line-height: 1.45; }
.gm-line b { margin-right: 4px; }
/* the guide's last step in the library: the Review button lit, the rest dimmed */
.guide-tip { position: fixed; inset: 0; z-index: 9500; }
.guide-hole { position: absolute; border-radius: 16px; box-shadow: 0 0 0 2px #fff, 0 0 0 9999px rgba(28,24,18,.55); pointer-events: none; }
.guide-tip .coach-card p { margin: 0 0 6px; }
/* after reading: words waiting for review (once a day) */
#review-nudge { position: fixed; left: 50%; bottom: calc(76px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 9000;
  display: flex; align-items: center; gap: 10px; max-width: calc(100vw - 24px); padding: 8px 8px 8px 16px; border-radius: 999px;
  background: var(--surface); color: var(--ink); box-shadow: 0 4px 18px rgba(0,0,0,.18); font-family: var(--sans); font-size: 14px; white-space: nowrap; }
#review-nudge span { overflow: hidden; text-overflow: ellipsis; }
#review-nudge button { border: 0; border-radius: 999px; padding: 6px 14px; font: inherit; font-weight: 600; background: var(--accent); color: var(--accent-ink, #fff); cursor: pointer; }
#review-nudge .ub-x { background: transparent; color: inherit; padding: 6px 8px; font-weight: 400; }
/* end of chapter: a short review in the sheet */
.mini-review .flash-head { margin: 6px 0 4px; }
.mini-review .flash-sent { margin: 0 0 14px; }
.mini-review .mr-back { margin-top: 10px; }
.mini-review .grade { margin-top: 12px; }
/* Discura: reading time left, under the progress bar */
#r-left { font-size: 12px; opacity: .65; text-align: center; margin: -2px 0 4px; font-variant-numeric: tabular-nums; min-height: 1em; }
/* a footnote over the page */
.fn-text { font-family: var(--serif); font-size: 17px; line-height: 1.55; margin: 4px 0 16px; white-space: pre-line; }
/* a picture or table seen large */
.zoom { position: fixed; inset: 0; z-index: 9800; background: rgba(12,10,8,.94); display: flex; flex-direction: column; }
.zoom.table { background: var(--bg, #F2EFE8); }
.zoom-box { flex: 1; overflow: auto; display: flex; align-items: safe center; justify-content: safe center; padding: 12px; -webkit-overflow-scrolling: touch; }
.zoom-box img { display: block; max-width: none; height: auto; background: #fff; }
.zoom-box.table { align-items: flex-start; justify-content: flex-start; }
.zoom-box.table table { border-collapse: collapse; font-family: var(--serif); line-height: 1.4; color: var(--ink); margin: auto; }
.zoom-box.table td, .zoom-box.table th { border: 1px solid var(--line); padding: 6px 9px; vertical-align: top; text-align: left; }
.zoom-box.table th { background: var(--surface-2); }
.zoom-bar { display: flex; justify-content: center; gap: 18px; padding: 10px 0 calc(14px + env(safe-area-inset-bottom)); }
.zoom-bar .icon-btn { width: 48px; height: 48px; border-radius: 50%; background: rgba(255,255,255,.16); color: #fff; font-size: 22px; }
.zoom.table .zoom-bar .icon-btn { background: var(--surface-2); color: var(--ink); }
.switch.off { opacity: .5; }
/* Discura: library search, sort and shelves */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink, #fff); }
.chip.add { border-style: dashed; color: var(--muted); }
.lib-tools { display: grid; gap: 10px; margin: 0 0 14px; }
.lib-row { display: flex; gap: 8px; }
.lib-search { flex: 1; min-width: 0; border: 1px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 999px; padding: 9px 14px; font: inherit; font-size: 15px; }
.lib-sort { border: 1px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 999px; padding: 8px 12px; font: inherit; font-size: 14px; max-width: 46%; }
.lib-none { margin: 24px 0; }
.shelf-row { display: block; }
.shelf-row > span { display: block; margin-bottom: 2px; }
.shelf-row .muted.small { margin: 0 0 8px; }
.shelf-new { display: inline-flex; gap: 6px; align-items: center; }
.shelf-input { border: 1px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 999px; padding: 4px 12px; font: inherit; font-size: 13px; width: 150px; }
/* free classics */
.catalog .lib-search { width: 100%; margin: 4px 0 10px; box-sizing: border-box; }
.catalog .chips { margin-bottom: 8px; }
.cat-status { min-height: 1.2em; }
.cat-list { list-style: none; margin: 0 0 12px; padding: 0; }
.cat-list li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.cat-info { display: grid; gap: 2px; min-width: 0; }
.cat-info b { font-family: var(--serif); font-weight: 600; font-size: 16px; line-height: 1.3; }
.btn.small { padding: 6px 14px; font-size: 14px; min-height: 0; }
/* Discura: reading-ready plan */
.plan-box { margin: 18px 0 6px; padding: 14px 14px 10px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.plan-box h3.sub { margin-top: 0; }
.plan-box .seg { margin: 8px 0; }
.plan-box .btn.primary { margin-top: 6px; }
.plan-meter { margin: 8px 0 6px; }
.plan-chip { display: inline-block; margin-top: 4px; border: 0; background: var(--accent-soft, rgba(78,95,140,.12)); color: var(--accent); border-radius: 999px; padding: 3px 10px; font-size: 12px; font-weight: 600; }

/* Discura: old money menus (10 Nov) - navy and cream with cognac links in the light themes, brass in the dark ones.
   Only the menus: the book page, word colours and glosses keep their own colours (settings.js themeColors). */
:root { --link: var(--accent); }
a, .link-btn, .plan-cta, .nc-link { color: var(--link); }
:root[data-theme="light"] {
  --bg: #F8F4EA; --surface: #FDFBF6; --surface-2: #EEE8DA; --line: #DFD7C4;
  --accent: #24375A; --accent-ink: #FFF6E6; --accent-soft: #E1E4EA; --good: #24375A; --link: #8B5A2B; --head: #24375A;
}
:root[data-theme="paper"] { --accent: #24375A; --accent-ink: #FFF6E6; --accent-soft: #E1E4EA; --good: #24375A; --link: #8B5A2B; --head: #24375A; }
:root[data-theme="sepia"] { --accent: #2A3B57; --accent-ink: #FFF6E6; --accent-soft: #E2E2DC; --good: #2A3B57; --link: #7A4B12; }
:root[data-theme="papyrus"] { --accent: #24375A; --accent-ink: #FFF6E6; --accent-soft: #E4E0D4; --good: #24375A; --link: #6E4E1E; }
:root[data-theme="parchment"] { --accent: #24375A; --accent-ink: #FFF4E0; --accent-soft: #E6DCC6; --good: #24375A; --link: #7A3F10; }
:root[data-theme="dark"] {
  --bg: #141C2B; --surface: #1B2436; --surface-2: #243048; --line: #2E3A52; --ink: #EDE4D0; --muted: #A9A28F;
  --accent: #C8A877; --accent-ink: #1A140A; --accent-soft: #2E2A22; --good: #C8A877; --link: #9FB0D0;
}
:root[data-theme="night"] { --accent: #C9A46A; --good: #C9A46A; }
h1, h2 { color: var(--head, inherit); }

/* Discura: familiar-word rate (page in the reader footer, chapters in the contents, progress in the library) */
.cov-page { margin-left: 8px; font-weight: 600; white-space: nowrap; }
.cov-page::before, .toc-cov::before { content: ''; display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 4px; vertical-align: 1px; background: currentColor; }
.cov-ok { color: #3F8A5A; } .cov-mid { color: #B88A1E; } .cov-low { color: #C0602A; }
:root[data-theme="dark"] .cov-ok, :root[data-theme="night"] .cov-ok { color: #8CCB9C; }
:root[data-theme="dark"] .cov-mid, :root[data-theme="night"] .cov-mid { color: #E2BE62; }
:root[data-theme="dark"] .cov-low, :root[data-theme="night"] .cov-low { color: #F0A070; }
:root[data-theme="contrast"] .cov-ok { color: #7CFF9B; } :root[data-theme="contrast"] .cov-mid { color: #FFE14D; } :root[data-theme="contrast"] .cov-low { color: #FF8A80; }
.toc-item { display: flex; align-items: baseline; gap: 10px; }
.toc-label { flex: 1; min-width: 0; }
.toc-cov { flex: none; font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; }
.toc-cov:empty { display: none; }
.toc-cov-head { display: block; border: 0; background: none; padding: 4px 0 8px; text-align: left; font: 12px var(--sans); color: var(--muted); }
.cov-since { margin: 2px 0 0; font-size: 12px; color: var(--muted); }
.level-note { margin-top: 10px; font-size: 12px; opacity: .85; }
/* Discura: dark themes - the chosen option in brass (the lighter grey read as "not chosen") */
:root[data-theme="dark"] .seg button.on, :root[data-theme="night"] .seg button.on, :root[data-theme="contrast"] .seg button.on,
#reader[data-theme="dark"] .seg button.on, #reader[data-theme="night"] .seg button.on, #reader[data-theme="contrast"] .seg button.on { background: var(--accent); color: var(--accent-ink); box-shadow: none; }
.wp-wiki { display: block; margin: -4px 0 12px; }
/* Discura: the book's file type on the cover's top left, past the spine (the ribbon hangs on the right) */
.fmt-tag { position: absolute; top: 7px; left: 16px; z-index: 2; padding: 1px 5px; border-radius: 4px; background: rgba(20,20,20,.62); color: #fff;
  font: 700 9.5px/1.45 var(--sans); letter-spacing: .06em; pointer-events: none; }
/* PDF pages are the file's own; in the dark themes they are turned dark (pictures too: the price of reading at night) */
#reader[data-theme="dark"] .pane.pdf foliate-view, #reader[data-theme="night"] .pane.pdf foliate-view { filter: invert(.88) hue-rotate(180deg); }
#reader[data-theme="contrast"] .pane.pdf foliate-view { filter: invert(1) hue-rotate(180deg); }
/* Discura: PDF in the sepia and paper themes: the white page takes the theme's paper (black print stays black) */
#reader[data-theme="sepia"] .pane.pdf foliate-view, #reader[data-theme="paper"] .pane.pdf foliate-view { mix-blend-mode: multiply; }
/* PDF zoomed: how far, and a tap to fit the page again */
.pdf-zoom { position: absolute; top: calc(env(safe-area-inset-top, 0px) + 10px); left: 50%; transform: translateX(-50%); z-index: 6;
  border: 0; border-radius: 16px; padding: 6px 12px; background: rgba(20,20,20,.7); color: #fff; font: 600 13px/1 var(--sans); }
.pdf-zoom[hidden] { display: none; }

/* Discura: My notes (library) */
.head-btns { display: flex; align-items: center; gap: 4px; flex: none; }
.notes-btn { color: var(--accent); padding: 0 14px; }
@media (max-width: 379px) { .notes-btn { padding: 0; width: 44px; } .notes-btn .nb-label { display: none; } }   /* a narrow phone: the framed icon only */
.notes-page .np-search { width: 100%; margin: 6px 0 10px; box-sizing: border-box; flex: none; }
.notes-page .np-tags { margin-bottom: 8px; }
.np-book { font-size: 15px; margin: 18px 0 2px; }
.np-book small { font-weight: 400; }

/* Discura: scrolled flow - the label while pulling on to the next (previous) section */
.sec-pull { position: absolute; left: 50%; bottom: calc(env(safe-area-inset-bottom, 0px) + 18px); transform: translateX(-50%); z-index: 6;
  background: var(--surface); color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 6px 14px;
  font: 600 13px/1.2 system-ui, sans-serif; box-shadow: 0 2px 8px rgba(0,0,0,.18); pointer-events: none; white-space: nowrap; }
.sec-pull.top { bottom: auto; top: calc(env(safe-area-inset-top, 0px) + 18px); }
.sec-pull.ready { color: var(--accent); border-color: var(--accent); }
.sec-pull[hidden] { display: none; }

/* Discura: handwriting - the note sheet's Pen tab, thumbnails, the pen's tools over a PDF page */
.tool[hidden] { display: none !important; }
.note-tabs { margin: 8px 0; }
.note-tabs button { display: inline-flex; align-items: center; gap: 4px; }
.ink-box[hidden], .note-input[hidden] { display: none; }
.ink-pad { border-radius: 10px; overflow: hidden; border: 1px solid var(--line); background: #FBF8F1; }
.ink-canvas { display: block; width: 100%; touch-action: none; background: #FBF8F1;
  background-image: repeating-linear-gradient(to bottom, transparent 0 31px, rgba(46,63,127,.10) 31px 32px); }
.ink-padbar { display: flex; align-items: center; gap: 6px; padding: 6px 8px; background: var(--surface); border-top: 1px solid var(--line); }
.ink-dot { width: 26px; height: 26px; border-radius: 50%; border: 2px solid transparent; box-shadow: inset 0 0 0 2px var(--surface), 0 0 0 1px var(--line); flex: none; }   /* the ring keeps black visible on a dark bar */
.ink-dot.on { border-color: var(--accent); }
.ink-tool { width: 36px; height: 36px; display: grid; place-items: center; border: 0; background: none; border-radius: 8px; color: var(--ink); flex: none; }
.ink-tool.on { background: var(--surface-2); color: var(--accent); }
.ink-padbar .ink-tool:first-of-type { margin-left: auto; }
.ink-thumb { display: block; width: min(220px, 70%); margin-top: 4px; border-radius: 6px; overflow: hidden; border: 1px solid var(--line); }
.ink-thumb svg { display: block; width: 100%; height: auto; }
.note-bar.ink { background: #2E3F7F; }
.ink-bar { position: absolute; top: calc(env(safe-area-inset-top, 0px) + 56px); left: 50%; transform: translateX(-50%); z-index: 7;
  display: flex; align-items: center; gap: 4px; padding: 4px 6px; border-radius: 14px; background: var(--surface); color: var(--ink);
  border: 1px solid var(--line); box-shadow: 0 4px 14px rgba(0,0,0,.22); max-width: calc(100% - 16px); overflow-x: auto; }
.ink-bar[hidden] { display: none; }
.ink-bar .ink-dot { width: 24px; height: 24px; }
.ink-sep { width: 1px; height: 22px; background: var(--line); margin: 0 2px; flex: none; }
.ink-done { border: 0; background: var(--accent); color: var(--accent-ink, #fff); border-radius: 10px; padding: 7px 12px; font-weight: 600; font-size: 13px; flex: none; margin-left: 2px; }

/* Discura: PDF - the meaning of the picked word, in a strip under the page */
.pdf-mean { position: absolute; left: 50%; bottom: calc(env(safe-area-inset-bottom, 0px) + 16px); transform: translateX(-50%); z-index: 7;
  display: flex; align-items: center; gap: 4px; max-width: min(640px, calc(100% - 24px)); padding: 4px 6px 4px 4px; border-radius: 14px;
  background: var(--surface); color: var(--ink); border: 1px solid var(--line); box-shadow: 0 4px 14px rgba(0,0,0,.22); }
.pdf-mean[hidden] { display: none; }
.pdf-mean .pm-main { display: flex; align-items: baseline; gap: 10px; min-width: 0; border: 0; background: none; color: inherit; text-align: left; padding: 8px 10px; font-size: 15px; }
.pdf-mean .pm-main b { font-family: var(--serif); font-size: 17px; flex: none; }
.pdf-mean .pm-main span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--muted); }

/* Discura: right after a pen stroke was tidied - keep it as drawn */
.tidy-chip { position: absolute; z-index: 8; border: 1px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 999px;
  padding: 7px 12px; font-size: 13px; box-shadow: 0 3px 10px rgba(0,0,0,.2); white-space: nowrap; animation: tidy-in .15s ease; }
.tidy-chip b { color: var(--accent); }
.tidy-chip.first { white-space: normal; width: max-content; max-width: min(300px, calc(100% - 16px)); border-radius: 14px; text-align: left; display: grid; gap: 4px; }
.tidy-chip .tc-hint { font-size: 12px; color: var(--muted); line-height: 1.35; }
.tidy-chip .tc-hint svg { vertical-align: -3px; color: var(--accent); }
/* the shape-tidying switch on the pen bar: on - the accent colour on a light wash of it; off - grey, struck through */
.ink-tool.tidy.on { color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, transparent); }
.ink-tool.tidy.off { color: var(--muted); background: none; }
/* the pen note's wait: a ring fills round its button in 3 s, then the note opens (a tap opens it at once) */
@property --nw { syntax: '<number>'; inherits: false; initial-value: 0; }
.ink-tool.note { position: relative; }
.ink-tool.note.waiting::after { content: ''; position: absolute; inset: 1px; border-radius: 50%; pointer-events: none;
  background: conic-gradient(var(--accent) calc(var(--nw) * 1turn), transparent 0);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 calc(100% - 2.5px));
  mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 calc(100% - 2.5px));
  animation: note-wait 3s linear forwards; animation-delay: var(--wd, 0ms); }
@keyframes note-wait { from { --nw: 0; } to { --nw: 1; } }
@keyframes tidy-in { from { opacity: 0; transform: translateY(4px); } }
