/* Abai45 website. Colours, sizes and type follow the app (src/theme/ThemeContext.tsx, tokens.ts). */

@font-face { font-family: 'Literata'; src: url('fonts/literata-400.woff2') format('woff2'); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: 'Literata'; src: url('fonts/literata-400italic.woff2') format('woff2'); font-weight: 400; font-style: italic; font-display: swap; }
@font-face { font-family: 'Literata'; src: url('fonts/literata-600.woff2') format('woff2'); font-weight: 600; font-style: normal; font-display: swap; }

:root {
  --serif: 'Literata', Georgia, 'Times New Roman', serif;
  --sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --scale: 1;
  --content: 720px;
  --column: 620px;
  --gutter: 16px;
  --radius-card: 20px;
  --hairline: 1px;
  --tabbar-space: 104px;
  color-scheme: light;

  --canvas: #F6F1E8; --paper: #FFFDF8; --raised: #FFFFFF; --subtle: #EEE7DC;
  --brand: #123F39; --brand-2: #1B5149;
  --text: #182B27; --text-2: #50635D; --text-3: #5B6C65; --accent-text: #1B5149;
  --gold-deco: #B69A5B; --gold: #806426;
  --border: #CFC5B7; --border-strong: #9D9386; --focus: #176B5D;
  --control: #EEE7DC; --selected: #1B5149; --on-selected: #FFFFFF;
  --page: #F8F3EA; --reader-text: #1C2B27; --reader-muted: #53665F; --divider: rgba(28, 43, 39, 0.16);
  --highlight: rgba(182, 154, 91, 0.30); --highlight-glow: rgba(182, 154, 91, 0.48); --selection: rgba(27, 81, 73, 0.18);
  --controls: rgba(255, 253, 248, 0.94); --floating: #FFF9EF;
  --progress-track: rgba(28, 43, 39, 0.13); --progress-fill: #806426;
  --hero-bg: #123F39; --hero-border: #123F39; --hero-kicker: #B69A5B; --hero-meta: rgba(255, 255, 255, 0.72); --hero-quote: #FFFFFF; --hero-action: #FFFFFF;
  --bar: rgba(18, 63, 57, 0.94); --bar-text: #D5E2DD; --bar-active: #FFFFFF; --bar-indicator: rgba(255, 255, 255, 0.16);
  --petal-lit: rgba(182, 154, 91, 0.72); --petal-idle: rgba(18, 63, 57, 0.035);
  --scrim: rgba(16, 31, 27, 0.42);
  --shadow: 0 4px 12px rgba(10, 30, 25, 0.06);
  --shadow-float: 0 8px 24px rgba(10, 30, 25, 0.16);
  --portrait-glow: transparent;
}

:root[data-theme="sepia"] {
  --canvas: #F2E6D0; --paper: #FAF1E1; --raised: #FFF8EC; --subtle: #E9DBC1;
  --text: #3A2D1F; --text-2: #6B5A45; --text-3: #6F5E49;
  --gold: #7A5B22; --border: #CDB894; --border-strong: #9C8766; --control: #E9DBC1;
  --page: #F2E6D0; --reader-text: #3A2D1F; --reader-muted: #6B5A45; --divider: rgba(58, 45, 31, 0.18);
  --highlight: rgba(170, 130, 60, 0.30); --highlight-glow: rgba(170, 130, 60, 0.48); --selection: rgba(27, 81, 73, 0.16);
  --controls: rgba(250, 241, 225, 0.95); --floating: #FAF1E1;
  --progress-track: rgba(58, 45, 31, 0.14); --progress-fill: #7A5B22;
  --scrim: rgba(40, 30, 18, 0.42);
}

