/* ===============================================================
   LERNKARTEI — Stylesheet
   Stil A: editorial / Bibliothek. Newsreader (Serif) für Headlines,
   IBM Plex Sans für Body. Warmes Off-White, dezenter Terra-Akzent.
   Marc: alle Farben sind oben als CSS-Variablen definiert.
   Wenn ihr was ändern wollt, hier — und es wirkt überall.
   =============================================================== */

:root {
  --paper:     #f5f1ea;
  --paper-2:   #ebe4d6;
  --card:      #fffdf8;
  --ink:       #1f1a13;
  --ink-2:     #5a5045;
  --ink-3:     #908577;
  --rule:      rgba(31, 26, 19, 0.12);
  --rule-soft: rgba(31, 26, 19, 0.06);
  --accent:    #7a3b1f;
  --accent-soft: rgba(122, 59, 31, 0.08);
  --good:      #3d5c3a;
  --warn:      #8b6a1a;
  --bad:       #a23028;

  --serif: 'Newsreader', 'Iowan Old Style', Georgia, serif;
  --serif-italic: 'Instrument Serif', 'Newsreader', Georgia, serif;
  --sans:  'IBM Plex Sans', system-ui, -apple-system, sans-serif;
  --mono:  'IBM Plex Mono', ui-monospace, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  background-image: radial-gradient(rgba(0,0,0,0.025) 1px, transparent 1px);
  background-size: 14px 14px;
  min-height: 100vh;
}

a { color: var(--ink); text-decoration: none; }
a:hover { text-decoration: underline; text-decoration-color: var(--accent); text-underline-offset: 3px; }

/* ===== Topnav ============================================== */
.topnav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 48px 16px;
  border-bottom: 1px solid var(--rule);
  background: rgba(245, 241, 234, 0.85);
  backdrop-filter: blur(6px);
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 34px; height: 34px;
  border-radius: 8px;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--serif-italic);
  font-size: 20px;
  display: grid; place-items: center;
}
.brand-name { font-family: var(--serif-italic); font-size: 20px; line-height: 1; }
.brand-sub { font-size: 10.5px; letter-spacing: 1.5px; color: var(--ink-2); margin-top: 4px; }

.topnav-items { display: flex; gap: 28px; }
.topnav-item {
  font-size: 14px;
  color: var(--ink-2);
  padding: 4px 0;
  border-bottom: 1.5px solid transparent;
}
.topnav-item.is-active {
  color: var(--ink);
  font-weight: 600;
  border-bottom-color: var(--accent);
}
.topnav-item:hover { text-decoration: none; color: var(--ink); }

.topnav-right { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--paper-2);
  display: grid; place-items: center;
  font-family: var(--serif-italic);
}
.avatar-name { color: var(--ink-2); }

/* ===== Layout-Container ===================================== */
.container { max-width: 1180px; margin: 0 auto; padding: 36px 48px 72px; }
.container.narrow { max-width: 880px; }

/* ===== Headlines & Text ==================================== */
.eyebrow {
  font-size: 11px;
  letter-spacing: 1.8px;
  color: var(--ink-2);
  text-transform: uppercase;
}
.eyebrow.accent { color: var(--accent); }

h1, .h1 {
  font-family: var(--serif);
  font-size: 56px;
  line-height: 1.02;
  letter-spacing: -0.5px;
  font-weight: 500;
  margin: 8px 0 0;
}
h1 em { font-family: var(--serif-italic); font-style: italic; }
h2, .h2 {
  font-family: var(--serif);
  font-size: 32px;
  line-height: 1.1;
  font-weight: 500;
  margin: 0;
}
h3, .h3 {
  font-family: var(--serif);
  font-size: 22px;
  line-height: 1.2;
  font-weight: 500;
  margin: 0;
}
.serif-italic { font-family: var(--serif-italic); font-style: italic; }

.lead {
  font-size: 16px;
  line-height: 1.65;
  color: var(--ink-2);
  max-width: 60ch;
}

