/* Presentation layer; reader sizing, storage and generation behavior stay independent. */
:root {
  --bg: #141819; --surface: #1b2021; --surface-2: #252c2d; --field: #202627;
  --line: #374142; --text: #f0f3f0; --muted: #a7b4b0; --accent: #9be2c7;
  --accent-2: #e8b19c; --accent-ink: #15352b; --danger: #f2a29d;
  --hover: #303b38; --nav-bg: #191e1f; --soft-accent: #253b33;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif;
}
:root[data-theme="paper"] { --bg: #f7f9f8; --surface: #fff; --surface-2: #ecf1ee; --field: #fff; --line: #d6dfda; --text: #202e29; --muted: #596c62; --accent: #267156; --accent-2: #92563d; --accent-ink: #fff; --danger: #a03e3c; --hover: #e1ece5; --nav-bg: #fff; --soft-accent: #e5f1ea; }
:root[data-theme="sepia"] { --bg: #f0e9dc; --surface: #faf4e8; --surface-2: #e8dec9; --field: #faf4e8; --line: #d0c1a8; --text: #3b3025; --muted: #706049; --accent: #596c43; --accent-2: #945639; --accent-ink: #fff; --danger: #a03e3c; --hover: #e6dbc5; --nav-bg: #faf4e8; --soft-accent: #e2e5d3; }
:root[data-theme="ocean"] { --bg: #101c22; --surface: #17272d; --surface-2: #22373f; --field: #1b2e35; --line: #39515a; --text: #edf5f5; --muted: #adc1c6; --accent: #9cdce0; --accent-2: #eac29c; --accent-ink: #143037; --danger: #f4aaa4; --hover: #2c4148; --nav-bg: #17272d; --soft-accent: #234149; }
* { letter-spacing: 0; }
[hidden] { display: none !important; }
body { -webkit-font-smoothing: antialiased; }
button, input, textarea, select { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
button:disabled { opacity: .5; }
summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
h1 { font-size: 21px; font-weight: 700; }
h2 { font-size: 30px; font-weight: 650; line-height: 1.3; }
h3 { font-size: 17px; font-weight: 650; line-height: 1.4; }
p { line-height: 1.6; }
.ui-icon { display: inline-block; flex: 0 0 auto; vertical-align: middle; width: 20px; height: 20px; pointer-events: none; }
.app-shell { width: min(100%, 1040px); padding-bottom: calc(104px + env(safe-area-inset-bottom)); }
.topbar { gap: 12px; padding: max(20px, env(safe-area-inset-top)) 30px 20px; border-color: var(--line); }
.brand-lockup { gap: 11px; min-width: 0; }
.brand-mark { width: 42px; height: 42px; flex-shrink: 0; color: var(--accent-ink); background: var(--accent); border: 0; border-radius: 8px; }
.brand-mark .ui-icon { width: 25px; height: 25px; }
.brand-lockup .eyebrow { display: none; }
.topbar-actions { gap: 6px; }
.main-content { padding: 34px 30px 38px; }
.eyebrow { margin: 0 0 7px; font-size: 11px; letter-spacing: 0; line-height: 1.3; font-weight: 650; }
.page-intro { align-items: center; gap: 20px; margin: 0 0 28px; min-width: 0; }
.page-intro > div { min-width: 0; }
.page-intro p:last-child { margin-bottom: 0; color: var(--muted); font-size: 13px; }
.intro-actions { align-items: center; gap: 8px; flex-shrink: 0; }
.primary, .secondary, .icon-button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 10px 16px; line-height: 1.4; font-size: 13px; font-weight: 600; transition: border-color .15s ease; }
.primary { border-color: transparent; }
.icon-only { flex: 0 0 44px; width: 44px; height: 44px; padding: 0; }
.avatar, .topbar-settings, .inbox-toggle { position: relative; display: inline-grid; place-items: center; width: 44px; height: 44px; padding: 0; border: 0; border-radius: 8px; color: var(--muted); background: transparent; }
.avatar:hover, .topbar-settings:hover, .inbox-toggle:hover { background: var(--surface-2); color: var(--text); }
.notification-dot { position: absolute; right: 10px; top: 9px; width: 6px; height: 6px; border-radius: 50%; background: var(--accent-2); }
.toolbar { align-items: center; }
.shelf-meta { flex-direction: row; padding: 0 0 16px; margin-bottom: 6px; gap: 16px; }
.shelf-meta > :first-child { color: var(--text); font-weight: 600; }
.book-list { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 28px; }
.book-card { grid-template-columns: 94px minmax(0, 1fr); gap: 20px; min-width: 0; padding: 26px 0; background: transparent; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; }
.book-card:hover { transform: none; border-color: var(--line); }
.book-info { min-width: 0; }
.book-card h3 { margin: 0 0 7px; font-size: 18px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.book-card p { margin-bottom: 12px; font-size: 11px; }
.book-current { display: block; color: var(--accent); font-size: 11px; margin-bottom: 6px; }
.book-cover { position: relative; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 8px; width: 94px; height: 136px; padding: 12px; background: #366154; color: #f1f4e5; border-radius: 3px 6px 6px 3px; border: 0; border-left: 5px solid #284c40; box-shadow: 3px 5px 12px #0002; overflow: hidden; }
.book-cover::after { content: ''; position: absolute; inset: 9px; border: 1px solid #ffffff38; pointer-events: none; }
.cover-1 { background: #875551; border-left-color: #673d3a; }
.cover-2 { background: #436476; border-left-color: #2b4a5a; }
.cover-3 { background: #806541; border-left-color: #5e482e; }
.cover-imprint { font-size: 6px; opacity: .75; font-weight: 400; }
.book-cover .ui-icon { width: 17px; height: 17px; opacity: .7; }
.cover-letter { font: 32px/1 Georgia, "Noto Serif CJK SC", serif; }
.cover-rule { width: 20px; height: 1px; background: currentColor; opacity: .55; }
.book-progress { display: flex; gap: 10px; align-items: center; margin: 10px 0 12px; }
.book-progress > span { color: var(--muted); font-size: 10px; font-variant-numeric: tabular-nums; }
.progress-track { flex: 1; height: 3px; margin: 0; background: var(--surface-2); border-radius: 8px; }
.book-actions { grid-column: auto; gap: 8px; }
.book-open { padding: 8px 13px; font-size: 12px; }
.book-open .ui-icon { width: 16px; height: 16px; }
.book-actions .danger-button { margin-left: auto; background: transparent; color: var(--muted); border-color: transparent; }
.book-actions .danger-button:hover { color: var(--danger); border-color: var(--danger); }
.library-footnote { display: flex; align-items: center; justify-content: center; gap: 7px; color: var(--muted); margin: 28px 0 0; font-size: 11px; }
.library-footnote .ui-icon { width: 16px; height: 16px; }
.empty { padding: 48px 20px; border: 0; border-radius: 0; }
.empty h3 { color: var(--text); }
.empty-library { grid-column: 1 / -1; display: flex; flex-direction: column; align-items: center; padding: 24px 0 32px; }
.empty-library p { font-size: 13px; max-width: 300px; }
.library-art { display: block; width: min(360px, 100%); height: auto; margin: 0 0 20px; }
.section-label { letter-spacing: 0; }
.settings-section { padding: 26px 0; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; box-shadow: none; background: transparent; margin: 0; }
.settings-section:first-of-type { padding-top: 0; }
.settings-section:last-of-type { border-bottom: 0; }
.section-heading { align-items: center; justify-content: flex-start; gap: 12px; margin-bottom: 22px; }
.section-icon { width: 40px; height: 40px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 8px; background: var(--soft-accent); color: var(--accent); }
.section-heading .eyebrow { display: none; }
.section-heading h3 { font-size: 17px; }
.control-grid { gap: 14px; }
.settings-section .control-grid { gap: 18px 22px; }
label { gap: 8px; min-width: 0; font-size: 12px; line-height: 1.5; }
input, textarea, select { min-width: 0; padding: 12px 13px; min-height: 46px; border-radius: 6px; font-size: 14px; }
select { padding-right: 8px; cursor: pointer; }
textarea { min-height: 124px; line-height: 1.6; }
.form { gap: 18px; max-width: 480px; }
.toggle { gap: 11px; margin: 18px 0 10px; min-height: 28px; color: var(--text); cursor: pointer; }
.toggle input { appearance: none; position: relative; flex: 0 0 34px; width: 34px; height: 20px; min-height: 20px; margin: 0; padding: 0; border-radius: 12px; background: var(--surface-2); border-color: var(--muted); cursor: pointer; }
.toggle input::before { content: ''; position: absolute; top: 3px; left: 3px; width: 12px; height: 12px; border-radius: 50%; background: var(--muted); transition: transform .15s; }
.toggle input:checked { background: var(--accent); border-color: var(--accent); }
.toggle input:checked::before { transform: translateX(14px); background: var(--accent-ink); }
.setting-toggle { margin-bottom: 8px; }
.font-preview { margin: 0; padding: 16px 0; border-block: 1px solid var(--line); }
input[type="range"] { padding: 0; min-height: 44px; background: transparent; border: 0; }
output { font-variant-numeric: tabular-nums; color: var(--accent); }
.settings-section > .small { margin-top: 15px; line-height: 1.6; }
.reader-controls { padding: 0 0 12px; margin: 0 0 18px; }
.reader-controls > summary { min-height: 44px; padding: 13px 0; font-size: 12px; }
body[data-view="reader"] .page-intro { margin-bottom: 16px; }
body[data-view="reader"] .page-intro h2 { font-size: 23px; }
body[data-view="reader"] .page-intro > button { flex-shrink: 0; }
.reader-actionbar { gap: 9px; padding: 12px 0; }
.reader-actionbar button { min-height: 46px; line-height: 1.4; }
.reader-actionbar .primary:disabled { opacity: 1; background: var(--soft-accent); color: var(--accent); border-color: var(--line); }
.reader-card { padding: 14px 52px 30px; background: transparent; line-height: 1.9; }
.reader-card p { margin: 0 0 .8em; line-height: inherit; }
.page-nav { gap: 10px; padding: 0 0 18px; margin-bottom: 22px; font-family: -apple-system, "Segoe UI", "Microsoft YaHei", sans-serif; }
.page-nav strong { font-size: 12px; color: var(--muted); font-weight: 500; font-variant-numeric: tabular-nums; }
.page-nav .secondary { background: transparent; border-color: transparent; padding: 10px; font-size: 12px; }
.page-nav .secondary:hover:not(:disabled) { background: var(--surface-2); }
.page-nav-bottom { margin: 28px 0 0; padding: 18px 0 0; }
.inline-images { gap: 12px; margin: 20px 0 28px; }
.inline-image { padding: 0; }
.local-reader-image, .task-image { border-radius: 6px; }
.generation-status, .inline-generation-status { padding: 10px 12px; border-left-width: 2px; background: var(--soft-accent); font: 12px/1.6 -apple-system, "Segoe UI", "Microsoft YaHei", sans-serif; }
.inline-generation-status.is-queued { color: var(--text); }
.inline-generation-status.is-failed { background: var(--surface); }
.prompt-preview summary { min-height: 36px; padding-block: 8px; }
.task-card { padding: 22px 0; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; margin: 0; background: transparent; }
.task-head { align-items: center; gap: 14px; margin-bottom: 12px; }
.task-head strong { font-size: 15px; }
.status { color: var(--accent); background: var(--soft-accent); border-radius: 4px; padding: 4px 8px; font-size: 11px; }
.task-card summary { color: var(--muted); font-size: 12px; line-height: 1.5; min-height: 30px; }
.credits { gap: 16px; margin: 22px 0 28px; }
.credit-card { padding: 24px; background: var(--surface); border: 1px solid var(--line); }
.credit-card:first-child { border-top: 3px solid var(--accent); }
.credit-card:last-child { border-top: 3px solid var(--accent-2); }
.credit-card strong { font-size: 38px; line-height: 1.3; margin: 12px 0; font-weight: 600; }
.credit-card .credit-label { font-size: 13px; }
.credit-card .credit-usage { color: var(--muted); font-size: 12px; }
.credit-policy { color: var(--muted); font-size: 12px; line-height: 1.7; margin: 16px 0; }
.daily-reward { gap: 22px; padding: 24px 0; }
.daily-reward > div { flex-basis: 200px; }
.panel { background: transparent; border: 0; border-radius: 0; padding: 24px 0 !important; }
.bottom-nav { width: min(100%, 1040px); height: calc(76px + env(safe-area-inset-bottom)); padding: 6px 18px calc(6px + env(safe-area-inset-bottom)); background: var(--nav-bg); }
.nav-item { display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 5px; min-width: 0; min-height: 44px; }
.nav-item > span { display: grid; place-items: center; width: 46px; height: 28px; border-radius: 6px; }
.nav-item .ui-icon { width: 21px; height: 21px; }
.nav-item small { font-size: 10px; line-height: 1.4; }
.nav-item.active > span { background: var(--soft-accent); }
.nav-item.active small { font-weight: 650; }
.toast { z-index: 50; bottom: calc(96px + env(safe-area-inset-bottom)); padding: 12px 18px; line-height: 1.5; border: 1px solid var(--line); border-radius: 8px; background: var(--text); color: var(--bg); }
.image-lightbox { background: #070a0df2; backdrop-filter: none; }
.image-lightbox img { max-height: 92dvh; border-radius: 6px; }
.image-lightbox-close { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 8px; }
.onboarding-backdrop { background: #070a0dcc; backdrop-filter: none; }
.onboarding-card { width: min(100%, 520px); max-height: calc(100dvh - 36px); overflow: auto; overscroll-behavior: contain; border: 1px solid var(--line); border-radius: 8px; }
.onboarding-art { display: block; width: 240px; max-width: 100%; height: auto; margin: -4px auto 12px; }
.onboarding-card h2 { font-size: 23px; }
.onboarding-card > p { font-size: 13px; }
.onboarding-close { top: 10px; right: 10px; width: 44px; height: 44px; min-height: 44px; padding: 0; background: var(--surface); }
.onboarding-steps { gap: 17px; margin: 20px 0; }
.onboarding-steps li { grid-template-columns: 30px minmax(0, 1fr); gap: 4px 10px; font-size: 13px; }
.onboarding-steps li::before { grid-row: 1 / 3; align-self: start; border-radius: 6px; color: var(--accent); background: var(--soft-accent); }
.onboarding-steps strong { grid-row: auto; }
.onboarding-steps span { grid-row: auto; }
.onboarding-note { border: 0; padding: 12px 0; margin-bottom: 10px; background: transparent; }
.user-inbox { padding: 24px; }
.user-inbox header h2 { margin: 0; font-size: 22px; }
.user-inbox [data-close] { width: 44px; height: 44px; min-height: 44px; padding: 0; }
@media (min-width: 1000px) { body[data-view="settings"] .main-content, body[data-view="account"] .main-content { max-width: 800px; margin-inline: auto; } }
@media (max-width: 699px) {
  .topbar { padding: max(14px, env(safe-area-inset-top)) 18px 14px; flex-wrap: nowrap; }
  .main-content { padding: 26px 20px 30px; }
  h1 { font-size: 18px; } h2 { font-size: 27px; }
  .brand-mark { width: 36px; height: 36px; }
  .brand-mark .ui-icon { width: 22px; height: 22px; }
  .brand-lockup { gap: 9px; }
  .topbar-actions { gap: 0; margin-left: 0; }
  .topbar-settings { display: inline-grid; }
  .page-intro { flex-direction: row; align-items: center; gap: 16px; margin-bottom: 26px; }
  .page-intro > .secondary { flex-shrink: 0; }
  .library-intro .eyebrow { font-size: 10px; }
  .library-intro h2 { margin-bottom: 0; }
  .intro-actions { gap: 5px; flex-wrap: nowrap; }
  .intro-actions > button { flex: initial; }
  .intro-actions .primary { padding: 10px 12px; }
  .intro-actions .icon-only { width: 44px; }
  .book-list { grid-template-columns: minmax(0, 1fr); }
  .book-card { grid-template-columns: 90px minmax(0, 1fr); padding: 24px 0; gap: 20px; }
  .book-cover { width: 90px; height: 130px; }
  .book-card h3 { font-size: 17px; }
  .shelf-meta { font-size: 11px; }
  .library-footnote { align-items: start; text-align: center; line-height: 1.5; }
  .control-grid { grid-template-columns: minmax(0, 1fr); }
  .settings-section { padding-block: 24px; }
  .settings-section .control-grid { gap: 17px; }
  .section-heading { margin-bottom: 20px; }
  body[data-view="reader"] .main-content { padding: 22px 0 28px; }
  body[data-view="reader"] .page-intro, body[data-view="reader"] .reader-controls, #pageGenerationStatus { margin-left: 20px; margin-right: 20px; }
  body[data-view="reader"] .page-intro h2 { font-size: 20px; }
  body[data-view="reader"] .page-intro > button { font-size: 0; padding: 0; width: 44px; height: 44px; }
  .reader-actionbar { padding: 10px 20px; }
  .reader-actionbar button { font-size: 12px; padding: 10px 12px; }
  .reader-actionbar .ui-icon { width: 17px; height: 17px; }
  .reader-card { padding: 8px 22px 28px; }
  .page-nav { grid-template-columns: 44px minmax(0, 1fr) 44px; gap: 8px; margin-bottom: 20px; }
  .page-nav .page-arrow { width: 44px; height: 44px; padding: 0; }
  .page-arrow span { display: none; }
  .inline-images { margin-left: -16px; margin-right: -16px; }
  .bottom-nav { height: calc(70px + env(safe-area-inset-bottom)); padding-inline: 5px; }
  .credits { gap: 12px; }
  .credit-card { padding: 18px 14px; }
  .credit-card strong { font-size: 32px; }
  .credit-card .credit-label { font-size: 12px; }
  .credit-card .credit-usage { font-size: 11px; }
  .daily-reward { gap: 16px; }
  .daily-reward > button { width: 100%; }
  .onboarding-card { padding: 22px; }
  .onboarding-art { width: 200px; }
  .onboarding-card .toolbar > button { flex: 1; padding-inline: 10px; }
  .user-inbox { padding: 18px; }
}
@media (max-width: 359px) { .main-content { padding-inline: 16px; } .library-intro { flex-wrap: wrap; } .book-card { grid-template-columns: 76px minmax(0, 1fr); gap: 16px; } .book-cover { width: 76px; height: 114px; } }
