:root {
  color-scheme: light dark;
  --ground: #f2f5f4;
  --surface: #ffffff;
  --sunk: #e8edeb;
  --ink: #16211f;
  --ink-soft: #3c4c49;
  --muted: #63736f;
  --line: #d3dcd9;
  --accent: #0f6e63;
  --accent-soft: #dceae7;
  --ok: #2c6e51;
  --warn: #8e5b12;
  --stop: #9c3227;
  --stop-soft: #f4dfdc;
  --sans: "IBM Plex Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ground: #0e1413;
    --surface: #161e1c;
    --sunk: #1d2725;
    --ink: #e5ebe9;
    --ink-soft: #bfccc8;
    --muted: #8d9c98;
    --line: #2a3735;
    --accent: #5cbfb0;
    --accent-soft: #16302c;
    --ok: #6fc49a;
    --warn: #d4a055;
    --stop: #e08076;
    --stop-soft: #331c19;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

[hidden] { display: none !important; }

/* ---------- Anmeldung ---------- */

.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--line);
  padding: 32px;
  width: min(100%, 380px);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.login-card h1 { margin: 0; font-size: 26px; letter-spacing: -0.02em; }
.login-card .sub { margin: 0 0 16px; color: var(--muted); font-size: 13px;
  text-transform: uppercase; letter-spacing: 0.1em; }

label { font-size: 12px; font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.06em; }

input, select {
  font: inherit;
  padding: 9px 11px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  border-radius: 2px;
  width: 100%;
}

input:focus-visible, select:focus-visible, button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

button {
  font: inherit;
  font-weight: 600;
  padding: 10px 14px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--surface);
  border-radius: 2px;
  cursor: pointer;
}
button:hover { filter: brightness(1.08); }
button[disabled] { opacity: 0.45; cursor: not-allowed; }

.login-card button { margin-top: 16px; }

.error { color: var(--stop); background: var(--stop-soft); padding: 8px 10px;
  margin: 12px 0 0; font-size: 14px; }

/* ---------- Kopfzeile ---------- */

.topbar {
  display: flex; flex-wrap: wrap; gap: 12px;
  align-items: center; justify-content: space-between;
  padding: 14px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5;
}

.brand { font-weight: 700; letter-spacing: -0.015em; }
.brand span { font-weight: 400; color: var(--muted); }

.status { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-soft); }
.sep { color: var(--line); }

.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--stop); flex: none; }
.dot.on { background: var(--ok); }

.linkish {
  background: none; border: none; color: var(--accent);
  padding: 2px 4px; font-size: 13px; font-weight: 500; text-decoration: underline;
}
.linkish:hover { filter: none; opacity: 0.8; }

/* ---------- Raster ---------- */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
  padding: 16px 20px 40px;
  max-width: 1400px;
  margin: 0 auto;
  align-items: start;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  padding: 18px;
  display: flex; flex-direction: column; gap: 10px;
}
.card.wide { grid-column: span 2; }
@media (max-width: 900px) { .card.wide { grid-column: span 1; } }

h2 { margin: 0 0 4px; font-size: 13px; text-transform: uppercase;
  letter-spacing: 0.1em; color: var(--muted); font-weight: 600; }
h3 { margin: 10px 0 0; font-size: 12px; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--muted); font-weight: 600; }

.radios { border: none; margin: 0; padding: 0; display: flex; gap: 16px; align-items: center; }
.radios legend { font-size: 12px; font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.06em; padding: 0; }
.radios label { display: flex; align-items: center; gap: 6px;
  text-transform: none; letter-spacing: 0; font-size: 14px; color: var(--ink); }
.radios input { width: auto; }

.phases { display: flex; flex-wrap: wrap; gap: 6px; }
.phases button { font-size: 13px; padding: 7px 10px; font-family: var(--mono); font-weight: 500; }
.phases button.secondary {
  background: var(--sunk); color: var(--ink); border-color: var(--line);
}
.phases button.active { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }

.hint { margin: 4px 0 0; font-size: 13px; color: var(--muted); }
code { font-family: var(--mono); font-size: 0.9em; background: var(--sunk); padding: 1px 4px; }

/* ---------- Sätze ---------- */

.answer-controls { display: flex; gap: 8px; flex-wrap: wrap; }
.answer-controls input { flex: 1 1 200px; }
.answer-controls select { flex: 0 0 auto; width: auto; min-width: 140px; }

.sentences { list-style: none; margin: 0; padding: 0;
  max-height: 420px; overflow-y: auto; border-top: 1px solid var(--line); }
.sentences li { border-bottom: 1px solid var(--line); }
.sentences button {
  width: 100%; text-align: left; background: none; border: none;
  color: var(--ink); font-family: var(--mono); font-size: 13px; font-weight: 400;
  padding: 9px 6px; word-break: break-all;
}
.sentences button:hover { background: var(--accent-soft); color: var(--accent); }

/* ---------- Verlauf ---------- */

.log { list-style: none; margin: 0; padding: 0; max-height: 420px; overflow-y: auto;
  font-size: 13px; display: flex; flex-direction: column-reverse; }
.log li { padding: 6px 0; border-bottom: 1px solid var(--line); display: flex; gap: 8px; }
.log time { color: var(--muted); font-family: var(--mono); font-size: 12px; flex: none; }
.log .out { color: var(--accent); }
.log .in { color: var(--muted); }

/* ---------- Toast ---------- */

.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  background: var(--ink); color: var(--ground);
  padding: 10px 16px; border-radius: 2px; font-size: 14px; z-index: 20;
  max-width: min(90vw, 480px);
}
.toast.bad { background: var(--stop); color: #fff; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

.sentences .more, .sentences .blocked {
  padding: 8px 6px;
  font-size: 12.5px;
  color: var(--muted);
  font-family: var(--mono);
}
.sentences .blocked { color: var(--warn); word-break: break-all; }
