:root {
  --bg: #0f1420;
  --bg-alt: #161d2e;
  --panel: #1b2336;
  --panel-hover: #212b42;
  --border: #2a3550;
  --text: #e7ecf7;
  --text-dim: #9aa7c2;
  --accent: #5b8cff;
  --accent-dim: #3a5ba8;
  --good: #3ecf8e;
  --good-bg: rgba(62, 207, 142, 0.12);
  --bad: #ff6b6b;
  --bad-bg: rgba(255, 107, 107, 0.12);
  --warn: #ffb84d;
  --radius: 14px;
  --shadow: 0 4px 20px rgba(0,0,0,0.25);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: linear-gradient(180deg, var(--bg) 0%, #0b0f19 100%);
  color: var(--text);
  min-height: 100vh;
}

h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 0.4em 0; }
p { line-height: 1.55; }
code {
  background: rgba(91, 140, 255, 0.14);
  color: #a9c4ff;
  padding: 0.1em 0.4em;
  border-radius: 5px;
  font-size: 0.92em;
  font-family: "SF Mono", Menlo, Consolas, monospace;
}
strong { color: #fff; font-weight: 650; }

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(15, 20, 32, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.header-inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 16px 24px 0 24px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.spacer-flex { flex: 1; min-width: 8px; }
.profile-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
}
.profile-pill {
  background: rgba(91, 140, 255, 0.14);
  color: var(--accent);
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 12.5px;
  font-weight: 700;
  white-space: nowrap;
}

/* ---------- Profil-Gate ---------- */
.profile-gate {
  min-height: 55vh;
  display: flex;
  align-items: center;
  justify-content: center;
}
.profile-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px 34px;
  max-width: 480px;
  width: 100%;
  box-shadow: var(--shadow);
  text-align: center;
}
.profile-card h2 { font-size: 21px; }
.profile-card p { color: var(--text-dim); font-size: 13.5px; margin-top: 10px; }
.profile-existing {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin: 20px 0 6px 0;
}
.profile-pick-wrap {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding-right: 2px;
}
.profile-pick-wrap .profile-pick { border-radius: 8px; background: transparent; border: none; }
.profile-pick-wrap .profile-delete {
  background: transparent;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 13px;
  padding: 6px 10px;
  border-radius: 8px;
}
.profile-pick-wrap .profile-delete:hover { color: var(--bad); }
.profile-new {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}
.profile-new input {
  flex: 1;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 12px;
  color: var(--text);
  font-size: 14px;
}
.profile-new input:focus { outline: 1px solid var(--accent); }
.profile-status { margin-top: 16px; text-align: left; }
.profile-loading { color: var(--text-dim); font-size: 13.5px; text-align: center; }
.profile-error { color: var(--bad); font-size: 13.5px; text-align: center; }
.profile-confirm p { margin: 0 0 8px 0; text-align: center; }
.profile-confirm ul {
  list-style: none;
  padding: 0;
  margin: 0 0 12px 0;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.profile-confirm ul li {
  padding: 8px 14px;
  font-size: 13.5px;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border);
}
.profile-confirm ul li:last-child { border-bottom: none; }
.profile-confirm-buttons { display: flex; gap: 10px; margin-top: 14px; }
.profile-confirm-buttons .btn { flex: 1; }
.brand-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), #8f6bff);
  color: white;
  font-weight: 800;
  font-size: 15px;
  letter-spacing: 0.5px;
  flex-shrink: 0;
}
.brand h1 { font-size: 19px; }
.subtitle { margin: 2px 0 0 0; color: var(--text-dim); font-size: 13px; }

.tabs {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab-btn {
  background: transparent;
  border: none;
  color: var(--text-dim);
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 550;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  transition: color 0.15s, border-color 0.15s;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }

main#app {
  max-width: 1080px;
  margin: 0 auto;
  padding: 28px 24px 80px 24px;
}

.app-footer {
  text-align: center;
  color: var(--text-dim);
  font-size: 12px;
  padding: 24px;
  border-top: 1px solid var(--border);
}

/* ---------- Dashboard ---------- */
.hero {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 26px;
  margin-bottom: 24px;
  box-shadow: var(--shadow);
}
.hero h2 { font-size: 20px; }
.hero p { color: var(--text-dim); margin: 6px 0 0 0; font-size: 14px; }
.stat-row {
  display: flex;
  gap: 14px;
  margin-top: 18px;
  flex-wrap: wrap;
}
.stat-chip {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 16px;
  min-width: 120px;
}
.stat-chip .num { font-size: 22px; font-weight: 700; color: var(--accent); }
.stat-chip .label { font-size: 12px; color: var(--text-dim); margin-top: 2px; }

.section-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}
.section-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  transition: transform 0.15s, border-color 0.15s;
}
.section-card:hover { border-color: var(--accent-dim); transform: translateY(-2px); }
.section-card h3 { font-size: 15px; }
.section-card .sec-num {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
  background: rgba(91,140,255,0.14);
  padding: 2px 8px;
  border-radius: 20px;
  margin-bottom: 8px;
}
.progress-bar {
  height: 6px;
  background: var(--bg-alt);
  border-radius: 4px;
  overflow: hidden;
  margin: 10px 0 6px 0;
}
.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #8f6bff);
  border-radius: 4px;
  transition: width 0.3s;
}
.section-card .meta { font-size: 12px; color: var(--text-dim); display: flex; justify-content: space-between; }
.section-card .card-actions { display: flex; gap: 8px; margin-top: 12px; }

