/* ==========================================================================
   PLATO – Design-System
   Freundlich & rund wie Duolingo, aber ruhiger: warmes Papier, Petrol als
   Leitfarbe, ein einziger warmer Akzent (Münz-Gold). Signatur: der Übersicht,
   in dem gemeisterte Inhaltsbereiche als Häuser "gebaut" werden.
   ========================================================================== */
:root {
  --paper: #fbfaf6;
  --card: #ffffff;
  --ink: #26324b;
  --ink-soft: #5c6b8a;
  --line: #e6e4da;
  --primary: #0e9594;
  --primary-deep: #0b6e6d;
  --primary-tint: #e3f3f2;
  --accent: #f2b34c;
  --accent-deep: #c8871c;
  --accent-tint: #fdf3df;
  --success: #5ea854;
  --success-tint: #e9f4e6;
  --error: #d95d39;
  --error-tint: #fbe9e3;
  --radius: 16px;
  --shadow: 0 2px 8px rgba(38, 50, 75, 0.08);
  --font-display: "Baloo 2", system-ui, sans-serif;
  --font-body: "Nunito Sans", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
  min-height: 100vh;
}
h1, h2, h3 { font-family: var(--font-display); font-weight: 600; line-height: 1.2; margin: 0 0 .5em; }
h1 { font-size: 1.9rem; }
h2 { font-size: 1.4rem; }
h3 { font-size: 1.15rem; }
p { margin: 0 0 1em; }
.hidden { display: none !important; }
.muted { color: var(--ink-soft); font-size: .92rem; }

/* ---- Topbar ---- */
.topbar {
  display: flex; align-items: center; gap: 1rem;
  padding: .6rem 1.2rem;
  background: var(--card);
  border-bottom: 1.5px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: .5rem; font-family: var(--font-display); font-size: 1.25rem; font-weight: 700; color: var(--primary-deep); cursor: pointer; }
.topbar nav { display: flex; gap: .25rem; margin-left: auto; flex-wrap: wrap; }
.navlink {
  border: none; background: transparent; font-family: var(--font-body); font-weight: 700;
  color: var(--ink-soft); padding: .45rem .8rem; border-radius: 10px; cursor: pointer; font-size: .95rem;
}
.navlink:hover, .navlink.active { background: var(--primary-tint); color: var(--primary-deep); }
.coinbox {
  display: flex; align-items: center; gap: .35rem;
  background: var(--accent-tint); border: 1.5px solid var(--accent);
  border-radius: 999px; padding: .25rem .75rem; font-weight: 700; color: var(--accent-deep);
}

/* ---- Layout ---- */
main#app { max-width: 880px; margin: 0 auto; padding: 1.5rem 1rem 4rem; }
.card {
  background: var(--card); border: 1.5px solid var(--line);
  border-radius: var(--radius); padding: 1.4rem; box-shadow: var(--shadow); margin-bottom: 1rem;
}
.row { display: flex; gap: 1rem; flex-wrap: wrap; }
.grow { flex: 1 1 260px; }

