:root {
  --green-950: #063a24;
  --green-900: #064c2b;
  --green-800: #075c32;
  --green-700: #08733d;
  --green-600: #0b8c49;
  --green-100: #e7f5ec;
  --green-50: #f2faf5;
  --blue-50: #eef6ff;
  --amber-50: #fff8e8;
  --amber-600: #c77800;
  --red-50: #fff1ef;
  --red-600: #d13b2f;
  --ink: #122019;
  --muted: #64716b;
  --line: #dce5df;
  --surface: #ffffff;
  --background: #f5f8f6;
  --shadow: 0 16px 45px rgba(8, 54, 32, .09);
  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 14px;
  --safe-bottom: max(12px, env(safe-area-inset-bottom));
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--background);
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--background); }
body { margin: 0; min-height: 100%; background: var(--background); }
button, input, select, textarea { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid rgba(11,140,73,.25); outline-offset: 2px; }

.app-shell { min-height: 100vh; padding-bottom: 96px; }
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  min-height: 72px; padding: 12px 20px;
  background: linear-gradient(135deg, var(--green-950), var(--green-800)); color: white;
  box-shadow: 0 8px 26px rgba(6,58,36,.16);
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-mark { width: 44px; height: 44px; flex: 0 0 auto; }
.brand-copy { min-width: 0; }
.brand-title { margin: 0; font-size: 1.05rem; font-weight: 800; letter-spacing: .01em; }
.brand-subtitle { margin: 2px 0 0; font-size: .72rem; text-transform: uppercase; letter-spacing: .17em; opacity: .78; }
.top-actions { display: flex; gap: 8px; }
.icon-button {
  display: inline-grid; place-items: center; width: 44px; height: 44px; border: 0; border-radius: 50%;
  background: rgba(255,255,255,.11); color: inherit; cursor: pointer;
}
.icon-button:hover { background: rgba(255,255,255,.18); }
.icon-button.light { background: var(--surface); color: var(--green-800); border: 1px solid var(--line); }
.icon-button.light:hover { background: var(--green-50); }

