:root {
  --bg: #f6f7f4; --surface: #fff; --surface-2: #eef1ec; --ink: #20251f; --muted: #687066;
  --line: #d9ded6; --accent: #176b52; --accent-dark: #10513e; --accent-soft: #dff0e9;
  --danger: #a63c35; --danger-soft: #f8e7e4; --shadow: 0 14px 36px rgba(31, 42, 34, .11);
  --reader-size: 19px; --topbar-h: 68px; --detail-w: 340px; --library-w: 300px;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; min-width: 300px; background: var(--bg); color: var(--ink); font-family: system-ui, -apple-system, "Segoe UI", "Microsoft YaHei", sans-serif; }
button, input { font: inherit; }
button, label { -webkit-tap-highlight-color: transparent; }
button:focus-visible, input:focus-visible, label.button:focus-within, .word:focus-visible { outline: 3px solid rgba(23,107,82,.28); outline-offset: 2px; }
dialog { color: inherit; font: inherit; }
[hidden] { display: none !important; }
.topbar { height: var(--topbar-h); position: sticky; top: 0; z-index: 30; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 0 24px; border-bottom: 1px solid var(--line); background: rgba(246,247,244,.95); backdrop-filter: blur(12px); }
.brand { display: flex; align-items: center; gap: 10px; flex: 0 0 auto; }
.brand-mark { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 7px; background: var(--accent); color: white; font-family: Georgia, serif; font-size: 21px; }
.brand strong, .brand small { display: block; }.brand strong { font-size: 17px; }.brand small { margin-top: 1px; color: var(--muted); font-size: 11px; }
.top-actions { display: flex; align-items: center; gap: 10px; }
.button { min-height: 40px; display: inline-flex; align-items: center; justify-content: center; padding: 8px 14px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--ink); cursor: pointer; text-decoration: none; font-weight: 650; }
.button:hover { border-color: #aab4a8; background: var(--surface-2); }.button:active { transform: translateY(1px); }.button:disabled { cursor: not-allowed; opacity: .55; }
.button.primary { border-color: var(--accent); background: var(--accent); color: white; }.button.primary:hover { background: var(--accent-dark); }.button.large { min-height: 46px; padding-inline: 20px; }
.button.danger { border-color: var(--danger); background: var(--danger); color: white; }
.icon-button { width: 40px; height: 40px; border: 0; background: transparent; border-radius: 6px; color: var(--muted); cursor: pointer; font-size: 24px; }.icon-button:hover { background: var(--surface-2); color: var(--ink); }
.font-control { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 13px; }.font-control input { width: 92px; accent-color: var(--accent); }.font-control output { min-width: 22px; color: var(--ink); font-variant-numeric: tabular-nums; }
.notice { position: fixed; z-index: 70; top: 78px; left: 50%; max-width: min(560px, calc(100vw - 24px)); transform: translateX(-50%); padding: 10px 14px; border: 1px solid var(--line); border-radius: 6px; box-shadow: var(--shadow); background: var(--surface); font-size: 14px; }
.notice.error { color: var(--danger); border-color: #e5b6b1; background: #fff7f6; }
.workspace { min-height: calc(100vh - var(--topbar-h)); }
.library { position: fixed; z-index: 45; top: var(--topbar-h); bottom: 0; left: 0; width: min(var(--library-w), 88vw); padding: 20px 16px; overflow-y: auto; border-right: 1px solid var(--line); background: var(--surface); box-shadow: var(--shadow); transform: translateX(-105%); transition: transform .2s ease; }.library.open { transform: translateX(0); }
.panel-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }.panel-heading h2 { margin: 0; font-size: 18px; }.panel-heading p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.book-list { display: grid; gap: 4px; margin-top: 18px; }.book-item { display: grid; grid-template-columns: minmax(0,1fr) 40px; align-items: center; border-bottom: 1px solid var(--line); }.book-open { min-width: 0; padding: 13px 8px; border: 0; background: transparent; text-align: left; cursor: pointer; }.book-open:hover strong { color: var(--accent); }.book-open strong,.book-open span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }.book-open span { margin-top: 5px; color: var(--muted); font-size: 12px; }.book-delete { border: 0; background: transparent; color: var(--muted); height: 40px; cursor: pointer; border-radius: 5px; }.book-delete:hover { color: var(--danger); background: var(--danger-soft); }
.empty-state { min-height: 210px; display: grid; place-content: center; gap: 7px; text-align: center; color: var(--muted); }.empty-state strong { color: var(--ink); }
.reader-shell { min-height: calc(100vh - var(--topbar-h)); margin-right: var(--detail-w); }
.welcome { max-width: 780px; margin: 0 auto; padding: clamp(70px, 10vw, 132px) 32px 60px; }.eyebrow { margin: 0 0 10px; color: var(--accent); font-size: 12px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }.welcome h1 { max-width: 620px; margin: 0; font-family: Georgia, "Songti SC", serif; font-size: clamp(38px, 6vw, 68px); font-weight: 500; line-height: 1.08; }.welcome > p { max-width: 650px; margin: 24px 0 28px; color: var(--muted); font-size: 17px; line-height: 1.8; }.feature-list { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0; margin: 64px 0 0; padding: 22px 0 0; border-top: 1px solid var(--line); list-style: none; }.feature-list li { padding-right: 20px; }.feature-list strong,.feature-list span { display: block; }.feature-list strong { font-size: 14px; }.feature-list span { margin-top: 6px; color: var(--muted); font-size: 12px; line-height: 1.5; }
.reader { max-width: 850px; margin: 0 auto; padding: 58px clamp(24px, 6vw, 72px) 30vh; }.book-header { margin-bottom: 54px; padding-bottom: 26px; border-bottom: 1px solid var(--line); }.book-header h1 { margin: 9px 0 22px; overflow-wrap: anywhere; font-family: Georgia, "Songti SC", serif; font-size: clamp(31px, 5vw, 50px); font-weight: 500; line-height: 1.15; }.book-header > p { color: var(--muted); font-size: 12px; }.progress-track { height: 3px; background: var(--line); }.progress-track span { display: block; width: 0; height: 100%; background: var(--accent); transition: width .15s linear; }.progress-label { margin: 7px 0 0; text-align: right; font-variant-numeric: tabular-nums; }
.book-content { font-family: Georgia, "Times New Roman", "Songti SC", serif; font-size: var(--reader-size); line-height: 1.9; }.paragraph { margin: 0 0 1.28em; overflow-wrap: anywhere; }.word { display: inline; padding: 1px 0; border-radius: 3px; cursor: pointer; transition: color .12s, background .12s; }.word:hover,.word.active { color: var(--accent-dark); background: var(--accent-soft); }.word:focus { position: relative; }.sentence { scroll-margin-top: 90px; }.render-status { padding: 30px; color: var(--muted); text-align: center; }
.detail-panel { position: fixed; z-index: 25; top: var(--topbar-h); right: 0; bottom: 0; width: var(--detail-w); padding: 24px; overflow-y: auto; border-left: 1px solid var(--line); background: var(--surface); }.detail-handle { display: none; }.detail-panel .panel-heading { padding-bottom: 18px; border-bottom: 1px solid var(--line); }.detail-idle { padding-top: 22px; color: var(--muted); font-size: 14px; line-height: 1.7; }.privacy-note { margin-top: 24px; padding: 12px; border-left: 3px solid var(--accent); background: var(--surface-2); font-size: 12px; }.detail-state { min-height: 240px; display: grid; place-content: center; justify-items: center; text-align: center; color: var(--muted); }.spinner { width: 24px; height: 24px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .75s linear infinite; }.error-state strong { color: var(--danger); }.error-state p { max-width: 260px; font-size: 13px; }.detail-result { padding: 22px 0; overflow-wrap: anywhere; }.result-word { margin: 0; font-family: Georgia, serif; font-size: 31px; }.result-phonetic { margin: 4px 0 18px; color: var(--muted); }.result-section { padding: 16px 0; border-top: 1px solid var(--line); }.result-section h3 { margin: 0 0 8px; color: var(--muted); font-size: 12px; }.result-section p { margin: 0; white-space: pre-wrap; line-height: 1.7; }.stale-badge { display: inline-block; margin-bottom: 14px; padding: 3px 7px; border-radius: 4px; background: #f5e9c9; color: #735b20; font-size: 11px; }
.result-notice p { color: var(--muted); font-size: 12px; }
.history-section { margin-top: 10px; padding-top: 20px; border-top: 1px solid var(--line); }
.history-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 10px; }.history-heading h3 { margin: 0; font-size: 15px; }.history-heading p { margin: 4px 0 0; color: var(--muted); font-size: 11px; overflow-wrap: anywhere; }
.text-button { min-height: 36px; padding: 4px 7px; border: 0; border-radius: 5px; background: transparent; color: var(--accent); cursor: pointer; font-weight: 650; }.text-button:hover { background: var(--surface-2); }.danger-text { color: var(--danger); }
.history-list { display: grid; }.history-item { display: grid; grid-template-columns: minmax(0,1fr) 36px; align-items: center; border-bottom: 1px solid var(--line); }.history-replay { min-width: 0; display: grid; grid-template-columns: auto minmax(0,1fr) auto; align-items: center; gap: 7px; padding: 10px 4px; border: 0; background: transparent; color: var(--ink); text-align: left; cursor: pointer; }.history-replay:hover strong { color: var(--accent); }.history-replay strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }.history-replay small { color: var(--muted); font-size: 10px; white-space: nowrap; }.history-kind { padding: 2px 4px; border: 1px solid var(--line); border-radius: 3px; color: var(--muted); font-size: 10px; line-height: 1.2; }.selection-kind { border-color: #d5c48d; color: #735b20; }.word-kind { border-color: #9bc5b7; color: var(--accent-dark); }.history-delete { width: 36px; height: 36px; border: 0; border-radius: 5px; background: transparent; color: var(--muted); cursor: pointer; font-size: 18px; }.history-delete:hover { background: var(--danger-soft); color: var(--danger); }.history-empty { margin: 12px 0 4px; color: var(--muted); font-size: 12px; }
.dialog-backdrop { position: fixed; z-index: 90; inset: 0; display: grid; place-items: center; padding: 20px; background: rgba(22,28,23,.45); }.dialog { width: min(410px, 100%); padding: 24px; border-radius: 8px; background: var(--surface); box-shadow: var(--shadow); }.dialog h2 { margin: 0; font-size: 20px; }.dialog p { color: var(--muted); line-height: 1.6; }.dialog-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 24px; }
.encoding-dialog { width: min(720px, calc(100vw - 32px)); max-height: min(760px, calc(100vh - 32px)); padding: 0; overflow: hidden; border: 0; border-radius: 10px; background: var(--surface); box-shadow: var(--shadow); }.encoding-dialog::backdrop { background: rgba(22,28,23,.55); }.encoding-dialog form { display: flex; max-height: inherit; flex-direction: column; padding: 24px; }.encoding-dialog h2 { margin: 0; font-size: 22px; }.encoding-dialog form > p { margin: 8px 0 18px; color: var(--muted); line-height: 1.55; }.encoding-candidates { display: grid; gap: 10px; overflow: auto; }.encoding-candidate { display: grid; grid-template-columns: 1fr auto; gap: 4px 14px; width: 100%; padding: 14px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); color: var(--ink); text-align: left; cursor: pointer; }.encoding-candidate:hover,.encoding-candidate:focus-visible { border-color: var(--accent); background: var(--accent-soft); }.encoding-score { color: var(--muted); font-size: 12px; }.encoding-preview { grid-column: 1 / -1; max-height: 150px; margin: 7px 0 0; overflow: hidden; color: var(--muted); font: 13px/1.55 ui-monospace, SFMono-Regular, Consolas, monospace; white-space: pre-wrap; overflow-wrap: anywhere; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (max-width: 850px) {
  :root { --topbar-h: 62px; }.topbar { padding: 0 12px; }.brand small,.font-control > span { display: none; }.font-control input { width: 70px; }.top-actions { gap: 6px; }.button { padding-inline: 10px; }.reader-shell { margin-right: 0; }.reader { padding-top: 38px; }.welcome { padding-inline: 22px; }.feature-list { grid-template-columns: 1fr; gap: 20px; }
  .detail-panel { top: auto; left: 0; right: 0; bottom: 0; width: auto; height: min(58vh, 520px); padding: 12px 20px max(20px, env(safe-area-inset-bottom)); border: 1px solid var(--line); border-bottom: 0; border-radius: 8px 8px 0 0; box-shadow: 0 -12px 36px rgba(31,42,34,.15); transform: translateY(calc(100% - 52px)); transition: transform .2s ease; }.detail-panel.open { transform: translateY(0); }.detail-handle { display: block; width: 38px; height: 4px; margin: 0 auto 10px; border-radius: 3px; background: var(--line); }.detail-panel .panel-heading { padding-bottom: 10px; }.detail-idle,.detail-state,.detail-result { padding-top: 14px; }.detail-state { min-height: 180px; }
}
@media (max-width: 520px) { .brand > div { display: none; }.top-actions { width: calc(100% - 46px); justify-content: flex-end; }.font-control output { display: none; }.welcome h1 { font-size: 40px; }.reader { padding-inline: 20px; }.book-content { line-height: 1.82; }.encoding-dialog { width: calc(100vw - 16px); max-height: calc(100vh - 16px); }.encoding-dialog form { padding: 18px 14px; }.encoding-candidate { grid-template-columns: 1fr; }.encoding-score { grid-row: 2; }.encoding-preview { grid-row: 3; max-height: 120px; } }
@media (prefers-reduced-motion: reduce) { *,*::before,*::after { scroll-behavior: auto !important; transition: none !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; } }