/* ---- Buttons & Inputs ---- */
.btn {
  font-family: var(--font-body); font-weight: 800; font-size: 1rem;
  border: none; border-radius: 14px; padding: .7rem 1.4rem; cursor: pointer;
  background: var(--primary); color: #fff;
  box-shadow: 0 3px 0 var(--primary-deep);
  transition: transform .06s ease;
}
.btn:hover { filter: brightness(1.05); }
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--primary-deep); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.secondary { background: var(--card); color: var(--primary-deep); border: 2px solid var(--primary); box-shadow: 0 3px 0 var(--primary-tint); }
.btn.gold { background: var(--accent); color: #5b3c05; box-shadow: 0 3px 0 var(--accent-deep); }
.btn.ghost { background: transparent; color: var(--ink-soft); box-shadow: none; }
input[type="text"], input[type="number"], input[type="email"], input[type="password"], textarea, select {
  font-family: var(--font-body); font-size: 1rem; color: var(--ink);
  border: 2px solid var(--line); border-radius: 12px; padding: .65rem .8rem; width: 100%;
  background: #fff;
}
input:focus, textarea:focus, select:focus, .btn:focus-visible, .navlink:focus-visible, .choice:focus-visible {
  outline: 3px solid rgba(14, 149, 148, .4); outline-offset: 1px;
}
label { font-weight: 700; font-size: .92rem; display: block; margin: .8rem 0 .3rem; }

/* ---- Übersicht / Häuser ---- */
.city-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 1rem; }
.house-card {
  background: var(--card); border: 1.5px solid var(--line); border-radius: var(--radius);
  padding: 1.1rem; cursor: pointer; text-align: center; transition: transform .12s ease, border-color .12s ease;
}
.house-card:hover { transform: translateY(-3px); border-color: var(--primary); }
.house-card.mastered { border-color: var(--accent); background: linear-gradient(180deg, #fff, var(--accent-tint)); }
.house-svg { width: 110px; height: 96px; margin: 0 auto .4rem; display: block; }
.progressbar { height: 10px; background: var(--line); border-radius: 999px; overflow: hidden; margin-top: .6rem; }
.progressbar > div { height: 100%; background: var(--primary); border-radius: 999px; transition: width .4s ease; }
.house-card.mastered .progressbar > div { background: var(--accent); }
.badge { display: inline-block; font-size: .78rem; font-weight: 800; padding: .15rem .6rem; border-radius: 999px; background: var(--primary-tint); color: var(--primary-deep); }
.badge.gold { background: var(--accent-tint); color: var(--accent-deep); }

/* ---- Aufgaben ---- */
.task-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: .6rem; flex-wrap: wrap; }
.session-progress { display: flex; gap: .3rem; }
.session-progress span { width: 26px; height: 8px; border-radius: 99px; background: var(--line); }
.session-progress span.done { background: var(--success); }
.session-progress span.wrong { background: var(--error); }
.session-progress span.current { background: var(--primary); }
.question { font-size: 1.15rem; font-weight: 600; margin: .6rem 0 1rem; }
.choices { display: grid; gap: .6rem; }
.choice {
  text-align: left; font-family: var(--font-body); font-size: 1rem; font-weight: 600;
  background: #fff; border: 2px solid var(--line); border-radius: 12px; padding: .75rem 1rem; cursor: pointer;
}
.choice:hover { border-color: var(--primary); background: var(--primary-tint); }
.choice.selected { border-color: var(--primary); background: var(--primary-tint); }
.choice.correct { border-color: var(--success); background: var(--success-tint); }
.choice.incorrect { border-color: var(--error); background: var(--error-tint); }
.feedback { border-radius: 12px; padding: .8rem 1rem; margin-top: 1rem; font-weight: 600; }
.feedback.ok { background: var(--success-tint); border: 1.5px solid var(--success); }
.feedback.no { background: var(--error-tint); border: 1.5px solid var(--error); }
.match-cols { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem 1.4rem; }
.match-item { border: 2px solid var(--line); border-radius: 12px; padding: .6rem .8rem; cursor: pointer; font-weight: 600; background: #fff; }
.match-item.active { border-color: var(--primary); background: var(--primary-tint); }
.match-item.paired { border-style: dashed; opacity: .8; }
.graph-wrap svg { touch-action: none; cursor: crosshair; background: #fff; border: 2px solid var(--line); border-radius: 12px; max-width: 100%; }
.slider-row { display: flex; align-items: center; gap: 1rem; }
input[type="range"] { flex: 1; accent-color: var(--primary); }

/* ---- Tutor-Chat ---- */
.tutor {
  border: 2px solid var(--primary-tint); border-radius: var(--radius);
  background: #fff; margin-top: 1.2rem; overflow: hidden;
}
.tutor-head { background: var(--primary-tint); padding: .5rem .9rem; font-weight: 800; color: var(--primary-deep); display: flex; justify-content: space-between; align-items: center; }
.tutor-log { max-height: 260px; overflow-y: auto; padding: .8rem; display: flex; flex-direction: column; gap: .5rem; }
.msg { max-width: 85%; padding: .55rem .85rem; border-radius: 14px; font-size: .95rem; }
.msg.user { align-self: flex-end; background: var(--primary); color: #fff; border-bottom-right-radius: 4px; }
.msg.bot { align-self: flex-start; background: var(--paper); border: 1.5px solid var(--line); border-bottom-left-radius: 4px; }
.tutor-input { display: flex; gap: .5rem; padding: .6rem; border-top: 1.5px solid var(--line); }

/* ---- Onboarding ---- */
.onb-step { text-align: center; padding: 1rem 0; }
.emoji-scale { display: flex; justify-content: center; gap: .7rem; margin: 1rem 0; flex-wrap: wrap; }
.emoji-opt {
  font-size: 1.6rem; background: #fff; border: 2px solid var(--line); border-radius: 16px;
  padding: .7rem .9rem; cursor: pointer; min-width: 96px;
}
.emoji-opt small { display: block; font-size: .78rem; font-weight: 700; color: var(--ink-soft); margin-top: .3rem; }
.emoji-opt:hover, .emoji-opt.selected { border-color: var(--primary); background: var(--primary-tint); }
.onb-dots { display: flex; justify-content: center; gap: .4rem; margin-top: 1.4rem; }
.onb-dots span { width: 9px; height: 9px; border-radius: 50%; background: var(--line); }
.onb-dots span.on { background: var(--primary); }

/* ---- Arcade / Sudoku ---- */
.arcade-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 1rem; }
.sudoku { display: grid; grid-template-columns: repeat(4, 56px); gap: 4px; justify-content: center; margin: 1rem auto; }
.sudoku input, .sudoku div {
  width: 56px; height: 56px; text-align: center; font-size: 1.3rem; font-weight: 800;
  border: 2px solid var(--line); border-radius: 10px; display: flex; align-items: center; justify-content: center;
}
.sudoku div { background: var(--primary-tint); color: var(--primary-deep); }
.sudoku input { padding: 0; }
.sudoku .bad { border-color: var(--error); background: var(--error-tint); }

/* ---- Auth / Landing ---- */
.landing { text-align: center; padding: 2.5rem 1rem 1rem; }
.landing h1 { font-size: 2.4rem; color: var(--primary-deep); }
.auth-card { max-width: 420px; margin: 1rem auto; text-align: left; }
.tabbar { display: flex; gap: .4rem; margin-bottom: 1rem; }
.tabbar button { flex: 1; }

/* ---- Tabellen (Forschung) ---- */
table.data { border-collapse: collapse; width: 100%; font-size: .85rem; }
table.data th, table.data td { border: 1px solid var(--line); padding: .35rem .5rem; text-align: left; }
table.data th { background: var(--primary-tint); }

/* ---- Toast ---- */
.toast {
  position: fixed; bottom: 1.2rem; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: #fff; font-weight: 700;
  padding: .7rem 1.3rem; border-radius: 999px; box-shadow: var(--shadow); z-index: 50;
}

@media (max-width: 620px) {
  .topbar { padding: .5rem .6rem; }
  .brand span { display: none; }
  .match-cols { grid-template-columns: 1fr; }
  .sudoku { grid-template-columns: repeat(4, 48px); }
  .sudoku input, .sudoku div { width: 48px; height: 48px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ===== Lehrkraft-Dashboard (v2) ===== */
.stat-row { display: flex; gap: 1.2rem; flex-wrap: wrap; }
.stat { background: var(--paper-2, #f3f1ea); border-radius: 12px; padding: .7rem 1.1rem; text-align: center; min-width: 90px; }
.stat strong { display: block; font-family: var(--font-display); font-size: 1.5rem; }
.stat span { font-size: .82rem; color: var(--muted, #6b6b60); }

.agg-row { display: grid; grid-template-columns: minmax(140px, 1fr) minmax(120px, 2fr) auto; gap: .8rem; align-items: center; padding: .45rem 0; border-bottom: 1px solid rgba(0,0,0,.05); }
.agg-row:last-child { border-bottom: none; }
.agg-row.clickable, tr.clickable { cursor: pointer; }
tr.clickable:hover, .agg-row.clickable:hover { background: rgba(14,149,148,.06); }

.ttable { width: 100%; border-collapse: collapse; font-size: .95rem; }
.ttable th { text-align: left; font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted, #6b6b60); padding: .4rem .5rem; border-bottom: 2px solid rgba(0,0,0,.08); }
.ttable td { padding: .5rem; border-bottom: 1px solid rgba(0,0,0,.05); vertical-align: middle; }
.ttable .progressbar { min-width: 90px; }

.ke-grid { display: flex; flex-wrap: wrap; gap: .4rem; }
.ke { border-radius: 999px; padding: .25rem .7rem; font-size: .85rem; background: #eee; }
.ke.ok { background: rgba(46,160,67,.12); }
.ke.no { background: rgba(242,179,76,.18); }

details.mis { border-left: 3px solid var(--primary, #0e9594); padding: .3rem .8rem; margin: .5rem 0; background: rgba(14,149,148,.04); border-radius: 0 8px 8px 0; }
details.mis summary { cursor: pointer; padding: .2rem 0; }

.progressbar.gold > div { background: var(--gold, #f2b34c); }
#role-field label, #age-field label { display: block; margin-bottom: .3rem; }

/* ---- PLATO-Aufgabentypen: Zahlenmauer, Balkendiagramm, Begründung ---- */
.zahlenmauer { display: flex; flex-direction: column; align-items: center; gap: .35rem; margin: 1rem 0; }
.zahlenmauer-row { display: flex; justify-content: center; gap: .35rem; }
.zahlenmauer-cell {
  min-width: 64px; height: 46px; display: flex; align-items: center; justify-content: center;
  border: 2px solid var(--line); border-radius: 12px; background: #fff; font-weight: 800;
  box-shadow: 0 2px 0 rgba(38,50,75,.05);
}
.zahlenmauer-cell.given { background: var(--primary-tint); color: var(--primary-deep); }
.zahlenmauer-cell input { width: 54px; text-align: center; padding: .25rem; }
.zahlenmauer-cell small { margin-left: .25rem; color: var(--success); font-weight: 800; }

.bar-task { display: grid; grid-template-columns: minmax(260px, 1.4fr) minmax(180px, .9fr); gap: 1rem; align-items: end; margin: 1rem 0; }
.bar-chart { height: 240px; display: flex; gap: .7rem; align-items: end; padding: .8rem .8rem 2.2rem; border-left: 2px solid var(--ink); border-bottom: 2px solid var(--ink); background: linear-gradient(to top, rgba(0,0,0,.05) 1px, transparent 1px); background-size: 100% 24px; }
.bar-col { flex: 1; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; position: relative; }
.bar-fill { width: 72%; min-height: 4px; border-radius: 8px 8px 0 0; background: var(--primary); position: relative; transition: height .15s ease; }
.bar-fill::before { content: attr(data-value); position: absolute; top: -1.35rem; left: 50%; transform: translateX(-50%); font-size: .8rem; font-weight: 800; color: var(--ink); }
.bar-label { position: absolute; bottom: -1.8rem; font-size: .78rem; font-weight: 800; text-align: center; max-width: 80px; overflow-wrap: anywhere; }
.bar-controls { display: grid; gap: .45rem; }
.bar-control { display: grid; grid-template-columns: 1fr 70px; gap: .5rem; align-items: center; margin: 0; }
.bar-control input { padding: .35rem .45rem; }

label textarea { display: block; width: 100%; margin-top: .35rem; }

@media (max-width: 720px) {
  .bar-task { grid-template-columns: 1fr; }
  .bar-chart { min-width: 0; }
  .zahlenmauer-cell { min-width: 52px; }
}

/* ===== v3.1: Themen-Kacheln (ohne Häuser) ===== */
.topic-card { background: var(--card, #fff); border: 1.5px solid var(--line, #e6e4da); border-radius: 16px; padding: 1.1rem 1.2rem; cursor: pointer; transition: transform .15s, box-shadow .15s; }
.topic-card:hover { transform: translateY(-3px); box-shadow: 0 8px 22px rgba(20, 40, 40, .10); }
.topic-emoji { font-size: 2.2rem; line-height: 1; margin-bottom: .4rem; }

/* ===== Stadt & Bewohner ===== */
.bewohner { margin: .3rem 0 0; }
.bewohner-fakt { font-size: .82rem; font-style: italic; }

/* ===== Richtfest-Feier ===== */
.celebrate-overlay { position: fixed; inset: 0; background: rgba(20, 35, 35, .55); backdrop-filter: blur(3px); display: flex; align-items: center; justify-content: center; z-index: 1000; overflow: hidden; }
.celebrate-card { background: var(--paper, #fbfaf6); border-radius: 20px; padding: 2rem 2.2rem; max-width: 420px; width: calc(100% - 2rem); text-align: center; box-shadow: 0 24px 60px rgba(0,0,0,.35); animation: pop-in .45s cubic-bezier(.2,1.4,.4,1); position: relative; z-index: 2; }
.celebrate-house .house-svg { width: 140px; height: auto; animation: house-grow .8s cubic-bezier(.2,1.3,.4,1); }
.bewohner-card { display: flex; gap: .8rem; align-items: center; text-align: left; background: rgba(242,179,76,.12); border: 1.5px solid var(--gold, #f2b34c); border-radius: 14px; padding: .8rem 1rem; margin: 1rem 0; }
.bewohner-emoji { font-size: 2.4rem; }
.celebrate-card .bonus { font-family: var(--font-display); font-size: 1.15rem; color: var(--gold-dark, #c8871c); }
@keyframes pop-in { from { transform: scale(.7); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes house-grow { from { transform: translateY(30px) scale(.4); opacity: 0; } to { transform: none; opacity: 1; } }
.confetti { position: absolute; top: -12px; width: 10px; height: 14px; border-radius: 2px; z-index: 1; animation: confetti-fall linear forwards; }
@keyframes confetti-fall { to { transform: translateY(105vh) translateX(var(--drift, 0)) rotate(720deg); opacity: .7; } }
@media (prefers-reduced-motion: reduce) { .confetti { display: none; } .celebrate-card, .celebrate-house .house-svg { animation: none; } }

/* ===== Stufen-Gliederung der Themenliste ===== */
#area-grid { display: block; }
.stage-head { margin: 1.6rem 0 .7rem; font-size: 1.15rem; display: flex; align-items: center; gap: .6rem; border-bottom: 2px solid var(--line, #e6e4da); padding-bottom: .35rem; }

/* Pia-Antworten nicht markier-/kopierbar (Kopie in Freitext verhindern) */
.no-copy, .no-copy * { -webkit-user-select: none; user-select: none; }


/* ===== Anti-Copy: Tutor-Antworten nicht markierbar ===== */
.tutor-log { user-select: none; -webkit-user-select: none; }

/* ===== Themen-Empfehlungen ===== */
.reco-card { border: 1.5px solid var(--gold, #f2b34c); background: linear-gradient(180deg, rgba(242,179,76,.07), transparent); }
.reco-grid { display: grid; gap: .7rem; margin-top: .6rem; }
.reco-item { display: flex; align-items: center; gap: .9rem; padding: .7rem .9rem; border-radius: 12px; background: var(--card, #fff); border: 1px solid var(--line, #e6e4da); cursor: pointer; transition: transform .12s, box-shadow .12s; }
.reco-item:hover { transform: translateX(3px); box-shadow: 0 4px 14px rgba(20,40,40,.09); }
.reco-emoji { font-size: 1.9rem; flex: 0 0 auto; }
.reco-body { display: flex; flex-direction: column; gap: .15rem; flex: 1 1 auto; min-width: 0; }
.reco-meter { height: 6px; border-radius: 999px; background: rgba(0,0,0,.08); overflow: hidden; margin-top: .3rem; max-width: 220px; }
.reco-meter > div { height: 100%; background: var(--gold, #f2b34c); border-radius: 999px; }
.reco-go { flex: 0 0 auto; font-weight: 600; color: var(--primary, #0e9594); font-size: .9rem; }
@media (max-width: 520px) { .reco-go { display: none; } }

/* ===== Strategie-Reflexion ===== */
.reflect-box { margin-top: .7rem; padding: .7rem .9rem; border-radius: 12px; border: 1px dashed var(--line, #cfcabb); background: rgba(0,0,0,.02); display: flex; flex-direction: column; gap: .45rem; }
.reflect-box label { font-weight: 600; font-size: .93rem; }
.reflect-box textarea { resize: vertical; }
.btn-sm { align-self: flex-start; padding: .35rem .8rem; font-size: .88rem; }


/* ===== Gleichungslöser ===== */
.eq-solver { margin-top: .4rem; }
.eq-start { font-size: 1.25rem; font-weight: 700; padding: .55rem .9rem; background: rgba(14,149,148,.08); border: 1.5px solid var(--primary, #0e9594); border-radius: 10px; display: inline-block; font-variant-numeric: tabular-nums; }
.eq-lines { display: flex; flex-direction: column; gap: .45rem; margin-top: .6rem; }
.eq-line { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.eq-line input { flex: 0 1 300px; font-size: 1.05rem; padding: .5rem .7rem; border: 1px solid var(--line, #cfcabb); border-radius: 8px; font-variant-numeric: tabular-nums; }
.eq-line input[readonly] { background: rgba(0,0,0,.03); }
.eq-status { font-size: .88rem; font-weight: 600; }
.eq-status.ok { color: #2e7d32; }
.eq-status.warn { color: #c8871c; }
.eq-status.unread { color: #8a8a8a; }
.eq-beispiel { margin-top: .8rem; padding: .7rem .9rem; border-left: 3px solid var(--primary, #0e9594); background: rgba(0,0,0,.02); border-radius: 0 10px 10px 0; line-height: 1.7; }
