:root {
  --bg: #f7f7f5;
  --panel: #ffffff;
  --text: #1c2733;
  --muted: #5b6b7b;
  --line: #dde3ea;
  --accent: #1e5fa8;
  --accent-soft: #e8f0fa;
  --good: #1e7d46;
  --bad: #b3372e;
  --warn-bg: #fdf3d7;
  --warn-text: #6d5514;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14181d;
    --panel: #1d232b;
    --text: #e6ebf1;
    --muted: #93a1b1;
    --line: #313a45;
    --accent: #6ca6e8;
    --accent-soft: #223243;
    --good: #58b97e;
    --bad: #e07b72;
    --warn-bg: #3a3220;
    --warn-text: #e3cf8f;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}
a { color: var(--accent); }

.nav {
  display: flex;
  gap: 1.2rem;
  align-items: center;
  padding: 0.7rem 1.2rem;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}
.nav a { text-decoration: none; color: var(--muted); }
.nav a.active { color: var(--text); font-weight: 600; }
.nav .brand { font-weight: 700; color: var(--text); font-size: 1.05rem; }

.wrap { max-width: 860px; margin: 0 auto; padding: 1.6rem 1.2rem 3rem; }
.foot {
  max-width: 860px;
  margin: 0 auto;
  padding: 1rem 1.2rem 2rem;
  color: var(--muted);
  font-size: 0.82rem;
  border-top: 1px solid var(--line);
}

h1 { font-size: 1.7rem; margin: 0.4rem 0 0.6rem; }
h2 { font-size: 1.15rem; margin: 1.4rem 0 0.5rem; }
.sub { color: var(--muted); margin-top: 0; }
.nowrap { white-space: nowrap; }

.hero { text-align: center; margin: 1.5rem 0 0.5rem; }
.hero h1 { font-size: 2.2rem; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1rem; margin-top: 1.5rem; }
.card {
  display: block;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1.1rem 1.2rem;
  text-decoration: none;
  color: var(--text);
}
.card:hover { border-color: var(--accent); }
.card h2 { margin-top: 0; }
.card p { color: var(--muted); font-size: 0.95rem; }
.card .go { color: var(--accent); font-weight: 600; }

.row { display: flex; gap: 0.6rem; margin: 1.2rem 0 0.6rem; }
input[type="text"] {
  flex: 1;
  font-size: 1.1rem;
  padding: 0.65rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  color: var(--text);
  min-width: 0;
}
input[type="text"]:focus { outline: 2px solid var(--accent); border-color: transparent; }

button {
  font-size: 1rem;
  padding: 0.65rem 1.2rem;
  border: 1px solid var(--accent);
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}
button:hover { filter: brightness(1.08); }
button:disabled { opacity: 0.55; cursor: default; }
button.primary { font-size: 1.1rem; padding: 0.8rem 1.6rem; }
#again-btn { margin-top: 1.2rem; background: transparent; color: var(--accent); }

.error {
  color: var(--bad);
  background: color-mix(in srgb, var(--bad) 10%, transparent);
  border-radius: 8px;
  padding: 0.5rem 0.8rem;
}

.metrics { display: flex; flex-wrap: wrap; gap: 0.8rem; margin: 1.2rem 0; }
.metric {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.7rem 1.1rem;
  min-width: 8.5rem;
}
.metric.big { border-color: var(--accent); background: var(--accent-soft); }
.metric-label { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.metric-value { font-size: 1.7rem; font-weight: 700; margin-top: 0.15rem; }
.metric.big .metric-value { font-size: 2.4rem; color: var(--accent); }

.lemma-line { color: var(--muted); }
.warning {
  background: var(--warn-bg);
  color: var(--warn-text);
  border-radius: 8px;
  padding: 0.5rem 0.8rem;
  margin: 0.4rem 0;
  font-size: 0.92rem;
}

table { border-collapse: collapse; width: 100%; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
th, td { text-align: left; padding: 0.5rem 0.7rem; border-top: 1px solid var(--line); font-size: 0.95rem; }
thead th { border-top: none; background: color-mix(in srgb, var(--line) 40%, var(--panel)); font-size: 0.85rem; }
.freq-table { margin: 1rem 0 1.4rem; }
.table-scroll { overflow-x: auto; }

.chart-title { margin-top: 1.6rem; }
#curve { width: 100%; max-width: 720px; height: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; }

details.method { margin: 0.8rem 0; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 0.6rem 1rem; }
details.method summary { cursor: pointer; font-weight: 600; }
.formula { font-family: ui-monospace, monospace; background: var(--accent-soft); padding: 0.5rem 0.8rem; border-radius: 8px; font-size: 0.92rem; }

.rules { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 0.8rem 1.2rem; margin: 1.2rem 0; }
.rules h2 { margin-top: 0.3rem; }

.test-top { display: flex; justify-content: space-between; color: var(--muted); font-variant-numeric: tabular-nums; margin-top: 1rem; }
.bar { height: 8px; background: var(--line); border-radius: 4px; margin: 0.4rem 0 1.6rem; overflow: hidden; }
.bar .fill { height: 100%; width: 100%; background: var(--accent); border-radius: 4px; }
.bar .fill.low { background: var(--bad); }

.prompt { color: var(--muted); margin-bottom: 0.2rem; }
.target { font-size: 2.3rem; font-weight: 700; margin: 0.2rem 0 1.2rem; }
.options { display: grid; gap: 0.6rem; max-width: 32rem; }
.options button {
  text-align: left;
  font-size: 1.15rem;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--line);
  padding: 0.7rem 1rem;
}
.options button:hover:not(:disabled) { border-color: var(--accent); background: var(--accent-soft); }

.note { color: var(--muted); font-size: 0.92rem; }
.review td.ok { color: var(--good); font-weight: 600; }
.review td.miss { color: var(--bad); font-weight: 600; }
.review .dim { color: var(--muted); }

@media (max-width: 560px) {
  .row { flex-direction: column; }
  .target { font-size: 1.8rem; }
  .metric { min-width: 7rem; }
}

.form-picker { display: flex; align-items: center; gap: 0.6rem; margin: 1rem 0 1.2rem; flex-wrap: wrap; }
.form-label { color: var(--muted); }
.form-option {
  display: inline-flex; align-items: center; gap: 0.35rem;
  border: 1px solid var(--line); border-radius: 8px;
  padding: 0.35rem 0.8rem; cursor: pointer; background: var(--panel);
}
.form-option:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); font-weight: 600; }
.form-option input { accent-color: var(--accent); }
.form-badge {
  font-size: 0.95rem; vertical-align: middle; color: var(--accent);
  background: var(--accent-soft); border-radius: 8px; padding: 0.15rem 0.6rem; margin-left: 0.4rem;
}