/* ---------- Buttons ---------- */
.btn {
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 9px;
  padding: 9px 16px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: filter 0.15s, transform 0.1s;
}
.btn:hover { filter: brightness(1.1); }
.btn:active { transform: scale(0.97); }
.btn.secondary {
  background: var(--bg-alt);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn.ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
}
.btn.small { padding: 6px 12px; font-size: 12.5px; }
.btn.good { background: var(--good); color: #06281a; }
.btn.bad { background: var(--bad); color: #2c0808; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

/* ---------- Controls bar ---------- */
.controls-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 20px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 16px;
}
.controls-bar label { font-size: 13px; color: var(--text-dim); }
select {
  background: var(--bg-alt);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 13.5px;
}
.spacer { flex: 1; }

/* ---------- Lesemodus ---------- */
.read-section { margin-bottom: 34px; }
.read-section h2 {
  font-size: 18px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 10px;
  margin-bottom: 16px;
}
.read-item {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 18px;
  margin-bottom: 10px;
}
.read-item .q { font-weight: 650; margin-bottom: 8px; color: #fff; }
.read-item .a { color: var(--text-dim); font-size: 14.5px; }
.read-item.tf .q::before { content: "R/F  "; color: var(--warn); font-weight: 800; font-size: 12px; }
.tf-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 800;
  padding: 2px 9px;
  border-radius: 20px;
  margin-left: 8px;
  vertical-align: middle;
}
.tf-badge.true { background: var(--good-bg); color: var(--good); }
.tf-badge.false { background: var(--bad-bg); color: var(--bad); }

/* ---------- Flashcards ---------- */
.card-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}
.flip-card {
  width: 100%;
  max-width: 640px;
  min-height: 260px;
  perspective: 1400px;
  cursor: pointer;
}
.flip-card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 260px;
  transition: transform 0.5s;
  transform-style: preserve-3d;
}
.flip-card.flipped .flip-card-inner { transform: rotateY(180deg); }
.flip-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 28px 30px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  box-shadow: var(--shadow);
}
.flip-front { background: var(--panel); }
.flip-back { background: var(--bg-alt); transform: rotateY(180deg); }
.flip-face .kicker {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  font-weight: 700;
  margin-bottom: 12px;
}
.flip-face .content { font-size: 16.5px; }
.flip-face .hint { position: absolute; bottom: 14px; right: 18px; font-size: 11.5px; color: var(--text-dim); }

.card-controls {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: center;
}
.card-progress { font-size: 13px; color: var(--text-dim); }

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-dim);
}
.empty-state .big { font-size: 40px; margin-bottom: 12px; }

/* ---------- Richtig/Falsch Test ---------- */
.tf-stage {
  max-width: 640px;
  margin: 0 auto;
}
.tf-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 30px;
  box-shadow: var(--shadow);
  min-height: 160px;
}
.tf-card .kicker { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--warn); font-weight: 700; margin-bottom: 14px; }
.tf-card .statement { font-size: 17px; font-weight: 550; }
.tf-answer-buttons { display: flex; gap: 12px; margin-top: 22px; }
.tf-answer-buttons .btn { flex: 1; padding: 14px; font-size: 15px; }
.tf-explanation {
  margin-top: 16px;
  padding: 14px 16px;
  border-radius: 10px;
  font-size: 14px;
  color: var(--text);
  border-left: 3px solid var(--accent);
  background: var(--bg-alt);
}
.tf-explanation.correct { border-left-color: var(--good); }
.tf-explanation.incorrect { border-left-color: var(--bad); }
.tf-result-tag {
  display: inline-block;
  font-weight: 800;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12.5px;
  margin-bottom: 10px;
}
.tf-result-tag.correct { background: var(--good-bg); color: var(--good); }
.tf-result-tag.incorrect { background: var(--bad-bg); color: var(--bad); }
.tf-footer { display: flex; justify-content: space-between; align-items: center; margin-top: 18px; }
.score-line { font-size: 14px; color: var(--text-dim); text-align: center; margin-bottom: 14px; }

/* ---------- Results screen ---------- */
.results-panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  text-align: center;
  box-shadow: var(--shadow);
}
.results-panel .big-score { font-size: 46px; font-weight: 800; margin: 10px 0; }
.results-panel .big-score.good-score { color: var(--good); }
.results-panel .big-score.mid-score { color: var(--warn); }
.results-panel .big-score.low-score { color: var(--bad); }
.review-list { text-align: left; margin-top: 24px; }
.review-item {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 10px;
}
.review-item .statement { font-weight: 600; margin-bottom: 6px; }
.review-item .explanation { font-size: 13.5px; color: var(--text-dim); }

/* ---------- Simulation mode ---------- */
.sim-progress-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}
.sim-progress-wrap .progress-bar { flex: 1; }
.self-grade-buttons { display: flex; gap: 10px; margin-top: 20px; }
.self-grade-buttons .btn { flex: 1; }

/* responsive */
@media (max-width: 640px) {
  .header-inner { padding: 12px 14px 0 14px; }
  main#app { padding: 20px 14px 60px 14px; }
  .brand h1 { font-size: 16px; }
  .flip-face { padding: 20px; }
  .flip-face .content { font-size: 15px; }
}
