/* Dogear design system: tokens (from tokens.json) + components (from bundle.css). Synced with the component library on 2026-10-05. */
:root, [data-theme="light"]{--surface-000:#f4f3f0;--surface-100:#ffffff;--surface-200:#ebe9e4;--line:#dedbd4;--line-strong:#bfbbb2;--ink:#1d1c1a;--ink-muted:#67635c;--ink-inverse:#ffffff;--sky:#bcd2ec;--lavender:#cfc0e0;--peach:#f3a77b;--sun:#f6cf5e;--periwinkle:#b3bbf6;--sticker-blue:#3473cf;--sticker-orange:#ed713e;--sticker-green:#4dab65;--sticker-lilac:#cbb2f3;--sticker-sand:#efc975;--sticker-pink:#f7ccd9;--sticker-mint:#c4e4da;--sticker-red:#e24a5a;--sticker-sky:#81c2ff;--sticker-lime:#a4da6f;--sticker-blush:#ffb7c2;--focus:#2a5fb8;--positive:#2d7650;--negative:#c0412a;--shadow-card:0 1px 2px rgba(29,28,26,0.06), 0 8px 24px rgba(29,28,26,0.07);--shadow-cover:0 2px 4px rgba(29,28,26,0.10), 0 12px 28px rgba(29,28,26,0.14);}
[data-theme="dark"]{--surface-000:#141417;--surface-100:#1e1e23;--surface-200:#29292f;--line:#34343c;--line-strong:#4a4a53;--ink:#f2f0ea;--ink-muted:#a8a59e;--ink-inverse:#141417;--sky:#2c4466;--lavender:#4b3d66;--peach:#8c4a30;--sun:#8f6c1c;--periwinkle:#56609e;--sticker-blue:#3473cf;--sticker-orange:#ed713e;--sticker-green:#4dab65;--sticker-lilac:#cbb2f3;--sticker-sand:#efc975;--sticker-pink:#f7ccd9;--sticker-mint:#c4e4da;--sticker-red:#e24a5a;--sticker-sky:#81c2ff;--sticker-lime:#a4da6f;--sticker-blush:#ffb7c2;--focus:#7d9bff;--positive:#5cc08b;--negative:#ff7a60;--shadow-card:0 1px 2px rgba(0,0,0,0.4), 0 8px 24px rgba(0,0,0,0.35);--shadow-cover:0 2px 4px rgba(0,0,0,0.5), 0 12px 28px rgba(0,0,0,0.5);}
[data-theme="eink"]{--surface-000:#ffffff;--surface-100:#ffffff;--surface-200:#ececec;--line:#8a8a8a;--line-strong:#000000;--ink:#000000;--ink-muted:#333333;--ink-inverse:#ffffff;--sky:#e6e6e6;--lavender:#d4d4d4;--peach:#bdbdbd;--sun:#f2f2f2;--periwinkle:#9a9a9a;--sticker-blue:#000000;--sticker-orange:#5c5c5c;--sticker-green:#2e2e2e;--sticker-lilac:#c4c4c4;--sticker-sand:#dadada;--sticker-pink:#cfcfcf;--sticker-mint:#e6e6e6;--sticker-red:#454545;--sticker-sky:#d4d4d4;--sticker-lime:#bdbdbd;--sticker-blush:#ececec;--focus:#000000;--positive:#000000;--negative:#000000;--shadow-card:none;--shadow-cover:none;}
:root{--space-1:4px;--space-2:8px;--space-3:12px;--space-4:16px;--space-6:24px;--space-8:32px;--space-12:48px;--radius-sm:8px;--radius-md:14px;--radius-lg:24px;--radius-pill:999px;--font-sans:Jost, Futura, "Century Gothic", system-ui, sans-serif;--font-mono:"DM Mono", ui-monospace, Menlo, monospace;--font-serif:Literata, Georgia, "Times New Roman", serif;}

/* ---------- Dogear base ---------- */
[class*="dg-"], [class*="dg-"] *, [class*="dg-"] *::before, [class*="dg-"] *::after { box-sizing: border-box; }
body { margin: 0; background: var(--surface-000); color: var(--ink); font-family: var(--font-sans); -webkit-font-smoothing: antialiased; }
.dg-row { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; padding: 16px; }
.dg-col { display: flex; flex-direction: column; align-items: flex-start; gap: 12px; padding: 16px; }
.dg-label { font-family: var(--font-mono); font-size: 12px; line-height: 16px; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-muted); }
.dg-caption { font-family: var(--font-mono); font-size: 11px; line-height: 14px; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-muted); }
.dg-focus:focus-visible, .dg-btn:focus-visible, .dg-ibtn:focus-visible, .dg-seg button:focus-visible, .dg-tab:focus-visible, .dg-search input:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* ---------- Icon ---------- */
.dg-icon { display: inline-block; flex: none; vertical-align: middle; }

/* ---------- Sticker ---------- */
.dg-sticker { display: inline-block; flex: none; }
.dg-sticker .dg-st-shape { fill: var(--st-bg); }
.dg-sticker .dg-st-glyph { stroke: var(--st-fg); fill: none; }
.dg-sticker .dg-st-glyph.is-filled, .dg-sticker .dg-st-glyph .is-fill { fill: var(--st-fg); stroke: none; }
.dg-sticker text { fill: var(--st-fg); font-family: var(--font-sans); font-weight: 500; }
.dg-st-blue { --st-bg: var(--sticker-blue); --st-fg: #ffffff; }
.dg-st-orange { --st-bg: var(--sticker-orange); --st-fg: #ffffff; }
.dg-st-green { --st-bg: var(--sticker-green); --st-fg: #0f2e1b; }
.dg-st-lilac { --st-bg: var(--sticker-lilac); --st-fg: #2a1f4a; }
.dg-st-sand { --st-bg: var(--sticker-sand); --st-fg: #1d1c1a; }
.dg-st-pink { --st-bg: var(--sticker-pink); --st-fg: var(--sticker-red); }
.dg-st-mint { --st-bg: var(--sticker-mint); --st-fg: #1f4a3c; }
.dg-st-red { --st-bg: var(--sticker-red); --st-fg: #ffffff; }
.dg-st-sky { --st-bg: var(--sticker-sky); --st-fg: #0f2f55; }
.dg-st-lime { --st-bg: var(--sticker-lime); --st-fg: #1e3a12; }
.dg-st-blush { --st-bg: var(--sticker-blush); --st-fg: #8a1f36; }
[data-theme="eink"] .dg-sticker .dg-st-shape { stroke: #000; stroke-width: 2.5; }
[data-theme="eink"] .dg-st-sand, [data-theme="eink"] .dg-st-pink, [data-theme="eink"] .dg-st-mint, [data-theme="eink"] .dg-st-lilac, [data-theme="eink"] .dg-st-sky, [data-theme="eink"] .dg-st-lime, [data-theme="eink"] .dg-st-blush { --st-fg: #000000; }
[data-theme="eink"] .dg-st-red, [data-theme="eink"] .dg-st-orange, [data-theme="eink"] .dg-st-green, [data-theme="eink"] .dg-st-blue { --st-fg: #ffffff; }

/* ---------- Buttons ---------- */
.dg-btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 48px; padding: 0 22px; border-radius: var(--radius-pill); border: 1.5px solid transparent; font: 500 16px/1 var(--font-sans); cursor: pointer; transition: transform .12s ease, background .12s ease; white-space: nowrap; }
.dg-btn:active { transform: scale(.97); }
.dg-btn-sm { height: 36px; padding: 0 16px; font-size: 14px; gap: 6px; }
.dg-btn-primary { background: var(--ink); color: var(--ink-inverse); }
.dg-btn-secondary { background: var(--surface-100); color: var(--ink); border-color: var(--line-strong); }
.dg-btn-quiet { background: transparent; color: var(--ink); }
.dg-btn-quiet:hover { background: var(--surface-200); }
.dg-btn-secondary:hover { background: var(--surface-200); }
.dg-btn[disabled] { opacity: .4; cursor: default; transform: none; }
.dg-btn-block { width: 100%; }
[data-theme="eink"] .dg-btn { transition: none; }
[data-theme="eink"] .dg-btn-secondary { border-color: #000; border-width: 2px; }
[data-theme="eink"] .dg-btn-quiet { text-decoration: underline; text-underline-offset: 4px; }

.dg-ibtn { display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; border: 1.5px solid transparent; background: transparent; color: var(--ink); cursor: pointer; padding: 0; transition: transform .12s ease; }
.dg-ibtn:active { transform: scale(.94); }
.dg-ibtn-lg { width: 72px; height: 72px; }
.dg-ibtn-sm { width: 36px; height: 36px; }
.dg-ibtn-filled { background: var(--ink); color: var(--ink-inverse); }
.dg-ibtn-outline { border-color: var(--line-strong); background: var(--surface-100); }
.dg-ibtn-ghost:hover { background: var(--surface-200); }
[data-theme="eink"] .dg-ibtn-outline { border: 2px solid #000; }

/* ---------- Tag ---------- */
.dg-tag { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px; border-radius: var(--radius-pill); background: var(--surface-200); color: var(--ink); font: 400 11px/1 var(--font-mono); letter-spacing: .08em; text-transform: uppercase; white-space: nowrap; }
.dg-tag i { width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; }
.dg-tag-audio i { background: var(--sticker-blue); }
.dg-tag-ebook i { background: var(--sticker-green); }
.dg-tag-both i { background: linear-gradient(90deg, var(--sticker-blue) 50%, var(--sticker-green) 50%); }
.dg-tag-new { background: var(--sticker-orange); color: #1d1c1a; }
.dg-tag-new i, .dg-tag-neutral i { display: none; }
.dg-tag-outline { background: transparent; box-shadow: inset 0 0 0 1px var(--line-strong); }
[data-theme="eink"] .dg-tag { background: #fff; box-shadow: inset 0 0 0 1.5px #000; color: #000; }

/* ---------- Gradients ---------- */
.dg-grad-sunset { background: radial-gradient(120% 90% at 45% 100%, var(--sun) 0%, var(--peach) 32%, var(--lavender) 62%, var(--sky) 100%); }
.dg-grad-dawn   { background: radial-gradient(110% 90% at 30% 90%, var(--sun) 0%, var(--sky) 70%); }
.dg-grad-haze   { background: radial-gradient(110% 100% at 70% 80%, var(--peach) 0%, var(--lavender) 60%, var(--sky) 110%); }
.dg-grad-tide   { background: radial-gradient(120% 100% at 20% 100%, var(--periwinkle) 0%, var(--sky) 55%, var(--surface-200) 120%); }
.dg-grad-ember  { background: radial-gradient(100% 90% at 50% 100%, var(--peach) 0%, var(--sun) 55%, var(--surface-200) 120%); }
.dg-grad-mist   { background: radial-gradient(100% 100% at 80% 20%, var(--lavender) 0%, var(--surface-200) 75%); }
[data-theme="eink"] [class*="dg-grad-"] { background: var(--surface-200); }

.dg-hero { position: relative; overflow: hidden; border-radius: var(--radius-lg); padding: 24px; min-height: 180px; color: var(--ink); }
.dg-hero-flush { border-radius: 0; }
[data-theme="dark"] .dg-hero { color: #f2f0ea; }
[data-theme="eink"] .dg-hero { border: 2px solid #000; }

/* ---------- Book cover ---------- */
.dg-cover { position: relative; flex: none; aspect-ratio: 2 / 3; border-radius: var(--radius-sm); overflow: hidden; box-shadow: var(--shadow-cover); display: flex; flex-direction: column; justify-content: space-between; padding: .85em .85em .95em; color: #1d1c1a; }
.dg-cover-title { font: 500 1em/1.05 var(--font-sans); letter-spacing: -.01em; }
.dg-cover-author { font: 400 .5em/1.2 var(--font-mono); letter-spacing: .08em; text-transform: uppercase; opacity: .75; }
.dg-cover .dg-sticker { position: absolute; right: -6%; top: 34%; }
.dg-cover-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
[data-theme="eink"] .dg-cover-img { filter: grayscale(1) contrast(1.1); }
[data-theme="dark"] .dg-cover { color: #f2f0ea; }
[data-theme="eink"] .dg-cover { border: 2px solid #000; color: #000; }

/* ---------- Book card ---------- */
.dg-book { display: flex; flex-direction: column; gap: 10px; width: 148px; color: var(--ink); }
.dg-book-meta { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.dg-book-title { font: 500 15px/20px var(--font-sans); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dg-book-author { font: 400 13px/18px var(--font-sans); color: var(--ink-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dg-book-row { flex-direction: row; align-items: center; width: 100%; gap: 14px; }
.dg-book-row .dg-cover { width: 64px; flex: none; }
.dg-book-row .dg-book-meta { flex: 1; gap: 4px; }

/* ---------- Progress ---------- */
.dg-progress { display: flex; flex-direction: column; gap: 6px; width: 100%; }
.dg-progress-track { position: relative; height: 6px; border-radius: var(--radius-pill); background: var(--surface-200); overflow: hidden; }
.dg-progress-fill { position: absolute; inset: 0 auto 0 0; border-radius: inherit; background: linear-gradient(90deg, var(--sun), var(--periwinkle)); }
.dg-progress-lg .dg-progress-track { height: 56px; border-radius: 16px; }
.dg-progress-lg .dg-progress-fill { border-radius: 16px; }
.dg-progress-lg .dg-progress-value { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); font: 400 30px/1 var(--font-sans); color: #1d1c1a; }
.dg-progress-lg .dg-progress-value small { font-size: 12px; opacity: .6; margin-left: 3px; }
.dg-progress-meta { display: flex; justify-content: space-between; }
[data-theme="eink"] .dg-progress-track { background: #fff; box-shadow: inset 0 0 0 1.5px #000; }
[data-theme="eink"] .dg-progress-fill { background: #000; }
[data-theme="eink"] .dg-progress-lg .dg-progress-value { color: #fff; mix-blend-mode: difference; }

/* ---------- Stat ---------- */
.dg-stat { display: grid; grid-template-columns: 1fr auto; gap: 4px 16px; align-items: end; min-width: 150px; }
.dg-stat-value { font: 400 28px/1.1 var(--font-sans); letter-spacing: -.01em; grid-column: 1; }
.dg-stat-value small { font-size: .5em; color: var(--ink-muted); margin-left: 4px; }
.dg-stat .dg-label { grid-column: 1 / -1; }
.dg-stat-xl .dg-stat-value { font-size: 64px; line-height: 1; letter-spacing: -.02em; }
.dg-gauge { grid-column: 2; grid-row: 2; position: relative; width: 6px; height: 34px; border-radius: 3px; background: linear-gradient(180deg, var(--peach), var(--sky)); }
.dg-gauge b { position: absolute; left: -5px; right: -5px; height: 2px; background: var(--ink); border-radius: 1px; }
[data-theme="eink"] .dg-gauge { background: #fff; box-shadow: inset 0 0 0 1.5px #000; }

/* ---------- Mini player ---------- */
.dg-mini { position: relative; display: flex; align-items: center; gap: 12px; padding: 10px 10px 12px; border-radius: var(--radius-md); background: var(--surface-100); box-shadow: var(--shadow-card); overflow: hidden; width: 100%; max-width: 420px; }
.dg-mini .dg-cover { width: 44px; flex: none; box-shadow: none; }
.dg-mini-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.dg-mini-bar { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: var(--surface-200); }
.dg-mini-bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--sun), var(--periwinkle)); }
[data-theme="eink"] .dg-mini { border: 2px solid #000; }
[data-theme="eink"] .dg-mini-bar i { background: #000; }

/* ---------- Player controls ---------- */
.dg-controls { display: flex; align-items: center; justify-content: center; gap: 14px; }
.dg-skip { position: relative; }
.dg-skip span { position: absolute; inset: 0; display: grid; place-items: center; font: 500 9px/1 var(--font-mono); padding-top: 2px; pointer-events: none; }
.dg-speed { font: 500 13px/1 var(--font-mono); width: 44px; height: 44px; border-radius: 50%; border: 1.5px solid var(--line-strong); background: transparent; color: var(--ink); cursor: pointer; }

/* ---------- Chapter row ---------- */
.dg-chapter { width: 100%; display: grid; grid-template-columns: 32px 1fr auto; align-items: center; gap: 12px; padding: 14px 4px; border-bottom: 1px solid var(--line); color: var(--ink); }
.dg-chapter-idx { font: 400 12px/1 var(--font-mono); color: var(--ink-muted); }
.dg-chapter-title { font: 400 16px/22px var(--font-sans); }
.dg-chapter-dur { font: 400 12px/1 var(--font-mono); color: var(--ink-muted); display: flex; align-items: center; gap: 6px; }
.dg-chapter.is-done .dg-chapter-title { color: var(--ink-muted); }
.dg-chapter.is-current .dg-chapter-title { font-weight: 500; }
.dg-chapter.is-current .dg-chapter-idx { color: var(--ink); }
.dg-eq { display: inline-flex; gap: 2px; align-items: flex-end; height: 12px; }
.dg-eq i { width: 3px; background: var(--sticker-blue); border-radius: 1px; animation: dg-eq 1s ease-in-out infinite; }
.dg-eq i:nth-child(2) { animation-delay: -.3s; } .dg-eq i:nth-child(3) { animation-delay: -.6s; }
@keyframes dg-eq { 0%,100% { height: 30%; } 50% { height: 100%; } }
[data-theme="eink"] .dg-eq i { animation: none; height: 100%; background: #000; }
[data-theme="eink"] .dg-chapter { border-bottom-color: #000; }

/* ---------- Segmented ---------- */
.dg-seg { display: inline-flex; padding: 4px; gap: 2px; border-radius: var(--radius-pill); background: var(--surface-200); }
.dg-seg button { height: 34px; padding: 0 16px; border: 0; border-radius: var(--radius-pill); background: transparent; color: var(--ink-muted); font: 500 14px/1 var(--font-sans); cursor: pointer; }
.dg-seg button[aria-pressed="true"] { background: var(--surface-100); color: var(--ink); box-shadow: 0 1px 3px rgba(29,28,26,.12); }
[data-theme="eink"] .dg-seg { background: #fff; box-shadow: inset 0 0 0 2px #000; }
[data-theme="eink"] .dg-seg button[aria-pressed="true"] { background: #000; color: #fff; box-shadow: none; }

/* ---------- Tab bar ---------- */
.dg-tabbar { display: flex; justify-content: space-around; padding: 8px 8px 12px; background: var(--surface-100); border-top: 1px solid var(--line); width: 100%; }
.dg-tab { display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 64px; padding: 6px 0; border: 0; background: transparent; color: var(--ink-muted); cursor: pointer; font: 400 10px/1 var(--font-mono); letter-spacing: .08em; text-transform: uppercase; }
.dg-tab[aria-current="page"] { color: var(--ink); }
.dg-tab[aria-current="page"] .dg-tab-dot { background: var(--sticker-orange); }
.dg-tab-dot { width: 4px; height: 4px; border-radius: 50%; background: transparent; }
[data-theme="eink"] .dg-tabbar { border-top: 2px solid #000; }
[data-theme="eink"] .dg-tab[aria-current="page"] .dg-tab-dot { background: #000; }

/* ---------- Search ---------- */
.dg-search { display: flex; align-items: center; gap: 10px; height: 48px; padding: 0 16px; border-radius: var(--radius-md); background: var(--surface-200); color: var(--ink-muted); width: 100%; }
.dg-search input { flex: 1; border: 0; background: transparent; font: 400 16px/1 var(--font-sans); color: var(--ink); min-width: 0; outline: none; }
.dg-search input::placeholder { color: var(--ink-muted); }
.dg-search:focus-within { box-shadow: 0 0 0 2px var(--focus); }
[data-theme="eink"] .dg-search { background: #fff; box-shadow: inset 0 0 0 2px #000; }

/* ---------- Reader page ---------- */
.dg-reader { display: flex; flex-direction: column; background: var(--surface-000); color: var(--ink); padding: 28px 32px 20px; min-height: 100%; }
.dg-reader-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 28px; }
.dg-reader h2 { font: 500 28px/36px var(--font-serif); margin: 0 0 20px; letter-spacing: -.005em; }
.dg-reader p { font: 400 19px/31px var(--font-serif); margin: 0; text-indent: 1.4em; hyphens: auto; text-align: justify; }
.dg-reader p:first-of-type { text-indent: 0; text-align: left; }
.dg-reader p:first-of-type::first-letter { font-size: 3.1em; float: left; line-height: .9; padding: 4px 8px 0 0; font-weight: 500; }
.dg-reader-body { flex: 1; }
.dg-reader-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 24px; gap: 16px; }
.dg-reader-foot .dg-progress { flex: 1; max-width: 50%; }
.dg-reader-sepia { --surface-000: #f5eddf; --ink: #3b2f22; --ink-muted: #7a6a57; }
[data-theme="eink"] .dg-reader p { font-size: 20px; line-height: 32px; }

/* ---------- Chips (genres, shelves) ---------- */
.dg-chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding: 2px; }
.dg-chips::-webkit-scrollbar { display: none; }
.dg-chip { display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 14px; flex: none; border-radius: var(--radius-pill); border: 1.5px solid var(--line); background: var(--surface-100); color: var(--ink); font: 500 14px/1 var(--font-sans); cursor: pointer; white-space: nowrap; }
.dg-chip:hover { border-color: var(--line-strong); }
.dg-chip:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.dg-chip-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; box-shadow: inset 0 0 0 1px rgba(29,28,26,.12); }
.dg-chip-count { font: 400 11px/1 var(--font-mono); letter-spacing: .04em; color: var(--ink-muted); }
.dg-chip.is-selected { background: var(--ink); border-color: var(--ink); color: var(--ink-inverse); }
.dg-chip.is-selected .dg-chip-count { color: var(--ink-inverse); opacity: .7; }
[data-theme="eink"] .dg-chip { border: 2px solid #000; }
[data-theme="eink"] .dg-chip-dot { box-shadow: 0 0 0 1.5px #000; }
