:root {
  --bg: #f6f5f2;
  --surface: #ffffff;
  --surface-2: #f1f0ec;
  --ink: #1c1b1a;
  --ink-2: #4b4a46;
  --muted: #6f6d67;
  --line: #e4e2dc;
  --accent: #4338ca;
  --accent-ink: #ffffff;
  --accent-soft: #eef0ff;
  --ok: #15803d;
  --ok-soft: #e8f6ec;
  --warn: #a16207;
  --warn-soft: #fdf6e3;
  --bad: #b91c1c;
  --bad-soft: #fdecec;
  --radius: 14px;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.05), 0 2px 8px rgb(0 0 0 / 0.04);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --tabbar-h: 64px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #141414;
    --surface: #1e1e1d;
    --surface-2: #272725;
    --ink: #f1f0ec;
    --ink-2: #cfcdc7;
    --muted: #a19f98;
    --line: #34332f;
    --accent: #8b93ff;
    --accent-ink: #12122a;
    --accent-soft: #23244a;
    --ok: #4ade80;
    --ok-soft: #12301d;
    --warn: #facc15;
    --warn-soft: #332b0d;
    --bad: #f87171;
    --bad-soft: #3a1717;
    --shadow: none;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #141414;
  --surface: #1e1e1d;
  --surface-2: #272725;
  --ink: #f1f0ec;
  --ink-2: #cfcdc7;
  --muted: #a19f98;
  --line: #34332f;
  --accent: #8b93ff;
  --accent-ink: #12122a;
  --accent-soft: #23244a;
  --ok: #4ade80;
  --ok-soft: #12301d;
  --warn: #facc15;
  --warn-soft: #332b0d;
  --bad: #f87171;
  --bad-soft: #3a1717;
  --shadow: none;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 17px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
a { color: var(--accent); text-decoration: none; }
h1 { font-size: 1.6rem; line-height: 1.2; margin: 0.4rem 0 0.8rem; letter-spacing: -0.01em; }
h2 { font-size: 1.15rem; margin: 0 0 0.5rem; }
h3 { font-size: 1rem; margin: 0.8rem 0 0.4rem; }
p { margin: 0.3rem 0; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.warn-text { color: var(--warn); }
.grow { flex: 1; min-width: 0; }
.center { text-align: center; justify-content: center; }

/* ---------- Grundgerüst */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(env(safe-area-inset-top) + 10px) max(16px, env(safe-area-inset-right)) 10px max(16px, env(safe-area-inset-left));
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(12px);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); font-weight: 700; }
.logo, .login-logo {
  display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 9px;
  background: var(--accent); color: var(--accent-ink); font-weight: 800;
}
.top-right { display: flex; align-items: center; gap: 8px; }
.who { color: var(--muted); font-size: 0.9rem; }
main {
  max-width: 920px; margin: 0 auto;
  padding: 16px max(16px, env(safe-area-inset-right)) calc(var(--tabbar-h) + 32px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  outline: none;
}
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; justify-content: center; gap: 4px;
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
}
.tabbar a {
  flex: 1; max-width: 140px; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 6px 4px; border-radius: 10px; color: var(--muted); font-size: 0.75rem; font-weight: 600;
}
.tabbar a .ti { font-size: 1.35rem; line-height: 1; }
.tabbar a.active { color: var(--accent); background: var(--accent-soft); }

