:root {
  --bg: #f5f5f0; --card: #fff; --line: #d1d1c7; --line-soft: #e5e5dc;
  --ink: #2f3437; --muted: #6b7280; --accent: #5a7d7c; --accent-soft: #85b7b6;
  --ok: #588157; --ok-bg: #f0f8f0; --bad: #e76f51; --bad-bg: #fdf5f0; --warn: #b8860b;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
.page { max-width: 980px; margin: 0 auto; padding: 24px 16px 60px; }
header.site { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.brand { color: var(--accent); text-decoration: none; font-size: 20px; }
nav { display: flex; gap: 14px; align-items: center; }
nav a { color: var(--accent); }
.card { background: var(--card); border: 1px solid var(--line); padding: 24px; }
h1 { font-weight: 400; color: var(--accent); font-size: 24px; margin: 0 0 8px; }
h2 { font-weight: 400; color: var(--accent); font-size: 18px; margin: 24px 0 12px; border-bottom: 1px solid var(--line-soft); padding-bottom: 6px; }
.muted { color: var(--muted); } .small { font-size: 13px; } .caps { text-transform: uppercase; letter-spacing: .1em; font-size: 11px; }
.error { color: var(--bad); } .ok { color: var(--ok); } .warn { color: var(--warn); }
.inline { display: inline; }
button { font: inherit; cursor: pointer; }
button.link { background: none; border: none; color: var(--accent); padding: 0; text-decoration: underline; }
button:not(.link):not(.sym) { background: var(--accent-soft); color: #fff; border: none; padding: 8px 18px; }
button:not(.link):not(.sym):hover { background: var(--accent); }
button:disabled { background: #b3c8c8 !important; cursor: not-allowed; }
.stack { display: flex; flex-direction: column; gap: 14px; } .narrow { max-width: 380px; }
label { display: flex; flex-direction: column; gap: 4px; color: var(--muted); }
input[type=text], input[type=password], input:not([type]), input[inputmode] { font: inherit; padding: 8px 10px; border: 1px solid var(--line); background: #fafaf5; color: var(--ink); }
input:focus, math-field:focus-within { outline: none; border-color: var(--accent-soft); }

.summary { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
.chip { border: 1px solid var(--line); background: #fff; padding: 8px 10px; display: flex; flex-direction: column; }
.chip b { color: var(--accent); } .chip.overdue { border-color: var(--bad); background: var(--bad-bg); }

.layout { display: flex; gap: 24px; align-items: flex-start; }
.questions { flex: 1; min-width: 0; }
.cheatsheet { width: 150px; flex-shrink: 0; position: sticky; top: 16px; }
.cheatsheet .row { display: flex; align-items: center; gap: 6px; margin: 8px 0; flex-wrap: wrap; }
.cheatsheet code { background: #f0f0e8; border: 1px solid var(--line); padding: 1px 5px; font-size: 12px; color: var(--accent); }
.cheatsheet math-field { font-size: 14px; border: 1px solid var(--line); background: #f8f8f3; padding: 0 4px; }
@media (max-width: 760px) { .cheatsheet { display: none; } }

details.group { border: 1px solid var(--line); margin: 14px 0; }
details.group > summary { padding: 10px 12px; background: #f0f0e8; color: var(--accent); cursor: pointer; }
details.group > article { margin: 12px; }

article.question { border: 1px solid var(--line); background: #fafaf5; margin-bottom: 18px; }
article.question.overdue { border-color: #edcdc2; background: var(--bad-bg); }
article.question.solved { background: var(--ok-bg); }
article.question > header { padding: 10px 14px; border-bottom: 1px solid var(--line-soft); display: flex; gap: 12px; align-items: baseline; flex-wrap: wrap; }
.booknum { color: var(--accent); font-size: 17px; }
.tag { font-size: 12px; background: var(--ok-bg); color: var(--ok); padding: 1px 6px; }
.prompt { padding: 10px 14px 0; margin: 0; color: var(--muted); }
.symbols { padding: 10px 14px 0; display: flex; gap: 6px; flex-wrap: wrap; }
button.sym { background: #fff; border: 1px solid var(--line); padding: 3px 10px; border-radius: 3px; }
button.sym:hover { border-color: var(--accent-soft); }
article.question math-field.answer, article.question input.answer { display: block; width: calc(100% - 28px); margin: 12px 14px; min-height: 48px; font-size: 18px; border: 1px solid var(--line); background: #fff; padding: 6px 10px; }
.answer-table { margin: 12px 14px; border-collapse: collapse; }
.answer-table th, .answer-table td { border: 1px solid var(--line); padding: 4px 6px; }
.answer-table th { background: #f0f0e8; font-weight: 500; }
.answer-table th math-field { font-size: 15px; background: transparent; }
.answer-table td math-field { min-width: 110px; min-height: 34px; font-size: 16px; background: #fff; border: 1px solid var(--line-soft); }
.actions { padding: 10px 14px; border-top: 1px solid var(--line-soft); display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.feedback { font-size: 14px; }
article.question > p.ok { padding: 10px 14px; margin: 0; }
details.history { padding: 8px 14px 12px; border-top: 1px solid var(--line-soft); font-size: 14px; }
details.history summary { color: var(--accent); cursor: pointer; }
details.history ul { list-style: none; padding: 0; margin: 8px 0 0; }
details.history li { display: flex; gap: 8px; align-items: center; padding: 4px 0; border-bottom: 1px solid var(--line-soft); }
details.history math-field { font-size: 15px; background: transparent; }
.dot { width: 12px; height: 12px; display: inline-block; flex-shrink: 0; }
.dot.good { background: var(--ok); } .dot.bad { background: var(--bad); }

/* admin */
table.data { border-collapse: collapse; width: 100%; font-size: 14px; }
table.data th, table.data td { border: 1px solid var(--line-soft); padding: 6px 8px; text-align: left; vertical-align: top; }
table.data th { background: #f0f0e8; font-weight: 500; }
pre.wrap { white-space: pre-wrap; word-break: break-word; background: #f8f8f3; padding: 8px; font-size: 12px; max-height: 260px; overflow: auto; }
.pill { font-size: 12px; padding: 1px 7px; border-radius: 10px; }
.pill.good { background: var(--ok-bg); color: var(--ok); } .pill.bad { background: var(--bad-bg); color: var(--bad); }
.pill.gray { background: #eee; color: var(--muted); }
