/* Sprachkiste – Oberfläche
   Bildwelt: Emaille-Wegweiser und ein echter Karteikasten. */

@import url('https://fonts.googleapis.com/css2?family=Bricolage+Grotesque:opsz,wght@12..96,500;12..96,700;12..96,800&family=Figtree:wght@400;500;600;700&family=DM+Mono:wght@400;500&display=swap');

:root {
  --ink:       #101a2b;
  --ink-2:     #24354f;
  --ink-3:     #5b6b83;
  --paper:     #edf0ee;
  --card:      #ffffff;
  --line:      #d5dbdd;

  --cobalt:    #2d5be3;
  --sun:       #f0a808;
  --coral:     #e04b32;
  --mint:      #109a72;
  --berry:     #6f45d8;

  --accent:    var(--cobalt);
  --accent-ink:#ffffff;

  --r-s: 8px;
  --r-m: 14px;
  --r-l: 22px;

  --shadow:    0 1px 0 rgba(16,26,43,.06), 0 10px 24px -14px rgba(16,26,43,.45);
  --shadow-lg: 0 2px 0 rgba(16,26,43,.08), 0 26px 50px -24px rgba(16,26,43,.55);

  --display: 'Bricolage Grotesque', 'Trebuchet MS', system-ui, sans-serif;
  --body:    'Figtree', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono:    'DM Mono', ui-monospace, 'SF Mono', Menlo, monospace;
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--body);
  font-size: 16px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}
body { min-height: 100dvh; }

h1, h2, h3, .display { font-family: var(--display); letter-spacing: -0.02em; margin: 0 0 .4em; }
h1 { font-size: 1.75rem; font-weight: 800; }
h2 { font-size: 1.25rem; font-weight: 700; }
h3 { font-size: 1rem; font-weight: 700; }
p  { margin: 0 0 1em; }
a  { color: var(--accent); }

.eyebrow {
  font-family: var(--mono);
  font-size: .72rem; text-transform: uppercase; letter-spacing: .14em;
  color: var(--ink-3); margin: 0 0 .5rem;
}

/* ------------------------------------------------------------- Grundgerüst */
#app { padding-bottom: 84px; }
.wrap { max-width: 720px; margin: 0 auto; padding: 0 16px; }

.topbar {
  position: sticky; top: 0; z-index: 30;
  background: var(--ink); color: #fff;
  padding: 10px 0;
  box-shadow: 0 1px 0 rgba(0,0,0,.15);
}
.topbar .wrap { display: flex; align-items: center; gap: 12px; }
.brand { display: flex; align-items: center; gap: 10px; font-family: var(--display); font-weight: 800; }
.brand-mark {
  display: grid; place-items: center;
  width: 30px; height: 30px; border-radius: 9px;
  background: var(--sun); color: var(--ink);
  font-family: var(--display); font-size: .8rem; font-weight: 800;
}
.brand small { font-family: var(--mono); font-weight: 400; opacity: .6; font-size: .68rem; }
.topbar .spacer { flex: 1; }

.profile-chip {
  display: inline-flex; align-items: center; gap: 8px;
  background: rgba(255,255,255,.12); color: #fff;
  border: 0; border-radius: 999px; padding: 5px 12px 5px 6px;
  font: inherit; font-size: .85rem; cursor: pointer;
}
.profile-chip .av { font-size: 1.1rem; line-height: 1; }
.profile-chip:hover { background: rgba(255,255,255,.2); }

/* --------------------------------------------------------------- Navigation */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--card);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar button {
  background: none; border: 0; padding: 10px 4px 12px;
  font: inherit; font-size: .7rem; color: var(--ink-3);
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  cursor: pointer;
}
.tabbar button .ic { font-size: 1.25rem; line-height: 1; }
.tabbar button[aria-current="true"] { color: var(--ink); font-weight: 600; }
.tabbar button[aria-current="true"] .ic { transform: translateY(-1px); }

/* -------------------------------------------------------------------- Karten */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-m);
  padding: 16px;
  box-shadow: var(--shadow);
  margin-bottom: 14px;
}
.card.flat { box-shadow: none; }
.card h2 { margin-bottom: .25em; }