/* ===== Buttons ============================================= */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 18px;
  border-radius: 8px;
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 500;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
}
.btn:hover { text-decoration: none; }
.btn.primary {
  background: var(--ink);
  color: var(--paper);
}
.btn.primary:hover { background: #2d2820; }
.btn.ghost {
  background: transparent;
  color: var(--ink);
  border-color: var(--rule);
}
.btn.ghost:hover { background: var(--paper-2); }
.btn.accent {
  background: var(--accent);
  color: var(--paper);
}

/* ===== Cards =============================================== */
.card {
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 12px;
  padding: 22px;
}
.card.tight { padding: 16px; }
.card-title {
  font-family: var(--serif);
  font-size: 20px;
  margin: 0 0 8px;
}

/* ===== Progress bar ======================================== */
.progress {
  height: 4px;
  background: var(--rule-soft);
  border-radius: 999px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
  transition: width .25s ease;
}

/* ===== Sparten-Grid (Dashboard) ============================ */
.sparten-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-top: 18px;
}
@media (max-width: 980px) {
  .sparten-grid { grid-template-columns: repeat(2, 1fr); }
}
.sparte-card {
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 10px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 120px;
  transition: transform .15s, box-shadow .15s, border-color .15s;
  text-decoration: none;
  color: inherit;
}
.sparte-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(31,26,19,0.08);
  border-color: rgba(122,59,31,0.3);
  text-decoration: none;
}
.sparte-card .row { display: flex; justify-content: space-between; align-items: center; }
.sparte-card .short {
  font-size: 10px; letter-spacing: 1.8px; color: var(--ink-2);
  font-family: var(--mono);
}
.sparte-card .pct { font-size: 11px; font-family: var(--mono); }
.sparte-card .pct.high { color: var(--good); }
.sparte-card .pct.mid { color: var(--warn); }
.sparte-card .pct.low { color: var(--accent); }
.sparte-card .name {
  font-family: var(--serif);
  font-size: 18px;
  line-height: 1.15;
}
.sparte-card .kurz {
  font-size: 12.5px;
  color: var(--ink-2);
  line-height: 1.4;
}

/* ===== Dashboard hero ====================================== */
.hero {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: 36px;
  margin-bottom: 32px;
}
@media (max-width: 900px) { .hero { grid-template-columns: 1fr; } }
.hero-stat {
  font-family: var(--serif);
  font-size: 32px;
  line-height: 1.05;
}
.hero-stat-small {
  font-size: 12px;
  color: var(--ink-2);
  display: flex;
  justify-content: space-between;
  margin-top: 10px;
}

/* ===== Sparten-Detail Layout =============================== */
.detail-layout {
  display: grid;
  grid-template-columns: 240px 1fr 320px;
  gap: 0;
  min-height: calc(100vh - 70px);
  border-top: 1px solid var(--rule);
}
@media (max-width: 1100px) {
  .detail-layout { grid-template-columns: 200px 1fr; }
  .detail-side-right { display: none; }
}

.detail-side {
  background: var(--paper-2);
  padding: 24px 18px;
  border-right: 1px solid var(--rule);
}
.detail-main {
  padding: 36px 44px;
  min-width: 0;
  max-width: 720px;
}
.detail-side-right {
  border-left: 1px solid var(--rule);
  background: var(--card);
  padding: 30px 24px;
}

.modul-list { display: flex; flex-direction: column; gap: 2px; margin-top: 14px; }
.modul-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  border: none;
  background: transparent;
  text-align: left;
  width: 100%;
  font-family: inherit;
  color: var(--ink);
}
.modul-item.is-active { background: var(--card); }
.modul-item:hover { background: var(--card); }
.modul-item .check {
  width: 18px; height: 18px; border-radius: 50%;
  border: 1.5px solid var(--rule);
  display: grid; place-items: center;
  font-size: 10px; color: var(--paper);
}
.modul-item .check.done { background: var(--good); border-color: var(--good); }
.modul-item .titel { flex: 1; }
.modul-item .titel strong { display: block; }
.modul-item .titel small { color: var(--ink-2); font-size: 11px; }

/* ===== Inhalts-Blöcke (Sparte) ============================= */
.block { margin-top: 26px; }
.block-eyebrow { font-size: 11px; letter-spacing: 1.8px; color: var(--ink-2); text-transform: uppercase; }
.block-title {
  font-family: var(--serif);
  font-size: 22px;
  margin: 6px 0 12px;
}
.block-text { font-size: 14.5px; line-height: 1.65; color: var(--ink); }
.block-text strong { color: var(--ink); font-weight: 600; }
.block-text em { font-family: var(--serif-italic); font-style: italic; }

.zitat {
  background: var(--card);
  border: 1px solid var(--rule);
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  padding: 18px 22px;
  font-family: var(--serif-italic);
  font-size: 17px;
  line-height: 1.55;
  color: var(--ink);
}

