:root {
  --paper: #f5f1e8;
  --paper-deep: #ece5d7;
  --card: #fffdf8;
  --ink: #16241d;
  --ink-soft: #33443a;
  --muted: #748073;
  --line: #ddd5c5;
  --line-soft: #ebe5d8;
  --accent: #b85c38;
  --accent-soft: #f3dfd4;
  --green: #1f4d3a;
  --green-soft: #dce8e1;
  --gold: #a9852f;
  --danger: #a44232;
  --l1: #7f9a72;
  --l2: #2f6b4f;
  --l3: #b07a3a;
  --l4: #8c4a3f;
  --serif: "Noto Serif SC", "Songti SC", "Source Han Serif SC", Georgia, serif;
  --sans: "Inter", "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  --mono: "JetBrains Mono", "Cascadia Code", Consolas, monospace;
  --shadow: 0 1px 2px rgba(22, 36, 29, .05), 0 12px 32px -24px rgba(22, 36, 29, .35);
  --radius: 16px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

[hidden] { display: none !important; }

::selection { background: var(--accent-soft); color: var(--ink); }

.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: .35;
  background-image: radial-gradient(rgba(22, 36, 29, .12) .6px, transparent .6px);
  background-size: 5px 5px;
  mix-blend-mode: multiply;
}

a { color: inherit; text-decoration: none; }

button, input, select, textarea { font: inherit; color: inherit; }

button { cursor: pointer; }

svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

/* ---------------------------------------------------------------- topbar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px clamp(20px, 5vw, 64px);
  background: rgba(245, 241, 232, .86);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line-soft);
}

.brand { display: flex; align-items: center; gap: 11px; }

.brand-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: var(--green);
  color: #f7f2e6;
  font-family: var(--serif);
  font-size: 21px;
  letter-spacing: 0;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .12);
}

.brand-text { display: flex; flex-direction: column; line-height: 1.05; }
.brand-text b { font-family: var(--serif); font-size: 19px; letter-spacing: .06em; }
.brand-text i { font-style: normal; font-size: 10.5px; letter-spacing: .22em; color: var(--muted); text-transform: uppercase; }

.top-actions { display: flex; align-items: center; gap: 8px; }

.link-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border: 0;
  background: transparent;
  color: var(--ink-soft);
  border-radius: 9px;
  font-size: 13.5px;
  transition: background .18s ease, color .18s ease;
}
.link-btn:hover { background: var(--paper-deep); color: var(--ink); }
.link-btn svg { width: 16px; height: 16px; }

/* ------------------------------------------------------------------ main */
main {
  position: relative;
  z-index: 1;
  width: min(1180px, calc(100% - clamp(32px, 8vw, 96px)));
  margin: 0 auto;
  padding: 52px 0 80px;
}

.view { animation: none; }

@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

.eyebrow {
  margin: 0 0 14px;
  font-size: 11px;
  letter-spacing: .24em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 600;
}

.hero { max-width: 760px; margin-bottom: 42px; }

.hero h1, .result-head h1 {
  margin: 0;
  font-family: var(--serif);
  font-weight: 600;
  font-size: clamp(36px, 5.4vw, 62px);
  line-height: 1.16;
  letter-spacing: -.015em;
}

.hero h1 em {
  font-style: italic;
  color: var(--accent);
  position: relative;
  white-space: nowrap;
}

.hero h1 em::after {
  content: "";
  position: absolute;
  left: 2%;
  right: 2%;
  bottom: .06em;
  height: .32em;
  background: var(--accent-soft);
  z-index: -1;
  border-radius: 2px;
}

.lede {
  margin: 20px 0 0;
  max-width: 620px;
  font-size: 16.5px;
  color: var(--ink-soft);
}

/* ------------------------------------------------------------- upload */
.upload-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(260px, .8fr);
  gap: 22px;
  align-items: stretch;
}

.dropzone {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 52px 32px 40px;
  min-height: 340px;
  border: 1.5px dashed #c9c0ad;
  border-radius: 22px;
  background:
    linear-gradient(180deg, rgba(255, 253, 248, .9), rgba(255, 253, 248, .55)),
    repeating-linear-gradient(135deg, transparent 0 9px, rgba(22, 36, 29, .022) 9px 10px);
  text-align: center;
  transition: border-color .2s ease, background .2s ease, transform .2s ease;
}

.dropzone:hover, .dropzone:focus-visible {
  border-color: var(--accent);
  background: var(--card);
  outline: none;
}

.dropzone.dragging {
  border-color: var(--accent);
  background: var(--accent-soft);
  transform: scale(.995);
}

.drop-icon {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  border-radius: 16px;
  background: var(--green-soft);
  color: var(--green);
  margin-bottom: 18px;
}
.drop-icon svg { width: 26px; height: 26px; }

.dropzone h2 { margin: 0 0 6px; font-family: var(--serif); font-size: 23px; font-weight: 600; }
.drop-hint { margin: 0 0 22px; color: var(--muted); font-size: 13.5px; }

.upload-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }

.formats { margin: 24px 0 0; font-size: 10.5px; letter-spacing: .12em; color: #9a9588; text-transform: uppercase; }

.primary, .ghost {
  border-radius: 10px;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 500;
  transition: transform .15s ease, background .18s ease, border-color .18s ease, box-shadow .18s ease;
}

.primary {
  border: 1px solid var(--green);
  background: var(--green);
  color: #f8f4ea;
  box-shadow: 0 6px 18px -10px rgba(31, 77, 58, .7);
}
.primary:hover { background: #173d2d; transform: translateY(-1px); }
.primary:disabled { opacity: .5; cursor: wait; transform: none; }

.ghost {
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink-soft);
}
.ghost:hover { border-color: #bdb3a0; background: #fff; }
.ghost.small { padding: 7px 13px; font-size: 12.5px; }

.side-notes {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 1px;
  background: var(--line-soft);
  border: 1px solid var(--line-soft);
  border-radius: 22px;
  overflow: hidden;
}

.note {
  display: flex;
  gap: 14px;
  padding: 24px 22px;
  background: var(--card);
  flex: 1;
}

.note-num {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--accent);
  padding-top: 4px;
}

.note b { display: block; font-size: 14.5px; margin-bottom: 3px; }
.note p { margin: 0; font-size: 13px; color: var(--muted); line-height: 1.6; }

/* ------------------------------------------------------------- paste */
.paste-panel {
  margin-top: 26px;
  padding: 26px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
}

.paste-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 14px; }
.paste-head h2 { margin: 0; font-family: var(--serif); font-size: 20px; }

.paste-panel textarea {
  width: 100%;
  min-height: 200px;
  resize: vertical;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fbf8f1;
  font-size: 15px;
  line-height: 1.75;
  outline: none;
  transition: border-color .18s ease, box-shadow .18s ease;
}
.paste-panel textarea:focus { border-color: var(--green); box-shadow: 0 0 0 3px var(--green-soft); }

.paste-actions { display: flex; justify-content: space-between; align-items: center; margin-top: 14px; }
.paste-actions > div { display: flex; gap: 8px; }