/* The dark palette, written twice: once for the chosen theme, once for «Auto» while the device is dark. */
:root[data-theme="dark"] {
  color-scheme: dark;
  --canvas: #0F1513; --paper: #171D1B; --raised: #1E2724; --subtle: #222C28;
  --text: #F0E9DD; --text-2: #B6C0BA; --text-3: #A1ADA7; --accent-text: #86C6B3;
  --gold-deco: #D0B875; --gold: #E0C98A;
  --border: #4B5953; --border-strong: #718078; --focus: #86C6B3;
  --control: #222C28; --on-selected: #F8F3EA;
  --page: #0F1513; --reader-text: #F0E9DD; --reader-muted: #B6C0BA; --divider: rgba(240, 233, 221, 0.17);
  --highlight: rgba(208, 184, 117, 0.26); --highlight-glow: rgba(208, 184, 117, 0.42); --selection: rgba(126, 196, 176, 0.30);
  --controls: rgba(23, 29, 27, 0.95); --floating: #1E2724;
  --progress-track: rgba(240, 233, 221, 0.16); --progress-fill: #D0B875;
  --hero-bg: #171D1B; --hero-border: #4B5953; --hero-kicker: #E0C98A; --hero-meta: #B6C0BA; --hero-quote: #F0E9DD; --hero-action: #86C6B3;
  --bar: rgba(17, 27, 24, 0.94); --bar-text: #BFCAC4; --bar-active: #F0E9DD; --bar-indicator: rgba(134, 198, 179, 0.22);
  --petal-lit: rgba(208, 184, 117, 0.78); --petal-idle: rgba(240, 233, 221, 0.04);
  --scrim: rgba(0, 0, 0, 0.58);
  --shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  --shadow-float: 0 8px 24px rgba(0, 0, 0, 0.52);
  --portrait-glow: radial-gradient(circle, rgba(208, 184, 117, 0.20) 0%, rgba(208, 184, 117, 0) 65%);
}
@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] {
    color-scheme: dark;
    --canvas: #0F1513; --paper: #171D1B; --raised: #1E2724; --subtle: #222C28;
    --text: #F0E9DD; --text-2: #B6C0BA; --text-3: #A1ADA7; --accent-text: #86C6B3;
    --gold-deco: #D0B875; --gold: #E0C98A;
    --border: #4B5953; --border-strong: #718078; --focus: #86C6B3;
    --control: #222C28; --on-selected: #F8F3EA;
    --page: #0F1513; --reader-text: #F0E9DD; --reader-muted: #B6C0BA; --divider: rgba(240, 233, 221, 0.17);
    --highlight: rgba(208, 184, 117, 0.26); --highlight-glow: rgba(208, 184, 117, 0.42); --selection: rgba(126, 196, 176, 0.30);
    --controls: rgba(23, 29, 27, 0.95); --floating: #1E2724;
    --progress-track: rgba(240, 233, 221, 0.16); --progress-fill: #D0B875;
    --hero-bg: #171D1B; --hero-border: #4B5953; --hero-kicker: #E0C98A; --hero-meta: #B6C0BA; --hero-quote: #F0E9DD; --hero-action: #86C6B3;
    --bar: rgba(17, 27, 24, 0.94); --bar-text: #BFCAC4; --bar-active: #F0E9DD; --bar-indicator: rgba(134, 198, 179, 0.22);
    --petal-lit: rgba(208, 184, 117, 0.78); --petal-idle: rgba(240, 233, 221, 0.04);
    --scrim: rgba(0, 0, 0, 0.58);
    --shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    --shadow-float: 0 8px 24px rgba(0, 0, 0, 0.52);
    --portrait-glow: radial-gradient(circle, rgba(208, 184, 117, 0.20) 0%, rgba(208, 184, 117, 0) 65%);
  }
}