.kv-list { display: flex; flex-direction: column; gap: 8px; }
.kv-list > div {
  display: flex;
  justify-content: space-between;
  border-bottom: 1px dashed var(--rule);
  padding: 7px 0;
  font-size: 13px;
}
.kv-list .k { color: var(--ink-2); }
.kv-list .v { text-align: right; max-width: 60%; font-weight: 500; }

.schaden-list { display: flex; flex-direction: column; gap: 10px; }
.schaden-row {
  display: flex;
  justify-content: space-between;
  background: var(--paper-2);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 13.5px;
  gap: 12px;
}
.schaden-row .summe { font-family: var(--mono); color: var(--accent); font-weight: 600; white-space: nowrap; }

/* Skript-Kärtchen rechts */
.skript-block { border-left: 2px solid var(--accent); padding-left: 12px; margin-bottom: 16px; }
.skript-eyebrow {
  font-size: 10px;
  letter-spacing: 1.4px;
  color: var(--accent);
  text-transform: uppercase;
  font-weight: 600;
}
.skript-text {
  font-family: var(--serif-italic);
  font-size: 14.5px;
  line-height: 1.5;
  margin-top: 6px;
}

/* ===== Übung / Rollenspiel ================================ */
.uebung-layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 32px;
  margin-top: 24px;
}
@media (max-width: 1000px) { .uebung-layout { grid-template-columns: 1fr; } }

.persona-card { background: var(--card); border: 1px solid var(--rule); border-radius: 14px; padding: 22px; }
.persona-avatar {
  width: 60px; height: 60px; border-radius: 50%;
  background: var(--paper-2);
  font-family: var(--serif-italic);
  font-size: 26px;
  display: grid; place-items: center;
}

.chat {
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  min-height: 560px;
  max-height: calc(100vh - 200px);
  padding: 24px;
}
.chat-head { display: flex; justify-content: space-between; align-items: baseline; padding-bottom: 14px; border-bottom: 1px solid var(--rule); }
.chat-stream {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 18px 0;
}
.msg { display: flex; flex-direction: column; gap: 4px; }
.msg.kunde { align-items: flex-start; }
.msg.berater { align-items: flex-end; }
.msg .meta { font-size: 10.5px; letter-spacing: 1.2px; color: var(--ink-2); text-transform: uppercase; }
.msg .bubble {
  max-width: 78%;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.5;
  white-space: pre-wrap;
}
.msg.kunde .bubble { background: var(--paper-2); color: var(--ink); }
.msg.berater .bubble { background: var(--ink); color: var(--paper); }
.msg.coach {
  align-self: center;
}
.msg.coach .bubble {
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px dashed var(--accent);
  font-family: var(--serif-italic);
  font-size: 13px;
  max-width: 70%;
}

.chat-input {
  border: 1px solid var(--rule);
  border-radius: 10px;
  padding: 10px 12px;
  background: var(--paper);
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
}
.chat-input input {
  flex: 1;
  border: none;
  background: transparent;
  outline: none;
  font-family: var(--sans);
  font-size: 14px;
  color: var(--ink);
}

.spinner {
  width: 14px; height: 14px;
  border-radius: 50%;
  border: 2px solid var(--rule);
  border-top-color: var(--accent);
  animation: spin .9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Auth-Seiten (Login / Passwort vergessen / zurücksetzen) === */
.auth-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 14px;
  padding: 36px 32px;
  box-shadow: 0 12px 40px rgba(31,26,19,0.08);
}
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 28px; }
.auth-title {
  font-family: var(--serif);
  font-size: 26px;
  font-weight: 500;
  margin: 0 0 6px;
}
.auth-sub { color: var(--ink-2); font-size: 13.5px; line-height: 1.5; margin: 0 0 24px; }

.field { margin-bottom: 16px; }
.field label {
  display: block;
  font-size: 12.5px;
  color: var(--ink-2);
  margin-bottom: 6px;
  letter-spacing: 0.2px;
}
.input {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: var(--paper);
  font-family: var(--sans);
  font-size: 14.5px;
  color: var(--ink);
  outline: none;
  transition: border-color .15s;
}
.input:focus { border-color: var(--accent); }
.input-wrap { position: relative; }
.input-wrap .input { padding-right: 42px; }
.eye-btn {
  position: absolute;
  right: 5px;
  top: 50%;
  transform: translateY(-50%);
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--ink-3);
  border-radius: 6px;
  padding: 0;
}
.eye-btn:hover { color: var(--ink); background: var(--paper-2); }