/* ------------------------------------------------------------ status */
.status-panel {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-top: 26px;
  padding: 22px 26px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
}
.status-panel b { font-size: 15px; }
.status-panel p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.status-panel .link-btn { margin-left: auto; }

.spinner {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2.5px solid var(--line);
  border-top-color: var(--accent);
  animation: spin 1s linear infinite;
  flex: none;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ----------------------------------------------------------------- how */
.how {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 22px;
  margin-top: 58px;
  padding-top: 34px;
  border-top: 1px solid var(--line);
}

.how-item b { font-family: var(--serif); font-size: 17px; }
.how-item p { margin: 7px 0 0; font-size: 12.8px; color: var(--muted); line-height: 1.65; }

/* --------------------------------------------------------------- result */
.result-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
  margin-bottom: 30px;
}

.result-head h1 { font-size: clamp(30px, 4vw, 44px); }
.result-head .muted { margin: 8px 0 0; }
.result-actions { display: flex; align-items: center; gap: 10px; }

.export-wrap { position: relative; }
.export-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  width: 210px;
  padding: 6px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 18px 40px -20px rgba(22, 36, 29, .5);
  z-index: 20;
}
.export-menu button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 9px 11px;
  border: 0;
  background: transparent;
  border-radius: 8px;
  font-size: 13.5px;
}
.export-menu button:hover { background: var(--paper-deep); }

.stats-row {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.stat {
  padding: 20px 22px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.stat .num { font-family: var(--serif); font-size: 32px; line-height: 1; }
.stat .label { margin-top: 7px; font-size: 12px; color: var(--muted); letter-spacing: .04em; }
.stat .sub { font-size: 11.5px; color: var(--accent); margin-top: 2px; }

.overview-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 34px;
}

.panel {
  padding: 22px 24px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.panel-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 18px; }
.panel-head h2 { margin: 0; font-family: var(--serif); font-size: 18px; }
.muted { color: var(--muted); font-size: 12.5px; }

.level-chart { display: flex; flex-direction: column; gap: 13px; }
.level-row { display: grid; grid-template-columns: 92px 1fr 38px; align-items: center; gap: 12px; font-size: 12.5px; }
.level-track { height: 9px; border-radius: 6px; background: var(--line-soft); overflow: hidden; }
.level-fill { height: 100%; border-radius: 6px; transition: width .7s cubic-bezier(.2, .7, .3, 1); }
.level-row .n { text-align: right; font-family: var(--mono); font-size: 12px; color: var(--ink-soft); }

.grammar-chart { display: flex; flex-wrap: wrap; gap: 7px; }
.g-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 11px;
  border-radius: 999px;
  background: var(--paper);
  border: 1px solid var(--line-soft);
  font-size: 12px;
}
.g-chip em { font-style: normal; font-family: var(--mono); font-size: 10.5px; color: var(--accent); }
.g-chip.more { color: var(--muted); }

/* --------------------------------------------------------------- tabs */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 26px;
  overflow-x: auto;
}