.section { padding: 18px 0 4px; }
.stack { display: grid; gap: 12px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.muted { color: var(--ink-3); }
.small { font-size: .85rem; }
.mono { font-family: var(--mono); }
.center { text-align: center; }

/* ------------------------------------------------------------------ Knöpfe */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  border-radius: 999px; padding: 10px 18px;
  font: inherit; font-weight: 600; cursor: pointer;
  transition: transform .08s ease, background .15s ease, border-color .15s ease;
  text-decoration: none;
}
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 3px solid var(--sun); outline-offset: 2px; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-dark { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn-ghost { background: transparent; }
.btn-lg { padding: 14px 24px; font-size: 1.05rem; width: 100%; }
.btn-sm { padding: 6px 12px; font-size: .82rem; }
.btn-danger { color: var(--coral); border-color: #f0c4bb; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

/* ---------------------------------------------------------------- Formulare */
label { display: block; font-weight: 600; font-size: .88rem; }
input[type=text], input[type=email], input[type=password], input[type=number], select, textarea {
  display: block; width: 100%; margin-top: 5px;
  padding: 11px 13px;
  border: 1px solid var(--line); border-radius: var(--r-s);
  background: #fff; color: var(--ink);
  font: inherit;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
.switch { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: .9rem; }
.switch input { width: 20px; height: 20px; accent-color: var(--accent); }

.alert { border-radius: var(--r-s); padding: 11px 13px; font-size: .9rem; margin-bottom: 12px; }
.alert-error { background: #fdece8; color: #8f2a16; border: 1px solid #f3c3b7; }
.alert-ok { background: #e4f6ef; color: #0c6b4f; border: 1px solid #b3e2d0; }
.alert-info { background: #e9eefc; color: #1c3a94; border: 1px solid #c2d0f5; }

/* ------------------------------------------------------------ Sprachkacheln */
.lang-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.lang-tile {
  position: relative; text-align: left;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r-m);
  padding: 14px; cursor: pointer; font: inherit; color: inherit;
  box-shadow: var(--shadow);
  border-left: 6px solid var(--accent);
}
.lang-tile .flag { font-size: 1.8rem; line-height: 1; }
.lang-tile .name { font-family: var(--display); font-weight: 700; font-size: 1.1rem; margin-top: 6px; }
.lang-tile .meta { font-family: var(--mono); font-size: .72rem; color: var(--ink-3); }
.badge-due {
  position: absolute; top: 10px; right: 10px;
  background: var(--coral); color: #fff;
  font-family: var(--mono); font-size: .7rem; font-weight: 500;
  border-radius: 999px; padding: 2px 8px;
}

/* --------------------------------------------------------------- Lernkarte */
.trainer { min-height: calc(100dvh - 140px); display: flex; flex-direction: column; }
.trainer-head { display: flex; align-items: center; gap: 10px; padding: 12px 0; }
.progress-rail { flex: 1; height: 8px; background: #dfe4e4; border-radius: 999px; overflow: hidden; }
.progress-rail > i { display: block; height: 100%; background: var(--accent); border-radius: 999px; transition: width .3s ease; }

.qcard {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r-l);
  box-shadow: var(--shadow-lg);
  padding: 26px 20px; text-align: center;
  position: relative; overflow: hidden;
}
.qcard::before {
  content: ''; position: absolute; inset: 0 0 auto; height: 6px; background: var(--accent);
}
.qcard .pict { font-size: 3.6rem; line-height: 1; margin-bottom: 8px; }
.qcard .prompt {
  font-family: var(--display); font-weight: 800;
  font-size: clamp(1.6rem, 7vw, 2.4rem); line-height: 1.15;
  overflow-wrap: anywhere;
}
.qcard .prompt.small { font-size: clamp(1.2rem, 5.4vw, 1.7rem); }
.qcard .prompt.tiny  { font-size: clamp(1.05rem, 4.4vw, 1.35rem); line-height: 1.25; }
.qcard .sub { color: var(--ink-3); font-size: .92rem; margin-top: 6px; }
.qcard .ask { font-family: var(--mono); font-size: .72rem; text-transform: uppercase; letter-spacing: .12em; color: var(--ink-3); }

.speak-btn {
  margin-top: 14px;
  display: inline-flex; align-items: center; gap: 8px;
  border: 1px solid var(--line); background: #fff; border-radius: 999px;
  padding: 8px 16px; font: inherit; font-weight: 600; cursor: pointer;
}
.speak-btn.big { font-size: 1.1rem; padding: 14px 22px; }
.speak-btn.playing { background: var(--ink); color: #fff; border-color: var(--ink); }

.options { display: grid; gap: 10px; margin-top: 18px; }
.opt {
  display: flex; align-items: center; gap: 12px;
  background: var(--card); border: 1.5px solid var(--line); border-radius: var(--r-m);
  padding: 14px 16px; font: inherit; font-size: 1.05rem; font-weight: 600;
  text-align: left; cursor: pointer; width: 100%;
  transition: border-color .12s ease, background .12s ease, transform .08s ease;
}
.opt .oic { font-size: 1.4rem; line-height: 1; width: 1.6rem; text-align: center; flex: 0 0 auto; }
.opt.long { font-size: .95rem; line-height: 1.35; padding: 12px 14px; }
.opt:hover { border-color: var(--ink-3); }
.opt:active { transform: translateY(1px); }
.opt.right { border-color: var(--mint); background: #e8f7f1; }
.opt.wrong { border-color: var(--coral); background: #fdeeea; }
.opt.dim { opacity: .5; }
.opt:disabled { cursor: default; }

.answer-box { margin-top: 18px; }
.answer-box input { font-size: 1.15rem; text-align: center; }

.feedback { margin-top: 16px; border-radius: var(--r-m); padding: 14px 16px; }
.feedback.right { background: #e8f7f1; border: 1px solid #b3e2d0; }
.feedback.wrong { background: #fdeeea; border: 1px solid #f3c3b7; }
.feedback .verdict { font-family: var(--display); font-weight: 800; font-size: 1.15rem; }
.feedback .solution { font-size: 1.05rem; }
.feedback .solution b { font-weight: 700; }

/* ------------------------------------------------------- Karteikasten (Signatur) */
.kasten {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px;
  align-items: end;
  background: linear-gradient(180deg, #e5e9e7, #dbe1de);
  border: 1px solid var(--line); border-radius: var(--r-m);
  padding: 14px 12px 10px;
}
.kasten .slot { text-align: center; }
.kasten .stack-vis {
  position: relative; height: 82px;
  display: flex; flex-direction: column-reverse; align-items: center; justify-content: flex-start;
  gap: 2px;
}
.kasten .sheet {
  width: 100%; height: 5px; border-radius: 2px;
  background: #fff; border: 1px solid #c9d1cd;
}
.kasten .slot[data-box="0"] .sheet { background: #f8d7cf; border-color: #e8a795; }
.kasten .slot[data-box="1"] .sheet { background: #fde6c0; border-color: #efc880; }
.kasten .slot[data-box="2"] .sheet { background: #fdf1c8; border-color: #ecd88a; }
.kasten .slot[data-box="3"] .sheet { background: #e2f0d5; border-color: #b2d49a; }
.kasten .slot[data-box="4"] .sheet { background: #d3ecdd; border-color: #97cdb1; }
.kasten .slot[data-box="5"] .sheet { background: #c7e6e2; border-color: #86c3bd; }
.kasten .slot[data-box="6"] .sheet { background: #c8dcf6; border-color: #8aaee2; }
.kasten .cnum { font-family: var(--mono); font-size: .8rem; font-weight: 500; margin-top: 5px; }
.kasten .clabel { font-family: var(--mono); font-size: .58rem; color: var(--ink-3); text-transform: uppercase; letter-spacing: .06em; }

/* ------------------------------------------------------------ Fortschritt */
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r-m);
  padding: 12px; text-align: center;
}
.stat .v { font-family: var(--display); font-weight: 800; font-size: 1.5rem; line-height: 1.1; }
.stat .l { font-family: var(--mono); font-size: .62rem; text-transform: uppercase; letter-spacing: .1em; color: var(--ink-3); }

.topic-row { display: grid; gap: 4px; margin-bottom: 12px; }
.topic-row .t { display: flex; justify-content: space-between; font-size: .9rem; font-weight: 600; }
.bar { height: 9px; background: #dfe4e4; border-radius: 999px; overflow: hidden; display: flex; }
.bar > .b-solid { background: var(--mint); }
.bar > .b-started { background: var(--sun); }

.spark { display: flex; align-items: flex-end; gap: 4px; height: 76px; }
.spark .d { flex: 1; background: var(--accent); border-radius: 3px 3px 0 0; min-height: 3px; opacity: .85; }
.spark .d.zero { background: #dfe4e4; }
.spark-x { display: flex; gap: 4px; margin-top: 5px; }
.spark-x span { flex: 1; text-align: center; font-family: var(--mono); font-size: .55rem; color: var(--ink-3); }

.chiplist { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: #fff; border: 1px solid var(--line); border-radius: 999px;
  padding: 5px 12px; font-size: .85rem;
}

/* ----------------------------------------------------------------- Tabellen */
.tbl { width: 100%; border-collapse: collapse; font-size: .9rem; }
.tbl th { text-align: left; font-family: var(--mono); font-size: .66rem; text-transform: uppercase; letter-spacing: .1em; color: var(--ink-3); padding: 6px 8px; border-bottom: 1px solid var(--line); }
.tbl td { padding: 9px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tag { font-family: var(--mono); font-size: .68rem; padding: 2px 7px; border-radius: 999px; border: 1px solid var(--line); }
.tag.admin { background: var(--ink); color: #fff; border-color: var(--ink); }
.tag.off { background: #fdeeea; color: #8f2a16; border-color: #f3c3b7; }

/* ------------------------------------------------------------------- Dialog */
.sheet-overlay {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(16,26,43,.5);
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet-panel {
  background: var(--card); width: 100%; max-width: 520px;
  border-radius: var(--r-l) var(--r-l) 0 0;
  padding: 20px 18px calc(20px + env(safe-area-inset-bottom));
  max-height: 88dvh; overflow: auto;
  animation: rise .22s ease;
}
@keyframes rise { from { transform: translateY(18px); opacity: .6; } to { transform: none; opacity: 1; } }

/* --------------------------------------------------------------- Einrichtung */
body.setup { display: grid; place-items: center; min-height: 100dvh; padding: 20px; }
.setup-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r-l);
  box-shadow: var(--shadow-lg); padding: 26px; max-width: 460px; width: 100%;
}
.setup-card .brand { color: var(--ink); margin-bottom: 18px; }
.lead { color: var(--ink-3); }
.pack-report { font-size: .9rem; padding-left: 18px; }

/* -------------------------------------------------------------------- Login */
.gate { max-width: 420px; margin: 0 auto; padding: 28px 16px; }
.gate .hero-mark {
  font-family: var(--display); font-weight: 800; font-size: 2.4rem; letter-spacing: -.03em;
  line-height: 1; margin-bottom: 4px;
}
.gate .hero-sub { color: var(--ink-3); margin-bottom: 22px; }
.tabs { display: flex; gap: 6px; margin-bottom: 16px; }
.tabs button {
  flex: 1; border: 1px solid var(--line); background: transparent; border-radius: 999px;
  padding: 9px; font: inherit; font-weight: 600; cursor: pointer;
}
.tabs button[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }

.toast {
  position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%);
  background: var(--ink); color: #fff; border-radius: 999px;
  padding: 10px 18px; font-size: .9rem; z-index: 70;
  box-shadow: var(--shadow-lg); max-width: 90vw; text-align: center;
}

.spinner {
  width: 22px; height: 22px; border-radius: 50%;
  border: 3px solid var(--line); border-top-color: var(--accent);
  animation: spin .7s linear infinite; margin: 30px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

@media (min-width: 720px) {
  .stat-grid { grid-template-columns: repeat(6, 1fr); }
}

/* ================================================================ Lektionen */
.tier-head {
  display: flex; align-items: baseline; gap: 10px;
  margin: 20px 0 8px; padding-bottom: 6px;
  border-bottom: 2px solid var(--ink);
}
.tier-head .tier-num {
  font-family: var(--mono); font-size: .68rem; text-transform: uppercase; letter-spacing: .14em;
  background: var(--ink); color: #fff; border-radius: 999px; padding: 2px 9px;
}
.tier-head .tier-name { font-family: var(--display); font-weight: 700; font-size: 1rem; }

.lesson {
  display: flex; align-items: center; gap: 12px; width: 100%;
  background: var(--card); border: 1px solid var(--line); border-left: 5px solid var(--line);
  border-radius: var(--r-m); padding: 12px 14px; margin-bottom: 8px;
  font: inherit; text-align: left; color: inherit; cursor: pointer;
  transition: border-color .12s ease, transform .08s ease;
}
.lesson:hover { border-color: var(--ink-3); }
.lesson:active { transform: translateY(1px); }
.lesson .lesson-icon { font-size: 1.6rem; line-height: 1; flex: 0 0 auto; width: 2rem; text-align: center; }
.lesson .lesson-body { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.lesson .lesson-title { font-family: var(--display); font-weight: 700; font-size: 1.02rem; }
.lesson .lesson-meta { font-family: var(--mono); font-size: .66rem; color: var(--ink-3); }
.lesson .lesson-state { font-family: var(--mono); font-size: .68rem; color: var(--ink-3); flex: 0 0 auto; }
.lesson.done { border-left-color: var(--mint); }
.lesson.done .lesson-state { color: var(--mint); font-weight: 500; }
.lesson.next { border-left-color: var(--accent); border-color: var(--accent); box-shadow: var(--shadow); }
.lesson.next .lesson-state { color: var(--accent); font-weight: 600; }
.lesson.locked { opacity: .45; cursor: not-allowed; background: transparent; box-shadow: none; }

.review-card { border-left: 5px solid var(--coral); }

.phase-line {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  font-size: .8rem; color: var(--ink-3); margin-bottom: 10px;
}
.phase-line .phase-tag {
  font-family: var(--mono); font-size: .62rem; text-transform: uppercase; letter-spacing: .1em;
  background: var(--ink); color: #fff; border-radius: 999px; padding: 2px 9px;
}

.tipcard { text-align: left; }
.tipcard .pict { text-align: center; }
.tipcard .ask { text-align: center; }
.tipcard .tiptext { color: var(--ink-2); margin: 0; }

/* ------------------------------------------------------------------- Paare */
.pair-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 16px; }
.pair-col { display: grid; gap: 8px; align-content: start; }
.pair {
  background: var(--card); border: 1.5px solid var(--line); border-radius: var(--r-m);
  padding: 12px 10px; font: inherit; font-weight: 600; font-size: .95rem;
  cursor: pointer; min-height: 52px; overflow-wrap: anywhere;
  transition: border-color .12s ease, background .12s ease, opacity .2s ease;
}
.pair.de { font-weight: 500; }
.pair.sel { border-color: var(--accent); background: #eef2fe; }
.pair.ok { border-color: var(--mint); background: #e8f7f1; opacity: .45; cursor: default; }
.pair.bad { border-color: var(--coral); background: #fdeeea; }

/* ----------------------------------------------------------- Satzbaukasten */
.build-line {
  min-height: 62px; margin-top: 16px; padding: 10px;
  border: 2px dashed var(--line); border-radius: var(--r-m);
  display: flex; flex-wrap: wrap; gap: 6px; align-items: flex-start; align-content: flex-start;
  background: #fbfcfc;
}
.build-hint { color: var(--ink-3); font-size: .85rem; padding: 4px; }
.tile-bank { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; justify-content: center; }
.tile {
  background: var(--card); border: 1.5px solid var(--line); border-radius: 10px;
  padding: 9px 13px; font: inherit; font-size: 1rem; font-weight: 600; cursor: pointer;
}
.tile:active { transform: translateY(1px); }
.tile.placed { border-color: var(--accent); background: #eef2fe; }
.tile.spent { opacity: .25; cursor: default; }

.qcard .prompt .gap {
  display: inline-block; border-bottom: 3px solid var(--accent);
  min-width: 3.2em; vertical-align: baseline; color: transparent;
}

/* ------------------------------------------------------------------ Dialog */
.dialog { margin-top: 16px; display: grid; gap: 10px; }
.bubble {
  padding: 11px 14px; border-radius: 16px; max-width: 88%;
  border: 1px solid var(--line); background: var(--card); cursor: pointer;
}
.bubble.me { justify-self: end; border-bottom-right-radius: 5px; background: #eef2fe; border-color: #c9d6fa; }
.bubble.you { justify-self: start; border-bottom-left-radius: 5px; }
.bubble .b-target { font-weight: 600; }
.bubble .b-de { font-size: .84rem; color: var(--ink-3); margin-top: 2px; }

@media (max-width: 380px) {
  .pair { font-size: .86rem; padding: 10px 8px; }
  .tile { font-size: .92rem; padding: 8px 11px; }
}