/* ───────── base ───────── */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-padding-top: 72px; }
body {
  margin: 0;
  background: var(--canvas);
  color: var(--text);
  font: 400 17px/1.45 var(--sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
}
body.page-reader { background: var(--page); }
img, svg { display: block; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 8px; }
::selection { background: var(--selection); }
[hidden] { display: none !important; }
.icon { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.motif { fill: none; stroke: var(--gold-deco); stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }

.skip-link { position: absolute; left: -999px; top: 8px; z-index: 100; background: var(--brand); color: #fff; padding: 8px 14px; border-radius: 12px; }
.skip-link:focus { left: 8px; }

main { max-width: calc(var(--content) + 2 * var(--gutter)); margin: 0 auto; padding: 8px var(--gutter) 0; }
.page-reader main { max-width: none; padding: 0; }

/* ───────── top bar ───────── */

.topbar {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--canvas) 88%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(14px); backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: var(--hairline) solid transparent;
  transition: border-color 0.2s;
}
.topbar.is-scrolled { border-bottom-color: var(--divider); }
.topbar-inner { max-width: calc(1080px + 2 * var(--gutter)); margin: 0 auto; height: 60px; padding: 0 var(--gutter); display: flex; align-items: center; gap: 20px; }
.brand { display: flex; align-items: center; gap: 10px; font: 700 13px/1 var(--sans); letter-spacing: 3.2px; color: var(--brand); }
:root[data-theme="dark"] .brand { color: var(--text); }
@media (prefers-color-scheme: dark) { :root[data-theme="auto"] .brand { color: var(--text); } }
.brand img { width: 36px; height: 36px; border-radius: 50%; background: #F9F3EA; }
.brand b { color: var(--gold); font-weight: 700; }
.nav-desktop { display: none; gap: 4px; margin-left: 12px; }
.nav-desktop a { padding: 8px 14px; border-radius: 999px; font-size: 15px; font-weight: 500; color: var(--text-2); }
.nav-desktop a:hover { color: var(--text); background: var(--subtle); }
.nav-desktop a[aria-current="page"] { color: var(--on-selected); background: var(--selected); }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.lang-switch { display: flex; background: var(--subtle); border-radius: 999px; padding: 3px; }
.lang-switch a { min-width: 40px; height: 32px; display: grid; place-items: center; border-radius: 999px; font: 600 12px/1 var(--sans); letter-spacing: 0.6px; color: var(--text-2); }
.lang-switch a[aria-current="true"] { background: var(--paper); color: var(--text); box-shadow: var(--shadow); }
.icon-button { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 50%; color: var(--text); flex: none; }
.icon-button:hover { background: var(--subtle); }

/* ───────── tab bar (phones), like the app's floating bar ───────── */

.tabbar {
  position: fixed; z-index: 30; left: 50%; transform: translateX(-50%);
  bottom: max(12px, env(safe-area-inset-bottom));
  width: min(540px, calc(100% - 2 * var(--gutter)));
  display: grid; grid-template-columns: repeat(4, 1fr); padding: 6px; gap: 4px;
  background: var(--bar); border-radius: 30px; box-shadow: var(--shadow-float);
  -webkit-backdrop-filter: blur(18px); backdrop-filter: blur(18px);
  border: var(--hairline) solid rgba(255, 255, 255, 0.12);
}
.tabbar a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-height: 54px; border-radius: 24px; color: var(--bar-text); font: 600 11px/1.2 var(--sans); text-align: center; }
.tabbar a[aria-current="page"] { color: var(--bar-active); background: var(--bar-indicator); }
.tabbar .icon { width: 24px; height: 24px; }
body:not(.page-reader) { padding-bottom: var(--tabbar-space); }

/* ───────── home ───────── */

.cover { position: relative; margin: 4px calc(-1 * var(--gutter)) 16px; padding: 8px var(--gutter) 0; overflow-x: clip; min-height: 196px; }
.cover::before { content: ''; position: absolute; right: -30px; top: -40px; width: 260px; height: 260px; border-radius: 50%; background: var(--portrait-glow); pointer-events: none; }
.cover-portrait { position: absolute; top: -4px; right: -96px; width: 294px; height: auto; pointer-events: none; animation: rise 0.7s cubic-bezier(0.2, 0.7, 0.2, 1) 0.1s both; }
.cover-copy { position: relative; max-width: 62%; }
.cover-brand { margin: 0; font: 700 11px/16px var(--sans); letter-spacing: 3.5px; color: var(--gold); }
.cover-name { margin: 8px 0 0; font: 400 27px/33px var(--serif); color: var(--text); }
.cover-years { margin: 8px 0 0; font: 600 12px/16px var(--sans); letter-spacing: 2px; color: var(--gold); }
.search-pill {
  margin-top: 16px; min-height: 44px; max-width: 86%; display: flex; align-items: center; gap: 8px; padding: 0 14px;
  background: var(--paper); border: var(--hairline) solid var(--border); border-radius: 22px; color: var(--text-2); font-size: 15px;
}
.search-pill .icon { width: 17px; height: 17px; }

.hero {
  position: relative; z-index: 1; display: block; border-radius: 24px; padding: 18px 20px 16px;
  background: var(--hero-bg); border: var(--hairline) solid var(--hero-border); transition: transform 0.15s, opacity 0.15s;
}
.hero:active, .word-row:active, .word-card:active, .stat:active { opacity: 0.78; transform: scale(0.99); }
.hero-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.hero-kicker { font: 700 11px/15px var(--sans); letter-spacing: 1.4px; text-transform: uppercase; color: var(--hero-kicker); }
.hero-meta { font: 600 12px/16px var(--sans); color: var(--hero-meta); white-space: nowrap; }
.hero-quote { display: -webkit-box; -webkit-line-clamp: 5; -webkit-box-orient: vertical; overflow: hidden; margin-top: 12px; font: 400 20px/29px var(--serif); color: var(--hero-quote); }
.hero-action { display: flex; align-items: center; gap: 6px; margin-top: 14px; font: 600 15px/20px var(--sans); color: var(--hero-action); }
.hero-action .icon { width: 16px; height: 16px; }

.word-row {
  margin-top: 12px; min-height: 72px; display: flex; align-items: center; gap: 14px; padding: 12px 12px 12px 14px;
  background: var(--paper); border: var(--hairline) solid var(--border); border-radius: var(--radius-card); transition: transform 0.15s, opacity 0.15s;
}
.word-row > .icon { color: var(--text-2); width: 20px; height: 20px; }
.word-row-copy { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.word-row-kicker { font: 600 12px/16px var(--sans); color: var(--text-2); }
.word-row-title { font: 400 18px/24px var(--serif); color: var(--text); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

.stats { margin-top: 12px; display: flex; padding: 6px 0; background: var(--paper); border: var(--hairline) solid var(--border); border-radius: var(--radius-card); }
.stat { flex: 1; display: flex; flex-direction: column; align-items: center; padding: 8px 6px; min-height: 56px; transition: transform 0.15s, opacity 0.15s; }
.stat + .stat { border-left: var(--hairline) solid var(--border); }
.stat-value { font: 700 20px/26px var(--sans); font-variant-numeric: tabular-nums; color: var(--text); }
.stat-label { margin-top: 2px; font-size: 12px; line-height: 15px; color: var(--text-2); text-align: center; }

.quote-card { display: block; margin-top: 12px; padding: 16px; background: var(--paper); border: var(--hairline) solid var(--border); border-radius: var(--radius-card); }
.quote-card-head { display: flex; justify-content: space-between; gap: 12px; font: 600 12px/16px var(--sans); color: var(--text-2); }
.quote-card-head a { color: var(--accent-text); font-size: 13px; }
.quote-card-body { display: block; margin-top: 12px; border-left: 2px solid var(--gold-deco); padding-left: 12px; }
.quote-card-text { margin: 0; font: 400 17px/25px var(--serif); color: var(--text); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.quote-card-source { margin: 6px 0 0; font-size: 12px; line-height: 16px; color: var(--text-2); }

.section-title { margin: 28px 0 2px; font: 400 22px/28px var(--serif); color: var(--text); }
.text-link { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; margin-top: 4px; font: 600 15px/20px var(--sans); color: var(--accent-text); }
.text-link .icon { width: 16px; height: 16px; }

.app-card {
  margin-top: 28px; display: flex; gap: 16px; align-items: flex-start; padding: 20px;
  background: var(--paper); border: var(--hairline) solid var(--border); border-radius: 24px;
}
.app-card-icon { width: 72px; height: 72px; border-radius: 17px; box-shadow: var(--shadow); flex: none; }
.app-card-copy { min-width: 0; }
.app-card-kicker { margin: 0; font: 700 11px/15px var(--sans); letter-spacing: 1.4px; text-transform: uppercase; color: var(--gold); }
.app-card-title { margin: 4px 0 0; font: 400 22px/28px var(--serif); }
.app-card-body { margin: 8px 0 0; font-size: 15px; line-height: 22px; color: var(--text-2); }
.app-card .button { margin-top: 14px; }
@media (max-width: 479px) { .app-card { flex-direction: column; } .app-card-icon { width: 60px; height: 60px; border-radius: 14px; } }
.app-card-note { margin: 8px 0 0; font-size: 13px; color: var(--text-2); }

.button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 0 20px;
  border-radius: 16px; font: 600 16px/1 var(--sans); background: var(--control); color: var(--text);
}
.button .icon { width: 20px; height: 20px; }
.button-primary { background: var(--brand); color: #FFFFFF; }
:root[data-theme="dark"] .button-primary { background: var(--brand-2); }

/* ───────── word list (catalog, recommendations, saved) ───────── */

.word-list { display: flex; flex-direction: column; }
.word-card { display: flex; gap: 14px; align-items: flex-start; padding-top: 14px; transition: transform 0.15s, opacity 0.15s; }
.word-card-copy { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; padding-bottom: 14px; border-bottom: var(--hairline) solid var(--border); }
.word-item:last-child .word-card-copy, .word-list > .word-card:last-child .word-card-copy { border-bottom-color: transparent; }
.word-card-title { font: 400 20px/26px var(--serif); color: var(--text); }
.word-card-excerpt { font-size: 15px; line-height: 21px; color: var(--text-2); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.word-card-details { margin-top: 3px; font-size: 12px; line-height: 16px; color: var(--text-3); }
.word-card:hover .word-card-title { color: var(--accent-text); }

.ring { position: relative; width: 44px; height: 44px; flex: none; display: grid; place-items: center; }
.ring svg { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 2; }
.ring-track { stroke: var(--border); }
.ring-fill { stroke: var(--gold-deco); stroke-linecap: round; transition: stroke-dasharray 0.4s; }
.ring-number { position: relative; font: 400 18px/24px var(--serif); font-variant-numeric: tabular-nums; color: var(--gold); }
.ring-gold { width: 46px; height: 46px; }
.ring-gold .ring-track { stroke: var(--gold-deco); }
.ring.is-started .ring-track, .ring-gold.is-started .ring-track { stroke: var(--border); }
.ring.is-read .ring-track { fill: var(--gold-deco); stroke: var(--gold-deco); }
.ring:not(.is-started) .ring-fill { display: none; }
.ring.is-read .ring-number { color: var(--brand); }

/* ───────── catalog ───────── */

.page-title { margin: 12px 0 0; font: 400 32px/42px var(--serif); color: var(--text); }
.progress-line { display: flex; align-items: center; gap: 14px; margin-top: 10px; }
.progress-track { flex: 1; height: 4px; border-radius: 2px; background: var(--progress-track); overflow: hidden; }
.progress-fill { display: block; height: 100%; width: 0; background: var(--progress-fill); border-radius: 2px; transition: width 0.4s; }
.progress-label { font: 600 13px/18px var(--sans); color: var(--text-2); white-space: nowrap; }

.search-field {
  margin-top: 18px; display: flex; align-items: center; gap: 10px; min-height: 52px; padding: 0 8px 0 16px;
  background: var(--paper); border: var(--hairline) solid var(--border); border-radius: 18px; color: var(--text-2);
}
.search-field:focus-within { border-color: var(--focus); }
.search-field input { flex: 1; min-width: 0; height: 50px; border: 0; background: none; outline: none; font: 400 17px var(--sans); color: var(--text); }
.search-field input::placeholder { color: var(--text-3); }
.search-field input::-webkit-search-cancel-button { display: none; }
.search-clear { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 50%; color: var(--text-2); }
.search-clear .icon { width: 18px; height: 18px; }

.filters { margin-top: 14px; display: flex; flex-direction: column; gap: 12px; }
.segmented { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 2px; padding: 3px; background: var(--subtle); border-radius: 16px; }
.segmented button { min-height: 50px; padding: 6px 4px; border-radius: 13px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; font: 600 14px/18px var(--sans); color: var(--text); }
.segmented button small { font-size: 12px; font-weight: 500; color: var(--text-2); }
.segmented button[aria-pressed="true"] { background: var(--selected); color: var(--on-selected); }
.segmented button[aria-pressed="true"] small { color: var(--on-selected); opacity: 0.8; }
.segmented-small button { min-height: 40px; font-size: 14px; }
.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; margin: 0 calc(-1 * var(--gutter)); padding: 0 var(--gutter) 2px; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; min-height: 40px; padding: 0 14px; border-radius: 999px; border: var(--hairline) solid var(--border); background: var(--paper); font: 600 14px/1 var(--sans); color: var(--text); white-space: nowrap; }
.chip small { margin-left: 4px; color: var(--text-2); font-weight: 500; }
.chip[aria-pressed="true"] { background: var(--selected); border-color: var(--selected); color: var(--on-selected); }
.chip[aria-pressed="true"] small { color: var(--on-selected); }
#word-list { margin-top: 6px; }
.empty-state { margin: 28px 0; text-align: center; color: var(--text-2); }

.search-results { margin-top: 12px; display: flex; flex-direction: column; gap: 10px; }
.search-summary { margin: 4px 0; font: 600 13px/18px var(--sans); color: var(--text-2); }
.search-hit-card { display: block; padding: 14px 16px; background: var(--paper); border: var(--hairline) solid var(--border); border-radius: 18px; }
.search-hit-card:hover { border-color: var(--border-strong); }
.search-hit-meta { display: flex; justify-content: space-between; gap: 8px; font: 600 12px/16px var(--sans); color: var(--text-2); }
.search-hit-meta b { color: var(--gold); font-weight: 700; letter-spacing: 0.6px; }
.search-hit-title { margin-top: 4px; font: 400 18px/24px var(--serif); color: var(--text); }
.search-hit-snippet { margin: 6px 0 0; font: 400 15px/22px var(--serif); color: var(--text-2); }
.search-hit-snippet mark, .search-hit-title mark { background: var(--highlight); color: inherit; border-radius: 3px; padding: 0 1px; }
.no-results { padding: 28px 0; text-align: center; }
.no-results p { margin: 6px 0 0; color: var(--text-2); }
.no-results .empty-title { color: var(--text); }

/* ───────── saved ───────── */

.saved-section { margin-top: 8px; }
.empty-card { margin-top: 12px; padding: 20px; border: var(--hairline) dashed var(--border-strong); border-radius: var(--radius-card); color: var(--text-2); }
.empty-card p { margin: 0 0 6px; font-size: 15px; line-height: 21px; }
.empty-title { font: 400 19px/25px var(--serif) !important; color: var(--text); }
.quote-list { display: flex; flex-direction: column; gap: 12px; margin-top: 12px; }
.saved-quote { padding: 16px; background: var(--paper); border: var(--hairline) solid var(--border); border-radius: var(--radius-card); }
.saved-quote blockquote { margin: 0; padding-left: 12px; border-left: 2px solid var(--gold-deco); font: 400 17px/26px var(--serif); color: var(--text); }
.saved-quote-foot { margin-top: 10px; display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.saved-quote-source { flex: 1; min-width: 140px; font-size: 13px; color: var(--text-2); }
.saved-quote-source a { color: var(--accent-text); font-weight: 600; }
.saved-quote-foot .icon-button { width: 40px; height: 40px; color: var(--text-2); }
.saved-quote-foot .icon { width: 20px; height: 20px; }
.fine-print { margin: 20px 0 0; font-size: 13px; line-height: 18px; color: var(--text-3); }

/* ───────── about ───────── */

.about { margin-top: 8px; }
.about-motif { width: 96px; height: 46px; margin: 12px 0 0; }
.about p { font-size: 17px; line-height: 26px; color: var(--text-2); }
.about .about-lead { font: 400 21px/31px var(--serif); color: var(--text); }
.feature-list { list-style: none; margin: 20px 0 0; padding: 0; display: grid; gap: 10px; }
.feature-list li { display: flex; gap: 12px; align-items: center; padding: 14px 16px; background: var(--paper); border: var(--hairline) solid var(--border); border-radius: 16px; font-size: 16px; }
.feature-list .icon { color: var(--gold); }
.about-abai { margin-top: 28px; display: flex; gap: 20px; align-items: center; flex-wrap: wrap; }
.about-abai img { width: 220px; height: auto; }
.about-abai > div { flex: 1; min-width: 220px; }
.about-abai .section-title { margin-top: 0; }
.about-abai p { color: var(--text-2); }
.not-found { margin-top: 40px; text-align: center; border-style: solid; }
.not-found .about-motif { margin: 0 auto; }

/* ───────── footer ───────── */

.site-footer { margin-top: 56px; border-top: var(--hairline) solid var(--divider); }
.footer-inner { max-width: calc(var(--content) + 2 * var(--gutter)); margin: 0 auto; padding: 28px var(--gutter) 24px; }
.footer-title { margin: 0; font: 400 18px/24px var(--serif); color: var(--text); }
.number-grid { list-style: none; margin: 14px 0 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(38px, 1fr)); gap: 8px; }
.number-grid a { display: grid; place-items: center; height: 38px; border-radius: 50%; border: var(--hairline) solid var(--border); font: 400 15px/1 var(--serif); font-variant-numeric: tabular-nums; color: var(--gold); }
.number-grid a:hover { border-color: var(--gold-deco); }
.number-grid a.is-read { background: var(--gold-deco); border-color: var(--gold-deco); color: var(--brand); }
.footer-meta { margin-top: 22px; font-size: 13px; line-height: 19px; color: var(--text-2); }
.footer-meta p { margin: 0 0 6px; }
.footer-links a { color: var(--accent-text); font-weight: 600; }
.footer-brand { margin-top: 14px !important; font: 700 11px/1 var(--sans); letter-spacing: 3px; color: var(--text-3); }
.footer-brand b { color: var(--gold); }
.page-reader .site-footer { margin-top: 24px; }
.page-reader .footer-inner { padding-bottom: 120px; }

/* ───────── reader ───────── */

.reader-bar {
  position: sticky; top: 0; z-index: 20; height: 56px; padding: 0 6px; display: flex; align-items: center; gap: 2px;
  background: var(--controls); border-bottom: var(--hairline) solid var(--divider);
  -webkit-backdrop-filter: saturate(1.3) blur(14px); backdrop-filter: saturate(1.3) blur(14px);
}
.reader-bar .icon-button { color: var(--reader-text); }
.reader-bar .icon-button[aria-pressed="true"] .icon { fill: currentColor; }
.reader-progress { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 5px; }
.reader-progress-label { font: 600 13px/16px var(--sans); color: var(--reader-muted); font-variant-numeric: tabular-nums; }
.reader-progress-track { width: min(150px, 100%); height: 2px; border-radius: 1px; background: var(--progress-track); overflow: hidden; }
.reader-progress-fill { display: block; height: 100%; width: 0; background: var(--progress-fill); }

.reader { max-width: calc(var(--column) + 2 * 20px); margin: 0 auto; padding: 28px 20px 0; color: var(--reader-text); }
.chapter-meta { display: flex; justify-content: space-between; align-items: baseline; font: 400 13px/18px var(--sans); color: var(--reader-muted); }
.chapter-number { font-weight: 700; letter-spacing: 3px; color: var(--gold); }
.chapter-title { margin: 14px 0 0; font: 400 32px/42px var(--serif); color: var(--reader-text); text-wrap: balance; }
.chapter-subtitle { margin: 8px 0 0; font: 400 16px/24px var(--serif); color: var(--reader-muted); }
.lang-pills { margin-top: 20px; display: flex; gap: 10px; }
.lang-pills a { min-width: 58px; height: 44px; padding: 0 12px; display: grid; place-items: center; border-radius: 22px; background: var(--control); border: var(--hairline) solid var(--border); font: 600 14px/1 var(--sans); color: var(--reader-text); }
.lang-pills a[aria-current="true"] { background: var(--selected); border-color: var(--selected); color: var(--on-selected); }
.short-rule { width: 48px; margin: 28px 0 30px; border: 0; border-top: 1px solid var(--gold-deco); opacity: 0.8; }

.reader-text { font: 400 calc(19px * var(--scale)) / 1.62 var(--serif); text-align: justify; hyphens: auto; -webkit-hyphens: auto; overflow-wrap: break-word; }
.reader-text p { margin: 0 0 0.95em; }
:root[data-font="system"] .reader-text { font-family: var(--sans); }
:root[data-align="left"] .reader-text { text-align: left; }
.drop-cap { float: left; font-size: 3.15em; line-height: 0.84; padding: 0.07em 0.08em 0 0; color: var(--gold); font-family: var(--serif); }
.reader-text mark { color: inherit; border-radius: 3px; }
.reader-text mark.saved-quote { background: var(--highlight); }
.reader-text mark.search-hit { background: var(--highlight-glow); box-shadow: 0 0 0 2px var(--highlight-glow); }
.reader-end { height: 1px; }

.finish { margin-top: 36px; padding-top: 36px; border-top: var(--hairline) solid var(--divider); display: flex; flex-direction: column; align-items: center; text-align: center; }
.ornament { width: 220px; height: 220px; }
.petal { fill: var(--petal-idle); stroke: var(--border); stroke-width: 1; transition: fill 0.6s, stroke 0.6s; }
.petal.is-lit { fill: var(--petal-lit); stroke: var(--gold-deco); stroke-width: 1.2; }
.petal-current:not(.is-lit) { fill: var(--petal-lit); stroke: var(--gold-deco); stroke-width: 1.6; animation: breathe 2.2s ease-in-out infinite; }
.petal.is-bloom { fill: var(--gold-deco); stroke: var(--gold-deco); stroke-width: 2; animation: bloom 0.9s cubic-bezier(0.2, 0.7, 0.2, 1) 0.25s both; }
.ornament-center { fill: var(--paper); stroke: var(--gold-deco); stroke-width: 1; }
.ornament-count { font: 400 24px var(--serif); fill: var(--brand); }
:root[data-theme="dark"] .ornament-count { fill: var(--text); }
@media (prefers-color-scheme: dark) { :root[data-theme="auto"] .ornament-count { fill: var(--text); } }
.finish-title { margin: 22px 0 0; font: 400 28px/36px var(--serif); color: var(--reader-text); animation: rise 0.5s ease both; }
.next-word {
  margin-top: 24px; width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 16px 20px;
  background: var(--brand); color: #FFFFFF; border-radius: 20px; text-align: left;
}
:root[data-theme="dark"] .next-word { background: var(--brand-2); }
.next-word strong { display: block; font: 600 17px/22px var(--sans); }
.next-word small { display: block; margin-top: 2px; font-size: 14px; line-height: 19px; opacity: 0.78; }
.reader-links { width: 100%; margin-top: 12px; display: flex; justify-content: space-between; gap: 12px; }
.reader-links a, .link-button { display: inline-flex; align-items: center; gap: 4px; min-height: 44px; font: 600 14px/1 var(--sans); color: var(--accent-text); }
.reader-links .icon { width: 18px; height: 18px; }

.explain-fab {
  position: fixed; z-index: 25; left: 50%; transform: translateX(-50%); bottom: max(16px, env(safe-area-inset-bottom));
  width: 66px; height: 66px; border-radius: 50%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  background: var(--brand); border: 1.5px solid var(--gold-deco); color: #FFFFFF; box-shadow: var(--shadow-float); font: 600 10px/1.1 var(--sans);
  transition: opacity 0.2s, transform 0.2s;
}
.explain-fab .icon { width: 22px; height: 22px; color: var(--gold-deco); }
.explain-fab.is-hidden { opacity: 0; pointer-events: none; transform: translate(-50%, 12px); }

.selection-bar {
  position: fixed; z-index: 26; left: 50%; transform: translateX(-50%); bottom: max(16px, env(safe-area-inset-bottom));
  display: flex; gap: 2px; padding: 6px; background: var(--floating); border: var(--hairline) solid var(--border); border-radius: 20px; box-shadow: var(--shadow-float);
}
.selection-bar button { min-width: 84px; min-height: 52px; padding: 4px 10px; border-radius: 14px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font: 600 12px/1.1 var(--sans); color: var(--reader-text); }
.selection-bar button:hover { background: var(--control); }
.selection-bar .icon { width: 20px; height: 20px; color: var(--gold); }

.resume-pill {
  position: fixed; z-index: 21; top: 66px; left: 50%; transform: translateX(-50%); max-width: calc(100% - 32px);
  min-height: 40px; padding: 0 16px; border-radius: 999px; background: var(--floating); border: var(--hairline) solid var(--border);
  box-shadow: var(--shadow-float); font: 600 14px/1.2 var(--sans); color: var(--reader-text); animation: rise 0.3s ease both;
}

.popover {
  position: absolute; top: calc(100% + 8px); right: 8px; width: min(360px, calc(100vw - 16px)); padding: 16px; display: grid; gap: 16px;
  background: var(--floating); border: var(--hairline) solid var(--border); border-radius: 22px; box-shadow: var(--shadow-float); color: var(--reader-text);
}
.setting { display: grid; gap: 8px; }
.setting-label { font: 600 12px/16px var(--sans); letter-spacing: 0.4px; color: var(--reader-muted); }
.stepper { display: flex; align-items: center; justify-content: space-between; background: var(--control); border-radius: 14px; padding: 3px; }
.stepper button { width: 64px; height: 40px; border-radius: 11px; font: 600 16px/1 var(--serif); }
.stepper button:hover { background: var(--paper); }
.stepper span { font: 600 14px/1 var(--sans); font-variant-numeric: tabular-nums; }
.popover .segmented button[aria-pressed="true"] { background: var(--selected); color: var(--on-selected); }
.theme-swatches { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.swatch { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 8px 2px; border-radius: 14px; font: 600 12px/1.1 var(--sans); }
.swatch span { width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--border-strong); }
.swatch-light span { background: #F8F3EA; }
.swatch-sepia span { background: #F2E6D0; }
.swatch-dark span { background: #0F1513; }
.swatch-auto span { background: linear-gradient(135deg, #F8F3EA 50%, #0F1513 50%); }
.swatch[aria-pressed="true"] { background: var(--control); }
.swatch[aria-pressed="true"] span { box-shadow: 0 0 0 2px var(--floating), 0 0 0 4px var(--gold-deco); }

/* ───────── sheets ───────── */

.sheet {
  width: 100%; max-width: 100%; max-height: 90vh; margin: auto 0 0; padding: 0; border: 0; border-radius: 28px 28px 0 0;
  background: var(--floating); color: var(--reader-text); box-shadow: var(--shadow-float); overflow: hidden;
}
.sheet[open] { display: flex; flex-direction: column; animation: sheet-up 0.32s cubic-bezier(0.2, 0.8, 0.2, 1); }
.sheet::backdrop { background: var(--scrim); animation: fade 0.2s ease; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 12px 8px 24px; }
.sheet-head h2 { margin: 0; font: 600 20px/26px var(--sans); }
.sheet-body { overflow-y: auto; padding: 4px 24px max(28px, env(safe-area-inset-bottom)); overscroll-behavior: contain; }
.sheet-sub { margin: 0 0 18px; font-size: 13px; color: var(--reader-muted); }
.explanation .kicker { margin: 24px 0 10px; font: 700 12px/16px var(--sans); letter-spacing: 1.2px; text-transform: uppercase; color: var(--gold); }
.explanation .kicker:first-of-type { margin-top: 0; }
.main-idea { margin: 0; font: 400 21px/31px var(--serif); }
.points { margin: 0; padding: 0; list-style: none; display: grid; gap: 10px; }
.points li { position: relative; padding-left: 18px; font-size: 16px; line-height: 23px; }
.points li::before { content: ''; position: absolute; left: 2px; top: 9px; width: 6px; height: 6px; border-radius: 50%; background: var(--gold-deco); }
.terms { margin: 0; display: grid; gap: 10px; }
.terms div { padding: 12px 14px; border-radius: 14px; background: var(--control); }
.terms dt { font: 600 16px/22px var(--serif); }
.terms dd { margin: 2px 0 0; font-size: 15px; line-height: 21px; color: var(--reader-muted); }
.question { margin: 0; padding-left: 14px; border-left: 2px solid var(--gold-deco); font: italic 400 19px/28px var(--serif); }
.sheet .fine-print { margin-top: 24px; }

.sheet-card .sheet-body { display: flex; flex-direction: column; gap: 16px; align-items: center; }
.card-styles { width: 100%; }
.card-canvas { width: auto; height: min(52vh, 460px); aspect-ratio: 9 / 16; border-radius: 18px; border: var(--hairline) solid var(--border); background: var(--subtle); }
.card-actions { width: 100%; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.toast {
  position: fixed; z-index: 60; left: 50%; bottom: calc(var(--tabbar-space) + 8px); transform: translate(-50%, 16px); opacity: 0; pointer-events: none;
  max-width: calc(100% - 32px); padding: 12px 18px; border-radius: 16px; background: var(--brand); color: #FFFFFF; font: 500 15px/20px var(--sans);
  box-shadow: var(--shadow-float); transition: opacity 0.2s, transform 0.2s; display: flex; gap: 14px; align-items: center;
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.toast button { font-weight: 700; color: var(--gold-deco); }
.page-reader .toast { bottom: 96px; }

.lang-banner {
  display: flex; align-items: center; gap: 8px; margin: 8px 0 12px; padding: 4px 4px 4px 16px; border-radius: 18px;
  background: var(--paper); border: var(--hairline) solid var(--border); animation: rise 0.3s ease both;
}
.page-reader .lang-banner { max-width: calc(var(--column) + 2 * 20px - 32px); margin: 12px auto 0; width: calc(100% - 32px); }
.lang-banner a { flex: 1; font: 600 15px/1.3 var(--sans); color: var(--accent-text); }
.lang-banner .icon-button { width: 40px; height: 40px; color: var(--text-2); }

/* ───────── motion ───────── */

@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } }
@keyframes sheet-up { from { transform: translateY(40px); opacity: 0; } }
@keyframes breathe { 50% { opacity: 0.3; } }
@keyframes bloom { from { opacity: 0; } }
.resume-pill { animation-name: rise-centered; }
@keyframes rise-centered { from { opacity: 0; transform: translate(-50%, -8px); } to { opacity: 1; transform: translate(-50%, 0); } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}

/* ───────── wider screens ───────── */

@media (min-width: 600px) {
  :root { --gutter: 24px; }
  .cover { min-height: 250px; }
  .cover-portrait { right: -40px; width: 380px; }
  .cover-name { font-size: 36px; line-height: 44px; }
  .hero { padding: 24px 28px 22px; }
  .hero-quote { font-size: 23px; line-height: 34px; }
  .chapter-title { font-size: 40px; line-height: 50px; }
  .reader { padding-top: 44px; }
  .sheet { max-width: 640px; margin: auto; border-radius: 28px; max-height: 86vh; }
  .card-actions { grid-template-columns: auto auto; justify-content: center; }
}
@media (min-width: 860px) {
  .nav-desktop { display: flex; }
  .tabbar { display: none; }
  body:not(.page-reader) { padding-bottom: 0; }
  .toast { bottom: 28px; }
  .cover-portrait { right: 0; }
  .footer-inner { padding-bottom: 40px; }
}
@media (hover: hover) {
  .hero:hover { box-shadow: var(--shadow-float); }
  .word-row:hover { border-color: var(--border-strong); }
}