.tab {
  position: relative;
  padding: 12px 16px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  white-space: nowrap;
}
.tab span { font-family: var(--mono); font-size: 10.5px; color: #a9a294; margin-left: 2px; }
.tab:hover { color: var(--ink); }
.tab.active { color: var(--ink); font-weight: 600; }
.tab.active::after {
  content: "";
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: -1px;
  height: 2px;
  background: var(--accent);
}

.tab-panel { animation: none; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* ------------------------------------------------------------- toolbar */
.toolbar {
  display: flex;
  gap: 9px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.toolbar input[type="search"], .toolbar select {
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--card);
  font-size: 13px;
  outline: none;
}
.toolbar input[type="search"] { flex: 1; min-width: 180px; }
.toolbar input[type="search"]:focus, .toolbar select:focus { border-color: var(--green); }

.switch { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--muted); cursor: pointer; }
.switch input { accent-color: var(--green); }

/* -------------------------------------------------------------- words */
.word-list { display: flex; flex-direction: column; gap: 8px; }

.word-row {
  background: var(--card);
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  transition: border-color .18s ease, box-shadow .18s ease;
}
.word-row:hover { border-color: #cfc6b4; box-shadow: var(--shadow); }
.word-row.open { border-color: var(--green); box-shadow: var(--shadow); }

.word-main {
  display: grid;
  grid-template-columns: minmax(150px, 210px) 1fr auto;
  gap: 16px;
  align-items: center;
  padding: 13px 16px;
  cursor: pointer;
}

.word-title { display: flex; align-items: baseline; gap: 7px; min-width: 0; }
.word-title b { font-size: 17px; font-family: var(--serif); letter-spacing: .01em; }
.word-title .phonetic { font-family: var(--mono); font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.speak {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 2px;
  line-height: 0;
  border-radius: 5px;
  flex: none;
}
.speak:hover { color: var(--accent); background: var(--accent-soft); }
.speak svg { width: 14px; height: 14px; }

.word-def { min-width: 0; }
.word-def .pos { font-family: var(--mono); font-size: 10.5px; color: var(--accent); text-transform: lowercase; margin-right: 6px; }
.word-def .tr { font-size: 13.5px; color: var(--ink-soft); display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
.word-def .exam-line { margin-top: 3px; font-size: 11.5px; color: var(--muted); display: flex; gap: 6px; flex-wrap: wrap; }

.badge {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 5px;
  font-size: 10.5px;
  letter-spacing: .02em;
  border: 1px solid transparent;
}
.badge.l1 { color: #4f6a45; background: #e6eede; }
.badge.l2 { color: #1f4d3a; background: var(--green-soft); }
.badge.l3 { color: #86591f; background: #f5e8d2; }
.badge.l4 { color: #7c3a30; background: #f2ddd8; }
.badge.plain { color: var(--muted); background: var(--paper); border-color: var(--line-soft); }

.word-side { display: flex; align-items: center; gap: 10px; }
.word-count { font-family: var(--mono); font-size: 11px; color: var(--muted); white-space: nowrap; }
.chev { color: #b2aa9a; transition: transform .2s ease; font-size: 12px; }
.word-row.open .chev { transform: rotate(90deg); color: var(--accent); }

.word-detail {
  padding: 4px 16px 18px;
  border-top: 1px dashed var(--line-soft);
  margin-top: 0;
}

.detail-grid { display: grid; grid-template-columns: 1.1fr 1fr; gap: 20px; padding-top: 14px; }
.detail-block h4 { margin: 0 0 8px; font-size: 11px; letter-spacing: .16em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.detail-block .translation-full { white-space: pre-line; font-size: 14px; line-height: 1.7; }

.exam-note {
  padding: 9px 11px;
  border-left: 2px solid var(--accent);
  background: #fbf6ee;
  border-radius: 0 8px 8px 0;
  margin-bottom: 7px;
}
.exam-note b { font-size: 12px; color: var(--accent); }
.exam-note p { margin: 3px 0 0; font-size: 12.5px; color: var(--ink-soft); line-height: 1.6; }

.phrase-mini { font-size: 12.5px; margin-bottom: 4px; }
.phrase-mini b { font-family: var(--serif); }
.phrase-mini span { color: var(--muted); }

.sentence-ref {
  padding: 8px 11px;
  background: var(--paper);
  border-radius: 8px;
  font-size: 12.8px;
  color: var(--ink-soft);
  margin-bottom: 6px;
  line-height: 1.6;
}

.load-more-wrap { text-align: center; margin-top: 18px; }

/* ------------------------------------------------------------ phrases */
.phrase-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }

.phrase-card {
  padding: 20px 22px;
  background: var(--card);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  gap: 9px;
}
.phrase-card header { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.phrase-card h3 { margin: 0; font-family: var(--serif); font-size: 19px; }
.phrase-card .cat { font-size: 10.5px; padding: 2px 7px; border-radius: 999px; background: var(--paper); color: var(--muted); border: 1px solid var(--line-soft); }
.phrase-card .times { margin-left: auto; font-family: var(--mono); font-size: 10.5px; color: var(--accent); }
.phrase-card .meaning { margin: 0; font-size: 14px; color: var(--ink-soft); }
.phrase-card .exam { padding: 10px 12px; background: #fbf6ee; border-radius: 9px; font-size: 12.5px; color: var(--ink-soft); line-height: 1.65; }
.phrase-card .exam b { color: var(--accent); font-size: 11px; letter-spacing: .08em; display: block; margin-bottom: 3px; }
.phrase-card blockquote { margin: 0; padding-left: 10px; border-left: 2px solid var(--line); font-size: 12px; color: var(--muted); font-style: italic; }

/* ------------------------------------------------------------ grammar */
.grammar-layout { display: grid; grid-template-columns: 280px 1fr; gap: 22px; align-items: start; }

.grammar-side {
  position: sticky;
  top: 88px;
  padding: 18px;
  background: var(--card);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
}
.grammar-side h3 { margin: 0 0 12px; font-size: 11px; letter-spacing: .16em; text-transform: uppercase; color: var(--muted); }
.gs-item { display: flex; align-items: center; gap: 8px; padding: 7px 8px; border-radius: 7px; font-size: 12.5px; cursor: pointer; }
.gs-item:hover { background: var(--paper); }
.gs-item.active { background: var(--green-soft); color: var(--green); }
.gs-item .n { margin-left: auto; font-family: var(--mono); font-size: 10.5px; color: var(--muted); }
.gs-item .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); opacity: .7; flex: none; }

.grammar-sentences { display: flex; flex-direction: column; gap: 10px; }

.sent-card { padding: 16px 18px; background: var(--card); border: 1px solid var(--line-soft); border-radius: 12px; }
.sent-card .idx { font-family: var(--mono); font-size: 10px; color: #b2aa9a; }
.sent-card .ts { font-family: var(--mono); font-size: 10px; color: var(--accent); margin-left: 6px; }
.sent-card p.en { margin: 5px 0 9px; font-size: 14.5px; line-height: 1.7; }
.sent-card .tags { display: flex; flex-wrap: wrap; gap: 5px; }
.g-tag { font-size: 10.5px; padding: 2px 8px; border-radius: 999px; background: var(--paper); border: 1px solid var(--line-soft); color: var(--ink-soft); }
.g-tag b { color: var(--accent); font-weight: 500; }
.sent-detail { margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--line-soft); display: none; }
.sent-card.open .sent-detail { display: block; }
.g-explain { margin-bottom: 8px; font-size: 12.5px; }
.g-explain b { font-family: var(--serif); font-size: 13.5px; }
.g-explain p { margin: 2px 0 0; color: var(--ink-soft); }
.g-explain .exam-tip { color: var(--accent); }

/* --------------------------------------------------------- translation */
.translate-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 20px; }
.translate-head h2 { margin: 0 0 3px; font-family: var(--serif); font-size: 22px; }
.translate-head p { margin: 0; }

.translation-list { display: flex; flex-direction: column; gap: 14px; }
.tr-block { padding: 20px 22px; background: var(--card); border: 1px solid var(--line-soft); border-radius: var(--radius); }
.tr-block .en { font-size: 14px; line-height: 1.75; color: var(--ink-soft); }
.tr-block .zh { margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--line-soft); font-size: 14.5px; line-height: 1.8; color: var(--ink); }
.tr-block .zh.loading { color: var(--muted); font-style: italic; }
.tr-block .zh.error { color: var(--danger); font-size: 12.5px; }
.empty { padding: 40px; text-align: center; color: var(--muted); font-size: 13.5px; }

/* -------------------------------------------------------------- source */
.text-tools { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.original-text {
  padding: 28px 32px;
  background: var(--card);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  font-size: 15px;
  line-height: 1.9;
  white-space: pre-wrap;
}
.original-text p { margin: 0 0 1em; }
.original-text .gk-hl { background: linear-gradient(180deg, transparent 62%, #f0d9a8 62%); padding: 0 1px; border-radius: 2px; }
.original-text .ts { font-family: var(--mono); font-size: 10.5px; color: var(--accent); margin-right: 8px; vertical-align: 2px; }

/* --------------------------------------------------------------- modal */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(22, 36, 29, .42);
  backdrop-filter: blur(4px);
  animation: fade .2s ease both;
}

.modal-card {
  width: min(680px, 100%);
  max-height: calc(100vh - 48px);
  display: flex;
  flex-direction: column;
  background: var(--card);
  border-radius: 20px;
  box-shadow: 0 30px 80px -30px rgba(10, 20, 14, .55);
  animation: rise .3s cubic-bezier(.2, .7, .3, 1) both;
  overflow: hidden;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--line-soft);
}
.modal-head h2 { margin: 0; font-family: var(--serif); font-size: 22px; }

.icon-btn {
  width: 34px;
  height: 34px;
  border: 0;
  background: var(--paper);
  border-radius: 9px;
  font-size: 20px;
  line-height: 1;
  color: var(--muted);
}
.icon-btn:hover { background: var(--paper-deep); color: var(--ink); }

.modal-body { padding: 22px 24px; overflow-y: auto; }

.settings-section { padding-bottom: 22px; margin-bottom: 22px; border-bottom: 1px solid var(--line-soft); }
.settings-section:last-child { border-bottom: 0; margin-bottom: 0; padding-bottom: 0; }
.settings-head { display: flex; align-items: center; gap: 9px; margin-bottom: 4px; }
.settings-head h3 { margin: 0; font-family: var(--serif); font-size: 18px; }
.pill { font-size: 10px; padding: 2px 8px; border-radius: 999px; background: var(--green-soft); color: var(--green); }
.field-hint { margin: 0 0 14px; font-size: 12px; color: var(--muted); }

.field { display: block; margin-bottom: 12px; }
.field > span { display: block; margin-bottom: 5px; font-size: 11.5px; color: var(--muted); letter-spacing: .03em; }
.field input, .field select {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fbf8f1;
  font-size: 13px;
  outline: none;
}
.field input:focus, .field select:focus { border-color: var(--green); box-shadow: 0 0 0 3px var(--green-soft); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.settings-actions { display: flex; align-items: center; gap: 12px; margin-top: 6px; }
.test-status { font-size: 12px; color: var(--muted); }
.test-status.ok { color: var(--green); }
.test-status.err { color: var(--danger); }

.modal-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 24px;
  border-top: 1px solid var(--line-soft);
  background: #faf7ef;
}
.modal-foot > div { display: flex; gap: 8px; }

.guide-card { width: min(720px, 100%); }
.guide-body h3 { margin: 18px 0 8px; font-family: var(--serif); font-size: 16px; }
.guide-body h3:first-child { margin-top: 0; }
.guide-body ol, .guide-body ul { margin: 0; padding-left: 20px; }
.guide-body li { margin-bottom: 6px; font-size: 13.5px; color: var(--ink-soft); }
.guide-body p { font-size: 13.5px; color: var(--ink-soft); }
.guide-body code { font-family: var(--mono); font-size: 12px; background: var(--paper); padding: 1px 5px; border-radius: 4px; }

/* --------------------------------------------------------------- footer */
.footer {
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  width: min(1180px, calc(100% - clamp(32px, 8vw, 96px)));
  margin: 0 auto;
  padding: 26px 0 36px;
  border-top: 1px solid var(--line);
  font-size: 11.5px;
  color: var(--muted);
}

/* ---------------------------------------------------------- responsive */
@media (max-width: 900px) {
  .upload-grid { grid-template-columns: 1fr; }
  .side-notes { flex-direction: row; }
  .note { padding: 18px; }
  .how { grid-template-columns: 1fr 1fr; }
  .stats-row { grid-template-columns: 1fr 1fr; }
  .overview-grid { grid-template-columns: 1fr; }
  .phrase-list { grid-template-columns: 1fr; }
  .grammar-layout { grid-template-columns: 1fr; }
  .grammar-side { position: static; }
  .word-main { grid-template-columns: 1fr auto; }
  .word-def { grid-column: 1 / -1; }
  .detail-grid { grid-template-columns: 1fr; }
}

@media (max-width: 620px) {
  main { padding-top: 34px; }
  .hero h1 { font-size: 34px; }
  .how { grid-template-columns: 1fr; }
  .stats-row { grid-template-columns: 1fr 1fr; gap: 9px; }
  .stat { padding: 15px; }
  .stat .num { font-size: 25px; }
  .toolbar { gap: 7px; }
  .toolbar input[type="search"] { flex-basis: 100%; }
  .modal { padding: 10px; }
  .modal-body { padding: 18px; }
  .field-row { grid-template-columns: 1fr; }
  .footer { flex-direction: column; gap: 4px; }
  .original-text { padding: 20px; }
}

/* ------------------------------------------------------------------ toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: 30px;
  z-index: 220;
  transform: translate(-50%, 14px);
  padding: 11px 20px;
  border-radius: 10px;
  background: var(--green);
  color: #f8f4ea;
  font-size: 13px;
  box-shadow: 0 16px 40px -16px rgba(10, 20, 14, .6);
  opacity: 0;
  transition: opacity .22s ease, transform .22s ease;
  pointer-events: none;
  max-width: min(560px, calc(100vw - 40px));
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { background: var(--danger); }

#openai-fields { transition: opacity .2s ease; }

.demo-link {
  margin-top: 18px;
  border: 0;
  background: transparent;
  color: var(--accent);
  font-size: 12.5px;
  border-bottom: 1px solid transparent;
  padding: 2px;
}
.demo-link:hover { border-bottom-color: var(--accent); }

.word-title .surface { font-family: var(--mono); font-size: 10px; color: var(--muted); background: var(--paper); padding: 1px 5px; border-radius: 4px; }

/* ============================================================ notebook */
.nav-badge {
  display: inline-grid;
  place-items: center;
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  margin-left: 2px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 9.5px;
  font-family: var(--mono);
}

.source-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 18px;
}

.source-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 20px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--card);
  text-align: left;
  transition: border-color .18s ease, transform .18s ease, box-shadow .18s ease;
}
.source-card:hover {
  border-color: var(--green);
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}
.source-card b { display: block; font-family: var(--serif); font-size: 16px; }
.source-card small { color: var(--muted); font-size: 11.5px; }
.source-icon {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: var(--green-soft);
  color: var(--green);
  font-size: 15px;
  flex: none;
}

.url-input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fbf8f1;
  font-size: 14px;
  outline: none;
}
.url-input:focus { border-color: var(--green); box-shadow: 0 0 0 3px var(--green-soft); }

.library-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.library-card {
  padding: 16px 18px;
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  background: #fbf8f1;
  text-align: left;
  transition: border-color .18s ease, background .18s ease;
}
.library-card:hover { border-color: var(--green); background: var(--card); }
.library-card .topic {
  display: inline-block;
  font-size: 10px;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--green-soft);
  color: var(--green);
  margin-bottom: 6px;
}
.library-card h3 { margin: 0 0 4px; font-family: var(--serif); font-size: 16px; }
.library-card p { margin: 0; font-size: 11.5px; color: var(--muted); }

/* --------------------------------------------------------- vocab view */
.curve-panel { margin-bottom: 22px; }
.curve-chart { width: 100%; overflow: hidden; }
.curve-chart svg { width: 100%; height: auto; display: block; }

.vocab-list { display: flex; flex-direction: column; gap: 8px; }

.vocab-row {
  display: grid;
  grid-template-columns: minmax(150px, 220px) 1fr auto;
  gap: 16px;
  align-items: center;
  padding: 13px 16px;
  background: var(--card);
  border: 1px solid var(--line-soft);
  border-radius: 12px;
}
.vocab-row:hover { border-color: #cfc6b4; box-shadow: var(--shadow); }
.vocab-word { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.vocab-word b { font-family: var(--serif); font-size: 18px; }
.vocab-word .phonetic { font-family: var(--mono); font-size: 10.5px; color: var(--muted); }
.vocab-def { min-width: 0; }
.vocab-def .tr { font-size: 13px; color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vocab-meta { display: flex; align-items: center; gap: 10px; margin-top: 4px; font-size: 10.5px; color: var(--muted); }
.vocab-side { display: flex; align-items: center; gap: 10px; }
.vocab-due { font-size: 10.5px; color: var(--accent); white-space: nowrap; }
.vocab-due.ok { color: var(--muted); }

.mastery { display: inline-flex; gap: 2px; }
.mastery i {
  width: 6px; height: 12px; border-radius: 2px; background: var(--line);
  display: inline-block;
}
.mastery i.on { background: var(--green); }
.mastery i.hot { background: var(--accent); }

.star-btn {
  border: 0;
  background: transparent;
  color: #b9b2a3;
  font-size: 19px;
  line-height: 1;
  padding: 3px 5px;
  border-radius: 6px;
}
.star-btn:hover { background: var(--accent-soft); color: var(--accent); }
.star-btn.on { color: var(--accent); }

.review-overlay {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(22, 36, 29, .55);
  backdrop-filter: blur(6px);
}
.review-card {
  width: min(620px, 100%);
  max-height: calc(100vh - 48px);
  display: flex;
  flex-direction: column;
  background: var(--card);
  border-radius: 22px;
  box-shadow: 0 40px 100px -40px rgba(10, 20, 14, .6);
  overflow: hidden;
}
.review-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line-soft);
}
.review-body {
  flex: 1;
  padding: 34px 32px 24px;
  text-align: center;
  overflow-y: auto;
}
.review-label {
  margin: 0;
  font-size: 10px;
  letter-spacing: .24em;
  color: var(--accent);
  text-transform: uppercase;
}
.review-word {
  margin: 10px 0 4px;
  font-family: var(--serif);
  font-size: clamp(36px, 6vw, 54px);
  line-height: 1.1;
  color: var(--green);
}
.review-phonetic { margin: 0 0 8px; font-family: var(--mono); font-size: 13px; color: var(--muted); min-height: 18px; }
.review-translation {
  margin: 18px 0 0;
  padding-top: 18px;
  border-top: 1px dashed var(--line);
  font-size: 15px;
  line-height: 1.7;
  text-align: left;
  white-space: pre-line;
}
.review-exam { margin-top: 12px; text-align: left; }
.review-exam .exam-note { margin-bottom: 6px; }
.review-source { margin-top: 12px; font-size: 11px; }

.review-foot {
  padding: 16px 20px 20px;
  border-top: 1px solid var(--line-soft);
  background: #faf7ef;
}
.review-foot .primary { width: 100%; padding: 13px; }
.review-grades {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}
.review-grades button {
  padding: 9px 4px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--card);
  display: flex;
  flex-direction: column;
  gap: 2px;
  transition: border-color .15s ease, background .15s ease;
}
.review-grades button b { font-size: 13px; }
.review-grades button small { font-size: 9.5px; color: var(--muted); }
.review-grades button:hover { border-color: var(--green); background: var(--green-soft); }
.review-grades button[data-grade="0"]:hover { border-color: var(--danger); background: #f7e3df; }
.review-grades button[data-grade="3"]:hover { border-color: var(--accent); background: var(--accent-soft); }

.review-done { padding: 30px 0; }
.review-done h3 { font-family: var(--serif); font-size: 26px; margin: 0 0 8px; color: var(--green); }
.review-done p { color: var(--muted); }

.vocab-empty {
  padding: 44px 20px;
  text-align: center;
  color: var(--muted);
  background: var(--card);
  border: 1px dashed var(--line);
  border-radius: 14px;
  font-size: 13px;
}

@media (max-width: 900px) {
  .source-row { grid-template-columns: 1fr; }
  .library-grid { grid-template-columns: 1fr; }
  .vocab-row { grid-template-columns: 1fr auto; }
  .vocab-def { grid-column: 1 / -1; grid-row: 2; }
}

@media (max-width: 620px) {
  .review-body { padding: 24px 18px 18px; }
  .review-grades { grid-template-columns: repeat(2, 1fr); }
  .vocab-side { gap: 6px; }
}

.library-tabs { display: flex; gap: 6px; margin-bottom: 14px; flex-wrap: wrap; }
.library-tabs button {
  padding: 6px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  font-size: 12px;
  color: var(--ink-soft);
}
.library-tabs button.active { background: var(--green); border-color: var(--green); color: #fff; }
.library-note { margin: 14px 0 0; font-size: 11px; color: var(--muted); }

.sort-dir {
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--card);
  color: var(--ink-soft);
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.2;
  min-width: 38px;
}
.sort-dir:hover { border-color: var(--green); color: var(--green); }

/* ========================================================== reading view */
.result-mode { display: flex; align-items: center; gap: 8px; margin: 4px 0 16px; flex-wrap: wrap; }
.result-mode button {
  padding: 7px 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  color: var(--ink-soft);
  font-size: 12.5px;
}
.result-mode button.active { background: var(--green); border-color: var(--green); color: #fff; }
.result-mode .muted { margin-left: 4px; }

.reading-layout { display: grid; grid-template-columns: minmax(0, 1.08fr) minmax(0, .92fr); gap: 18px; align-items: start; }
.reader-panel, .lexicon-panel { background: var(--card); border: 1px solid var(--line); border-radius: 18px; }
.reader-panel { padding: 20px 22px; }
.lexicon-panel { padding: 14px; position: sticky; top: 82px; }

.reader-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.reader-head h2 { margin: 0; font-family: var(--serif); font-size: 21px; }
.reader-head p { margin: 4px 0 0; }
.reader-legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 10.5px; color: var(--muted); margin: 12px 0 10px; }
.reader-legend span { display: inline-flex; align-items: center; gap: 5px; }
.lg { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.lg.l1 { background: #c9c2b2; }
.lg.l2 { background: #2f6b4f; }
.lg.l3 { background: #b07a3a; }
.lg.l4 { background: #8c4a3f; }

.reader-body {
  max-height: calc(100vh - 380px);
  min-height: 360px;
  overflow-y: auto;
  padding-right: 8px;
}
.rsent { display: grid; grid-template-columns: 24px 1fr; gap: 8px; padding: 4px 2px; border-radius: 8px; transition: background .3s; }
.rsent.flash { background: #fdf3ec; }
.rsent-no { font-family: var(--mono); font-size: 9.5px; color: #b2aa9a; padding-top: 5px; text-align: right; }
.rsent-text { margin: 0; font-size: 15.5px; line-height: 1.95; }
.rsent-zh { margin: 4px 0 0; font-size: 12.5px; color: var(--muted); border-left: 2px solid var(--line-soft); padding-left: 8px; line-height: 1.7; }

.rword {
  cursor: pointer;
  padding: 0 1px;
  border-radius: 3px;
  border-bottom: 2px solid transparent;
  transition: background .15s ease, color .15s ease;
}
.rword.l1 { border-bottom-color: #cfc7b6; }
.rword.l2 { border-bottom-color: #2f6b4f; background: linear-gradient(180deg, transparent 70%, #dce8e1 70%); }
.rword.l3 { border-bottom-color: #b07a3a; background: linear-gradient(180deg, transparent 70%, #f5e8d2 70%); }
.rword.l4 { border-bottom-color: #8c4a3f; background: linear-gradient(180deg, transparent 70%, #f2ddd8 70%); }
.rword:hover { background: #f3dfd4; }
.rword.active { background: var(--accent); color: #fff; border-bottom-color: var(--accent); }

.phrase-strip-wrap { border-top: 1px dashed var(--line); margin-top: 12px; padding-top: 12px; }
.phrase-strip-head { font-size: 10.5px; letter-spacing: .1em; color: var(--muted); margin-bottom: 7px; }
.phrase-strip { display: flex; gap: 6px; flex-wrap: wrap; max-height: 86px; overflow-y: auto; }
.phrase-chip { border: 1px solid var(--line-soft); background: #fbf6ee; border-radius: 999px; padding: 4px 10px; font-size: 11px; color: var(--ink-soft); }
.phrase-chip:hover { border-color: var(--accent); }
.phrase-chip b { font-family: var(--serif); font-size: 12px; }
.phrase-chip span { color: var(--muted); margin-left: 4px; }

.detail-card {
  padding: 15px 17px;
  border-radius: 12px;
  background: #fbf8f1;
  border: 1px solid var(--line-soft);
  max-height: 43vh;
  overflow-y: auto;
}
.detail-card .empty { margin: 20px 0; }
.dc-head { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.dc-head h2 { margin: 0; font-family: var(--serif); font-size: 30px; line-height: 1.1; color: var(--green); }
.dc-phonetic { font-family: var(--mono); font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.dc-actions { display: flex; gap: 3px; }
.dc-tags { display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0 4px; }
.dc-meaning { font-size: 13px; color: var(--ink-soft); white-space: pre-line; line-height: 1.7; margin: 6px 0; }
.dc-section h4 { margin: 10px 0 4px; font-size: 9.5px; letter-spacing: .14em; color: var(--muted); text-transform: uppercase; }
.dc-note { font-size: 11.5px; color: var(--ink-soft); background: #fff; border-left: 2px solid var(--accent); padding: 5px 9px; border-radius: 0 6px 6px 0; margin-bottom: 5px; line-height: 1.6; }
.dc-note b { color: var(--accent); font-size: 10.5px; }
.dc-sentence { font-size: 11.5px; color: var(--muted); border-top: 1px dashed var(--line); margin-top: 8px; padding-top: 8px; line-height: 1.6; }

.lex-tools { display: flex; gap: 6px; margin: 10px 0; flex-wrap: wrap; }
.lex-tools input { flex: 1; min-width: 110px; padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); font-size: 11.5px; }
.lex-tools select { padding: 7px 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); font-size: 11.5px; }
.lex-tools input:focus, .lex-tools select:focus { border-color: var(--green); outline: none; }
.word-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; max-height: 330px; overflow-y: auto; padding-right: 4px; }
.vcard { text-align: left; padding: 9px 11px; border: 1px solid var(--line-soft); border-radius: 10px; background: var(--card); }
.vcard:hover { border-color: var(--green); }
.vcard.active { border-color: var(--accent); background: #fdf3ec; }
.vc-top { display: flex; align-items: baseline; gap: 5px; flex-wrap: wrap; }
.vc-top b { font-family: var(--serif); font-size: 15px; }
.vc-top .phonetic { font-family: var(--mono); font-size: 9px; color: var(--muted); }
.vc-top .badge { margin-left: auto; font-size: 9px; padding: 0 5px; }
.vc-meaning { margin: 4px 0 0; font-size: 10.5px; color: var(--ink-soft); line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.vc-meta { margin: 3px 0 0; font-size: 9px; color: var(--muted); }

@media (max-width: 1000px) {
  .reading-layout { grid-template-columns: 1fr; }
  .lexicon-panel { position: static; }
  .reader-body { max-height: 60vh; }
  .word-grid { max-height: 420px; }
}
@media (max-width: 620px) {
  .word-grid { grid-template-columns: 1fr; }
  .reader-panel { padding: 16px; }
}

/* ============================================================= study lab */
.study-config { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.study-books { display: flex; gap: 9px; overflow-x: auto; padding-bottom: 4px; flex: 1 1 520px; }
.book-card {
  min-width: 156px;
  text-align: left;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  flex: none;
}
.book-card:hover { border-color: var(--green); }
.book-card.active { border-color: var(--green); background: var(--green-soft); }
.book-card .book-badge {
  display: inline-block;
  font-size: 8.5px;
  letter-spacing: .08em;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--paper);
  color: var(--accent);
  border: 1px solid var(--line-soft);
  margin-bottom: 4px;
}
.book-card b { display: block; font-family: var(--serif); font-size: 15px; }
.book-card small { display: block; font-size: 10px; color: var(--muted); line-height: 1.4; margin-top: 2px; }
.book-card em { display: block; font-style: normal; font-size: 9.5px; color: var(--accent); margin-top: 4px; }

.study-options { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; }
.field-inline { display: flex; flex-direction: column; gap: 4px; font-size: 10.5px; color: var(--muted); }
.field-inline select { padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); font-size: 12px; }

.study-layout { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 16px; align-items: start; }
.study-queue { padding: 12px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; max-height: 62vh; overflow-y: auto; }
.queue-head { font-size: 10.5px; letter-spacing: .1em; color: var(--muted); margin-bottom: 8px; }
.queue-list { display: flex; flex-direction: column; gap: 3px; }
.queue-item { display: flex; justify-content: space-between; gap: 6px; padding: 6px 8px; border-radius: 7px; font-size: 12px; cursor: pointer; }
.queue-item:hover { background: var(--paper); }
.queue-item.active { background: var(--green-soft); color: var(--green); font-weight: 600; }
.queue-item.done { opacity: .5; text-decoration: line-through; }
.q-tag { font-size: 8.5px; color: var(--accent); border: 1px solid var(--line-soft); padding: 0 4px; border-radius: 999px; }

.study-card { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 24px 28px; min-height: 480px; display: flex; flex-direction: column; }
.study-card .empty { margin: 60px auto; }
.study-card-top { display: flex; justify-content: space-between; font-size: 10px; letter-spacing: .1em; color: var(--muted); }
.study-word-row { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin: 14px 0 4px; }
.study-word-row h2 { margin: 0; font-family: var(--serif); font-size: clamp(36px, 5vw, 50px); color: var(--green); line-height: 1.1; }
.study-word-row .phonetic { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.study-translation { margin: 10px 0 0; font-size: 15px; line-height: 1.8; color: var(--ink-soft); white-space: pre-line; border-top: 1px dashed var(--line); padding-top: 12px; }
.study-exam { margin-top: 8px; }
.study-exam .dc-note { font-size: 11.5px; }
.study-notes { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
.study-note-block { background: #fbf8f1; border: 1px solid var(--line-soft); border-radius: 10px; padding: 9px 11px; }
.study-note-block h4 { margin: 0 0 5px; font-size: 9px; letter-spacing: .12em; color: var(--muted); text-transform: uppercase; }
.study-note-list { margin: 0 0 6px; padding-left: 15px; font-size: 11.5px; color: var(--ink-soft); line-height: 1.55; }
.study-note-list li { margin: 2px 0; }
.note-add { display: flex; gap: 4px; }
.note-add input { flex: 1; min-width: 0; padding: 5px 8px; border: 1px solid var(--line); border-radius: 6px; background: #fff; font-size: 11px; }
.note-add button { border: 1px solid var(--line); background: var(--card); border-radius: 6px; padding: 0 9px; font-size: 13px; }
.note-add button:hover { border-color: var(--green); color: var(--green); }
.study-note-block textarea { width: 100%; min-height: 54px; resize: vertical; border: 1px solid var(--line); border-radius: 6px; background: #fff; padding: 6px 8px; font-size: 11.5px; line-height: 1.5; }
.study-note-block .note-save { margin-top: 5px; border: 1px solid var(--line); background: var(--card); border-radius: 6px; padding: 3px 9px; font-size: 10.5px; }
.study-note-block .note-save:hover { border-color: var(--green); color: var(--green); }

.study-actions { margin-top: auto; padding-top: 16px; }
.study-actions .primary { width: 100%; padding: 12px; }
.study-grades { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.study-grades button { padding: 9px 4px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); display: flex; flex-direction: column; gap: 2px; }
.study-grades button b { font-size: 13px; }
.study-grades button small { font-size: 9px; color: var(--muted); }
.study-grades button:hover { border-color: var(--green); background: var(--green-soft); }
.study-grades button[data-grade="0"]:hover { border-color: var(--danger); background: #f7e3df; }

.study-done { margin: auto; text-align: center; padding: 40px 20px; }
.study-done h2 { font-family: var(--serif); font-size: 32px; color: var(--green); margin: 0 0 8px; }
.study-done p { color: var(--muted); margin: 0 0 20px; }

@media (max-width: 900px) {
  .study-layout { grid-template-columns: 1fr; }
  .study-queue { max-height: 180px; }
  .study-notes { grid-template-columns: 1fr; }
}

.study-note-list.system li { color: #6f7a70; }
.study-note-list.system small { display: block; font-size: 8.5px; color: #a9a294; margin-top: 1px; }
.study-note-list.system b { font-family: var(--serif); color: var(--ink-soft); font-size: 11.5px; }

.foot-left { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.quit-btn { color: var(--danger); }
.quit-btn:hover { background: #f7e3df; color: var(--danger); }
.quit-screen { display: grid; place-items: center; height: 100vh; font-family: var(--serif); font-size: 24px; color: var(--green); }

/* ============================================================ tools */
.dict-search { display: flex; gap: 8px; margin-bottom: 14px; }
.dict-search input {
  flex: 1;
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fbf8f1;
  font-size: 15px;
  outline: none;
}
.dict-search input:focus { border-color: var(--green); box-shadow: 0 0 0 3px var(--green-soft); }
.dict-result .detail-card { max-height: none; }
.dict-suggestions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.dict-suggestion {
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 12px;
}
.dict-suggestion:hover { border-color: var(--green); color: var(--green); }

.tr-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.tr-langs { display: flex; align-items: center; gap: 8px; }
.tr-langs select { padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); font-size: 13px; }
.tr-langs span { color: var(--muted); }
#tr-input {
  width: 100%;
  min-height: 140px;
  resize: vertical;
  padding: 13px 15px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fbf8f1;
  font-size: 14.5px;
  line-height: 1.7;
  outline: none;
}
#tr-input:focus { border-color: var(--green); box-shadow: 0 0 0 3px var(--green-soft); }
.tr-result { margin-top: 14px; }
.tr-output {
  padding: 14px 16px;
  background: #fbf8f1;
  border: 1px solid var(--line-soft);
  border-radius: 12px;
}
.tr-output-head { display: flex; justify-content: space-between; align-items: center; font-size: 10.5px; letter-spacing: .1em; color: var(--muted); margin-bottom: 6px; }
.tr-output-head button { border: 0; background: transparent; color: var(--accent); font-size: 11px; }
.tr-output p { margin: 0; font-size: 15px; line-height: 1.85; white-space: pre-wrap; color: var(--ink); }
.tr-error { color: var(--danger); font-size: 12.5px; }


.lookup-history {
  margin: 0 0 14px;
  padding: 10px 12px;
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  background: #fbf8f1;
}
.lookup-history-head { display: flex; justify-content: space-between; align-items: center; font-size: 10.5px; color: var(--muted); margin-bottom: 7px; }
.lookup-history-head .link-btn { padding: 2px 6px; font-size: 10.5px; }
.lookup-history-list { display: flex; flex-wrap: wrap; gap: 6px; }
.history-chip {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  font-size: 11.5px;
}
.history-chip:hover { border-color: var(--accent); }
.history-chip b { font-family: var(--serif); font-size: 12.5px; }
.history-chip small { color: var(--muted); font-size: 9px; }


.repeat-summary { margin: 0 0 12px; font-size: 12px; }
.repeat-list { display: flex; flex-direction: column; gap: 7px; }
.repeat-row {
  display: grid;
  grid-template-columns: 34px minmax(130px, 1.1fr) 64px 54px minmax(0, 2fr) 34px;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  cursor: pointer;
}
.repeat-row:hover { border-color: var(--green); }
.repeat-rank { font-family: var(--mono); font-size: 10.5px; color: var(--muted); }
.repeat-word b { font-family: var(--serif); font-size: 19px; color: var(--green); }
.repeat-word .phonetic { font-family: var(--mono); font-size: 10.5px; color: var(--muted); margin-left: 6px; }
.repeat-word small { display: block; color: var(--muted); font-size: 9.5px; }
.repeat-count { font-size: 10.5px; color: var(--muted); }
.repeat-count b { font-family: var(--serif); font-size: 20px; color: var(--accent); margin-right: 2px; }
.repeat-sent { font-size: 10.5px; color: var(--muted); }
.repeat-meaning {
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--ink-soft);
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.repeat-detail {
  margin: -3px 0 4px;
  padding: 8px 14px 12px 44px;
  font-size: 11.5px;
  line-height: 1.7;
  color: var(--ink-soft);
  border-left: 2px solid var(--green-soft);
}
.repeat-detail p { margin: 3px 0; }

@media (max-width: 900px) {
  .repeat-row { grid-template-columns: 28px 1fr 56px 34px; }
  .repeat-sent, .repeat-meaning { display: none; }
}

.stat[data-stat] { cursor: pointer; transition: border-color .15s, background .15s; }
.stat[data-stat]:hover { border-color: var(--green); background: var(--green-soft); }

.daily-modal-card { width: min(940px, 96vw); max-height: 90vh; }
.daily-summary { display: flex; gap: 10px; padding: 0 24px 14px; }
.daily-summary-item {
  flex: 1;
  padding: 11px 14px;
  background: #fbf8f1;
  border: 1px solid var(--line-soft);
  border-radius: 10px;
}
.daily-summary-item b { font-family: var(--serif); font-size: 26px; color: var(--green); line-height: 1; }
.daily-summary-item span { display: block; font-size: 10.5px; color: var(--muted); margin-top: 3px; }
.daily-preview { flex: 1; overflow-y: auto; padding: 0 24px 16px; min-height: 160px; }
.daily-section h3 { font-family: var(--serif); font-size: 18px; color: var(--green); margin: 10px 0 6px; }
.daily-section h3 span { font-family: var(--sans); font-size: 12px; }
.daily-word { padding: 9px 2px; border-bottom: 1px dashed var(--line-soft); }
.daily-word:last-child { border-bottom: 0; }
.daily-word-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.daily-rank { font-family: var(--mono); font-size: 10px; color: var(--muted); }
.daily-word-head b { font-family: var(--serif); font-size: 19px; color: var(--green); }
.daily-word-head .phonetic { font-family: var(--mono); font-size: 10.5px; color: var(--muted); }
.daily-state { margin-left: auto; font-size: 9.5px; color: var(--muted); }
.daily-meaning { font-size: 12px; color: var(--ink-soft); margin-top: 3px; }
.daily-example { font-size: 11px; color: var(--muted); margin-top: 3px; }
.daily-notes { font-size: 11px; color: var(--accent); margin-top: 3px; }
.daily-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 14px 24px;
  border-top: 1px solid var(--line);
  flex-wrap: wrap;
}
.daily-actions > div { display: flex; gap: 8px; }


.gaokao-panel {
  padding: 18px 20px;
  margin-bottom: 18px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.gaokao-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; }
.gaokao-head h2 { margin: 0; font-family: var(--serif); font-size: 20px; color: var(--green); }
.gaokao-percent { font-family: var(--serif); font-size: 34px; line-height: 1; color: var(--accent); }
.gaokao-track { height: 8px; background: var(--paper-deep); border-radius: 999px; overflow: hidden; margin: 12px 0 14px; }
.gaokao-fill { height: 100%; width: 0; background: linear-gradient(90deg, var(--green), var(--accent)); transition: width .45s ease; }
.gaokao-nums { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.gaokao-nums b { display: block; font-family: var(--serif); font-size: 22px; line-height: 1; }
.gaokao-nums span { font-size: 10.5px; color: var(--muted); }


.study-top-right { display: flex; align-items: center; gap: 10px; }
.blind-toggle {
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 10px;
  color: var(--muted);
  cursor: pointer;
}
.blind-toggle.on { border-color: var(--accent); color: var(--accent); background: #fdf1ec; }
.blind-context {
  margin: 14px 0 0;
  padding: 14px 16px;
  background: #fbf8f1;
  border: 1px dashed var(--line);
  border-radius: 10px;
}
.blind-context p:first-child { margin: 0 0 6px; font-size: 10px; letter-spacing: .1em; }
.blind-context p:last-child { margin: 0; font-size: 16px; line-height: 1.8; color: var(--ink); }


.study-modes { display: flex; gap: 3px; padding: 2px; background: var(--paper); border-radius: 999px; }
.mode-btn {
  border: 0;
  background: transparent;
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 10px;
  color: var(--muted);
  cursor: pointer;
}
.mode-btn.on { background: var(--card); color: var(--accent); box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.spell-hint { letter-spacing: .22em; color: var(--muted) !important; font-size: 34px !important; }
.spell-box {
  margin: 14px 0 0;
  padding: 14px 16px;
  background: #fbf8f1;
  border: 1px dashed var(--line);
  border-radius: 10px;
}
.spell-box > p:first-child { margin: 0 0 4px; font-size: 10px; letter-spacing: .1em; }
.spell-meaning { margin: 0 0 10px; font-size: 15px; line-height: 1.7; color: var(--ink); }
.spell-input-row { display: flex; gap: 8px; }
.spell-input-row input {
  flex: 1;
  min-width: 0;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  font-size: 15px;
  letter-spacing: .05em;
  outline: none;
}
.spell-input-row input:focus { border-color: var(--green); box-shadow: 0 0 0 3px var(--green-soft); }
.spell-result { margin: 12px 0 0; padding: 9px 12px; border-radius: 8px; font-size: 13px; }
.spell-result.ok { background: var(--green-soft); color: var(--green); }
.spell-result.bad { background: #f7e3df; color: var(--danger); }

.rword-poly { border-bottom: 2px solid var(--accent) !important; }
.poly-dot {
  display: inline-block;
  margin-left: 1px;
  padding: 0 3px;
  border-radius: 3px;
  background: var(--accent);
  color: #fff;
  font-size: 8px;
  line-height: 1.5;
  vertical-align: super;
  font-family: var(--sans);
}
.poly-warn {
  margin: 10px 0;
  padding: 10px 12px;
  border: 1px solid #e6b89c;
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  background: #fdf4ee;
}
.poly-warn h4 { margin: 0 0 4px; font-size: 10.5px; color: var(--accent); letter-spacing: .08em; }
.poly-warn p { margin: 2px 0; font-size: 11.5px; line-height: 1.6; }
.poly-hit {
  margin: 10px 0;
  padding: 9px 12px;
  border-radius: 8px;
  background: var(--green-soft);
  border: 1px solid #b9cfc2;
  font-size: 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.poly-hit span { font-size: 9.5px; letter-spacing: .1em; color: var(--green); }
.poly-hit b { font-size: 14px; color: var(--green); }
.poly-hit small { font-size: 10.5px; color: var(--ink-soft); }
.poly-hit.ai { background: #eef4f7; border-color: #bdd2dd; }
.confusable-panel {
  margin: 12px 0;
  max-width: 100%;
  overflow-x: auto;
  padding: 9px 11px;
  border: 1px solid #e8d9a8;
  border-radius: 8px;
  background: #fdfaf0;
}
.confusable-panel summary { cursor: pointer; font-size: 12px; color: #8a6d1f; font-weight: 600; }
.confusable-diff { margin: 7px 0; font-size: 11.5px; line-height: 1.6; color: var(--ink-soft); }
.confusable-table { width: 100%; min-width: 500px; border-collapse: collapse; font-size: 10.5px; }
.confusable-table th { text-align: left; color: var(--muted); font-weight: 500; padding: 4px 5px; border-bottom: 1px solid #e8d9a8; }
.confusable-table td { padding: 5px; border-bottom: 1px dashed #eee3c8; vertical-align: top; line-height: 1.5; }
.confusable-table button { border: 0; background: transparent; color: var(--green); font-family: var(--serif); font-size: 13px; padding: 0; cursor: pointer; text-decoration: underline; }

/* ============================================================ drill */
.drill-progress { display: flex; gap: 5px; font-size: 9.5px; color: var(--muted); }
.drill-progress span { padding: 2px 7px; border-radius: 999px; background: var(--paper); }
.drill-progress span.on { background: var(--green-soft); color: var(--green); font-weight: 600; }
.drill-prompt { margin: 16px 0 10px; font-size: 12.5px; color: var(--muted); }
.recognize-actions { display: flex; gap: 10px; margin-top: 18px; }
.recognize-actions button { flex: 1; padding: 13px; border-radius: 10px; font-size: 14px; }
.meaning-options { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-top: 6px; }
.meaning-option {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  text-align: left;
  font-size: 12.5px;
  line-height: 1.55;
}
.meaning-option b { font-family: var(--serif); font-size: 15px; color: var(--accent); line-height: 1.2; }
.meaning-option span { color: var(--ink-soft); }
.meaning-option:hover { border-color: var(--green); background: var(--green-soft); }
.drill-feedback { margin: 14px 0 0; padding: 9px 12px; border-radius: 8px; background: #f7e3df; color: var(--danger); font-size: 12.5px; }
.study-answer { margin-top: 12px; }
@media (max-width: 760px) {
  .meaning-options { grid-template-columns: 1fr; }
  .drill-progress { display: none; }
}