/* ---------- Bausteine */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; margin: 0 0 14px; box-shadow: var(--shadow);
}
.card.center { text-align: center; }
.card.action { display: flex; align-items: center; gap: 14px; color: var(--ink); }
.card.action:hover { border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); }
.card.highlight { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 30%, var(--line)); }
.card.warn-card { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 35%, var(--line)); }
.card.error-card { border-color: var(--bad); }
.chev { margin-left: auto; font-size: 1.8rem; color: var(--muted); line-height: 1; }
.grid { display: grid; gap: 14px; }
.grid > .card { margin: 0; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); margin-bottom: 14px; }
.grid.subjects { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); margin-bottom: 14px; }
.grid.tiles { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); margin-bottom: 14px; }
.grid.chips { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 10px; }
.row.small { gap: 6px; margin-top: 6px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.section-title { margin: 22px 0 10px; }
.hero h1 { font-size: 1.8rem; margin-bottom: 0; }
.hero { margin-bottom: 14px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 0 16px; border-radius: 11px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  font: inherit; font-weight: 600; font-size: 0.95rem; cursor: pointer; text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.ghost { background: transparent; }
.btn.small { min-height: 36px; padding: 0 12px; font-size: 0.85rem; }
.btn.icon { min-width: 40px; min-height: 40px; padding: 0 8px; }
.btn.block { width: 100%; margin-top: 14px; }
.btn.danger { color: var(--bad); }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 60%, transparent); outline-offset: 2px; }

.pill {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px;
  font-size: 0.78rem; font-weight: 600; background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line);
}
.pill.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.pill.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.tag { font-size: 0.75rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); margin-bottom: 4px; }
.code { font-family: ui-monospace, Menlo, monospace; font-size: 0.8rem; font-weight: 700; color: var(--accent); background: var(--accent-soft); padding: 1px 6px; border-radius: 6px; }
.stars { color: #d97706; letter-spacing: 1px; }

.bar { height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; margin: 8px 0 4px; }
.bar > span { display: block; height: 100%; background: var(--accent); border-radius: 99px; transition: width 0.3s; }

.subject-dot {
  display: inline-grid; place-items: center; flex: none; width: 34px; height: 34px; border-radius: 10px;
  color: #fff; font-weight: 800; font-size: 0.9rem;
}
.subject-dot.small { width: 24px; height: 24px; border-radius: 7px; font-size: 0.72rem; }
.subject-dot.blank { background: var(--surface-2); }
.subject-head { display: flex; align-items: center; gap: 10px; }
.subject-head h2, .subject-head h3, .subject-head h1 { margin: 0; }
.card.subject { color: var(--ink); }
.big-num { font-size: 2.4rem; font-weight: 800; color: var(--accent); min-width: 64px; text-align: center; line-height: 1; }
.big-icon { font-size: 2.4rem; }

.list { list-style: none; margin: 0; padding: 0; }
.list.cards li { margin: 0; }
.list-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); color: var(--ink); }
.list li:last-child .list-row, .list > .list-row:last-child { border-bottom: 0; }
.list-row.link:hover { background: var(--surface-2); }
.card.skill { display: flex; align-items: center; gap: 12px; color: var(--ink); }
.skill-title { line-height: 1.35; }

input[type=text], input[type=password], input[type=number], input[type=date], select, textarea {
  width: 100%; min-height: 48px; padding: 10px 12px; border-radius: 11px;
  border: 1.5px solid var(--line); background: var(--surface); color: var(--ink);
  font: inherit; font-size: 1.05rem;
}
textarea { min-height: 96px; resize: vertical; line-height: 1.45; }
select { width: auto; min-width: 140px; }
input:focus, textarea:focus, select:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
input.ok, .seg.ok { border-color: var(--ok); background: var(--ok-soft); }
input.typo, .seg.typo { border-color: var(--warn); background: var(--warn-soft); }
input.bad, .seg.bad { border-color: var(--bad); background: var(--bad-soft); }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 8px; margin: 8px 0; }
.form-col { display: grid; gap: 8px; margin-top: 8px; }
.check { display: inline-flex; align-items: center; gap: 6px; }
.checks { display: grid; gap: 6px; margin: 8px 0; }
.ef { display: block; margin: 8px 0; }
.ef .label, .field .label { display: block; font-size: 0.8rem; font-weight: 600; color: var(--muted); margin-bottom: 3px; }

.seg { display: inline-flex; flex-wrap: wrap; gap: 4px; padding: 4px; background: var(--surface-2); border-radius: 12px; border: 1.5px solid transparent; }
.seg button, .seg a {
  min-height: 40px; padding: 0 14px; border-radius: 9px; border: 0; background: transparent;
  color: var(--ink-2); font: inherit; font-weight: 600; font-size: 0.92rem; cursor: pointer; display: inline-flex; align-items: center;
}
.seg [aria-checked=true], .seg [aria-selected=true] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); outline: 1.5px solid var(--accent); }
.seg.modes { margin: 12px 0 4px; }
.seg.tabs { margin-bottom: 14px; }

