/* 句读：版式与交互样式。颜色按功能类别统一管理。 */
:root {
  color-scheme: dark;
  --background: #0c0f0d;
  --surface: #141a16;
  --border: #29332c;
  --text: #edf2ee;
  --muted: #a0afa4;
  --accent: #b6f36a;
  --noun: #ff6577;
  --adjective: #ffdc68;
  --adverb: #83df97;
  --verb: #e391ed;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  background: var(--background);
  color: var(--text);
  font: 16px/1.65 system-ui, -apple-system, "Segoe UI", "Microsoft YaHei", sans-serif;
  overflow-wrap: anywhere;
}
button, input, select, textarea { font: inherit; }
button, select { cursor: pointer; }
button { color: inherit; }
button:disabled { opacity: .4; cursor: default; }
a { color: inherit; }
input, select, textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  color: var(--text);
  background: #0c120e;
  border: 1px solid var(--border);
  border-radius: 9px;
}
textarea { resize: vertical; }
button:focus-visible, a:focus-visible, summary:focus-visible,
input:focus-visible, textarea:focus-visible, select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}
h1, h2, h3, p { margin-top: 0; }
h1 { font-size: clamp(25px, 2.3vw, 34px); line-height: 1.3; margin-bottom: 12px; }
h2 { font-size: 22px; }
h3 { font-size: 17px; }
.button {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  min-height: 44px;
  padding: 9px 15px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: #171e19;
  font-size: 14px;
  cursor: pointer;
  text-decoration: none;
}
.button:hover { background: #253027; border-color: #53674f; }
.primary { background: var(--accent); border-color: var(--accent); color: #1a2b0f; font-weight: 650; }
.primary:hover { background: #c6ff89; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.eyebrow { color: var(--muted); font-size: 12px; letter-spacing: 1.8px; }
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 80px;
  padding: 16px 3%;
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 12px; font-size: 24px; font-weight: 750; text-decoration: none; }
.brand small { font-size: 12px; color: var(--muted); font-weight: 500; letter-spacing: 2px; }
.brand-mark { display: grid; place-items: center; width: 40px; height: 40px; background: var(--accent); border-radius: 10px; color: #1a2b0f; }
.header-note { color: var(--muted); font-size: 14px; }
.workspace { display: grid; grid-template-columns: 240px minmax(350px, 1fr) 330px; max-width: 1700px; margin: auto; min-height: calc(100vh - 80px); }
.sidebar { padding: 30px 20px; border-right: 1px solid var(--border); }
.sidebar > select { margin-top: 12px; }
.sidebar-note { margin-top: 28px; font-size: 13px; color: var(--muted); }
.grammar-nav { margin-top: 28px; }
summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; gap: 8px; }
summary::before { content: "+"; color: var(--muted); }
details[open] > summary::before { content: "−"; }
.grammar-group { margin-top: 16px; }
.grammar-group h3 { margin: 0 0 5px; font-size: 14px; }
.grammar-item { display: flex; align-items: center; justify-content: space-between; width: 100%; min-height: 42px; border: 0; padding: 8px 10px; background: transparent; border-radius: 7px; text-align: left; color: var(--muted); font-size: 14px; }
.grammar-item:hover, .grammar-item.active { background: #23311e; color: var(--accent); }
.grammar-item small { font-size: 12px; color: var(--muted); }
.reading { min-width: 0; padding: 35px clamp(22px, 3vw, 48px); }
.article-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; }
.article-heading .button { flex-shrink: 0; }
.article-description { font-size: 14px; color: var(--muted); margin-bottom: 25px; }
.view-controls { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.view-tabs { display: flex; gap: 3px; border: 1px solid var(--border); padding: 4px; background: #151d17; border-radius: 10px; }
.view-tabs button { min-height: 40px; border: 0; background: transparent; border-radius: 6px; padding: 7px 12px; font-size: 14px; }
.view-tabs button.active { background: #33442c; color: var(--accent); }
.check-label { display: flex; gap: 7px; align-items: center; font-size: 14px; color: var(--muted); }
.check-label input { width: 18px; min-height: 18px; height: 18px; accent-color: var(--accent); }
.legend { display: flex; flex-wrap: wrap; gap: 10px; padding: 21px 0; border-bottom: 1px solid var(--border); }
.legend-item { font-size: 13px; padding: 3px 10px; border-radius: 5px; }
.noun { --component-color: var(--noun); color: var(--noun); background: #ff657720; }
.adjective { --component-color: var(--adjective); color: var(--adjective); background: #ffdc681c; }
.adverb { --component-color: var(--adverb); color: var(--adverb); background: #83df971b; }
.verb { --component-color: var(--verb); color: var(--verb); background: #e391ed1c; }
.article-content { margin: 24px 0 20px; }
.sentence-row { position: relative; margin-bottom: 12px; padding: 14px 16px 14px 43px; border: 1px solid transparent; border-radius: 10px; cursor: pointer; }
.sentence-row:hover { background: #141b16; }
.sentence-row.selected { background: #151e17; border-color: #405039; }
.sentence-row .number { position: absolute; left: 12px; top: 21px; font-size: 12px; color: var(--muted); }
.sentence-text { font-size: 20px; line-height: 2.05; white-space: pre-wrap; }
.component { border-radius: 3px; padding: 2px 0; box-decoration-break: clone; -webkit-box-decoration-break: clone; cursor: pointer; }
.component.has-children { text-decoration: underline; text-decoration-style: dotted; text-underline-offset: 6px; }
.component:focus-visible { outline: 2px solid var(--component-color); }
.component .component { border-bottom: 2px solid var(--component-color); }
.reading-tip { font-size: 13px; color: var(--muted); }
.reader-pagination { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 15px; }
.filter-status { padding: 12px 0; font-size: 14px; color: var(--accent); }
.analysis { padding: 32px 24px; border-left: 1px solid var(--border); background: #101611; min-width: 0; }
.analysis-header h2 { margin-top: 8px; }
.analysis-section { border-top: 1px solid var(--border); padding-top: 18px; margin-top: 20px; }
.analysis-label { color: var(--muted); font-size: 13px; margin-bottom: 8px; }
.backbone { font-size: 18px; line-height: 1.8; color: var(--accent); }
.translation, .analysis-note { font-size: 14px; line-height: 1.9; }
.annotation-card { border: 1px solid var(--border); border-left: 3px solid var(--component-color); background: #161e18; border-radius: 7px; padding: 11px 12px; margin-top: 10px; color: var(--text); }
.annotation-card.focused { outline: 2px solid var(--component-color); }
.annotation-card .annotation-quote { font-size: 15px; color: var(--component-color); }
.annotation-card p { margin: 6px 0 0; font-size: 13px; color: var(--muted); }
.annotation-card .role { font-size: 13px; color: var(--text); }
.empty { padding: 30px 12px; color: var(--muted); }
.dialog-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; }
.dialog-heading h2 { margin-bottom: 12px; }
dialog { width: min(850px, calc(100% - 32px)); max-height: 90dvh; padding: 28px; color: var(--text); background: #141b16; border: 1px solid #475b42; border-radius: 16px; }
dialog::backdrop { background: #000b; backdrop-filter: blur(4px); }
.editor-top { display: flex; align-items: center; gap: 10px; margin: 20px 0; flex-wrap: wrap; }
.editor-top select { flex: 1; min-width: 190px; }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 16px 0; }
.field-grid .wide { grid-column: 1 / -1; }
dialog label { display: block; font-size: 14px; color: var(--muted); }
dialog label > input, dialog label > textarea, dialog label > select { margin-top: 7px; }
.paste-panel { margin: 20px 0; padding: 12px 16px; border: 1px solid var(--border); border-radius: 8px; }
.paste-panel .button { margin-top: 10px; }
.annotation-preview { padding: 16px; border: 1px solid #54634d; border-radius: 9px; font-size: 20px; line-height: 2; white-space: pre-wrap; user-select: text; }
.annotation-list { margin-top: 16px; }
.editor-annotation { display: flex; gap: 10px; align-items: center; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--border); }
.editor-annotation span { font-size: 14px; }
.editor-footer { display: flex; flex-wrap: wrap; gap: 10px; border-top: 1px solid var(--border); padding-top: 20px; margin-top: 22px; }
#editor-status { font-size: 14px; color: var(--accent); min-height: 24px; margin: 15px 0 0; }
.file-label { color: var(--text); }
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: #293b24; border: 1px solid #617c51; padding: 12px 20px; border-radius: 10px; z-index: 10; max-width: calc(100% - 32px); font-size: 14px; }
@media (max-width: 1180px) {
  .workspace { grid-template-columns: 220px minmax(0, 1fr); }
  .analysis { grid-column: 2; border-left: 0; border-top: 1px solid var(--border); }
  .sidebar { grid-row: 1 / 3; }
}
@media (max-width: 680px) {
  .header { padding: 14px 18px; gap: 12px; }
  .brand { font-size: 21px; }
  .brand small, .header-note { display: none; }
  .workspace { display: block; }
  .sidebar { border-right: 0; border-bottom: 1px solid var(--border); padding: 18px; }
  .sidebar-note { display: none; }
  .grammar-nav { margin-top: 10px; }
  #grammar-tree { max-height: 260px; overflow: auto; }
  .reading, .analysis { padding: 24px 18px; }
  .article-heading { flex-wrap: wrap; gap: 8px; }
  .view-tabs { width: 100%; }
  .view-tabs button { flex: 1; padding: 8px 5px; }
  .sentence-text { font-size: 18px; }
  .sentence-row { padding-right: 10px; padding-left: 35px; }
  .sentence-row .number { left: 8px; }
  .reader-pagination { flex-wrap: wrap; }
  dialog { padding: 20px 16px; width: calc(100% - 20px); }
  .field-grid { grid-template-columns: 1fr; }
  .field-grid .wide { grid-column: 1; }
  .editor-top { gap: 8px; }
  .editor-top select { flex-basis: 100%; }
  .editor-footer .button { flex: 1 1 130px; }
  .annotation-preview { font-size: 18px; }
}
@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; }
}
