:root {
  --bg: #f6f7fb;
  --card: #fff;
  --text: #111827;
  --muted: #6b7280;
  --line: #e5e7eb;
  --primary: #111827;
  --good: #047857;
  --bad: #b91c1c;
  --warn: #b45309;
  --soft: #f3f4f6;
  --shadow: 0 12px 30px rgba(17, 24, 39, .08);
  --radius: 18px;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background: radial-gradient(circle at top left, #fff 0, var(--bg) 42%, #eef2ff 100%);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
}
button, input, textarea, select { font: inherit; }
.app { width: min(960px, 100%); margin: 0 auto; padding: 18px 14px 90px; }
.topbar { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 8px 2px 16px; }
.title { margin: 0; font-size: 26px; line-height: 1.15; letter-spacing: -.04em; }
.subtitle, .hint, .muted, .source-line, .cloud-status { color: var(--muted); }
.subtitle { margin: 6px 0 0; font-size: 13px; line-height: 1.45; }
.pill { white-space: nowrap; border: 1px solid var(--line); background: rgba(255,255,255,.75); color: var(--muted); border-radius: 999px; padding: 8px 10px; font-size: 12px; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 14px; }
.stat { padding: 12px 10px; border: 1px solid rgba(229,231,235,.8); border-radius: 16px; background: rgba(255,255,255,.78); box-shadow: 0 6px 18px rgba(17,24,39,.04); }
.stat strong { display: block; font-size: 22px; line-height: 1; letter-spacing: -.03em; }
.stat span { display: block; margin-top: 6px; color: var(--muted); font-size: 12px; }
.panel { display: none; }
.panel.active { display: block; }
.card { margin-bottom: 14px; padding: 16px; border: 1px solid rgba(229,231,235,.9); border-radius: var(--radius); background: rgba(255,255,255,.88); box-shadow: var(--shadow); }
.card h2 { margin: 0 0 10px; font-size: 18px; letter-spacing: -.03em; }
.hint { margin: 8px 0 0; font-size: 13px; line-height: 1.55; }
.field-label { display: block; margin: 0 0 6px; font-size: 13px; font-weight: 700; }
.spaced { margin-top: 14px; }
textarea, input[type="text"], input[type="number"], input[type="search"], select { width: 100%; padding: 12px 13px; border: 1px solid var(--line); border-radius: 14px; background: #fff; color: var(--text); outline: none; }
textarea:focus, input:focus, select:focus { border-color: #9ca3af; box-shadow: 0 0 0 4px rgba(156,163,175,.16); }
textarea { min-height: 230px; resize: vertical; line-height: 1.55; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; align-items: center; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
.actions.compact { margin-top: 0; }
.btn { min-height: 44px; padding: 12px 14px; border: 0; border-radius: 14px; background: var(--primary); color: #fff; font-weight: 650; cursor: pointer; }
.btn.secondary { border: 1px solid var(--line); background: var(--soft); color: var(--text); }
.btn.good { background: var(--good); }
.btn.bad { background: var(--bad); }
.btn.warn { background: var(--warn); }
.btn.small { min-height: 34px; padding: 8px 10px; border-radius: 12px; font-size: 12px; font-weight: 600; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.review-card { min-height: 380px; display: flex; flex-direction: column; justify-content: space-between; gap: 18px; }
.review-meta { display: flex; justify-content: space-between; gap: 8px; color: var(--muted); font-size: 13px; }
.word { margin: 20px 0 8px; text-align: center; word-break: break-word; font-size: clamp(38px, 11vw, 78px); line-height: 1.05; font-weight: 800; letter-spacing: -.06em; }
.source-line { text-align: center; font-size: 13px; line-height: 1.6; }
.answer-box { display: none; padding: 14px; border: 1px solid var(--line); border-radius: 16px; background: #f9fafb; line-height: 1.65; }
.answer-box.show { display: block; }
.answer-grid { display: grid; gap: 10px; }
.answer-example { white-space: pre-line; }
.label { display: inline-block; min-width: 48px; color: var(--muted); font-size: 13px; }
.decision-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.empty { padding: 48px 16px; text-align: center; color: var(--muted); line-height: 1.7; }
.library-tools { display: grid; grid-template-columns: 1fr auto; gap: 10px; margin-bottom: 12px; }
.word-list { display: grid; gap: 10px; }
.word-item { padding: 13px; border: 1px solid var(--line); border-radius: 16px; background: #fff; }
.word-item-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.word-item strong { font-size: 17px; letter-spacing: -.02em; }
.badge-row { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.badge { padding: 4px 8px; border: 1px solid var(--line); border-radius: 999px; background: var(--soft); color: var(--muted); font-size: 11px; }
.badge.due { border-color: #fecaca; background: #fef2f2; color: var(--bad); }
.badge.drill { border-color: #fde68a; background: #fffbeb; color: var(--warn); }
.badge.ok { border-color: #a7f3d0; background: #ecfdf5; color: var(--good); }
.example { white-space: pre-line; }
.cloud-box { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; padding: 12px; border: 1px solid var(--line); border-radius: 16px; background: #f9fafb; }
.cloud-status { margin-top: 4px; font-size: 13px; line-height: 1.55; }
.danger-zone { border-color: #fecaca; background: #fff7f7; }
.kbd { padding: 1px 5px; border: 1px solid var(--line); border-radius: 6px; background: var(--soft); font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; }
.help-list { margin: 10px 0 0 18px; padding: 0; color: var(--muted); font-size: 13px; line-height: 1.65; }
.tabs { position: fixed; left: 50%; bottom: 0; z-index: 20; width: min(960px, 100%); transform: translateX(-50%); display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; padding: 10px 14px calc(10px + env(safe-area-inset-bottom)); border-top: 1px solid rgba(229,231,235,.9); background: rgba(246,247,251,.92); backdrop-filter: blur(16px); }
.tab-btn { padding: 10px 4px; border: 0; border-radius: 14px; background: transparent; color: var(--muted); font-size: 13px; cursor: pointer; }
.tab-btn.active { background: var(--primary); color: #fff; box-shadow: 0 10px 22px rgba(17,24,39,.18); }
.toast { display: none; position: fixed; left: 50%; bottom: 84px; z-index: 50; transform: translateX(-50%); max-width: min(92vw, 480px); padding: 11px 14px; border-radius: 999px; background: rgba(17,24,39,.95); color: #fff; font-size: 13px; box-shadow: 0 18px 32px rgba(17,24,39,.24); }
.toast.show { display: block; }
@media (max-width: 620px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .row, .library-tools { grid-template-columns: 1fr; }
  .actions .btn { flex: 1 1 auto; }
  .cloud-box { align-items: flex-start; }
}
.center { justify-content: center; }
.center-text { text-align: center; }
.full { width: 100%; }
.controls { display: block; }
.controls > .decision-grid { width: 100%; }
.word-item .muted { margin-top: 4px; font-size: 13px; line-height: 1.45; }