/* ---------- Vokabeln */
.session-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; gap: 10px; }
.session-stats { color: var(--muted); font-weight: 600; font-size: 0.9rem; }
.stage { max-width: 640px; margin: 0 auto; }
.flash { padding: 22px; }
.flash.new { border-color: color-mix(in srgb, var(--accent) 35%, var(--line)); }
.ask { font-size: 1.9rem; font-weight: 700; line-height: 1.25; margin: 6px 0; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; word-break: break-word; }
.instruction { color: var(--ink-2); margin: 10px 0; }
.fields { display: grid; gap: 10px; }
.field input { font-size: 1.2rem; }
.hint { min-height: 1.4em; margin-top: 8px; font-weight: 600; }
.hint.typo { color: var(--warn); }
.accents { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.accents button {
  min-width: 40px; min-height: 40px; border-radius: 9px; border: 1px solid var(--line); background: var(--surface-2);
  color: var(--ink); font: inherit; font-size: 1.05rem; cursor: pointer;
}
.solution { margin-top: 14px; padding: 14px; border-radius: 12px; border: 1.5px solid; }
.solution.ok { background: var(--ok-soft); border-color: var(--ok); }
.solution.typo { background: var(--warn-soft); border-color: var(--warn); }
.solution.bad { background: var(--bad-soft); border-color: var(--bad); }
.verdict { font-weight: 800; margin-bottom: 4px; }
.solution.ok .verdict { color: var(--ok); }
.solution.bad .verdict { color: var(--bad); }
.sol-term { font-size: 1.35rem; font-weight: 700; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.sol-term.large { font-size: 2rem; }
.sol-mean { font-size: 1.1rem; }
.sol-mean.large { font-size: 1.4rem; margin: 8px 0; }
.example { margin-top: 10px; padding-left: 10px; border-left: 3px solid var(--line); }
.note { margin-top: 8px; font-size: 0.92rem; }
.review .list-row.bad .mark { color: var(--bad); }
.review .list-row.ok .mark { color: var(--ok); }
.review .list-row.typo .mark { color: var(--warn); }
.mark { font-weight: 800; width: 1.4em; text-align: center; flex: none; }

/* ---------- Aufgaben */
.card.task { border-top: 5px solid var(--accent); }
.task-title { font-size: 1.3rem; margin: 2px 0 8px; }
.md { overflow-wrap: anywhere; }
.md p { margin: 0.45rem 0; }
.md ul, .md ol { margin: 0.4rem 0; padding-left: 1.4rem; }
.md table { border-collapse: collapse; margin: 8px 0; }
.md th, .md td { border: 1px solid var(--line); padding: 4px 8px; }
.md code { background: var(--surface-2); padding: 1px 5px; border-radius: 5px; }
.prompt { font-size: 1.12rem; }
.katex { font-size: 1.08em; }
.katex-display { overflow-x: auto; overflow-y: hidden; padding: 4px 0; }
.answer { margin-top: 10px; }
.choices { display: grid; gap: 8px; }
.choice {
  text-align: left; padding: 12px 14px; border-radius: 11px; border: 1.5px solid var(--line);
  background: var(--surface); color: var(--ink); font: inherit; cursor: pointer;
}
.choice[aria-checked=true] { border-color: var(--accent); background: var(--accent-soft); }
.choice p { margin: 0; }
.gaps { display: grid; gap: 8px; }
.gap { display: flex; align-items: center; gap: 8px; }
.gap-no { font-weight: 700; color: var(--accent); min-width: 2.2em; }
.steps { padding-left: 1.8rem; margin: 6px 0; display: grid; gap: 6px; }
.steps input { font-family: ui-monospace, Menlo, monospace; }
.photo-box .btn { margin: 6px 0; }
.photo-preview img, .thumb { max-width: 100%; border-radius: 10px; border: 1px solid var(--line); margin-top: 8px; display: block; }
.thumb { max-height: 260px; }
.thumb.wide { max-height: 480px; }
.thumbs { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.thumbs img { height: 90px; border-radius: 8px; border: 1px solid var(--line); }
.grading { margin-top: 12px; }

.pad-wrap { margin-top: 6px; }
.pad-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 6px; }
.pad-tools .tool.active { border-color: var(--accent); background: var(--accent-soft); }
.swatch { width: 32px; height: 32px; border-radius: 50%; border: 3px solid var(--surface); box-shadow: 0 0 0 1px var(--line); cursor: pointer; }
.swatch.active { box-shadow: 0 0 0 2px var(--accent); }
.pad-scroll { max-height: 70vh; overflow-y: auto; border: 1.5px solid var(--line); border-radius: 12px; background: #fff; -webkit-overflow-scrolling: touch; }
.pad { display: block; touch-action: none; cursor: crosshair; }

.attempt { border-left: 4px solid var(--line); padding: 4px 0 8px 12px; margin: 12px 0; }
.attempt.ok { border-color: var(--ok); }
.attempt.typo { border-color: var(--warn); }
.attempt.bad { border-color: var(--bad); }
.score { font-weight: 800; }
.graded-steps { list-style: none; padding: 0; margin: 8px 0; display: grid; gap: 4px; }
.graded-steps li { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px; padding: 6px 8px; border-radius: 8px; background: var(--surface-2); }
.graded-steps li.bad { background: var(--bad-soft); }
.graded-steps li.ok .mark { color: var(--ok); }
.graded-steps li.bad .mark { color: var(--bad); }
.step-comment { flex-basis: 100%; font-size: 0.9rem; color: var(--ink-2); padding-left: 1.8em; }
.feedback { background: var(--accent-soft); padding: 8px 12px; border-radius: 10px; margin-top: 6px; }
.help-item { border-left: 4px solid var(--accent); padding: 4px 0 4px 12px; margin: 10px 0; }
.help-item.l4 { border-color: var(--warn); }
.done-card { border-color: var(--ok); }
details summary { cursor: pointer; font-weight: 600; padding: 6px 0; }
.answer-pre { white-space: pre-wrap; background: var(--surface-2); padding: 10px; border-radius: 10px; font: inherit; }

/* ---------- Tutor */
.chip {
  display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink); font: inherit; font-weight: 600; cursor: pointer;
}
.chat-title { font-size: 1.2rem; }
.chat-log { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }
.msg { max-width: 88%; padding: 10px 14px; border-radius: 16px; line-height: 1.45; }
.msg.user { align-self: flex-end; background: var(--accent); color: var(--accent-ink); border-bottom-right-radius: 4px; white-space: pre-wrap; }
.msg.assistant { align-self: flex-start; background: var(--surface); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.msg.pending { opacity: 0.7; }
.msg .thumb { max-height: 180px; margin: 0 0 6px; }
.typing { display: flex; gap: 4px; }
.typing span { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite; }
.typing span:nth-child(2) { animation-delay: 0.2s; }
.typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%, 80%, 100% { opacity: 0.25; } 40% { opacity: 1; } }
.chat-input { position: sticky; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 8px); }
.chat-input textarea { min-height: 56px; }
.chat-photo-prev img { max-height: 90px; border-radius: 8px; }

/* ---------- Elternbereich */
.subnav { display: flex; gap: 4px; overflow-x: auto; margin: 0 -4px 10px; padding: 0 4px 4px; scrollbar-width: none; }
.subnav a { white-space: nowrap; padding: 8px 12px; border-radius: 10px; color: var(--ink-2); font-weight: 600; font-size: 0.9rem; }
.subnav a.active { background: var(--accent-soft); color: var(--accent); }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.tile-num { font-size: 1.4rem; font-weight: 800; }
.table-wrap { overflow-x: auto; }
table.data { border-collapse: collapse; width: 100%; font-size: 0.92rem; }
table.data th, table.data td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.data th { color: var(--muted); font-weight: 600; font-size: 0.8rem; }
table.data td.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.bad-row td { background: var(--bad-soft); }
.tags { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.focus-list { margin: 6px 0 0; padding-left: 1.1rem; font-size: 0.9rem; }
.subject-sum { padding: 6px 0; }
.chart-box { margin: 0; }
.chart-wrap { position: relative; }
.chart { width: 100%; height: auto; display: block; }
.chart .axis { font-size: 11px; fill: var(--muted); }
.chart .baseline { stroke: var(--line); stroke-width: 1; }
.chart-tip {
  position: absolute; top: -6px; transform: translate(-50%, -100%); pointer-events: none; opacity: 0;
  background: var(--ink); color: var(--bg); font-size: 0.8rem; padding: 4px 8px; border-radius: 6px; white-space: nowrap; transition: opacity 0.1s;
}
.chart-tip.show { opacity: 1; }
.item-editor { display: grid; gap: 10px; margin-bottom: 14px; }
.item-card { display: flex; gap: 10px; align-items: flex-start; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; }
.item-no { font-weight: 800; color: var(--muted); min-width: 1.6em; padding-top: 28px; }
.item-fields { flex: 1; display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 0 10px; min-width: 0; }
.item-fields .ef { margin: 4px 0; }
.item-fields .ef.wide { grid-column: span 2; }
@media (max-width: 520px) { .item-fields .ef.wide { grid-column: 1 / -1; } }
.item-fields input, .item-fields select { min-height: 42px; font-size: 1rem; }
.sticky-actions {
  position: sticky; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 8px); z-index: 5;
  display: flex; flex-wrap: wrap; gap: 8px; padding: 10px; border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface) 94%, transparent); border: 1px solid var(--line); box-shadow: 0 4px 18px rgb(0 0 0 / 0.08);
}
.skill-admin { flex-wrap: wrap; }
.skill-admin.inactive { opacity: 0.55; }
.level { display: flex; align-items: center; gap: 6px; }
.level input { width: 110px; }
.timeline .time { min-width: 92px; }