.auth-actions { margin-top: 22px; }
.auth-actions .btn { width: 100%; justify-content: center; }
.auth-links { margin-top: 18px; display: flex; justify-content: space-between; font-size: 13px; }
.auth-back { margin-top: 22px; text-align: center; font-size: 13px; color: var(--ink-2); }

.alert { border-radius: 8px; padding: 10px 14px; font-size: 13px; margin-bottom: 18px; line-height: 1.5; }
.alert.error { background: rgba(162,48,40,0.08); color: var(--bad); border: 1px solid rgba(162,48,40,0.25); }
.alert.success { background: rgba(61,92,58,0.08); color: var(--good); border: 1px solid rgba(61,92,58,0.25); }

/* ===== Diverses =========================================== */
.hidden { display: none !important; }
.muted { color: var(--ink-2); }
.tiny { font-size: 12px; }
.center { text-align: center; }
.row { display: flex; align-items: center; gap: 10px; }
.gap-2 { display: flex; gap: 8px; }
.mt-2 { margin-top: 8px; } .mt-4 { margin-top: 16px; } .mt-6 { margin-top: 24px; }
.mb-2 { margin-bottom: 8px; } .mb-4 { margin-bottom: 16px; } .mb-6 { margin-bottom: 24px; }

ul.clean { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
ul.clean li { display: flex; gap: 8px; align-items: flex-start; font-size: 14px; line-height: 1.5; }
ul.clean li:before { content: '▸'; color: var(--accent); margin-top: 2px; }

/* ===============================================================
   MOBILE / RESPONSIVE
   Marc: hier ist alles, was bei kleineren Bildschirmen anders aussieht.
   Drei Stufen:
     1) Tablet ≤ 1100px — Detail-Layout wird einspaltig, Skript wandert nach unten
     2) Schmaler ≤ 880px — Container kleiner, Typo kleiner, Topnav kompakter
     3) Smartphone ≤ 560px — Sparten-Grid 1-spaltig, weitere Größenanpassungen
   =============================================================== */

/* === Stufe 1: Detail-Layouts (Sparte, Übung) bei ≤ 1100px === */
@media (max-width: 1100px) {
  .detail-layout {
    display: block;            /* aus 3-Spalten-Grid wird ein normaler Block-Flow */
    border-top: none;
  }
  /* Modul-Liste wird zu horizontaler Chip-Reihe oben */
  .detail-side {
    border-right: none;
    border-bottom: 1px solid var(--rule);
    padding: 12px 16px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    position: sticky;
    top: 58px;                 /* Höhe der Topnav auf Mobile */
    background: var(--paper-2);
    z-index: 5;
  }
  .detail-side::-webkit-scrollbar { display: none; }
  .detail-side > .eyebrow { display: none; }
  .modul-list {
    flex-direction: row;
    flex-wrap: nowrap;
    gap: 8px;
    margin-top: 0;
  }
  .modul-item {
    flex-shrink: 0;
    background: var(--card);
    border: 1px solid var(--rule);
    border-radius: 999px;
    padding: 8px 14px;
    font-size: 13px;
    min-height: 44px;           /* gute Tap-Fläche */
  }
  .modul-item.is-active {
    background: var(--accent);
    color: var(--paper);
    border-color: var(--accent);
  }
  .modul-item .check { display: none; }
  .modul-item .titel small { display: none; }
  .modul-item .titel strong { font-weight: 500; }
  /* Hauptinhalt nimmt volle Breite */
  .detail-main {
    padding: 28px 20px;
    max-width: none;
  }
  /* Skript-Spalte als Bottom-Section */
  .detail-side-right {
    display: block !important;  /* überschreibt das alte display:none */
    border-left: none;
    border-top: 1px solid var(--rule);
    padding: 28px 20px;
    background: var(--card);
  }
}

/* === Stufe 2: Schmaler Bildschirm ≤ 880px === */
@media (max-width: 880px) {
  /* Topnav kompakt */
  .topnav {
    padding: 12px 16px;
    gap: 8px;
  }
  .brand { gap: 10px; min-width: 0; flex-shrink: 0; }
  .brand-sub { display: none; }
  .brand-name { font-size: 16px; }
  .brand-mark { width: 30px; height: 30px; font-size: 16px; }
  .topnav-items {
    gap: 14px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    flex: 1 1 auto;
    min-width: 0;
    justify-content: flex-end;
    padding-right: 4px;
  }
  .topnav-items::-webkit-scrollbar { display: none; }
  .topnav-item {
    white-space: nowrap;
    font-size: 13.5px;
    padding: 8px 0;            /* tap-freundlicher */
  }
  .avatar-name { display: none; }
  .topnav-right { flex-shrink: 0; }

  /* Container kleiner */
  .container { padding: 22px 18px 60px; }

  /* Typografie skalieren */
  h1, .h1 { font-size: 38px; line-height: 1.05; }
  h2, .h2 { font-size: 26px; }
  h3, .h3 { font-size: 20px; }
  .hero-stat { font-size: 28px; }

  /* Hero immer einspaltig (war schon bei 900px, präzisieren) */
  .hero { grid-template-columns: 1fr !important; gap: 22px; margin-bottom: 24px; }

  /* Sparten-Grid auf Mobile: 2 Spalten */
  .sparten-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .sparte-card { padding: 12px; min-height: 110px; }
  .sparte-card .name { font-size: 16px; line-height: 1.1; }
  .sparte-card .kurz { font-size: 12px; line-height: 1.35; }

  /* Buttons mit guter Tap-Fläche */
  .btn { padding: 12px 18px; min-height: 44px; font-size: 14px; }

  /* Zitate kleiner */
  .zitat { padding: 14px 18px; font-size: 15px; }

  /* Cards weniger Padding */
  .card { padding: 18px; }

  /* Schaden-Reihen brechen um */
  .schaden-row { flex-direction: column; align-items: flex-start; gap: 4px; }

  /* Detail-Main: H1 nicht zu groß */
  .detail-main h1 { font-size: 36px !important; }
  .detail-main .block-title { font-size: 20px; }
}

/* === Stufe 3: Smartphone ≤ 560px === */
@media (max-width: 560px) {
  h1, .h1 { font-size: 32px; }
  .container { padding: 18px 14px 60px; }

  /* Sparten-Grid: 1-spaltig bei sehr schmalen Geräten? Wir bleiben bei 2,
     weil 1-spaltig zu viel Scrollen wird. Aber Karten dürfen schmaler werden. */
  .sparten-grid { gap: 8px; }
  .sparte-card { padding: 10px; min-height: 100px; }

  /* Hero kleiner */
  .hero-stat { font-size: 24px; }

  /* Detail-Main */
  .detail-main { padding: 22px 14px; }
  .detail-side-right { padding: 22px 14px; }
  .detail-main h1 { font-size: 30px !important; }

  /* Skript-Blöcke etwas enger */
  .skript-text { font-size: 14px; }
}

/* === Chat / Rollenspiel auf Touch-Geräten ============== */
@media (max-width: 880px) {
  /* Übungs-Layout 1-spaltig */
  .uebung-layout { grid-template-columns: 1fr !important; gap: 14px; }

  /* Persona-Karte kompakter & flacher */
  .persona-card { padding: 16px; }
  .persona-avatar { width: 48px; height: 48px; font-size: 22px; }

  /* Chat füllt den Bildschirm — nutzt dynamic viewport height
     wegen iOS-Adressleiste, die ein- und ausfährt */
  .chat {
    min-height: 70svh;
    max-height: none;
    padding: 16px;
    border-radius: 12px;
  }
  .chat-stream { padding: 12px 0; }
  .msg .bubble { max-width: 88%; font-size: 14.5px; padding: 10px 13px; }

  /* Eingabezeile bequemer */
  .chat-input { padding: 10px 12px; }
  .chat-input input { font-size: 16px; }  /* iOS-Zoom verhindern */

  /* Auswahl-Listen breiter */
  .auswahl-grid { grid-template-columns: 1fr !important; }
}

/* === iOS verhindert Auto-Zoom bei Eingabe nur wenn font-size ≥ 16px === */
@media (max-width: 880px) {
  input, textarea, select { font-size: 16px; }
}

/* === Touch-Geräte allgemein: keine Hover-Animationen, größere Tap-Flächen === */
@media (hover: none) and (pointer: coarse) {
  .sparte-card:hover { transform: none; box-shadow: none; }
  .modul-item, .btn, .topnav-item, .auswahl-row { min-height: 44px; }
}

/* ===== Print/PDF ========================================== */
@media print {
  body { background: white; }
  .topnav { display: none; }
}
