:root {
  --bg: #f6f7f5;
  --surface: #ffffff;
  --text: #1c211e;
  --muted: #5d665f;
  --border: #d9ded9;
  --accent: #1f6f50;
  --accent-ink: #ffffff;
  --accent-soft: #e4f1ea;
  --warn: #8a5a00;
  --warn-soft: #fff4dc;
  --radius: 10px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #141917; --surface: #1d2420; --text: #e8ece9; --muted: #a3ada6; --border: #33403a;
    --accent: #5fbf93; --accent-ink: #0f1a14; --accent-soft: #1f3a2d; --warn: #f2c66d; --warn-soft: #3a2f14;
  }
}
:root[data-theme="dark"] {
  --bg: #141917; --surface: #1d2420; --text: #e8ece9; --muted: #a3ada6; --border: #33403a;
  --accent: #5fbf93; --accent-ink: #0f1a14; --accent-soft: #1f3a2d; --warn: #f2c66d; --warn-soft: #3a2f14;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); line-height: 1.5; font-size: 16px; }
a { color: var(--accent); }
.wrap { max-width: 1100px; margin: 0 auto; padding: 0 16px; }

.site-header { padding: 28px 0 8px; }
.site-header h1 { margin: 0 0 6px; font-size: 1.7rem; letter-spacing: -0.01em; }
.lede { margin: 0; color: var(--muted); max-width: 70ch; }

.layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(300px, 400px); gap: 20px; padding-top: 16px; padding-bottom: 40px; align-items: start; }
@media (max-width: 820px) { .layout { grid-template-columns: 1fr; } .sticky { position: static; } }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; margin: 0 0 16px; min-width: 0; }
fieldset.card { padding-top: 10px; min-inline-size: 0; }
legend { font-weight: 600; padding: 0 6px; }
.sticky { position: sticky; top: 12px; }

.help { color: var(--muted); font-size: 0.92rem; margin: 4px 0 10px; }
.help.small, .small { font-size: 0.82rem; }
.hidden { display: none !important; }

.radio-row label { display: block; padding: 4px 0; }
label.inline { display: block; padding: 4px 0; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--accent); width: 16px; height: 16px; vertical-align: -2px; margin-right: 6px; }

details.group { border-top: 1px solid var(--border); padding: 6px 0; }
details.group:last-child { border-bottom: 1px solid var(--border); }
details.group summary { cursor: pointer; font-weight: 600; padding: 6px 0; list-style: none; display: flex; justify-content: space-between; align-items: center; }
details.group summary::-webkit-details-marker { display: none; }
details.group summary::before { content: "▸"; display: inline-block; width: 1.1em; color: var(--muted); transition: transform .15s; }
details.group[open] summary::before { transform: rotate(90deg); }
details.group summary .title { flex: 1; }
.count { font-size: 0.78rem; font-weight: 600; background: var(--accent-soft); color: var(--accent); border-radius: 999px; padding: 1px 8px; min-width: 1.8em; text-align: center; }
.count:empty { display: none; }
.terms { padding: 0 0 6px 1.1em; }
.terms label { display: flex; gap: 6px; align-items: flex-start; padding: 3px 0; font-size: 0.95rem; }
.terms label input { margin-top: 4px; flex: none; }
.terms .term-text { flex: 1; }
.terms .note { display: block; color: var(--muted); font-size: 0.8rem; line-height: 1.35; }
.terms .def { color: var(--muted); font-size: 0.75rem; white-space: nowrap; opacity: 0; font-variant-numeric: tabular-nums; }
.terms label:hover .def { opacity: 1; }

input[type="text"], select { width: 100%; font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; }
input[type="text"]:focus, select:focus, button:focus-visible, .output-text:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
label[for] { display: block; font-weight: 600; font-size: 0.92rem; margin: 6px 0 4px; }
.subfield { margin-top: 8px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 560px) { .grid-2 { grid-template-columns: 1fr; } }

.chip-input { display: flex; gap: 8px; }
.chip-input input { flex: 1; }
.chips { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.chips li { background: var(--accent-soft); color: var(--text); border-radius: 999px; padding: 4px 6px 4px 12px; font-size: 0.92rem; display: flex; align-items: center; gap: 4px; }
.chips button { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 1rem; line-height: 1; padding: 0 4px; }
.chips button:hover { color: var(--text); }

button { font: inherit; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text); padding: 8px 14px; cursor: pointer; }
button:hover { border-color: var(--accent); }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
button.linkish { background: none; border: none; color: var(--accent); padding: 0 4px; text-decoration: underline; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 8px; }
.tabs button { border: none; border-bottom: 2px solid transparent; border-radius: 0; background: none; padding: 8px 12px; color: var(--muted); font-weight: 600; margin-bottom: -1px; }
.tabs button[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); }

.output-text { min-height: 7em; padding: 12px 14px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); font-size: 1.02rem; line-height: 1.55; white-space: pre-wrap; word-wrap: break-word; }
.output-text.invalid { color: var(--warn); background: var(--warn-soft); border-color: transparent; }
.meta { color: var(--muted); font-size: 0.8rem; margin: 6px 0 10px; min-height: 1.2em; }
.notes { list-style: none; margin: 0 0 12px; padding: 0; }
.notes li { background: var(--accent-soft); border-left: 3px solid var(--accent); border-radius: 0 8px 8px 0; padding: 8px 12px; margin: 0 0 6px; font-size: 0.88rem; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 8px 16px; border-radius: 999px; font-size: 0.9rem; opacity: 0; transition: opacity .2s; pointer-events: none; }
.toast.show { opacity: 1; }

.site-footer { border-top: 1px solid var(--border); padding: 18px 0 32px; color: var(--muted); font-size: 0.9rem; }
.site-footer p { margin: 0 0 8px; max-width: 90ch; }