/* ---------- Anmeldung, Laden, Meldungen */
.login-wrap { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 16px; }
.login { width: 100%; max-width: 380px; text-align: center; padding: 28px 22px; }
.login-logo { width: 56px; height: 56px; border-radius: 16px; font-size: 1.6rem; margin-bottom: 8px; }
.login h1 { margin: 4px 0; }
.login input { margin-top: 14px; text-align: center; }
.user-pick { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 14px; }
.user-pick button {
  min-height: 56px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--surface);
  color: var(--ink); font: inherit; font-weight: 700; cursor: pointer;
}
.user-pick button.active { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.loading { display: grid; place-items: center; gap: 10px; padding: 48px 16px; color: var(--muted); text-align: center; }
.spin { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.empty { text-align: center; padding: 28px 12px; color: var(--muted); }
.empty h3 { color: var(--ink); }
#toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 18px); z-index: 60;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none; transition: all 0.2s;
  max-width: min(92vw, 520px); padding: 12px 16px; border-radius: 12px; background: var(--ink); color: var(--bg);
  font-weight: 600; box-shadow: 0 6px 20px rgb(0 0 0 / 0.2);
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.error { background: var(--bad); color: #fff; }
#toast.ok { background: var(--ok); color: #fff; }
.modal-wrap { position: fixed; inset: 0; z-index: 50; background: rgb(0 0 0 / 0.4); display: grid; place-items: center; padding: 16px; }
.modal { background: var(--surface); border-radius: var(--radius); width: 100%; max-width: 520px; max-height: 90vh; overflow: auto; padding: 16px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; }

@media (max-width: 520px) {
  body { font-size: 16px; }
  h1 { font-size: 1.4rem; }
  .ask { font-size: 1.55rem; }
  .who { display: none; }
  .card { padding: 14px; }
  .flash { padding: 16px; }
  .big-num { font-size: 2rem; min-width: 52px; }
}
@media (min-width: 900px) {
  .tabbar { top: auto; }
}
@media print {
  .topbar, .tabbar, .btn { display: none !important; }
}