.main { width: min(1120px, 100%); margin: 0 auto; padding: 24px 18px 36px; }
.hero {
  position: relative; overflow: hidden; min-height: 320px; padding: 34px;
  border-radius: var(--radius-xl); color: white; box-shadow: var(--shadow);
  background:
    radial-gradient(circle at 82% 12%, rgba(255,255,255,.18), transparent 22%),
    linear-gradient(135deg, rgba(4,54,31,.96), rgba(7,92,50,.83)),
    linear-gradient(170deg, #0a6a3b, #04331e);
}
.hero::after {
  content: ""; position: absolute; inset: auto -8% -52% 45%; height: 320px;
  border-radius: 50%; background: rgba(255,255,255,.08); transform: rotate(-10deg);
}
.hero-copy { position: relative; z-index: 2; width: min(580px, 100%); }
.hero h1 { margin: 0; max-width: 620px; font-size: clamp(2.1rem, 6vw, 4.25rem); line-height: .98; letter-spacing: -.045em; }
.hero p { max-width: 560px; margin: 18px 0 0; font-size: 1.05rem; line-height: 1.6; color: rgba(255,255,255,.83); }
.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 26px; }
.hero-stat {
  position: absolute; right: 30px; bottom: 28px; z-index: 2; width: 205px; padding: 20px;
  border: 1px solid rgba(255,255,255,.2); border-radius: 22px; background: rgba(255,255,255,.11); backdrop-filter: blur(12px);
}
.hero-stat strong { display: block; font-size: 2.2rem; line-height: 1; }
.hero-stat span { display: block; margin-top: 8px; font-size: .86rem; color: rgba(255,255,255,.75); }
.progress-track { height: 8px; overflow: hidden; margin-top: 14px; border-radius: 999px; background: rgba(255,255,255,.18); }
.progress-fill { height: 100%; border-radius: inherit; background: white; transition: width .35s ease; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 9px; min-height: 48px; padding: 0 18px;
  border: 1px solid transparent; border-radius: 14px; font-size: .94rem; font-weight: 760; cursor: pointer; text-decoration: none;
  transition: transform .15s ease, box-shadow .15s ease, background .15s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn.primary { background: var(--green-700); color: white; box-shadow: 0 10px 24px rgba(7,115,61,.21); }
.btn.primary:hover { background: var(--green-600); }
.btn.hero-primary { background: white; color: var(--green-900); }
.btn.hero-secondary { color: white; border-color: rgba(255,255,255,.28); background: rgba(255,255,255,.08); }
.btn.secondary { background: white; color: var(--ink); border-color: var(--line); }
.btn.danger { background: var(--red-50); color: var(--red-600); border-color: #f2cbc6; }
.btn.ghost { background: transparent; color: var(--green-800); border-color: transparent; }
.btn.full { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }

.section-head { display: flex; align-items: end; justify-content: space-between; gap: 16px; margin: 30px 0 14px; }
.section-head h2 { margin: 0; font-size: 1.4rem; letter-spacing: -.02em; }
.section-head p { margin: 6px 0 0; color: var(--muted); font-size: .92rem; }

.action-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.action-card, .topic-card, .stat-card, .panel {
  border: 1px solid var(--line); background: var(--surface); border-radius: var(--radius-lg); box-shadow: 0 8px 30px rgba(11,70,42,.045);
}
.action-card {
  display: flex; flex-direction: column; align-items: flex-start; min-height: 170px; padding: 20px; cursor: pointer; text-align: left;
  transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease;
}
.action-card:hover { transform: translateY(-3px); border-color: #b8d5c2; box-shadow: 0 14px 32px rgba(11,70,42,.09); }
.action-icon { display: grid; place-items: center; width: 48px; height: 48px; margin-bottom: 18px; border-radius: 14px; background: var(--green-100); color: var(--green-800); }
.action-card h3 { margin: 0; font-size: 1.05rem; }
.action-card p { margin: 7px 0 0; color: var(--muted); line-height: 1.45; font-size: .88rem; }
.action-card .card-meta { margin-top: auto; padding-top: 16px; font-size: .78rem; color: var(--green-700); font-weight: 750; }

.topic-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.topic-card { padding: 20px; }
.topic-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.topic-code { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; color: white; font-weight: 850; background: var(--green-700); }
.topic-card:nth-child(2) .topic-code { background: #3156a6; }
.topic-card:nth-child(3) .topic-code { background: #a66a15; }
.topic-card:nth-child(4) .topic-code { background: #50616c; }
.topic-title { margin: 0; font-size: 1rem; line-height: 1.35; }
.topic-count { margin-top: 5px; color: var(--muted); font-size: .82rem; }
.topic-progress { margin-top: 18px; }
.topic-progress-row { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 8px; font-size: .78rem; color: var(--muted); }
.topic-progress .progress-track { background: #edf1ee; margin: 0; height: 7px; }
.topic-progress .progress-fill { background: var(--green-600); }

.bottom-nav {
  position: fixed; left: 50%; bottom: var(--safe-bottom); z-index: 50; transform: translateX(-50%);
  display: grid; grid-template-columns: repeat(5, minmax(56px, 96px)); width: min(620px, calc(100% - 24px));
  padding: 8px; border: 1px solid rgba(220,229,223,.9); border-radius: 22px; background: rgba(255,255,255,.95);
  box-shadow: 0 16px 45px rgba(14,55,35,.16); backdrop-filter: blur(16px);
}
.nav-item { display: flex; flex-direction: column; align-items: center; gap: 4px; min-height: 54px; padding: 7px 3px 5px; border: 0; border-radius: 15px; background: transparent; color: #64716b; cursor: pointer; font-size: .68rem; font-weight: 650; }
.nav-item svg { width: 21px; height: 21px; }
.nav-item.active { color: var(--green-800); background: var(--green-50); }

.study-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 18px; }
.study-card { min-height: 520px; padding: 24px; }
.study-side { display: flex; flex-direction: column; gap: 14px; }
.study-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.study-progress-copy { color: var(--muted); font-size: .88rem; }
.study-progress-copy strong { color: var(--ink); }
.category-chip { display: inline-flex; align-items: center; gap: 7px; max-width: 100%; padding: 8px 12px; border-radius: 999px; background: var(--green-50); color: var(--green-800); font-size: .78rem; font-weight: 760; }
.question-title { margin: 24px 0 18px; font-size: clamp(1.65rem, 4.8vw, 2.55rem); line-height: 1.2; letter-spacing: -.035em; }
.answer-placeholder { display: grid; place-items: center; min-height: 190px; padding: 30px; border: 1px dashed #bdd2c5; border-radius: 20px; background: #fbfdfb; text-align: center; }
.answer-panel { margin-top: 20px; padding: 22px; border: 1px solid #cbe4d3; border-radius: 20px; background: linear-gradient(145deg, #f7fcf8, #eef8f1); }
.answer-label { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; color: var(--green-800); font-size: .85rem; font-weight: 850; text-transform: uppercase; letter-spacing: .06em; }
.answer-text { margin: 0; font-size: 1.08rem; line-height: 1.7; }
.study-controls { display: flex; gap: 10px; margin-top: 22px; }
.study-controls .btn { flex: 1; }

.mini-panel { padding: 18px; }
.mini-panel h3 { margin: 0 0 12px; font-size: .95rem; }
.mini-panel p { margin: 0; color: var(--muted); font-size: .85rem; line-height: 1.55; }
.metric-row { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid #edf1ee; font-size: .86rem; }
.metric-row:last-child { border-bottom: 0; }
.metric-row span { color: var(--muted); }
.metric-row strong { font-weight: 800; }

.filterbar { display: grid; grid-template-columns: minmax(220px, 1fr) repeat(2, minmax(150px, 220px)); gap: 10px; margin-bottom: 14px; }
.input, .select {
  width: 100%; min-height: 48px; padding: 0 14px; border: 1px solid var(--line); border-radius: 13px; background: white; color: var(--ink);
}
.input::placeholder { color: #89928e; }
.question-list { overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius-lg); background: white; }
.question-row { display: grid; grid-template-columns: 52px minmax(0, 1fr) auto; align-items: center; gap: 14px; width: 100%; padding: 15px 16px; border: 0; border-bottom: 1px solid #edf1ee; background: white; text-align: left; cursor: pointer; }
.question-row:last-child { border-bottom: 0; }
.question-row:hover { background: #fbfdfb; }
.row-status { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; background: #edf1ee; color: #718079; font-size: .75rem; font-weight: 800; }
.row-status.correct { background: var(--green-100); color: var(--green-800); }
.row-status.wrong { background: var(--red-50); color: var(--red-600); }
.row-main { min-width: 0; }
.row-title { margin: 0; font-size: .92rem; line-height: 1.4; }
.row-meta { margin-top: 4px; color: var(--muted); font-size: .75rem; }
.row-actions { display: flex; align-items: center; gap: 8px; }
.star { color: #9aa39f; }
.star.on { color: #d79b00; fill: #d79b00; }
.empty { padding: 50px 24px; text-align: center; color: var(--muted); }

.stats-grid { display: grid; grid-template-columns: 300px 1fr; gap: 18px; }
.progress-ring {
  --p: 0%; width: 190px; height: 190px; margin: 12px auto 20px; border-radius: 50%;
  display: grid; place-items: center; background: conic-gradient(var(--green-600) var(--p), #e6ebe8 0);
}
.progress-ring::before { content: ""; width: 148px; height: 148px; border-radius: 50%; background: white; }
.progress-ring-content { position: absolute; text-align: center; }
.progress-ring-content strong { display: block; font-size: 2rem; }
.progress-ring-content span { color: var(--muted); font-size: .78rem; }
.stats-summary { position: relative; padding: 22px; }
.stat-triplet { display: grid; grid-template-columns: repeat(3,1fr); border-top: 1px solid var(--line); }
.stat-triplet div { padding: 14px 8px 0; text-align: center; }
.stat-triplet div + div { border-left: 1px solid var(--line); }
.stat-triplet strong { display: block; font-size: 1.15rem; }
.stat-triplet span { color: var(--muted); font-size: .74rem; }
.stat-list { padding: 22px; }
.stat-list h3 { margin: 0 0 16px; }
.stat-topic { margin-bottom: 18px; }
.stat-topic:last-child { margin-bottom: 0; }
.stat-topic-head { display: flex; justify-content: space-between; gap: 16px; margin-bottom: 8px; font-size: .85rem; }
.stat-topic-head span:last-child { color: var(--muted); }
.stat-topic .progress-track { background: #edf1ee; margin: 0; height: 8px; }
.stat-topic .progress-fill { background: var(--green-600); }

.settings-stack { display: grid; gap: 14px; }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 18px; border: 1px solid var(--line); border-radius: 16px; background: white; }
.setting-copy h3 { margin: 0; font-size: .95rem; }
.setting-copy p { margin: 5px 0 0; color: var(--muted); font-size: .82rem; line-height: 1.45; }
.setting-control { flex: 0 0 min(220px, 42%); }
.source-note { padding: 18px; border-left: 4px solid var(--green-600); border-radius: 0 14px 14px 0; background: var(--green-50); color: #355044; font-size: .85rem; line-height: 1.6; }
.source-note a { color: var(--green-800); font-weight: 750; }

.session-setup { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.choice-card { display: flex; align-items: flex-start; gap: 13px; padding: 17px; border: 1px solid var(--line); border-radius: 16px; background: white; cursor: pointer; }
.choice-card.active { border-color: var(--green-600); box-shadow: inset 0 0 0 1px var(--green-600); background: var(--green-50); }
.choice-card input { margin-top: 3px; accent-color: var(--green-700); }
.choice-card strong { display: block; font-size: .92rem; }
.choice-card span { display: block; margin-top: 5px; color: var(--muted); font-size: .8rem; line-height: 1.45; }
.exam-result { padding: 28px; text-align: center; }
.exam-result h2 { font-size: 2rem; margin: 0 0 8px; }
.result-score { font-size: 4rem; font-weight: 900; color: var(--green-800); letter-spacing: -.06em; }

.toast { position: fixed; left: 50%; bottom: 100px; z-index: 100; transform: translateX(-50%) translateY(20px); padding: 12px 16px; border-radius: 13px; background: #15251d; color: white; font-size: .84rem; opacity: 0; pointer-events: none; transition: .2s ease; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 900px) {
  .action-grid { grid-template-columns: repeat(2, 1fr); }
  .study-layout, .stats-grid { grid-template-columns: 1fr; }
  .study-side { display: grid; grid-template-columns: repeat(2,1fr); }
  .hero-stat { position: relative; right: auto; bottom: auto; margin-top: 28px; }
}

@media (max-width: 640px) {
  .topbar { min-height: 64px; padding: 10px 14px; }
  .brand-mark { width: 40px; height: 40px; }
  .brand-title { font-size: .93rem; }
  .brand-subtitle { font-size: .63rem; }
  .main { padding: 16px 12px 28px; }
  .hero { min-height: auto; padding: 26px 22px; border-radius: 22px; }
  .hero h1 { font-size: 2.35rem; }
  .hero p { font-size: .94rem; }
  .hero-actions { flex-direction: column; }
  .hero-actions .btn { width: 100%; }
  .hero-stat { width: 100%; }
  .action-grid, .topic-grid, .session-setup { grid-template-columns: 1fr; }
  .action-card { min-height: 142px; }
  .section-head { align-items: flex-start; }
  .study-card { padding: 18px; min-height: 480px; }
  .question-title { font-size: 1.75rem; }
  .study-controls { flex-direction: column; }
  .study-side { grid-template-columns: 1fr; }
  .filterbar { grid-template-columns: 1fr; }
  .question-row { grid-template-columns: 42px minmax(0,1fr) auto; padding: 13px 12px; gap: 10px; }
  .row-meta { display: none; }
  .bottom-nav { grid-template-columns: repeat(5,1fr); width: calc(100% - 16px); bottom: max(8px, env(safe-area-inset-bottom)); border-radius: 20px; }
  .nav-item { font-size: .61rem; }
  .setting-row { align-items: flex-start; flex-direction: column; }
  .setting-control { width: 100%; flex: 1; }
  .stat-triplet strong { font-size: 1rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .001ms !important; animation-duration: .001ms !important; }
}

/* Multiple-Choice-Lernmodus */
.mcq-list { display: grid; gap: 12px; margin-top: 4px; }
.mcq-option {
  display: grid; grid-template-columns: 42px minmax(0,1fr) 28px; align-items: center; gap: 13px;
  width: 100%; min-height: 64px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 16px;
  background: white; color: var(--ink); text-align: left; cursor: pointer; transition: border-color .16s ease, background .16s ease, box-shadow .16s ease, transform .16s ease;
}
.mcq-option:hover:not(:disabled) { border-color: #a9cbb5; background: #fbfdfb; transform: translateY(-1px); }
.mcq-option:disabled { cursor: default; opacity: 1; }
.option-letter { display: grid; place-items: center; width: 36px; height: 36px; border: 1px solid #cfd9d3; border-radius: 50%; color: var(--muted); font-weight: 850; }
.option-text { font-size: .96rem; line-height: 1.48; }
.option-state { display: grid; place-items: center; color: inherit; }
.mcq-option.selected { border-color: var(--green-600); box-shadow: inset 0 0 0 1px var(--green-600); background: var(--green-50); }
.mcq-option.correct { border-color: var(--green-600); box-shadow: inset 0 0 0 1px var(--green-600); background: var(--green-50); color: var(--green-900); }
.mcq-option.correct .option-letter { border-color: var(--green-600); background: var(--green-700); color: white; }
.mcq-option.wrong { border-color: var(--red-600); box-shadow: inset 0 0 0 1px var(--red-600); background: var(--red-50); color: #8f271f; }
.mcq-option.wrong .option-letter { border-color: var(--red-600); background: var(--red-600); color: white; }
.feedback-panel { margin-top: 18px; padding: 18px; border: 1px solid; border-radius: 16px; }
.feedback-panel.correct { border-color: #b8dec4; background: var(--green-50); color: var(--green-900); }
.feedback-panel.wrong { border-color: #f0c2bd; background: var(--red-50); color: #74251e; }
.feedback-title { display: flex; align-items: center; gap: 8px; font-weight: 850; }
.feedback-panel p { margin: 10px 0 0; line-height: 1.6; }

.explanation-panel {
  margin-top: 14px; padding: 19px; border: 1px solid #bad9c5; border-radius: 16px;
  background: linear-gradient(145deg, #fbfefc, #eef8f1); color: var(--ink);
  animation: explanation-in .18s ease-out;
}
.explanation-title { display: flex; align-items: center; gap: 8px; color: var(--green-800); font-weight: 850; }
.explanation-panel p { margin: 10px 0 0; line-height: 1.65; }
.memory-tip { margin-top: 14px; padding: 12px 14px; border-left: 4px solid var(--green-600); border-radius: 0 10px 10px 0; background: rgba(255,255,255,.78); color: var(--green-900); font-size: .9rem; font-weight: 720; line-height: 1.5; }
@keyframes explanation-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: translateY(0); } }

.study-controls.single { justify-content: flex-end; }
.study-controls.single .btn { flex: 0 1 260px; }

@media (max-width: 640px) {
  .mcq-option { grid-template-columns: 36px minmax(0,1fr) 22px; gap: 10px; padding: 11px 12px; }
  .option-letter { width: 32px; height: 32px; }
  .option-text { font-size: .9rem; }
  .study-controls.single .btn { flex: 1; }
}
