:root {
  color-scheme: light;
  --paper: #f7f4ec;
  --white: #fffdf7;
  --input: #f9f7ef;
  --ink: #242923;
  --muted: #5f675b;
  --subtle: #6f7669;
  --line: #dbd9cd;
  --green: #264b3c;
  --green-light: #e8eee2;
  --gold: #f5dd84;
  --toolbar-height: 0px;
  --reader-gutter: clamp(14px, 3vw, 32px);
  --serif-cn: "Songti SC", "Noto Serif CJK SC", "STSong", "SimSun", serif;
  --sans-cn: "PingFang SC", "Noto Sans CJK SC", "Microsoft YaHei", sans-serif;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 14px/1.6 var(--sans-cn); }
button, input, textarea { font: inherit; }
button { color: inherit; }
button:enabled { cursor: pointer; }
:is(button, a, summary, input, textarea, [role="button"]):focus-visible { outline: 2px solid #548368; outline-offset: 3px; }
[hidden] { display: none !important; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.brand-mark { display: grid; place-items: center; width: 36px; height: 36px; color: var(--white); background: var(--green); border-radius: 9px; }
.nav-button, .secondary-button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 34px; padding: 4px 10px; background: var(--white);
  border: 1px solid var(--line); border-radius: 7px; color: var(--green);
  font-size: 12px; white-space: nowrap;
}
a.nav-button { text-decoration: none; }
a.nav-button:hover, .nav-button:enabled:hover, .secondary-button:enabled:hover { background: var(--green-light); }
.nav-button:disabled, .secondary-button:disabled { opacity: .55; }

.intro { padding-block: clamp(22px, 4vw, 38px) 18px; }
.eyebrow { display: flex; align-items: center; gap: 9px; color: var(--green); font: 600 11px/1.5 var(--mono); letter-spacing: .19em; }
.eyebrow span { display: inline-block; width: 21px; height: 1px; background: #647d68; }
h1 { font-family: var(--serif-cn); font-size: clamp(35px, 4.25vw, 63px); line-height: 1.24; letter-spacing: -.035em; margin: 12px 0; font-weight: 800; }
h1 span { color: #52715a; }
.intro p { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.8; }

.workspace { display: grid; gap: 16px; align-items: start; }
.panel { background: var(--white); border: 1px solid var(--line); border-radius: 14px; min-width: 0; box-shadow: 0 2px 2px #30281708; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 9px; min-height: 69px; padding-inline: 22px; }
.panel-title { display: flex; align-items: center; gap: 9px; min-width: 0; }
.panel-title h2 { margin: 0; font-size: 17px; font-weight: 650; white-space: nowrap; letter-spacing: .025em; }
.text-button { border: 0; background: transparent; padding: 4px 0; color: var(--green); font-size: 12px; white-space: nowrap; }
.text-button:enabled:hover { text-decoration: underline; text-underline-offset: 4px; }
.text-button:disabled { opacity: .6; }
.text-button span { margin-left: 1px; }

#translate-form, #url-form { margin: 0; padding: 0 var(--reader-gutter) var(--reader-gutter); }
.source-mode { margin: 0 var(--reader-gutter) 16px; }
.source-actions { display: flex; align-items: center; gap: 14px; }
.source-actions .text-button { min-height: 40px; }
.field-error { margin-bottom: 12px; }
[aria-invalid="true"] { border-color: #a55040 !important; }
#url-form label { display: block; margin-bottom: 5px; font-size: 13px; font-weight: 650; }
#article-url {
  display: block;
  width: 100%;
  padding: 10px 12px;
  color: var(--ink);
  background: var(--input);
  border: 1px solid var(--line);
  border-radius: 8px;
}
#url-form .sheet-note { margin: 7px 0 14px; }
.article-meta { display: flex; align-items: center; gap: 12px; }
.article-meta:has(> :not([hidden])) { margin-top: 8px; }
.article-meta a, .sheet-note a { color: var(--green); text-underline-offset: 3px; }
#page-title { overflow-wrap: anywhere; }
textarea {
  display: block;
  width: 100%;
  height: 270px;
  min-height: 145px;
  resize: vertical;
  padding: 14px 15px;
  color: var(--ink);
  background: var(--input);
  border: 1px solid var(--line);
  border-radius: 8px;
  font: 16px/1.62 Georgia, "Times New Roman", serif;
}
textarea::placeholder { color: var(--subtle); }
textarea:focus-visible { outline-offset: 1px; }
.input-meta { display: flex; justify-content: space-between; gap: 8px; margin: 10px 0 16px; color: var(--subtle); font-size: 11px; }
#source-count { font-family: var(--mono); white-space: nowrap; }
.translate-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  min-height: 47px;
  padding: 9px 15px;
  color: #fffdf5;
  background: var(--green);
  border: 0;
  border-radius: 7px;
  font-weight: 600;
  letter-spacing: .04em;
  transition: background .16s ease;
}
.translate-button:enabled:hover { background: #35604c; }
.translate-button:disabled { opacity: .78; }
.spinner { display: none; width: 15px; height: 15px; border: 2px solid #ffffff66; border-right-color: #fff; border-radius: 50%; animation: spin .8s linear infinite; }
form[aria-busy="true"] .spinner { display: block; }
form[aria-busy="true"] .button-arrow { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.request-status { font-size: 12px; margin: 0; color: var(--muted); }
.job-status { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.request-status[data-kind="error"] { color: #9a4033; }
.request-status[data-kind="success"] { color: var(--green); }

.reading-panel { container: reader / inline-size; }
.reading-head {
  position: sticky;
  top: var(--toolbar-height);
  z-index: 3;
  flex-wrap: wrap;
  padding: 8px var(--reader-gutter);
  min-height: 60px;
  border-bottom: 1px solid var(--line);
  border-radius: 13px 13px 0 0;
  background: var(--white);
}
.result-kind { color: var(--muted); font-size: 12px; white-space: nowrap; }
.segmented-control { display: inline-flex; width: fit-content; gap: 2px; padding: 3px; border: 1px solid var(--line); border-radius: 9px; background: var(--input); }
.segmented-control button { min-width: 46px; min-height: 40px; padding: 3px 10px; border: 0; border-radius: 6px; background: transparent; color: var(--muted); white-space: nowrap; font-weight: 600; }
.segmented-control button:enabled:not([aria-pressed="true"]):hover { background: var(--green-light); }
.segmented-control button[aria-pressed="true"] { background: var(--green); color: var(--white); }
.segmented-control button:disabled { opacity: .5; }
.reading-panel[data-view="original"] :is(.chinese, .reading-columns div:last-child),
.reading-panel[data-view="translation"] :is(.english, .reading-columns div:first-child) { display: none; }
.reading-panel:not([data-view="parallel"]) :is(.reading-columns, .paragraph) { grid-template-columns: minmax(0, 1fr); }
.reading-panel[data-view="translation"] :is(.chinese, .reading-columns div:last-child) { border-left: 0; }
.reading-columns, .paragraph { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.reading-columns { border-bottom: 1px solid var(--line); background: #f8f6ee; }
.reading-columns div { display: flex; align-items: center; gap: 8px; padding: 9px 22px; color: var(--muted); font-size: 12px; }
.reading-columns div + div, .chinese { border-left: 1px solid var(--line); }
.reading-columns b { display: grid; place-items: center; width: 24px; height: 22px; border: 1px solid var(--line); border-radius: 4px; color: var(--green); font: 600 10px/1 var(--mono); background: var(--white); }
.paragraph + .paragraph { border-top: 1px solid var(--line); }
.article-image { display: grid; justify-items: center; margin: 0; padding: 18px clamp(12px, 3vw, 22px); border-block: 1px solid var(--line); }
.article-image + .article-image { border-top: 0; }
.article-image img { display: block; max-width: 100%; height: auto; }
.paragraph > :is(.english, .chinese) { margin: 0; padding: 16px var(--reader-gutter) 19px; white-space: pre-wrap; overflow-wrap: anywhere; }
.reading-panel[data-view="original"] .english { width: min(100%, 68ch); margin-inline: auto; }
.reading-panel[data-view="translation"] .chinese { width: min(100%, 42em); margin-inline: auto; }
.chinese { line-break: strict; }
.language-tag { display: none; }
.english { font: 19px/1.72 Georgia, "Times New Roman", serif; }
.chinese { font: 17px/1.95 var(--serif-cn); }
.paragraph > :is(h2, h3, h4, h5, h6) { color: var(--green); font-weight: 700; line-height: 1.36; }
.paragraph > h2 { font-size: clamp(23px, 3.6vw, 33px); }
.paragraph > h3 { font-size: clamp(20px, 2.9vw, 27px); }
.paragraph > :is(h4, h5, h6) { font-size: clamp(17px, 2.5vw, 22px); }
.paragraph[data-block="quote"] { border-inline-start: 3px solid #a9bba7; background: #f5f7ef; }
.paragraph[data-block="caption"] > :is(.english, .chinese) { color: var(--muted); font-size: 14px; }
.paragraph[data-block="code"] > :is(.english, .chinese) { font-family: var(--mono); font-size: 14px; background: #f5f3e9; }
.paragraph[data-block="list"] > :is(.english, .chinese)::before { content: '•'; color: var(--green); margin-inline-end: 8px; }
.alignment {
  display: inline;
  padding: 0;
  border: 0;
  border-radius: 2px;
  background: transparent;
  font: inherit;
  color: inherit;
  text-align: inherit;
  white-space: inherit;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}
.alignment.highlighted { background: var(--gold); box-shadow: 1px 0 var(--gold), -1px 0 var(--gold); }
.alignment:focus-visible { outline-offset: 1px; position: relative; }
.alignment[aria-pressed="true"] { text-decoration: underline; text-decoration-color: #88642c; text-underline-offset: .16em; }
@container reader (width < 690px) {
  .reading-panel[data-view="parallel"] .reading-columns { display: none; }
  .paragraph { grid-template-columns: minmax(0, 1fr); }
  .paragraph > .chinese { border-left: 0; }
  .reading-panel[data-view="parallel"] .chinese { background: #f7f5ec; }
  .reading-panel[data-view="parallel"] .language-tag {
    display: block;
    width: fit-content;
    margin-bottom: 6px;
    color: var(--green);
    font: 650 11px/1.4 var(--sans-cn);
    letter-spacing: .08em;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

.word-unit { white-space: nowrap; }
.word:hover { text-decoration: underline; text-decoration-color: #927549; text-underline-offset: .18em; }
.sheet {
  width: min(490px, calc(100% - 28px));
  max-height: calc(100dvh - 32px);
  padding: 0;
  color: var(--ink);
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 16px 60px #24292340;
  overflow: auto;
}
.sheet::backdrop { background: #292c2594; }
.sheet-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  padding: 19px 22px 15px;
  background: var(--input);
  border-bottom: 1px solid var(--line);
}
.sheet-head h2 { margin: 2px 0 0; font: 700 25px/1.25 var(--serif-cn); overflow-wrap: anywhere; }
.sheet-kicker { color: var(--green); font-size: 11px; letter-spacing: .12em; }
.icon-button {
  flex: none;
  width: 32px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--white);
  color: var(--green);
  font: 22px/1 Georgia, serif;
}
.icon-button:hover { background: var(--green-light); }
.sheet-body { padding: 17px 22px 22px; }
.sheet-note, .sheet-status { color: var(--muted); font-size: 12px; margin: 0; }
.sheet-status:empty { display: none; }
.sheet-status[data-error="true"] { color: #9a4033; }
.word-sheet { width: min(410px, calc(100% - 28px)); }
.word-sheet h2 { font: 700 34px/1.18 Georgia, serif; }
.word-meta { color: var(--muted); font: 14px/1.5 Georgia, var(--sans-cn); margin: 4px 0 0; overflow-wrap: anywhere; }
.word-context { display: flex; align-items: baseline; gap: 9px; margin-bottom: 13px; }
.word-context span { flex: none; color: #6b5225; background: #f8ebbb; padding: 2px 6px; border-radius: 4px; font-size: 11px; }
.word-context p { margin: 0; color: var(--muted); font: 15px/1.55 var(--serif-cn); overflow-wrap: anywhere; }
.word-definition { margin-bottom: 12px; white-space: pre-line; overflow-wrap: anywhere; font: 17px/1.7 var(--serif-cn); }
.history-list { list-style: none; padding: 0; margin: 0; }
.history-record { display: block; width: 100%; padding: 10px 7px; text-align: left; background: none; border: 0; border-radius: 5px; }
.history-record:enabled:hover { background: var(--input); }
.history-record:disabled { opacity: .65; }
.history-record strong { display: block; color: var(--ink); font: 17px/1.4 Georgia, serif; overflow-wrap: anywhere; }
.history-info { display: flex; align-items: baseline; gap: 4px 7px; flex-wrap: wrap; margin-top: 4px; color: var(--muted); font-size: 11px; }
.history-info > * { white-space: nowrap; }
.history-state { padding: 1px 5px; border-radius: 4px; background: #f4f1e4; color: #61542f; }
.history-state[data-state="complete"] { background: #f3f6ee; color: var(--green); }
.history-state[data-state="failed"] { background: #f5e8e1; color: #8b4033; }
.history-pinned::before { content: '◆'; margin-right: 5px; color: var(--green); font-size: 9px; }
#history-more { margin-top: 12px; }
#history-status:not([hidden]) + .history-list:not(:empty) { margin-top: 10px; }
.settings-form fieldset { margin: 14px 0 0; padding: 0; border: 0; min-width: 0; }
.settings-form label:not(.check-label) { display: block; margin: 11px 0 4px; color: var(--ink); font-size: 13px; font-weight: 600; }
.settings-form input:not([type="checkbox"]) {
  display: block;
  width: 100%;
  padding: 8px 10px;
  color: var(--ink);
  background: var(--input);
  border: 1px solid var(--line);
  border-radius: 6px;
}
#key-hint, #settings-status { margin-top: 7px; }
.check-label { display: flex; gap: 6px; align-items: center; margin-top: 9px; font-size: 12px; }
.check-label input { accent-color: var(--green); }
.settings-save { margin-top: 14px; justify-content: center; }

/* Reading workspace and account screens */
.boot-status { margin: 44px auto; text-align: center; color: var(--muted); }
.auth-view { min-height: 100dvh; display: grid; place-items: center; padding: 24px; background: radial-gradient(ellipse at 20% 15%, #e5ebdc, transparent 48%), var(--paper); }
.auth-card { width: min(100%, 440px); padding: clamp(24px, 6vw, 44px); border: 1px solid var(--line); border-radius: 18px; background: var(--white); box-shadow: 0 16px 40px #2a332012; }
.auth-card h1 { font-size: 44px; }
.auth-card > p { color: var(--muted); margin: 0 0 22px; }
.auth-card legend { color: var(--green); font-size: 17px; font-weight: 650; }
#auth-toggle { margin-top: 12px; }
#auth-status { margin-top: 8px; }

.reader-shell { --sidebar-width: clamp(224px, 19vw, 264px); display: grid; grid-template-columns: var(--sidebar-width) minmax(0, 1fr); min-height: 100dvh; }
.sidebar { position: sticky; top: 0; height: 100dvh; display: flex; flex-direction: column; gap: 15px; padding: 16px 13px 12px; background: #e9ede2; border-right: 1px solid #d6dbce; }
.sidebar-brand { display: flex; align-items: center; gap: 9px; padding: 2px 5px; color: var(--green); font-weight: 700; letter-spacing: .08em; }
.sidebar-brand .brand-mark { width: 33px; height: 33px; flex: none; }
.new-reading { display: flex; align-items: center; gap: 7px; padding: 8px 10px; border: 1px solid #bdcbbd; border-radius: 8px; background: #f3f6ed; color: var(--green); text-align: left; font-weight: 650; }
.new-reading:hover { background: #fffdf7; }
.sidebar-nav { display: grid; gap: 2px; margin-block: -7px -3px; }
.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 38px;
  padding: 7px 10px;
  border-radius: 8px;
  color: var(--green);
  font-weight: 600;
  text-decoration: none;
}
.sidebar-nav svg { width: 17px; height: 17px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.sidebar-nav a:hover { background: #f3f6ed; }
.sidebar-nav a[aria-current="page"] { background: #d9e5d7; }
.sidebar-history { overscroll-behavior: contain; flex: 1 1 auto; overflow: auto; min-height: 0; padding: 0 1px 10px; }
.sidebar-history h2 { margin: 4px 6px 6px; font-size: 11px; letter-spacing: .12em; color: var(--muted); }
.sidebar-history .sheet-status { margin: 4px 6px; }
.sidebar-history .history-list li + li { border-top: 0; margin-top: 3px; }
.sidebar-history .history-list li { position: relative; }
.sidebar-history .history-record { padding: 8px; }
.sidebar-history .history-record strong { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; font-size: 15px; }
.sidebar-history .history-record[aria-current="true"] { background: #d9e5d7; }
.sidebar-history .history-info { padding-inline-end: 34px; }
.history-more-actions {
  position: absolute;
  inset-inline-end: 4px;
  inset-block-end: 4px;
  width: 32px;
  height: 27px;
  padding: 0;
  color: var(--green);
  background: none;
  border: 0;
  border-radius: 6px;
  font-size: 21px;
  line-height: 1;
  opacity: .65;
}
@media (hover: hover) and (pointer: fine) {
  .history-more-actions { opacity: 0; pointer-events: none; }
  .sidebar-history li:where(:hover, :has(:focus-visible)) > .history-more-actions { opacity: .65; pointer-events: auto; }
}
@media (pointer: coarse) {
  .sidebar-history .history-info { min-height: 36px; align-items: center; padding-inline-end: 44px; }
  .history-more-actions { width: 44px; height: 40px; }
}
.sidebar-history .history-more-actions:is(:hover, :focus-visible, [aria-expanded="true"]) {
  background: var(--white);
  opacity: 1;
  pointer-events: auto;
}
.history-menu { position: fixed; inset: auto; margin: 0; min-width: 132px; padding: 5px; border: 1px solid var(--line); border-radius: 9px; background: var(--white); color: var(--ink); box-shadow: 0 8px 24px #292c2526; }
.history-menu button { display: block; width: 100%; padding: 8px 10px; border: 0; border-radius: 5px; background: transparent; text-align: left; }
.history-menu button:is(:hover, :focus-visible) { background: var(--green-light); }
.history-menu [data-action="delete"] { color: #9a4033; }
.rename-form { padding: 20px; }
.rename-form h2 { margin: 0 0 12px; }
.rename-form input { width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--input); font-size: 16px; }
.rename-actions, .word-actions { display: flex; gap: 7px; margin-top: 9px; }
.rename-actions { justify-content: flex-end; }
.sidebar-footer { display: flex; justify-content: space-between; align-items: center; gap: 6px; padding: 8px 5px 0; border-top: 1px solid #d1d9ca; color: var(--green); }
#current-user { font-weight: 650; overflow: hidden; text-overflow: ellipsis; }
.sidebar-toggle, .sidebar-close, .sidebar-overlay, .mobile-new-reading { display: none; }

.reader-main { min-width: 0; }
.reader-toolbar { display: none; }
.reader-toolbar-title { color: var(--green); font-weight: 700; white-space: nowrap; }
select { min-width: 0; max-width: 100%; min-height: 38px; padding: 4px 8px; background: var(--white); border: 1px solid var(--line); border-radius: 7px; color: var(--green); font: 13px/1.4 var(--sans-cn); }
select:focus-visible { outline: 2px solid #548368; outline-offset: 2px; }
#model-switch-status { margin-top: 5px; }
.reader-content { width: min(1040px, calc(100% - 2 * var(--reader-gutter))); margin: 0 auto 38px; }
.reader-content .intro h1 { font-size: clamp(27px, 3.6vw, 46px); margin: 0 0 3px; }
.reader-content #source-input { min-height: 164px; height: 164px; }
.reader-content .source-panel .translate-button { width: auto; min-width: 150px; margin-left: auto; }
.reader-content .source-panel .panel-head { min-height: 58px; padding-inline: var(--reader-gutter); }

.settings-page .settings-form {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  min-height: 0;
  padding: 0;
}
.profile-scroll { overflow: auto; padding: 16px 24px 22px; }
.profile-actions { display: flex; gap: 8px; }
.profile-identity { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.parameter-section {
  margin-top: 16px;
  padding: 13px 16px 15px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #f8f7ef;
}
.parameter-section h3 { margin: 0 0 3px; color: var(--green); font-size: 14px; }
.model-parameters { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 5px 16px; }
.model-parameters select { display: block; width: 100%; }
.parameter-tag { margin-left: 4px; padding: 1px 6px; border-radius: 4px; background: var(--green-light); color: var(--green); font: 10px/1.5 var(--mono); }
.custom-parameters summary { color: var(--green); cursor: pointer; font-weight: 650; }
.custom-parameters .sheet-note { margin-top: 8px; }
#custom-parameters { height: auto; min-height: 112px; margin-top: 8px; padding: 9px 11px; font: 12px/1.55 var(--mono); tab-size: 2; }
#settings-prompt { height: auto; min-height: 170px; padding: 8px 10px; font: 13px/1.55 var(--sans-cn); }
.alignment-contract { font-size: 12px; margin-top: 8px; color: var(--muted); }
.alignment-contract summary { cursor: pointer; }
.alignment-contract p { white-space: pre-wrap; overflow-wrap: anywhere; }
.profile-footer { border-top: 1px solid var(--line); padding: 10px 24px 13px; background: var(--white); }
.profile-actions { justify-content: flex-end; align-items: center; }
.profile-actions .translate-button { width: auto; min-width: 116px; margin-top: 0; }
.profile-footer .sheet-status { margin: 0 0 8px; }
.dictionary-section h3 { margin: 0 0 5px; color: var(--green); font-size: 12px; letter-spacing: .04em; }
.dictionary-section + .dictionary-section { border-top: 1px solid var(--line); margin-top: 13px; padding-top: 12px; }
.word-english { margin: 0 0 9px; padding-left: 1.4em; font: 15px/1.5 Georgia, serif; }
.word-english li + li { margin-top: 7px; }
.word-english small { display: block; color: var(--muted); font-style: italic; }

@media (max-width: 980px) {
  :root { --toolbar-height: 57px; }
  .reader-shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { display: none; position: fixed; z-index: 8; inset: 0 auto 0 0; width: min(324px, 85vw); }
  .reader-toolbar { position: sticky; z-index: 6; top: 0; display: flex; align-items: center; gap: 10px; height: var(--toolbar-height); padding: 5px var(--reader-gutter); background: var(--paper); border-bottom: 1px solid var(--line); }
  .sidebar-toggle, .mobile-new-reading { display: inline-flex; min-height: 44px; }
  .mobile-new-reading { margin-inline-start: auto; }
  .sidebar-nav a { min-height: 44px; }
  .sidebar-close { display: block; margin-left: auto; }
  .reader-shell[data-sidebar="open"] .sidebar { display: flex; }
  .sidebar-overlay:not([hidden]) { display: block; position: fixed; z-index: 7; inset: 0; border: 0; background: #292c2570; }
  html:has(.reader-shell[data-sidebar="open"]) { overflow: hidden; }
}
@media (max-width: 600px) {
  .english { font-size: 17px; }
  .chinese { font-size: 16px; }
  .paragraph > :is(.english, .chinese) { padding-block: 12px; }
  .word-sheet { width: 100%; max-width: none; max-height: 77dvh; margin: auto 0 0; border-radius: 16px 16px 0 0; }
  .word-sheet .sheet-body { padding-bottom: max(20px, env(safe-area-inset-bottom)); }
  #article-url, #source-input { font-size: 16px; }
  .reading-modes button { min-height: 44px; }
  .profile-identity, .model-parameters { grid-template-columns: 1fr; gap: 4px; }
}
@media (max-width: 365px) {
  .reader-toolbar { gap: 4px; padding-inline: 8px; }
  .reader-toolbar .nav-button, .reader-toolbar .new-reading { padding-inline: 7px; }
  .profile-scroll, .profile-footer { padding-inline: 13px; }
  .reading-head .panel-title { gap: 4px; }
}
.word-sheet[open] { display: grid; grid-template-rows: auto minmax(0, 1fr); overflow: hidden; }
.word-sheet .sheet-body { overflow: auto; overscroll-behavior: contain; }
.word-sheet .sheet-head { padding: 13px 18px; }
.word-sheet .sheet-body { padding-inline: 18px; }
.word-sheet .sheet-head h2 { font-size: 28px; }
.word-sheet[data-anchored] { position: fixed; inset: auto; margin: 0; z-index: 10; width: 344px; max-height: min(450px, calc(100dvh - 24px)); }
@media (min-width: 601px) and (max-height: 480px) {
  .word-sheet { position: fixed; inset: 0 0 0 auto; width: min(310px, 47vw); height: 100dvh; max-height: 100dvh; margin: 0; border-radius: 12px 0 0 12px; }
  .word-sheet .sheet-head { padding: 8px 13px; }
  .word-sheet .sheet-kicker { display: none; }
  .word-sheet .sheet-body { padding: 10px 13px; }
  .word-actions { margin-top: 5px; }
}

.word-actions { flex-wrap: wrap; }
.word-save[aria-pressed="true"] { background: var(--green-light); border-color: #a9bba7; }
.word[aria-pressed="true"] { background: #f8ebbb; }
#word-save-status { margin-top: 6px; }

.vocabulary-page { max-width: 800px; }
.page-heading { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px 16px; }
.page-heading h1:focus { outline: none; }
.vocabulary-panel { padding: 16px clamp(12px, 3vw, 26px); }
.vocabulary-sheet { width: min(620px, calc(100% - 24px)); }
.vocabulary-sheet[open] { display: grid; grid-template-rows: auto minmax(0, 1fr); overflow: hidden; }
.vocabulary-body { overflow: auto; overscroll-behavior: contain; }
#vocabulary-detail-status:not([hidden]) { margin-bottom: 8px; }
.vocabulary-list, .vocabulary-origins { margin: 0; padding: 0; list-style: none; }
.vocabulary-list > li + li { border-top: 1px solid var(--line); }
.vocabulary-origins > li { padding: 7px 0 7px 12px; border-inline-start: 2px solid var(--green-light); }
.vocabulary-origins > li + li { margin-top: 8px; }
.vocabulary-origin { display: flex; align-items: baseline; gap: 12px; justify-content: space-between; }
.vocabulary-source { min-width: 0; padding: 0; border: 0; background: transparent; text-align: start; color: var(--green); font-weight: 650; overflow-wrap: anywhere; }
button.vocabulary-source { text-decoration: underline; text-underline-offset: 3px; }
.vocabulary-excerpt { margin: 3px 0; font: 16px/1.5 Georgia, serif; overflow-wrap: anywhere; }
.vocabulary-unavailable { margin-top: 5px; }
#vocabulary-more { margin-top: 8px; }
@media (max-width: 400px) {
  .vocabulary-sheet .sheet-body { padding-inline: 14px; }
}

.filter-input {
  width: 100%;
  min-width: 0;
  min-height: 35px;
  padding: 6px 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--white);
  color: var(--ink);
}
.history-search { margin: 3px 0 8px; font-size: 12px; }
.word-icon { width: 36px; height: 36px; padding: 0; }
.word-icon svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.65; stroke-linecap: round; stroke-linejoin: round; }
.word-save[aria-pressed="true"] svg { fill: currentColor; }
.word-icon:disabled { cursor: wait; opacity: .55; }
@media (pointer: coarse) { .word-icon { width: 44px; height: 44px; } }

.vocabulary-filter { display: flex; flex-wrap: wrap; gap: 8px 10px; align-items: flex-end; margin-bottom: 13px; }
.vocabulary-filter label { display: grid; gap: 3px; min-width: 0; font-size: 12px; color: var(--muted); }
.vocabulary-filter-actions { display: flex; align-items: center; gap: 8px; }
.vocabulary-filter .text-button { min-height: 35px; }
@media (max-width: 460px) {
  .vocabulary-filter { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .vocabulary-filter-actions { grid-column: 1 / -1; justify-content: flex-end; }
}
.vocabulary-definitions { padding: 0 0 10px; }
.vocabulary-definitions p { margin-top: 4px; }
.vocabulary-chinese { white-space: pre-line; margin-bottom: 4px; }
.vocabulary-definitions ol { padding-inline-start: 20px; margin: 6px 0; }
.vocabulary-definitions ol small { display: block; color: var(--muted); }
.vocabulary-time { display: block; margin-top: 2px; }

.profile-layout { display: grid; grid-template-columns: minmax(176px, 27%) minmax(0, 1fr); min-height: 0; }
.profile-sidebar { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; gap: 10px; min-height: 0; padding: 14px; background: var(--input); border-inline-end: 1px solid var(--line); }
.profile-list { display: grid; align-content: start; gap: 4px; overflow: auto; }
.profile-list-item { position: relative; width: 100%; min-width: 0; text-align: start; padding: 8px 10px; border: 1px solid transparent; border-radius: 7px; background: transparent; }
.profile-list-item strong, .profile-list-item small { display: block; overflow-wrap: anywhere; }
.profile-list-item small { color: var(--muted); }
.profile-list-item:hover, .profile-list-item[aria-current="true"] { background: var(--green-light); }
.profile-list-item[aria-current="true"] { border-color: #b7c8b3; }
.profile-current { display: inline-block; margin-top: 3px; border-radius: 4px; padding: 0 5px; background: var(--white); color: var(--green); font-size: 11px; }
.profile-editor-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 7px; padding-bottom: 9px; border-bottom: 1px solid var(--line); }
.profile-editor-head h3 { margin: 0; font-size: 19px; overflow-wrap: anywhere; }
#active-model[data-current="true"] { opacity: 1; background: var(--green-light); }
#settings-retry { max-width: 110px; }
#retry-hint { margin-top: 4px; }
.profile-advanced { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--line); }
.profile-advanced > summary { cursor: pointer; color: var(--green); font-weight: 650; }
.profile-advanced > summary span { margin-inline-start: 6px; color: var(--muted); font-size: 12px; font-weight: 400; }
@media (max-width: 620px) {
  .profile-layout { grid-template-columns: 1fr; grid-template-rows: auto minmax(0, 1fr); }
  .profile-sidebar { grid-template-rows: auto auto; grid-template-columns: minmax(0, 1fr) auto; gap: 7px; padding: 9px 12px; border-inline-end: 0; border-bottom: 1px solid var(--line); }
  .profile-list { grid-column: 1 / -1; grid-row: 2; grid-auto-flow: column; grid-auto-columns: minmax(116px, 1fr); justify-content: start; overflow-x: auto; }
  .profile-list-item { padding: 5px 8px; }
}

.settings-layout {
  display: grid;
  grid-template-columns: 136px minmax(0, 1fr);
  height: clamp(360px, calc(100dvh - var(--toolbar-height) - 122px), 720px);
  overflow: hidden;
}
.settings-nav {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 14px 10px;
  border-inline-end: 1px solid var(--line);
  background: var(--green-light);
}
.settings-nav button {
  padding: 8px 9px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  text-align: start;
  white-space: nowrap;
}
.settings-nav button:hover, .settings-nav button[aria-current="true"] { background: var(--white); }
.settings-nav button[aria-current="true"] { color: var(--green); font-weight: 700; }
.profile-layout, .settings-general { min-height: 0; min-width: 0; }
.settings-general { display: grid; }
.prompt-sidebar { grid-template-rows: minmax(0, 1fr); }
.settings-description { margin: 10px 0; }
@media (max-width: 760px) {
  .settings-layout { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
  .settings-nav { flex-direction: row; padding: 6px 10px; border-inline-end: 0; border-bottom: 1px solid var(--line); }
  .settings-nav button { min-height: 42px; }
}
@media (max-width: 620px) {
  .prompt-sidebar { grid-template-rows: auto; }
  .prompt-sidebar .profile-list { grid-row: 1; }
}

.vocabulary-row { display: flex; gap: 8px; align-items: center; min-height: 56px; }
.vocabulary-row .word-icon, .vocabulary-origin .word-icon { flex: none; }
.vocabulary-word {
  display: flex;
  flex: 1 1 auto;
  min-width: 0;
  flex-wrap: wrap;
  gap: 2px 8px;
  align-items: baseline;
  padding: 8px 3px;
  border: 0;
  background: transparent;
  text-align: start;
  overflow-wrap: anywhere;
}
.vocabulary-word strong { font: 700 21px/1.25 Georgia, serif; }
.vocabulary-word .word-meta { margin: 0; }
.vocabulary-word:is(:hover, :focus-visible) strong { color: var(--green); text-decoration: underline; text-underline-offset: 3px; }
.vocabulary-remove:enabled:hover { background: #f8ece7; color: #9a4033; }
