html { -webkit-text-size-adjust: 100%; }
:root {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  color-scheme: light;
  --bg: #f7f3ec;
  --bg-elevated: #f0e9de;
  --card: #fffdf8;
  --card-hover: #f2eadc;
  --border: rgba(62, 43, 24, 0.14);
  --text: #30251b;
  --text-muted: #665746;
  --text-faint: #796a59;
  --accent: #c9a063;
  --accent-text: #1c1714;
  --accent-strong: #80602f;
  --accent-soft: rgba(201, 160, 99, 0.18);
  --accent-wash: rgba(201, 160, 99, 0.10);
  --header-surface: rgba(255, 253, 248, 0.94);
  --scrim: rgba(22, 15, 10, 0.68);
  --shadow: rgba(32, 22, 12, 0.16);
  --shadow-soft: rgba(32, 22, 12, 0.06);
  --status-soft: #f0e5d2;
  --status-wishlist: #eee6da;
  --status-paused: #eee5d8;
  --progress-track: #e9dfd1;
  --danger: #9b4d35;
  --ink: var(--text); --muted: var(--text-muted); --line: var(--border); --paper: var(--card);
  --primary: var(--accent); --primary-dark: var(--accent-strong); --primary-soft: var(--accent-soft);
  --primary-foreground: var(--accent-text); --primary-muted: var(--accent-text); --primary-focus: var(--accent);
  --primary-hover: #b98d4d; --primary-hover-foreground: var(--accent-text);
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #1c1714;
  --bg-elevated: #241d18;
  --card: #262019;
  --card-hover: #2d251d;
  --border: rgba(255, 240, 220, 0.08);
  --text: #f2ebe0;
  --text-muted: #b8ab98;
  --text-faint: #8a7f70;
  --accent: #c9a063;
  --accent-text: #1c1714;
  --accent-strong: #d4b271;
  --accent-soft: rgba(201, 160, 99, 0.16);
  --accent-wash: rgba(201, 160, 99, 0.10);
  --header-surface: rgba(36, 29, 24, 0.94);
  --scrim: rgba(12, 8, 5, 0.82);
  --shadow: rgba(12, 8, 5, 0.22);
  --shadow-soft: rgba(12, 8, 5, 0.08);
  --status-soft: #342b20;
  --status-wishlist: #302820;
  --status-paused: #352b20;
  --progress-track: #382f25;
  --danger: #e1a18b;
  --primary-hover: #d4ad72;
}
* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; background: var(--bg); color: var(--ink); }
:root[data-theme="dark"] body { background: var(--bg); }
button, input, select { font: inherit; }
[hidden] { display: none !important; }
button { cursor: pointer; }
.topbar { height: 70px; padding: 0 max(22px, calc((100vw - 1120px) / 2)); display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--border); background: var(--header-surface); }
.brand { display: inline-flex; align-items: center; gap: 11px; color: var(--ink); font-size: 17px; font-weight: 800; text-decoration: none; letter-spacing: -.5px; }
.brand-mark { height: 34px; width: 34px; display: grid; place-items: center; border-radius: 11px; background: var(--primary); color: var(--primary-foreground); font-family: Georgia, serif; font-size: 21px; }
.shell { width: min(100% - 42px, 1000px); margin: 0 auto; padding: 42px 0 70px; }
.intro { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; margin: 4px 0 37px; }
.eyebrow { margin: 0 0 9px; color: var(--text-faint); font-size: 10px; font-weight: 700; letter-spacing: 1.35px; }
.intro h1, .section-heading h2, .dialog-heading h2 { margin: 0; font-family: "Segoe UI", sans-serif; letter-spacing: -1.2px; }
.intro h1 { font-size: clamp(29px, 5vw, 44px); line-height: 1.1; }
.subheading { margin: 12px 0 0; color: var(--muted); font-size: 15px; }
.privacy-note { display: flex; align-items: center; gap: 8px; padding: 9px 13px; border: 1px solid var(--border); border-radius: 999px; background: transparent; color: var(--text-muted); font-size: 12px; white-space: nowrap; }
.lock { font-size: 9px; color: var(--accent); }
.tabs { display: flex; flex-wrap: wrap; gap: 8px; border-bottom: 1px solid var(--line); margin-bottom: 28px; }
.tab { position: relative; padding: 12px 15px 14px; border: 0; background: transparent; color: var(--text-muted); font-size: 14px; font-weight: 600; }
.tab.active { color: var(--primary-dark); }
.tab.active::after { position: absolute; bottom: -1px; left: 12px; right: 12px; height: 2px; background: var(--primary); content: ""; border-radius: 2px; }
.view { animation: appear .18s ease; }
@keyframes appear { from { opacity: .5; transform: translateY(3px); } to { opacity: 1; transform: translateY(0); } }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.section-heading h2, .dialog-heading h2 { font-size: 25px; }
.button { min-height: 42px; padding: 0 16px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid transparent; border-radius: 11px; font-size: 13px; font-weight: 700; transition: background .15s, transform .15s; }
.button:active { transform: translateY(1px); }
.button-primary { background: var(--primary); color: var(--primary-foreground); }
.button-primary:hover { background: var(--primary-hover); color: var(--primary-hover-foreground); }
.button-light { border-color: var(--border); background: transparent; color: var(--text); }
.button-light:hover { background: var(--card-hover); }
.install-button { min-height: 36px; }
.toolbar { display: flex; gap: 10px; margin-bottom: 19px; }
.search-field, .select-field { height: 46px; display: flex; align-items: center; gap: 9px; padding: 0 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--paper); color: var(--muted); transition: border-color .15s, box-shadow .15s, background-color .15s; }
.select-field:focus-within, .search-field:focus-within { border-color: var(--primary-focus); box-shadow: 0 0 0 3px var(--primary-soft); }
.select-field:hover { border-color: var(--primary-focus); }
.search-field { flex: 1; }
.search-field > span:not(.visually-hidden) { font-size: 20px; }
.search-field input { width: 100%; border: 0; outline: none; background: transparent; color: var(--ink); font-size: 13px; }
.search-field input::placeholder { color: var(--text-faint); }
.custom-select { position: relative; width: 100%; min-width: 0; }
.select-field .custom-select { flex: 1; }
.custom-select-native { position: absolute !important; width: 1px !important; height: 1px !important; overflow: hidden !important; clip: rect(0, 0, 0, 0) !important; clip-path: inset(50%) !important; white-space: nowrap !important; }
.custom-select-trigger { width: 100%; min-height: 46px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 13px; border: 1px solid var(--line); border-radius: 11px; background: var(--paper); color: var(--ink); font-size: 13px; line-height: 1.35; text-align: left; cursor: pointer; transition: border-color .15s, box-shadow .15s, background-color .15s; }
.custom-select-trigger::after { width: 8px; height: 8px; flex: 0 0 8px; border-right: 1.8px solid var(--muted); border-bottom: 1.8px solid var(--muted); content: ""; transform: translateY(-2px) rotate(45deg); transition: transform .15s; }
.custom-select-trigger[aria-expanded="true"]::after { transform: translateY(2px) rotate(225deg); }
.custom-select-trigger:hover, .custom-select-trigger[aria-expanded="true"] { border-color: var(--primary-focus); background-color: var(--primary-soft); }
.custom-select-trigger:focus-visible { outline: none; border-color: var(--primary-focus); box-shadow: 0 0 0 3px var(--primary-soft); }
.select-field .custom-select-trigger { min-height: 44px; padding: 0; border: 0; background: transparent; }
.select-field .custom-select-trigger:hover, .select-field .custom-select-trigger[aria-expanded="true"] { background: transparent; box-shadow: none; }
.select-field .custom-select-trigger:focus-visible { box-shadow: none; }
.custom-select-menu { position: fixed; z-index: 1200; overflow-y: auto; overscroll-behavior: contain; padding: 6px; border: 1px solid var(--line); border-radius: 13px; background: var(--paper); box-shadow: 0 18px 46px var(--shadow), 0 3px 10px var(--shadow-soft); animation: menu-appear .13s ease-out; }
@keyframes menu-appear { from { opacity: 0; transform: translateY(-3px) scale(.99); } to { opacity: 1; transform: translateY(0) scale(1); } }
.custom-select-option { min-height: 44px; display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 8px; color: var(--ink); font-size: 13px; line-height: 1.35; cursor: pointer; outline: none; }
.custom-select-option:hover, .custom-select-option.is-focused { background: var(--primary-soft); color: var(--primary-dark); }
.custom-select-option[aria-selected="true"] { background: var(--primary-soft); color: var(--primary-dark); font-weight: 650; }
.custom-select-option[aria-selected="true"]::after { margin-left: auto; color: var(--primary-dark); content: "✓"; font-size: 14px; font-weight: 700; }
.book-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.book-card { min-width: 0; padding: 17px; border: 1px solid var(--border); border-radius: 15px; background: var(--paper); box-shadow: 0 3px 12px var(--shadow-soft); }
.book-topline { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.book-title { margin: 0; color: var(--text); font-size: 16px; font-weight: 700; line-height: 1.35; overflow-wrap: anywhere; }
.book-author { margin: 5px 0 0; color: var(--text-muted); font-size: 12px; }
.book-type { display: inline-block; margin-top: 12px; color: var(--text-faint); font-size: 10px; font-weight: 700; letter-spacing: .7px; text-transform: uppercase; }
.favorite-star { color: var(--accent); font-size: 17px; }
.status-pill { display: inline-flex; align-items: center; gap: 5px; margin-top: 13px; padding: 5px 9px; border-radius: 999px; background: var(--card-hover); color: var(--text-muted); font-size: 10px; font-weight: 700; }
.status-pill.inProgress { background: var(--accent-soft); color: var(--accent-strong); }
.status-pill.completed { background: var(--status-soft); color: var(--accent-strong); }
.status-pill.wishlist { background: var(--status-wishlist); color: var(--text-muted); }
.status-pill.paused { background: var(--status-paused); color: var(--accent-strong); }
.progress-area { margin-top: 13px; }
.progress-copy { display: flex; justify-content: space-between; gap: 8px; color: var(--text-muted); font-size: 11px; }
.progress-track { height: 5px; margin-top: 7px; overflow: hidden; border-radius: 5px; background: var(--progress-track); }
.progress-fill { height: 100%; border-radius: 5px; background: var(--accent); }
.progress-update { display: flex; gap: 7px; margin-top: 13px; }
.progress-update input { width: 90px; min-width: 0; height: 36px; padding: 0 9px; border: 1px solid var(--border); border-radius: 9px; background: var(--card); font-size: 12px; }
.progress-update button { height: 36px; padding: 0 11px; border: 1px solid var(--border); border-radius: 9px; background: var(--card-hover); color: var(--accent-strong); font-size: 11px; font-weight: 700; }
.card-footer { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border); }
.tag-list { display: flex; flex-wrap: wrap; gap: 5px; }
.tag { padding: 4px 7px; border-radius: 6px; background: var(--card-hover); color: var(--text-muted); font-size: 10px; }
.card-actions { display: flex; gap: 5px; }
.text-button { padding: 5px; border: 0; background: transparent; color: var(--text-muted); font-size: 11px; }
.text-button:hover { color: var(--primary-dark); text-decoration: underline; }
.empty-state { min-height: 190px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 25px; border: 1px dashed var(--border); border-radius: 16px; color: var(--text-muted); text-align: center; font-size: 13px; }
.empty-state strong { color: var(--text); font-size: 14px; }
.empty-icon { font-size: 26px; color: var(--accent-strong); }
.resource-shelf { margin: 22px 0; padding: 18px; border: 1px solid var(--border); border-radius: 16px; background: var(--bg-elevated); }
.resource-shelf .section-heading { margin-bottom: 8px; }
.resource-shelf .catalog-notice { margin: 6px 0 14px; }
.resource-result { position: relative; }
.resource-cover { width: 58px; height: 78px; float: right; object-fit: cover; border: 1px solid var(--border); border-radius: 7px; }
.resource-result .license-label { line-height: 1.5; }
.resource-result .free-book-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-top: 12px; }
.resource-result .free-book-actions .button { min-height: 40px; }
.resource-shelf .field-hint { margin: 10px 0; }
.tts-chunk.is-speaking { border-radius: 3px; background: var(--accent-soft); box-shadow: 0 0 0 2px var(--accent-soft); }
.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.stat-card { min-height: 143px; padding: 18px; border: 1px solid var(--border); border-radius: 15px; background: var(--paper); display: flex; flex-direction: column; align-items: flex-start; }
.stat-card strong { margin: 12px 0 2px; font-size: 34px; letter-spacing: -1px; }
.stat-card > span:last-child { color: var(--text-muted); font-size: 11px; }
.stat-label { color: var(--text-faint); font-size: 9px; font-weight: 700; letter-spacing: 1px; }
.stat-feature { background: var(--accent); color: var(--accent-text); }
.stat-feature .stat-label, .stat-feature > span:last-child { color: var(--accent-text); }
.history-panel { margin-top: 24px; padding: 20px; border: 1px solid var(--border); border-radius: 15px; background: var(--paper); }
.panel-heading { margin-bottom: 8px; }
.panel-heading h3, .backup-card h3 { margin: 0; font-size: 16px; letter-spacing: -.3px; }
.history-row { display: flex; align-items: center; justify-content: space-between; gap: 15px; padding: 13px 0; border-top: 1px solid var(--border); }
.history-row:first-child { border-top: 0; }
.history-book { font-weight: 600; font-size: 13px; }
.history-author { margin-top: 3px; color: var(--text-muted); font-size: 11px; }
.history-date { color: var(--text-muted); font-size: 11px; white-space: nowrap; }
.history-empty { padding: 20px 0; color: var(--text-muted); font-size: 13px; }
.backup-card { display: flex; gap: 17px; padding: 21px; margin-bottom: 12px; border: 1px solid var(--border); border-radius: 15px; background: var(--paper); }
.backup-symbol { width: 43px; height: 43px; flex: 0 0 43px; display: grid; place-items: center; border-radius: 13px; background: var(--accent-soft); color: var(--accent-strong); font-size: 22px; }
.backup-symbol-muted { background: var(--card-hover); color: var(--text-muted); }
.backup-card p { max-width: 580px; margin: 7px 0 14px; color: var(--text-muted); font-size: 13px; line-height: 1.55; }
.file-button { cursor: pointer; }
.notice { margin-top: 20px; padding: 17px 19px; border-left: 3px solid var(--accent); border-radius: 0 12px 12px 0; background: var(--accent-wash); }
.notice strong { font-size: 12px; }
.notice p { margin: 6px 0 0; color: var(--text-muted); font-size: 12px; line-height: 1.6; }
.app-message { position: fixed; z-index: 5; right: 20px; bottom: 20px; max-width: min(420px, calc(100vw - 40px)); margin: 0; padding: 12px 16px; border-radius: 11px; background: var(--accent); color: var(--accent-text); font-size: 13px; box-shadow: 0 8px 30px var(--shadow); opacity: 0; transform: translateY(8px); pointer-events: none; transition: .2s; }
.app-message.visible { opacity: 1; transform: translateY(0); }
.dialog { width: min(520px, calc(100% - 28px)); max-height: min(90vh, 780px); padding: 24px; border: 1px solid var(--border); border-radius: 18px; background: var(--paper); color: var(--ink); box-shadow: 0 20px 80px var(--shadow); }
.dialog::backdrop { background: var(--scrim); backdrop-filter: blur(3px); }
.dialog-heading { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 20px; }
.dialog-heading h2 { font-size: 23px; }
.icon-button { width: 34px; height: 34px; border: 0; border-radius: 9px; background: var(--card-hover); color: var(--text-muted); font-size: 22px; }
.form-field { display: flex; flex-direction: column; gap: 7px; margin: 12px 0; color: var(--text-muted); font-size: 12px; font-weight: 600; }
.form-field input { width: 100%; min-height: 46px; padding: 0 12px; border: 1px solid var(--line); border-radius: 11px; background-color: var(--paper); font-size: 13px; color: var(--ink); }
.form-field .custom-select { width: 100%; }
.form-field input:focus, .progress-update input:focus { outline: none; border-color: var(--primary-focus); box-shadow: 0 0 0 3px var(--primary-soft); }
.required { color: var(--danger); }
.field-hint { color: var(--text-faint); font-size: 10px; font-weight: 400; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.favorite-toggle { display: flex; align-items: center; gap: 9px; margin: 15px 0; color: var(--text-muted); font-size: 13px; }
.favorite-toggle input, .restore-choice input { accent-color: var(--primary); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 22px; }
.modal-body, .reader-body { display: contents; }
.mobile-accordion > summary { display: none; }
.mobile-accordion-content { display: contents; }
.discovery-panel { margin: 15px 0; padding: 14px; border: 1px solid var(--border); border-radius: 13px; background: var(--bg-elevated); }
.discovery-panel h3 { margin: 0; font-size: 14px; }
.discovery-panel > p, .field-hint { color: var(--text-muted); font-size: 11px; line-height: 1.5; }
.discovery-panel .form-row { align-items: end; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
.discovery-panel .form-field { margin: 8px 0 0; }
.discovery-search { min-height: 42px; margin-bottom: 0; font-size: 11px; }
.metadata-results { display: grid; gap: 7px; margin-top: 10px; }
.metadata-candidate { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px; border: 1px solid var(--border); border-radius: 10px; background: var(--card); }
.metadata-cover { flex: 0 0 44px; width: 44px; height: 62px; object-fit: cover; border: 1px solid var(--border); border-radius: 5px; background: var(--bg-elevated); }
.metadata-candidate > span { display: grid; gap: 3px; min-width: 0; }
.metadata-candidate strong { font-size: 12px; overflow-wrap: anywhere; }
.metadata-candidate small { color: var(--text-muted); font-size: 10px; }
.metadata-candidate a { color: var(--accent-strong); font-size: 10px; white-space: nowrap; }
.metadata-candidate button { flex: 0 0 auto; }
.reader-dialog { width: min(850px, calc(100% - 20px)); height: min(92vh, 900px); display: none; flex-direction: column; }
.reader-dialog[open] { display: flex; }
.reader-tools { display: flex; align-items: center; gap: 7px; padding-bottom: 12px; }
.reader-tools .button { min-height: 36px; padding: 0 10px; }
.reader-tts-tools { display: flex; flex: 1 0 100%; flex-wrap: wrap; align-items: end; gap: 9px; padding-top: 8px; border-top: 1px solid var(--border); }
.reader-tts-tools label, .audio-speed { display: grid; gap: 5px; color: var(--text-muted); font-size: 11px; }
.reader-tts-tools select, .audio-speed select { min-height: 38px; max-width: min(280px, 65vw); padding: 7px 32px 7px 10px; border: 1px solid var(--border); border-radius: 9px; background: var(--card); color: var(--text); font: inherit; }
.reader-tts-tools .field-hint { flex: 1 0 100%; }
.audio-dialog { width: min(620px, calc(100% - 20px)); display: none; flex-direction: column; }
.audio-dialog[open] { display: flex; }
.audio-player-body { display: grid; gap: 18px; padding: 24px; }
.audio-player-body audio { width: 100%; }
.audio-player-body .form-field { margin: 0; }
.audio-player-body input[type="range"] { width: 100%; padding: 0; accent-color: var(--accent); }
.audio-player-controls { display: flex; align-items: end; justify-content: space-between; gap: 14px; }
.audio-player-controls .field-hint { font-variant-numeric: tabular-nums; }
.reader-chapter-label { flex: 1; overflow: hidden; color: var(--text-muted); font-size: 12px; text-align: center; text-overflow: ellipsis; white-space: nowrap; }
.reader-content { min-height: 0; flex: 1; overflow: auto; padding: clamp(18px, 5vw, 50px); border: 1px solid var(--border); border-radius: 12px; background: var(--card); color: var(--text); font-family: Georgia, serif; font-size: 18px; line-height: 1.8; }
.reader-content h1, .reader-content h2, .reader-content h3 { line-height: 1.25; }
.reader-content blockquote { margin-left: 0; padding-left: 16px; border-left: 3px solid var(--accent); color: var(--text-muted); }
.reader-content iframe { width: 100%; height: 100%; min-height: 60vh; border: 0; background: white; }
.reader-attribution { margin: 0 0 10px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 9px; color: var(--text-muted); font-size: 12px; line-height: 1.55; }
.reader-attribution a, .free-book-actions a { color: var(--accent-strong); }
.discover-intro { max-width: 720px; color: var(--text-muted); line-height: 1.6; }
.discover-search { max-width: 720px; margin: 18px 0; }
.open-textbook-shelf { margin-top: 36px; padding-top: 26px; border-top: 1px solid var(--border); }
.open-textbook-shelf .section-heading { align-items: center; }
.open-textbook-shelf h3 { margin: 0; font-size: 20px; }
.catalog-notice { max-width: 850px; margin: 16px 0; padding: 13px 15px; border: 1px solid var(--border); border-left: 3px solid var(--accent); border-radius: 10px; background: var(--accent-soft); color: var(--text-muted); font-size: 12px; line-height: 1.6; }
#open-textbook-status { margin: 14px 0; }
#open-textbook-more { margin-top: 16px; }
.free-book-card { min-width: 0; padding: 20px; border: 1px solid var(--border); border-radius: 15px; background: var(--card); }
.free-book-card .eyebrow { margin: 0 0 8px; }
.free-book-card h3 { margin: 0 0 10px; overflow-wrap: anywhere; }
.free-book-card > p:not(.eyebrow) { color: var(--text-muted); font-size: 12px; line-height: 1.55; }
.free-book-card .license-label { color: var(--text-faint); }
.free-book-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 18px; }
.free-book-actions .button { min-height: 40px; }
.free-book-actions a { font-size: 12px; }
.book-cover { float: left; width: 48px; height: 66px; object-fit: cover; margin: 0 12px 8px 0; border-radius: 6px; }
.book-access { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 12px; color: var(--text-muted); font-size: 10px; }
.book-access a { color: var(--accent-strong); overflow-wrap: anywhere; }
.book-access button { padding: 4px 8px; border: 1px solid var(--border); border-radius: 8px; background: var(--card-hover); color: var(--accent-strong); font-size: 10px; font-weight: 700; }
.reader-error { margin: auto; max-width: 420px; color: var(--text-muted); text-align: center; font-size: 13px; }
.restore-summary { color: var(--text-muted); font-size: 13px; line-height: 1.6; }
.restore-choice { display: flex; align-items: flex-start; gap: 11px; margin-top: 11px; padding: 13px; border: 1px solid var(--border); border-radius: 11px; cursor: pointer; }
.restore-choice:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.restore-choice input { margin-top: 3px; }
.restore-choice span { display: grid; gap: 4px; }
.restore-choice strong { font-size: 13px; }
.restore-choice small { color: var(--text-faint); font-size: 11px; line-height: 1.4; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.settings-card { padding: 4px 20px; border: 1px solid var(--border); border-radius: 15px; background: var(--paper); }
.setting-row { min-height: 82px; display: flex; align-items: center; justify-content: space-between; gap: 18px; border-bottom: 1px solid var(--line); }
.setting-row:last-of-type { border-bottom: 0; }
.setting-row > span { display: grid; gap: 5px; }
.setting-row strong { font-size: 14px; }
.setting-row small { color: var(--muted); font-size: 12px; }
.setting-row .custom-select { width: min(240px, 52%); min-width: 180px; flex: 0 0 auto; }
.progress-fill { background: var(--primary); }
.status-pill.inProgress { background: var(--primary-soft); color: var(--primary-dark); }
.stat-feature { background: var(--primary); color: var(--primary-foreground); }
.stat-feature .stat-label, .stat-feature > span:last-child { color: var(--primary-muted); }
.progress-update button { border-color: var(--primary-soft); background: var(--primary-soft); color: var(--primary-dark); }
.backup-symbol { background: var(--primary-soft); color: var(--primary-dark); }
.notice { border-left-color: var(--accent); background: var(--accent-wash); }
:root[data-theme="dark"] .settings-card { color-scheme: dark; }
button:focus-visible, a:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button:disabled, input:disabled { cursor: not-allowed; opacity: .55; }
:root[data-theme="dark"] .tab.active { color: var(--accent); }
.review-panel { margin-bottom: 20px; padding: 18px 20px; border: 1px solid var(--border); border-radius: 15px; background: var(--bg-elevated); }
.review-panel .panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.review-panel .panel-heading .eyebrow { margin-bottom: 5px; }
.review-panel h3 { margin: 0; font-size: 18px; }
.review-count { min-width: 32px; padding: 6px 10px; border: 1px solid var(--border); border-radius: 999px; background: var(--card); color: var(--text-muted); text-align: center; font-size: 12px; font-weight: 700; }
.review-list { display: grid; gap: 10px; }
.review-empty { margin: 0; color: var(--text-muted); font-size: 13px; line-height: 1.5; }
.notes-toolbar { display: flex; gap: 10px; margin-bottom: 16px; }
.notes-toolbar .search-field { flex: 1; }
.notes-toolbar .select-field { min-width: 190px; }
.note-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.note-card { min-width: 0; padding: 16px; border: 1px solid var(--border); border-radius: 14px; background: var(--card); }
.note-card-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.note-type { padding: 4px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--primary-dark); font-size: 10px; font-weight: 700; }
.note-date, .note-location { color: var(--text-muted); font-size: 11px; }
.note-body { margin: 12px 0; color: var(--text); font-size: 14px; line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere; }
.note-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; color: var(--text-muted); font-size: 11px; }
.note-book { color: var(--text-muted); font-weight: 650; }
.note-meta .tag-list { display: contents; }
.note-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 13px; padding-top: 10px; border-top: 1px solid var(--border); }
.note-review-action { min-height: 36px; padding: 0 12px; font-size: 11px; }
#note-body { min-height: 120px; padding: 11px 12px; border: 1px solid var(--border); border-radius: 11px; background: var(--card); color: var(--text); font: inherit; font-size: 13px; line-height: 1.5; resize: vertical; }
#note-body:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
@media (max-width: 700px) {
  .topbar { height: 62px; padding: 0 18px; }
  .shell { width: calc(100% - 32px); padding: 30px 0 50px; }
  .intro { align-items: flex-start; flex-direction: column; margin-bottom: 28px; }
  .intro h1 { max-width: 440px; }
  .subheading { max-width: 340px; line-height: 1.5; }
  .privacy-note { font-size: 11px; }
  .section-heading h2 { font-size: 23px; }
  .section-heading { align-items: flex-end; }
  .section-heading > .button { min-height: 40px; padding: 0 12px; font-size: 12px; }
  .book-list { grid-template-columns: 1fr; }
  .book-card { padding: 15px; }
  .stat-grid { grid-template-columns: 1fr 1fr; gap: 9px; }
  .stat-card { min-height: 124px; padding: 15px; }
  .stat-card strong { font-size: 30px; }
  .toolbar { gap: 7px; }
  .search-field { padding: 0 9px; }
  .select-field { padding: 0 8px; }
  .select-field .custom-select-trigger { font-size: 12px; }
  .period-picker .custom-select-trigger { min-width: 100px; }
  .backup-card { padding: 17px; gap: 12px; }
  .backup-symbol { width: 37px; height: 37px; flex-basis: 37px; }
  .backup-card h3 { font-size: 15px; }
  .backup-card p { font-size: 12px; }
  .dialog { padding: 20px 17px; }
  .app-message { right: 12px; bottom: 12px; }
}
@media (max-width: 640px), (max-height: 500px) and (pointer: coarse) {
  button { min-height: 44px; }
  input, select, textarea { min-height: 44px; font-size: 16px; }
  input[type="checkbox"], input[type="radio"] { width: 20px; min-width: 20px; height: 20px; min-height: 20px; }
  select.custom-select-native { min-height: 0; }
  .search-field input, .progress-update input, #note-body { font-size: 16px; }
  dialog.mobile-sheet:not([open]) { display: none; }
  dialog.mobile-sheet[open] {
    position: fixed;
    inset-inline: 0;
    top: var(--sheet-top, 0px);
    bottom: auto;
    width: 100%;
    max-width: none;
    height: 100vh;
    height: 100dvh;
    height: var(--sheet-height, 100dvh);
    max-height: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }
  .mobile-modal-form { height: 100%; min-height: 0; display: flex; flex-direction: column; }
  .mobile-sheet .dialog-heading { min-height: 68px; flex: 0 0 auto; align-items: center; gap: 12px; margin: 0; padding: calc(8px + env(safe-area-inset-top, 0px)) 16px 10px; border-bottom: 1px solid var(--border); }
  .mobile-sheet .dialog-heading h2 { font-size: 20px; line-height: 1.25; }
  .mobile-sheet .icon-button { width: 44px; height: 44px; min-width: 44px; flex: 0 0 44px; }
  .mobile-sheet .modal-body { min-height: 0; flex: 1 1 auto; display: flex; flex-direction: column; gap: 12px; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; padding: 16px 18px 24px; }
  .mobile-sheet .reader-body { gap: 10px; overflow: hidden; }
  .mobile-sheet .reader-content { min-height: 0; flex: 1 1 auto; padding: 16px; }
  .mobile-sheet .reader-content iframe { height: 100%; min-height: 0; }
  .mobile-sheet .modal-footer { position: sticky; z-index: 2; bottom: 0; flex: 0 0 auto; justify-content: stretch; gap: 10px; margin: 0; padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px)); border-top: 1px solid var(--border); background: var(--paper); }
  .mobile-sheet .dialog-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .mobile-sheet .modal-footer .button, .mobile-sheet .dialog-actions .button, .mobile-sheet .reader-tools .button { min-height: 44px; }
  .mobile-sheet .modal-body > .form-field, .mobile-sheet .mobile-accordion-content > .form-field, .mobile-sheet .mobile-accordion-content > .form-row, .mobile-sheet .modal-body > .form-row { margin: 0; }
  .mobile-sheet .form-field { gap: 7px; margin: 0 0 12px; }
  .mobile-sheet .form-field input:not([type="checkbox"]):not([type="radio"]), .mobile-sheet .form-field textarea { min-height: 44px; font-size: 16px; }
  .mobile-sheet input[type="file"] { min-height: 44px; }
  .mobile-sheet .form-row, .mobile-sheet .discovery-panel .form-row { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .mobile-sheet .custom-select-trigger { min-height: 44px; font-size: 16px; }
  .mobile-sheet .discovery-panel { margin: 0; padding: 12px; }
  .mobile-sheet .discovery-panel .form-field { margin: 0; }
  .mobile-sheet .discovery-search { width: 100%; min-height: 44px; font-size: 13px; }
  .mobile-sheet .metadata-candidate { min-height: 48px; flex-wrap: wrap; justify-content: flex-start; }
  .mobile-sheet .metadata-candidate > span { flex: 1 1 140px; }
  .mobile-sheet .metadata-candidate .button { min-height: 44px; }
  .mobile-accordion { border: 1px solid var(--border); border-radius: 12px; background: var(--bg-elevated); }
  .mobile-accordion > summary { min-height: 48px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 13px; color: var(--text); font-size: 14px; font-weight: 700; list-style: none; cursor: pointer; }
  .mobile-accordion > summary::-webkit-details-marker { display: none; }
  .mobile-accordion > summary::after { content: ""; width: 8px; height: 8px; flex: 0 0 8px; border-right: 2px solid var(--text-muted); border-bottom: 2px solid var(--text-muted); transform: translateY(-2px) rotate(45deg); }
  .mobile-accordion[open] > summary::after { transform: translateY(2px) rotate(225deg); }
  .mobile-accordion-content { display: block; padding: 0 12px 12px; }
  .discovery-heading { display: none; }
  #book-discovery[open] { padding-bottom: 12px; }
  #book-discovery[open] .discovery-panel { padding: 12px; }
  .mobile-sheet .favorite-toggle { min-height: 44px; margin: 8px 0 0; }
  .mobile-sheet .restore-choice { min-height: 56px; margin-top: 0; padding: 12px; }
  .mobile-sheet .reader-tools { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; padding: 10px 14px calc(10px + env(safe-area-inset-bottom, 0px)); }
  .mobile-sheet .reader-tools .button { min-width: 44px; padding: 0 10px; }
  .mobile-sheet .reader-tts-tools { align-items: stretch; }
  .mobile-sheet .reader-tts-tools label { flex: 1 1 160px; }
  .mobile-sheet .reader-tts-tools select { width: 100%; max-width: none; min-height: 44px; }
  .audio-dialog { width: 100%; height: 100%; max-height: none; border-radius: 0; padding: 0; }
  .audio-player-body { padding: 16px; padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px)); }
  .audio-player-controls { align-items: center; flex-wrap: wrap; }
  .audio-speed select { min-height: 44px; }
  .mobile-sheet .reader-chapter-label { flex: 1 0 100%; order: 3; min-height: 24px; }
}
@media (max-width: 390px) {
  .shell { width: calc(100% - 24px); }
  .section-heading { gap: 8px; }
  .section-heading > .button { padding: 0 9px; }
  .tab { padding-left: 10px; padding-right: 10px; }
  .form-row { gap: 8px; }
  .backup-card { gap: 9px; }
  .backup-symbol { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
@media (max-width: 700px) {
  .toolbar { flex-wrap: wrap; }
  .search-field { flex: 1 1 100%; }
  .toolbar .select-field { flex: 1 1 0; min-width: 0; }
  .toolbar .select-field .custom-select { width: 100%; min-width: 0; }
  .notes-toolbar { flex-wrap: wrap; }
  .notes-toolbar .search-field { flex: 1 1 100%; }
  .notes-toolbar .select-field { flex: 1 1 100%; min-width: 0; }
  .note-list { grid-template-columns: 1fr; }
  .setting-row { align-items: stretch; flex-direction: column; gap: 10px; padding: 15px 0; }
  .setting-row .custom-select { width: 100%; min-width: 0; }
}
.sync-card { margin-top: 1.25rem; display: grid; gap: .9rem; }
.sync-card h3 { margin: 0; }
.sync-field { max-width: 34rem; }
.sync-consent { display: flex; align-items: flex-start; gap: .65rem; max-width: 56rem; color: var(--text-muted); line-height: 1.5; }
.sync-consent input { width: 1.1rem; height: 1.1rem; margin-top: .18rem; accent-color: var(--accent); flex: 0 0 auto; }
.sync-actions { display: flex; flex-wrap: wrap; gap: .65rem; }
.setup-page { max-width: 850px; margin: 3rem auto; padding: clamp(1rem, 4vw, 2.5rem); color: var(--text); }
.setup-page h1, .setup-page h2 { color: var(--text); }
.setup-page li { margin: .7rem 0; line-height: 1.6; }
.setup-page a { color: var(--accent); }
@media (max-width: 640px) { .sync-field input { font-size: 16px; } }
