:root {
  color-scheme: light;
  --font-ui: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft Yahei", sans-serif;
  --font-book: "Songti SC", "STSong", "Noto Serif CJK SC", Georgia, serif;
  --paper: #f8f9f4;
  --surface: #fffefb;
  --side: #eef1e9;
  --soft: #f0f3ec;
  --ink: #27332d;
  --muted: #5f6d62;
  --subtle: #5f6d62;
  --line: #dfe5da;
  --accent: #3c6652;
  --accent-hover: #2d513f;
  --accent-soft: #e4ede3;
  --accent-text: #3a634c;
  --link: #3a6651;
  --focus: #628870;
  --danger: #a14536;
  --danger-soft: #fcf1ed;
  --shadow: 0 8px 30px #27332d08;
  --reading-font-size: 18px;
  --ease-out: cubic-bezier(.23,1,.32,1);
  font-family: var(--font-ui);
  font-size: 16px;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
}
:root[data-theme="night"] {
  color-scheme: dark;
  --paper: #18211d;
  --surface: #202c25;
  --side: #141d18;
  --soft: #253329;
  --ink: #e2e8de;
  --muted: #b1bfaf;
  --subtle: #a2b19f;
  --line: #354439;
  --accent: #a5c7ab;
  --accent-hover: #bfd9c3;
  --accent-soft: #2c4333;
  --accent-text: #c2dac4;
  --link: #b3d3b6;
  --focus: #b2d8b9;
  --danger: #efb6a7;
  --danger-soft: #3a2823;
  --shadow: 0 8px 30px #00000016;
}
:root[data-reading-size="large"] { --reading-font-size: 20px; }
:root[data-reading-size="larger"] { --reading-font-size: 22px; }
* { box-sizing: border-box; }
body { margin: 0; }
button, input, textarea, select { font: inherit; }
button, a, input, textarea, select { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .5; }
button, a, input, textarea, select, summary { touch-action: manipulation; }
button { transition: transform 120ms var(--ease-out); }
button:active:not(:disabled) { transform: scale(.98); }
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible, summary:focus-visible {
  outline: 2px solid var(--focus); outline-offset: 4px;
}
::selection { background: var(--accent-soft); color: var(--ink); }
a { color: var(--link); text-decoration: none; text-underline-offset: 4px; }
a:hover { text-decoration: underline; }
input, textarea { color: var(--ink); caret-color: var(--accent); }
input::placeholder, textarea::placeholder { color: var(--subtle); opacity: 1; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.mobile-only { display: none; }
.wordmark { color: var(--ink); font-size: 1.05rem; font-weight: 750; letter-spacing: .045em; white-space: nowrap; }
.wordmark span { font-weight: 500; letter-spacing: .02em; padding-left: 12px; margin-left: 10px; border-left: 1px solid var(--line); }
.eyebrow { color: var(--muted); font-size: .76rem; font-weight: 550; letter-spacing: .085em; line-height: 1.6; }
.primary, .secondary { min-height: 44px; border-radius: 10px; padding: 11px 18px; border: 1px solid transparent; font-size: .9rem; font-weight: 600; }
.primary { background: var(--accent); color: var(--surface); }
.primary span { margin-left: 8px; }
.primary:disabled { opacity: .55; }
.secondary { background: var(--surface); border-color: var(--line); color: var(--ink); }
.icon-button { display: grid; place-items: center; width: 40px; height: 40px; padding: 8px; border: 0; border-radius: 8px; color: var(--muted); background: transparent; font-size: 1.6rem; flex-shrink: 0; }
.icon-button.mobile-only { display: none; }
.icon-button svg, .materials-toggle svg, .shelf-nav svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linejoin: round; stroke-linecap: round; flex-shrink: 0; }
.plain-button { min-height: 40px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); font-size: .86rem; padding: 9px 10px; text-align: left; }
.error { color: var(--danger); min-height: 1.4em; font-size: .86rem; }
.auth-shell { min-height: 100dvh; display: grid; grid-template-columns: 1fr 1fr; background: var(--surface); }
.auth-intro { background: #e7ece0; padding: 45px clamp(32px,7vw,110px); display: flex; flex-direction: column; justify-content: space-between; color: #2d4336; }
.auth-intro .wordmark { color: #2d4336; }
.auth-intro .wordmark span { border-color: #c7d3c4; }
.auth-intro .eyebrow, .auth-intro small { color: #5b6b5d; }
.auth-summary { max-width: 440px; padding: 90px 0; }
.auth-summary h1 { font-family: var(--font-book); font-size: clamp(2.5rem,4vw,3.7rem); font-weight: 500; line-height: 1.48; letter-spacing: .01em; margin: 24px 0; text-wrap: balance; }
.auth-summary p { font-size: 1rem; line-height: 2; color: #596e5d; }
.auth-features { display: grid; gap: 18px; margin-top: 45px; font-size: .86rem; color: #49604e; }
.auth-intro small { font-size: .76rem; line-height: 1.8; }
.auth-form-area { display: grid; place-items: center; padding: 45px; }
.auth-form-area form { width: 100%; max-width: 375px; }
.auth-form-area h2 { font-family: var(--font-book); font-size: 2.15rem; font-weight: 550; margin: 18px 0; }
.auth-form-area p { color: var(--muted); font-size: .9rem; line-height: 1.85; }
.auth-form-area label { display: block; font-size: .85rem; font-weight: 550; margin: 25px 0 10px; }
.auth-form-area input { width: 100%; min-height: 49px; padding: 13px; border: 1px solid var(--line); border-radius: 9px; background: var(--paper); }
.auth-form-area .primary { width: 100%; min-height: 49px; }
.auth-form-area small { display: block; font-size: .76rem; line-height: 1.8; color: var(--muted); margin-top: 18px; }
.auth-note { font-size: .78rem; line-height: 1.8; color: var(--muted); margin-top: 20px; }
.auth-form-area .error { color: var(--danger); }
:root[data-theme="night"] .auth-intro { background: var(--side); color: var(--ink); }
:root[data-theme="night"] .auth-intro .wordmark { color: var(--ink); }
:root[data-theme="night"] .auth-intro .wordmark span { border-color: var(--line); }
:root[data-theme="night"] .auth-intro .eyebrow, :root[data-theme="night"] .auth-intro small,
:root[data-theme="night"] .auth-summary p, :root[data-theme="night"] .auth-features { color: var(--muted); }
.workspace { display: flex; height: 100dvh; overflow: hidden; }
.sidebar { width: 238px; flex: 0 0 238px; padding: 30px 16px 22px; background: var(--side); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.side-top { display: flex; align-items: center; justify-content: space-between; padding: 0 10px 35px; }
.sidebar .wordmark { font-size: .95rem; }
.new-button { min-height: 44px; padding: 12px 13px; background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: 10px; text-align: left; font-size: .88rem; }
.new-button span { color: var(--accent-text); font-size: 1.08rem; margin-right: 9px; }
.shelf-nav { display: flex; align-items: center; gap: 11px; margin-top: 13px; padding: 11px 12px; min-height: 44px; border-radius: 9px; border: 0; background: transparent; color: var(--muted); text-align: left; font-size: .9rem; }
.shelf-nav[aria-current="page"] { background: var(--accent-soft); color: var(--accent-text); }
.nav-count { margin-left: auto; font-size: .73rem; font-variant-numeric: tabular-nums; }
.side-label { font-size: .73rem; color: var(--subtle); letter-spacing: .05em; margin: 32px 12px 12px; }
.sidebar nav { flex: 1; min-height: 0; overflow: auto; scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
.thread-button { display: block; width: 100%; min-height: 62px; text-align: left; color: var(--muted); border: 0; background: transparent; border-radius: 9px; margin: 4px 0; padding: 12px; }
.thread-button.active { color: var(--accent-text); background: var(--accent-soft); }
.thread-button strong { display: block; font-size: .86rem; font-weight: 500; text-overflow: ellipsis; overflow: hidden; white-space: nowrap; }
.thread-button small { display: block; font-size: .7rem; margin-top: 7px; color: var(--subtle); }
.thread-button:focus-visible, .quick-prompts button:focus-visible { outline-offset: -3px; }
.thread-empty { font-size: .8rem; line-height: 1.85; padding: 5px 12px; color: var(--muted); }
body.panel-open { overflow: hidden; }
.side-bottom { display: grid; gap: 14px; padding-top: 16px; margin-top: 16px; border-top: 1px solid var(--line); }
.side-bottom .plain-button { display: flex; align-items: center; justify-content: space-between; }
.private-label { padding-left: 11px; color: var(--muted); font-size: .7rem; display: flex; align-items: center; gap: 7px; }
.privacy-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--accent); }
.main { flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; background: var(--paper); }
.topbar { height: 76px; min-height: 76px; display: flex; align-items: center; justify-content: space-between; padding: 0 36px; border-bottom: 1px solid var(--line); gap: 16px; }
.page-heading { display: flex; align-items: center; gap: 10px; min-width: 0; color: var(--muted); font-size: .9rem; }
.page-heading > span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-actions { display: flex; align-items: center; gap: 13px; flex-shrink: 0; }
.status-pill { display: flex; align-items: center; gap: 7px; font-size: .7rem; color: var(--muted); white-space: nowrap; }
.status-pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--subtle); }
.status-pill.online::before { background: var(--accent); }
.display-button { display: flex; align-items: center; gap: 7px; min-width: 40px; min-height: 40px; padding: 8px 10px; border: 1px solid var(--line); background: var(--surface); color: var(--muted); border-radius: 9px; }
.display-button > span:first-child { font-family: Georgia, serif; font-size: 1rem; }
.display-button .control-label { font-size: .76rem; }
.materials-toggle { display: flex; align-items: center; gap: 7px; border: 1px solid var(--line); background: var(--surface); }
.materials-toggle[aria-expanded="true"] { border-color: var(--focus); color: var(--accent-text); }
.welcome { flex: 1; min-height: 0; overflow: auto; width: 100%; max-width: 1300px; padding: 46px clamp(28px,4vw,58px) 65px; margin: 0 auto; scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
.welcome-opening { display: grid; grid-template-columns: .85fr 1.15fr; align-items: center; gap: 42px; }
.welcome-heading h1 { font-family: var(--font-book); font-weight: 550; font-size: clamp(2.15rem,3vw,2.65rem); line-height: 1.45; letter-spacing: -.025em; margin: 19px 0 16px; text-wrap: balance; }
.welcome-heading p { color: var(--muted); line-height: 1.95; font-size: .92rem; margin: 0; }
.intro-note { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: .76rem; margin-top: 26px; }
.intro-note > span { font-size: 1rem; color: var(--accent); }
#start-form { background: var(--surface); border: 1px solid var(--line); border-radius: 15px; padding: 14px 18px; box-shadow: var(--shadow); }
#start-form:focus-within { border-color: var(--focus); box-shadow: 0 0 0 3px var(--accent-soft); }
.mode-tabs { display: flex; gap: 3px; padding: 4px; border-radius: 9px; background: var(--soft); }
.mode-tabs button { flex: 1; white-space: nowrap; border: 0; border-radius: 7px; background: transparent; color: var(--muted); font-size: .79rem; min-height: 38px; padding: 8px 5px; }
.mode-tabs button[aria-selected="true"] { color: var(--accent-text); background: var(--surface); box-shadow: 0 1px 4px #1f38250c; font-weight: 600; }
#reading-prompt { display: block; width: 100%; border: 0; background: transparent; padding: 18px 2px; min-height: 100px; max-height: 250px; resize: vertical; font-size: .92rem; line-height: 1.85; }
#reading-prompt:focus-visible { outline-offset: -4px; border-radius: 8px; }
.start-controls { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 10px; border-top: 1px solid var(--line); }
.start-controls label { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: .76rem; min-width: 0; }
select { color: var(--ink); background: transparent; border: 0; border-radius: 5px; font-size: .8rem; padding: 9px 2px; max-width: 170px; cursor: pointer; }
.bookshelf { margin-top: 48px; scroll-margin-top: 24px; }
.bookshelf-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 22px; }
.bookshelf-heading h2 { font-family: var(--font-book); font-weight: 550; font-size: 1.85rem; line-height: 1.4; margin: 9px 0 0; }
.bookshelf-heading h2 > span { vertical-align: middle; display: inline-flex; font-family: var(--font-ui); color: var(--muted); font-size: .73rem; font-weight: 400; margin-left: 12px; padding: 3px 9px; border-radius: 20px; border: 1px solid var(--line); }
.bookshelf-heading p { font-size: .8rem; line-height: 1.8; margin: 0 0 5px; color: var(--muted); }
.bookshelf-list { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 16px; counter-reset: book; }
.shelf-card { counter-increment: book; display: flex; flex-direction: column; min-width: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 13px; padding: 20px 21px 14px; }
.shelf-meta { display: flex; align-items: center; gap: 8px; min-height: 22px; margin-bottom: 17px; font-size: .66rem; }
.shelf-meta::before { content: counter(book,decimal-leading-zero); color: var(--muted); font-size: .67rem; font-variant-numeric: tabular-nums; padding-right: 8px; border-right: 1px solid var(--line); }
.shelf-category { color: var(--accent-text); font-weight: 500; }
.shelf-reading-status { margin-left: auto; color: var(--muted); white-space: nowrap; }
.shelf-reading-status.started { color: var(--accent-text); }
.shelf-card h3 { font-family: var(--font-book); font-size: 1.3rem; font-weight: 600; line-height: 1.55; margin: 0; text-wrap: balance; overflow-wrap: anywhere; }
.shelf-original { font-family: Georgia,serif; font-size: .77rem; color: var(--muted); line-height: 1.6; margin: 4px 0 0; }
.shelf-author { font-size: .73rem; line-height: 1.65; margin: 9px 0 0; color: var(--muted); overflow-wrap: anywhere; }
.shelf-description { font-size: .8rem; line-height: 1.8; color: var(--muted); margin: 15px 0 21px; }
.shelf-actions { margin-top: auto; border-top: 1px solid var(--line); padding-top: 8px; display: flex; align-items: center; justify-content: space-between; gap: 9px; }
.shelf-start { display: flex; align-items: center; justify-content: center; min-height: 38px; padding: 8px 0; border: 0; border-radius: 7px; color: var(--accent-text); background: transparent; font-size: .8rem; font-weight: 600; white-space: nowrap; }
.shelf-actions a { display: flex; align-items: center; min-height: 38px; font-size: .69rem; color: var(--muted); white-space: nowrap; }
.shelf-note, .shelf-empty { font-size: .75rem; line-height: 1.85; margin: 17px 0 0; color: var(--muted); }
.shelf-empty { grid-column: 1/-1; padding: 18px 0; }
.reading-methods { margin-top: 36px; border-top: 1px solid var(--line); }
.reading-methods summary { list-style: none; display: flex; justify-content: space-between; align-items: center; padding: 21px 0; min-height: 50px; cursor: pointer; color: var(--muted); font-size: .83rem; }
.reading-methods summary::-webkit-details-marker { display: none; }
.reading-methods summary > span { color: var(--accent-text); }
.reading-methods[open] summary > span { transform: rotate(45deg); }
.method-cards { display: grid; grid-template-columns: repeat(3,1fr); gap: 27px; padding: 7px 0 12px; }
.method-number { font-family: Georgia,serif; font-size: .9rem; color: var(--accent-text); }
.method-cards h3 { font-size: .88rem; font-weight: 600; margin: 12px 0 8px; }
.method-cards p { color: var(--muted); font-size: .8rem; line-height: 1.85; }
.method-cards a { color: var(--link); font-size: .71rem; line-height: 1.8; }
.method-note { color: var(--muted); font-size: .72rem; line-height: 1.8; }
.reading { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.messages { flex: 1; min-height: 0; overflow: auto; padding: 26px max(28px,calc((100% - 720px)/2)) 22px; scrollbar-width: thin; scrollbar-color: var(--line) transparent; scroll-padding-top: 25px; }
.message { line-height: 1.95; font-size: var(--reading-font-size); overflow-wrap: anywhere; margin: 22px 0 40px; color: var(--ink); }
.message-label { display: flex; align-items: center; gap: 10px; color: var(--accent-text); font-size: .76rem; font-weight: 600; margin-bottom: 14px; }
.message-label small { color: var(--muted); font-size: .68rem; font-weight: 400; }
.message.user { background: var(--accent-soft); max-width: 92%; margin-left: auto; border-radius: 15px 15px 4px 15px; padding: 17px 22px; font-size: calc(var(--reading-font-size) - 1px); }
.message.user .message-label { margin-bottom: 7px; }
.reading-request-details { margin-top: 10px; font-size: .76rem; color: var(--muted); }
.reading-request-details summary { cursor: pointer; min-height: 34px; display: flex; align-items: center; gap: 7px; }
.reading-request-details summary::after { content: "＋"; font-size: .85rem; color: var(--accent-text); }
.reading-request-details[open] summary::after { content: "−"; }
.reading-request-details .message-body { margin-top: 8px; font-size: .8rem; line-height: 1.85; }
.message p { margin: 0 0 1.15em; }
.message p:last-child { margin-bottom: 0; }
.message h3 { font-family: var(--font-book); font-size: 1.17em; font-weight: 600; line-height: 1.6; margin: 1.6em 0 .75em; text-wrap: balance; }
.message h3:first-child { margin-top: 0; }
.message strong { font-weight: 650; }
.message ul, .message ol { padding-left: 1.4em; margin: .75em 0 1.15em; }
.message li { padding-left: .25em; margin: .4em 0; }
.message li::marker { color: var(--accent-text); }
.message blockquote { margin: 1.2em 0; border-left: 3px solid var(--focus); background: var(--soft); border-radius: 0 8px 8px 0; padding: .7em 1em; color: var(--muted); font-size: .96em; }
.message a { text-decoration: underline; text-decoration-color: var(--focus); }
.message code { padding: .1em .35em; border-radius: 4px; background: var(--soft); font-size: .85em; font-family: ui-monospace,SFMono-Regular,Consolas,monospace; }
.message pre { background: var(--soft); border: 1px solid var(--line); border-radius: 9px; padding: 15px; overflow-x: auto; font-size: .85em; line-height: 1.7; }
.message pre code { padding: 0; background: transparent; }
.table-scroll { max-width: 100%; overflow-x: auto; border: 1px solid var(--line); border-radius: 9px; margin: 1.2em 0; }
.table-scroll:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }
.message table { width: 100%; border-collapse: collapse; text-align: left; font-size: .85em; line-height: 1.8; }
.message th { background: var(--soft); font-weight: 600; }
.message th, .message td { min-width: 100px; padding: 10px 13px; border-bottom: 1px solid var(--line); vertical-align: top; }
.message tbody tr:last-child td { border-bottom: 0; }
.message-basis { border-top: 1px solid var(--line); margin-top: 23px; padding-top: 12px; color: var(--muted); font-size: .71rem; line-height: 1.85; }
.message-sources { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 9px; }
.message-sources a { font-size: .7rem; line-height: 1.75; text-decoration: none; padding: 5px 8px; border: 1px solid var(--line); background: var(--surface); border-radius: 6px; }
.composer-wrap { background: var(--paper); border-top: 1px solid var(--line); padding: 12px max(28px,calc((100% - 720px)/2)) 16px; }
.quick-prompts { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 12px; }
.quick-prompts button { min-height: 34px; padding: 7px 11px; color: var(--muted); background: var(--surface); border: 1px solid var(--line); border-radius: 20px; font-size: .74rem; }
.quick-prompts button > span { margin-left: 5px; }
.composer { display: flex; align-items: flex-end; gap: 12px; padding: 10px 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 15px; box-shadow: var(--shadow); }
.composer:focus-within { border-color: var(--focus); box-shadow: 0 0 0 3px var(--accent-soft); }
.composer textarea { flex: 1; min-width: 0; resize: none; border: 0; background: transparent; min-height: 64px; max-height: 160px; padding: 8px 2px; font-size: 1rem; line-height: 1.75; }
.composer textarea:focus-visible { outline-offset: -3px; border-radius: 7px; }
.composer .primary { min-width: 78px; padding: 10px 13px; }
.composer .primary > span { margin-left: 6px; }
.composer-note { display: flex; justify-content: space-between; gap: 12px; font-size: .69rem; line-height: 1.8; color: var(--muted); margin: 10px 1px 0; }
.job-state { min-height: 38px; display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: .8rem; line-height: 1.7; color: var(--accent-text); padding: 5px 0 12px; }
.job-state button { border: 1px solid var(--line); border-radius: 7px; min-height: 36px; padding: 7px 12px; color: var(--accent-text); background: var(--surface); font-size: .78rem; white-space: nowrap; }
.materials { flex: 0 0 292px; width: 292px; min-height: 0; padding: 28px 22px; border-left: 1px solid var(--line); background: var(--surface); overflow: auto; scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
.materials-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 23px; gap: 8px; }
.materials-head .eyebrow { font-size: .67rem; }
.materials h2 { font-family: var(--font-book); font-size: 1.3rem; font-weight: 600; margin: 8px 0 0; }
.materials h3 { font-size: .81rem; margin: 26px 0 11px; font-weight: 600; }
.materials p { font-size: .82rem; color: var(--muted); line-height: 1.85; }
.book-card { padding: 14px 0; border-bottom: 1px solid var(--line); }
.book-card strong { font-family: var(--font-book); font-size: 1.07rem; line-height: 1.6; font-weight: 600; }
.book-card .author { font-size: .73rem; color: var(--muted); margin-top: 8px; }
.book-card p { font-size: .77rem; margin: 10px 0; }
.book-card a { font-size: .75rem; }
.step { display: flex; align-items: flex-start; gap: 10px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.step input { width: 18px; height: 18px; flex-shrink: 0; margin: 4px 0 0; accent-color: var(--accent); }
.step label { font-size: .8rem; line-height: 1.8; cursor: pointer; }
.step small { display: block; font-size: .74rem; line-height: 1.8; color: var(--muted); margin-top: 5px; }
.progress-track { height: 5px; border-radius: 8px; background: var(--soft); overflow: hidden; margin: 12px 0; }
.progress-track > span { display: block; height: 100%; background: var(--accent); }
.materials .source-note { font-size: .71rem; line-height: 1.9; color: var(--muted); padding-top: 13px; }
.panel-backdrop { position: fixed; inset: 0; border: 0; border-radius: 0; background: #14231866; backdrop-filter: blur(2px); z-index: 7; touch-action: none; }
.panel-backdrop:active { transform: none !important; }
dialog { max-height: calc(100dvh - 40px); width: calc(100% - 32px); max-width: 530px; color: var(--ink); border: 1px solid var(--line); background: var(--surface); border-radius: 18px; box-shadow: 0 30px 110px #13271b26; padding: 27px; overflow: auto; }
dialog::backdrop { background: #14231866; backdrop-filter: blur(3px); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 15px; }
.dialog-head h2 { font-family: var(--font-book); font-size: 1.45rem; font-weight: 600; margin: 0; }
.dialog-head .eyebrow { font-size: .7rem; display: block; margin-bottom: 7px; }
dialog p { color: var(--muted); font-size: .83rem; line-height: 1.85; }
dialog h3 { font-size: .87rem; margin: 27px 0 12px; }
.device-row { display: flex; align-items: center; justify-content: space-between; padding: 13px 0; border-bottom: 1px solid var(--line); gap: 14px; font-size: .83rem; }
.device-row small { display: block; color: var(--muted); font-size: .71rem; line-height: 1.7; margin-top: 6px; }
.device-row button { min-height: 36px; background: var(--danger-soft); color: var(--danger); border: 1px solid var(--line); font-size: .74rem; padding: 7px 10px; border-radius: 7px; white-space: nowrap; }
.ip-tag { display: inline-block; background: var(--soft); color: var(--muted); border-radius: 7px; font-size: .8rem; padding: 7px 9px; margin: 4px 4px 4px 0; overflow-wrap: anywhere; }
.inline-form { display: flex; gap: 9px; margin-top: 9px; }
.inline-form input { width: 100%; min-width: 0; border: 1px solid var(--line); background: var(--paper); border-radius: 8px; padding: 10px; font-size: .87rem; }
.inline-form button { white-space: nowrap; }
#ip-form label { color: var(--muted); font-size: .8rem; }
.danger { min-height: 43px; padding: 10px 14px; border-radius: 8px; border: 1px solid var(--line); color: var(--danger); background: var(--danger-soft); margin-top: 23px; font-size: .82rem; }
.reading-settings-dialog { max-width: 415px; }
.reading-settings-dialog fieldset { border: 0; padding: 0; margin: 26px 0 0; }
.reading-settings-dialog legend { font-size: .83rem; margin-bottom: 11px; color: var(--muted); }
.preference-options { display: grid; grid-template-columns: repeat(3,1fr); gap: 9px; }
.preference-options label { position: relative; cursor: pointer; }
.preference-options input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.preference-options label > span { min-height: 78px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 13px 8px; border: 1px solid var(--line); border-radius: 11px; color: var(--muted); font-size: .74rem; }
.preference-options input:checked + span { background: var(--accent-soft); border-color: var(--focus); color: var(--accent-text); }
.preference-options input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 3px; }
.size-options b { font-family: Georgia,serif; font-size: 18px; font-weight: 400; }
.size-options label:nth-child(2) b { font-size: 23px; }
.size-options label:nth-child(3) b { font-size: 28px; }
.theme-options { grid-template-columns: 1fr 1fr; }
.theme-options label > span { flex-direction: row; min-height: 58px; font-size: .85rem; }
.theme-swatch { width: 23px; height: 23px; border: 1px solid #98a690; border-radius: 50%; }
.paper-swatch { background: #f8f9f4; }
.night-swatch { background: #18211d; }
.preference-note { font-size: .73rem; margin: 22px 0 0; }
.toast { position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%); max-width: calc(100vw - 32px); padding: 13px 19px; background: var(--ink); color: var(--paper); border: 1px solid var(--line); border-radius: 11px; box-shadow: 0 7px 35px #112b1725; font-size: .83rem; line-height: 1.8; z-index: 25; }
@media (hover:hover) and (pointer:fine) {
  .primary:hover:not(:disabled) { background: var(--accent-hover); }
  .secondary:hover, .icon-button:hover, .plain-button:hover, .display-button:hover, .new-button:hover { background: var(--accent-soft); border-color: var(--focus); color: var(--accent-text); }
  .thread-button:hover, .shelf-nav:hover { background: var(--accent-soft); color: var(--accent-text); }
  .shelf-card:focus-within { border-color: var(--focus); }
  .shelf-start:hover:not(:disabled), .quick-prompts button:hover { color: var(--accent-text); text-decoration: underline; text-underline-offset: 4px; }
}
@media (min-width:1600px) { .sidebar { width: 256px; flex-basis: 256px; } .materials { width: 310px; flex-basis: 310px; } }
@media (max-width:1200px) {
  .materials { position: fixed; top: 0; right: 0; bottom: 0; width: 325px; max-width: 90vw; z-index: 8; border-radius: 16px 0 0 16px; box-shadow: -10px 0 55px #13281b18; padding-top: 26px; }
  .topbar { padding: 0 26px; }
  .welcome { padding: 38px 30px 55px; }
  .welcome-opening { gap: 27px; grid-template-columns: .8fr 1.2fr; }
  .welcome-heading h1 { font-size: 2.1rem; }
  .welcome-heading p { font-size: .87rem; }
  .bookshelf-list { grid-template-columns: repeat(2,minmax(0,1fr)); }
}
@media (max-width:960px) and (min-width:761px) {
  .sidebar { flex-basis: 212px; width: 212px; padding-left: 12px; padding-right: 12px; }
  .side-top { padding-left: 7px; padding-right: 7px; }
  .welcome-opening { grid-template-columns: 1fr; gap: 25px; }
  .intro-note { display: none; }
  .welcome-heading h1 { margin-top: 12px; }
  .top-actions { gap: 8px; }
  .display-button .control-label { display: none; }
}
@media (max-width:760px) {
  .mobile-only { display: grid; }
  .icon-button.mobile-only { display: grid; }
  .auth-shell { display: block; }
  .auth-intro { padding: 25px; }
  .auth-summary { padding: 31px 0 10px; }
  .auth-summary h1 { font-size: 2.25rem; margin: 15px 0; }
  .auth-summary h1 br { display: none; }
  .auth-summary p { font-size: .9rem; }
  .auth-intro small, .auth-features { display: none; }
  .auth-form-area { padding: 35px 25px 45px; }
  .auth-form-area h2 { font-size: 1.8rem; }
  .auth-form-area input { font-size: 1rem; }
  .sidebar { position: fixed; inset: 0 auto 0 0; z-index: 8; width: min(295px,85vw); transform: translateX(-100%); transition: transform 200ms var(--ease-out); border-radius: 0 15px 15px 0; padding: 25px 18px; visibility: hidden; }
  .sidebar.open { transform: translateX(0); visibility: visible; }
  .side-top { padding: 0 10px 24px; }
  .sidebar .wordmark { font-size: 1rem; }
  .sidebar .side-label { margin-top: 24px; }
  .topbar { height: 64px; min-height: 64px; padding: 0 15px 0 8px; gap: 8px; }
  .page-heading { gap: 3px; font-size: .81rem; }
  .page-heading > span { max-width: 25vw; }
  .top-actions { gap: 7px; }
  .status-pill { font-size: .6875rem; gap: 5px; }
  .status-pill::before { width: 5px; height: 5px; }
  .display-button, .materials-toggle { width: 38px; min-width: 38px; height: 38px; min-height: 38px; padding: 8px; justify-content: center; }
  .top-actions .control-label { display: none; }
  .welcome { padding: 30px 20px 45px; }
  .welcome-opening { grid-template-columns: 1fr; gap: 25px; }
  .welcome-heading h1 { font-size: 2.05rem; margin: 13px 0 11px; }
  .welcome-heading p { font-size: .86rem; }
  .intro-note { display: none; }
  #start-form { padding: 12px 14px; }
  .mode-tabs button { font-size: .75rem; min-height: 40px; }
  #reading-prompt { font-size: 1rem; min-height: 98px; padding: 16px 2px; }
  .start-controls { gap: 7px; }
  .start-controls label { gap: 5px; }
  select { font-size: .76rem; max-width: 132px; padding: 8px 0; }
  .start-controls .primary { font-size: .8rem; padding: 10px 12px; }
  .start-controls .primary span { margin-left: 4px; }
  .bookshelf { margin-top: 33px; }
  .bookshelf-heading { margin-bottom: 17px; gap: 10px; }
  .bookshelf-heading h2 { font-size: 1.6rem; }
  .bookshelf-heading .eyebrow { font-size: .7rem; letter-spacing: .035em; }
  .bookshelf-heading p { display: none; }
  .bookshelf-list { gap: 12px; }
  .shelf-card { padding: 15px 15px 9px; border-radius: 11px; }
  .shelf-meta { gap: 5px; flex-wrap: wrap; font-size: .7rem; margin-bottom: 12px; }
  .shelf-meta::before { display: none; }
  .shelf-reading-status { font-size: .7rem; }
  .shelf-card h3 { font-size: 1.09rem; line-height: 1.55; }
  .shelf-original { font-size: .75rem; margin-top: 5px; }
  .shelf-author { font-size: .76rem; line-height: 1.75; margin: 9px 0 14px; }
  .shelf-description { display: none; }
  .shelf-actions { flex-direction: column; align-items: stretch; gap: 2px; padding-top: 9px; }
  .shelf-start { font-size: .8rem; min-height: 44px; background: var(--accent-soft); }
  .shelf-actions a { justify-content: center; font-size: .75rem; min-height: 36px; }
  .shelf-note { font-size: .69rem; }
  .reading-methods { margin-top: 29px; }
  .reading-methods summary { font-size: .76rem; }
  .method-cards { grid-template-columns: 1fr; gap: 18px; }
  .method-cards article { display: grid; grid-template-columns: 29px 1fr; gap: 0 5px; }
  .method-number { grid-row: span 3; margin-top: 2px; }
  .method-cards h3 { margin: 0 0 7px; }
  .method-cards p { margin: 0 0 8px; }
  .messages { padding: 16px 22px 17px; }
  .message { margin: 17px 0 30px; line-height: 1.95; }
  .message.user { max-width: 96%; padding: 14px 17px; }
  .message-label { font-size: .72rem; gap: 8px; margin-bottom: 12px; }
  .message-basis { font-size: .75rem; }
  .message-sources a { font-size: .75rem; }
  .composer-wrap { padding: 10px 15px max(12px,env(safe-area-inset-bottom)); }
  .quick-prompts { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding: 2px 0 5px; margin-bottom: 6px; gap: 6px; }
  .quick-prompts::-webkit-scrollbar { display: none; }
  .quick-prompts button { flex-shrink: 0; font-size: .7rem; min-height: 36px; padding: 7px 10px; }
  .composer { gap: 8px; padding: 8px 9px; border-radius: 13px; }
  .composer textarea { min-height: 57px; padding: 6px 2px; font-size: 1rem; }
  .composer .primary { min-width: 61px; padding: 10px; font-size: .8rem; }
  .composer .primary span { margin-left: 3px; }
  .composer-note { font-size: .75rem; margin-top: 8px; }
  .keyboard-note { display: none; }
  .job-state { font-size: .76rem; }
  .materials { width: min(325px,90vw); }
  dialog { padding: 23px; }
}
@media (max-width:359px) {
  .status-pill { max-width: 68px; overflow: hidden; text-overflow: ellipsis; display: block; }
  .status-pill::before { display: none; }
  .shelf-card { padding-left: 12px; padding-right: 12px; }
  .shelf-actions { flex-direction: column; align-items: stretch; gap: 0; }
  .shelf-actions a { justify-content: center; min-height: 36px; }
}
@media (prefers-reduced-motion:reduce) { *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; } }
