/* Business English Trainer - handgeschriebenes CSS, kein Build-Schritt.
   Mobile-first, Dark Mode ueber prefers-color-scheme. */

:root {
  --bg: #f4f6fa;
  --card: #ffffff;
  --ink: #16202e;
  --muted: #5c6b80;
  --line: #dde3ec;
  --brand: #112b4a;
  --accent: #2d7ff0;
  --good: #1f8a4c;
  --good-bg: #e6f6ec;
  --bad: #c22f3a;
  --bad-bg: #fdeaec;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(16, 28, 45, .09), 0 6px 20px rgba(16, 28, 45, .06);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1724;
    --card: #17212f;
    --ink: #e8edf4;
    --muted: #93a2b6;
    --line: #26323f;
    --brand: #0c1c30;
    --accent: #58a6ff;
    --good: #58d68d;
    --good-bg: #133226;
    --bad: #ff8189;
    --bad-bg: #351a1e;
    --shadow: 0 1px 3px rgba(0, 0, 0, .45);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}

main {
  max-width: 720px;
  margin: 0 auto;
  padding: 20px 16px 64px;
}

/* --- Topbar ------------------------------------------------------------ */
.topbar {
  background: var(--brand);
  color: #fff;
  padding: env(safe-area-inset-top) 0 0;
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand {
  display: block;
  padding: 12px 16px 6px;
  color: #fff;
  font-weight: 650;
  text-decoration: none;
  font-size: 1.02rem;
}
.topbar nav {
  display: flex;
  gap: 2px;
  overflow-x: auto;
  padding: 0 10px 8px;
  scrollbar-width: none;
}
.topbar nav::-webkit-scrollbar { display: none; }
.topbar nav a {
  flex: 0 0 auto;
  color: #c9d8ec;
  text-decoration: none;
  padding: 7px 13px;
  border-radius: 999px;
  font-size: .9rem;
  white-space: nowrap;
}
.topbar nav a.on { background: rgba(255, 255, 255, .17); color: #fff; font-weight: 600; }

/* --- Bausteine --------------------------------------------------------- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 16px;
}

h1 { font-size: 1.4rem; margin: 0 0 4px; letter-spacing: -.01em; }
h2 { font-size: 1.1rem; margin: 22px 0 10px; }
.sub { color: var(--muted); font-size: .92rem; margin: 0 0 18px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

.prompt-label { color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; margin-bottom: 8px; }
.prompt-big { font-size: 1.55rem; font-weight: 650; line-height: 1.3; margin: 0 0 4px; }
.prompt-text { font-size: 1.08rem; line-height: 1.6; margin: 0 0 6px; }

/* --- Buttons & Eingaben ------------------------------------------------ */
.btn {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  border: 0;
  border-radius: 10px;
  padding: 13px 20px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
}
.btn:active { transform: translateY(1px); }
.btn.ghost { background: transparent; color: var(--accent); border: 1px solid var(--line); }
.btn.wide { display: block; width: 100%; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-row .btn { flex: 1 1 140px; }

input[type=text], input[type=password] {
  width: 100%;
  padding: 14px 15px;
  font-size: 1.08rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  color: var(--ink);
}
input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

/* Antwortoptionen als grosse Tap-Ziele */
.options { display: grid; gap: 10px; margin: 18px 0 4px; }
.option {
  display: block;
  width: 100%;
  text-align: left;
  background: var(--card);
  color: var(--ink);
  border: 1.5px solid var(--line);
  border-radius: 12px;
  padding: 15px 16px;
  font-size: 1.02rem;
  line-height: 1.45;
  cursor: pointer;
}
.option:hover { border-color: var(--accent); }
.option.correct { border-color: var(--good); background: var(--good-bg); }
.option.wrong { border-color: var(--bad); background: var(--bad-bg); }

/* --- Ergebnis ---------------------------------------------------------- */
.verdict { border-radius: var(--radius); padding: 16px 18px; margin-bottom: 16px; font-weight: 600; }
.verdict.ok { background: var(--good-bg); color: var(--good); border: 1px solid var(--good); }
.verdict.no { background: var(--bad-bg); color: var(--bad); border: 1px solid var(--bad); }
.verdict .line { font-weight: 400; color: var(--ink); margin-top: 6px; font-size: .95rem; }
.strike { text-decoration: line-through; opacity: .75; }

.explain {
  border-left: 3px solid var(--accent);
  padding: 4px 0 4px 14px;
  margin: 14px 0;
  color: var(--muted);
  font-size: .94rem;
}

/* --- Kacheln (Dashboard) ---------------------------------------------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-bottom: 18px; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 15px; box-shadow: var(--shadow); }
.tile .n { font-size: 1.7rem; font-weight: 700; line-height: 1.1; }
.tile .k { color: var(--muted); font-size: .82rem; margin-top: 2px; }

.modes { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.mode {
  display: block;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 17px;
  text-decoration: none;
  color: var(--ink);
  box-shadow: var(--shadow);
}
.mode:hover { border-color: var(--accent); }
.mode .t { font-weight: 650; font-size: 1.05rem; }
.mode .d { color: var(--muted); font-size: .88rem; margin-top: 3px; }
.mode .e { font-size: 1.5rem; }

/* --- Fortschrittsbalken ----------------------------------------------- */
.bar { height: 9px; background: var(--line); border-radius: 999px; overflow: hidden; margin: 8px 0 2px; }
.bar > span { display: block; height: 100%; background: var(--accent); }
.bar.ok > span { background: var(--good); }

/* --- Verlaufs-Diagramm ------------------------------------------------ */
.chart { display: flex; align-items: flex-end; gap: 5px; height: 130px; margin: 10px 0 4px; }
.chart .col { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; height: 100%; gap: 1px; }
.chart .g { background: var(--good); border-radius: 2px 2px 0 0; min-height: 0; }
.chart .b { background: var(--bad); border-radius: 0 0 2px 2px; }
.chart-x { display: flex; gap: 5px; color: var(--muted); font-size: .68rem; }
.chart-x span { flex: 1; text-align: center; }
.legend { display: flex; gap: 14px; font-size: .84rem; color: var(--muted); margin-top: 8px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; }

/* --- Tabellen --------------------------------------------------------- */
.tablewrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.is-learned td:first-child::after { content: " ✓"; color: var(--good); }

.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .76rem; font-weight: 600; }
.pill.good { background: var(--good-bg); color: var(--good); }
.pill.bad { background: var(--bad-bg); color: var(--bad); }
.pill.flat { background: var(--line); color: var(--muted); }

.chips { display: flex; gap: 7px; flex-wrap: wrap; margin-bottom: 16px; }
.chip { padding: 6px 13px; border: 1px solid var(--line); border-radius: 999px; text-decoration: none; color: var(--muted); font-size: .85rem; background: var(--card); }
.chip.on { background: var(--accent); color: #fff; border-color: var(--accent); font-weight: 600; }

/* --- Audio ------------------------------------------------------------ */
.speak {
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 999px;
  width: 40px; height: 40px;
  font-size: 1.05rem;
  cursor: pointer;
  color: var(--ink);
  vertical-align: middle;
  margin-left: 8px;
}
.speak:hover { border-color: var(--accent); }
.speak[hidden] { display: none; }

.flash { background: var(--good-bg); color: var(--good); padding: 11px 14px; border-radius: 10px; margin-bottom: 14px; }

/* --- Login ------------------------------------------------------------ */
.login-wrap { max-width: 380px; margin: 9vh auto; padding: 0 16px; }
.login-wrap h1 { text-align: center; margin-bottom: 20px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: .85rem; color: var(--muted); margin-bottom: 5px; }
.errors { background: var(--bad-bg); color: var(--bad); padding: 11px 14px; border-radius: 10px; margin-bottom: 14px; font-size: .92rem; }
