/* ==========================================================================
   Lernstudio 34a – Master Stylesheet
   Designsystem: Cream, Forest Green, Rust Accent, Georgia Serifen.
   Barrierefreiheit: WCAG 2.2 Konformitätsstufe AA.
   Stand: November 2026 · Version 2.0.0
   ========================================================================== */

:root {
  --bg: #f5efe5;
  --ink: #292c25;
  --muted: #746e64;
  --green: #34543d;
  --green-hover: #263e2d;
  --green-light: #e6ecdf;
  --rust: #a6492b;
  --rust-hover: #873b23;
  --paper: #fffcf6;
  --line: #d9d0c3;
  --soft: #e6ecdf;
  --card-shadow: 0 2px 8px rgba(41, 44, 37, 0.05);
  --focus-ring: #b39969;
  --good: #276c39;
  --good-bg: #eaf5ec;
  --bad: #a12f2f;
  --bad-bg: #faeaea;
  --warn: #b37418;
  --warn-bg: #fef7e9;
  --font-base: 16px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --transition: all 0.18s ease-in-out;
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
  --header-height: 80px;
}

/* --- Dark Theme --- */
html.dark-theme {
  --bg: #1c211d;
  --ink: #f0ede6;
  --muted: #a39e94;
  --green: #689f78;
  --green-hover: #7db88e;
  --green-light: #263329;
  --rust: #d66c4a;
  --rust-hover: #e58262;
  --paper: #252b26;
  --line: #384239;
  --soft: #2b362d;
  --card-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
  --focus-ring: #d4ba8a;
  --good: #5cb874;
  --good-bg: #1e3825;
  --bad: #e06262;
  --bad-bg: #3d1f1f;
  --warn: #e0a348;
  --warn-bg: #3d2f17;
}

/* --- High Contrast Modus --- */
html.high-contrast {
  --bg: #ffffff;
  --ink: #000000;
  --muted: #222222;
  --green: #0a4d1a;
  --green-light: #e0f2e3;
  --rust: #8a1d00;
  --paper: #ffffff;
  --line: #000000;
  --soft: #eeeeee;
  --focus-ring: #000000;
  --good: #006600;
  --bad: #990000;
  --warn: #664400;
}
html.dark-theme.high-contrast {
  --bg: #000000;
  --ink: #ffffff;
  --muted: #dddddd;
  --green: #77ff99;
  --green-light: #11331a;
  --rust: #ff8866;
  --paper: #0a0a0a;
  --line: #ffffff;
  --soft: #222222;
  --focus-ring: #ffff00;
  --good: #66ff66;
  --bad: #ff6666;
  --warn: #ffcc66;
}

/* --- Schriftgrößen-Skalierung --- */
html.font-large { font-size: 18px; }
html.font-xlarge { font-size: 20px; }

/* --- Basis & Reset --- */
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html {
  font-family: Arial, Helvetica, sans-serif;
  font-size: var(--font-base);
  background-color: var(--bg);
  color: var(--ink);
  line-height: 1.5;
  scroll-behavior: smooth;
}
body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
a {
  color: var(--green);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}
button, input, select, textarea {
  font: inherit;
  color: inherit;
  touch-action: manipulation;
}
button {
  cursor: pointer;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--green);
  font-weight: 650;
  padding: 10px 16px;
  border-radius: var(--radius-md);
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
}
button:hover:not(:disabled) {
  border-color: var(--green);
  background: var(--soft);
}
button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
button.primary {
  background: var(--rust);
  color: #fff;
  border-color: var(--rust);
}
button.primary:hover:not(:disabled) {
  background: var(--rust-hover);
  border-color: var(--rust-hover);
}
button.btn-outline {
  background: transparent;
  border-color: var(--line);
}
button.btn-sm {
  padding: 6px 10px;
  font-size: 0.82rem;
  border-radius: var(--radius-sm);
}
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 3px;
}
input, select, textarea {
  font-size: 1rem;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--paper);
  color: var(--ink);
  min-width: 0;
}
label {
  display: grid;
  gap: 6px;
  font-size: 0.9rem;
  font-weight: 650;
}
p {
  line-height: 1.6;
  margin: 0 0 14px;
  color: var(--muted);
  overflow-wrap: break-word;
}
h1, h2, h3, h4 {
  margin: 0 0 12px;
  color: var(--ink);
  font-family: Georgia, "Times New Roman", serif;
  letter-spacing: -0.025em;
  overflow-wrap: break-word;
  hyphens: auto;
  -webkit-hyphens: auto;
}
h1 {
  font-size: clamp(1.8rem, 4.5vw, 3.6rem);
  line-height: 1.15;
}
h2 {
  font-size: clamp(1.35rem, 2.5vw, 2.1rem);
  line-height: 1.25;
}
h3 {
  font-size: 1.25rem;
  line-height: 1.3;
}
h4 {
  font-size: 1.05rem;
}

/* --- Layout Container --- */
.shell {
  max-width: 1320px;
  margin: 0 auto;
  padding: 0 32px;
  width: 100%;
}
/* --- Header & Hauptnavigation (Einzeilig, Kompakt, Sticky) --- */
header.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg);
  background: color-mix(in srgb, var(--bg) 95%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
  width: 100%;
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: var(--header-height, 64px);
  gap: 16px;
  padding-top: max(4px, var(--sat));
  padding-bottom: 4px;
}

.brand {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  line-height: 1;
  flex-shrink: 0;
}
.brand:hover {
  text-decoration: none;
  opacity: 0.92;
}
.brand-logo {
  width: 76px;
  height: 76px;
  object-fit: contain;
  display: inline-block;
  vertical-align: middle;
  border-radius: var(--radius-sm);
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.14));
  transition: transform 0.18s ease-in-out, filter 0.18s ease-in-out;
}
.brand:hover .brand-logo {
  transform: scale(1.04);
  filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.2));
}
.footer-brand .brand-logo {
  width: 116px;
  height: 116px;
}

/* --- Hauptnavigation (Desktop) --- */
.main-nav {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: 12px;
  margin-right: auto;
}

.nav-item {
  position: relative;
}

.nav-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  font-size: 0.92rem;
  font-weight: 650;
  color: var(--ink);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  user-select: none;
}
.nav-btn:hover {
  color: var(--green);
  background: var(--soft);
  border-color: var(--line);
}
.nav-btn.active {
  color: var(--green);
  background: var(--soft);
  border-color: var(--green);
}
.nav-chevron {
  transition: transform 0.2s ease;
  opacity: 0.7;
}
.dropdown.open .nav-chevron {
  transform: rotate(180deg);
}

/* --- Dropdown Menüs (Desktop) --- */
.dropdown {
  position: relative;
}
.dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  min-width: 280px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.18);
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(-8px);
  transition: opacity 0.18s ease, transform 0.18s ease, visibility 0.18s;
  z-index: 110;
}
.dropdown.open .dropdown-menu {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0);
}
.dropdown-right .dropdown-menu {
  left: auto;
  right: 0;
}

.dropdown-link {
  display: flex;
  flex-direction: column;
  padding: 9px 12px;
  border-radius: var(--radius-md);
  text-decoration: none;
  transition: var(--transition);
}
.dropdown-link:hover, .dropdown-link:focus-visible {
  background: var(--soft);
  text-decoration: none;
}
.dropdown-link.active {
  background: var(--green-light);
}
.dropdown-link.active .dropdown-link-title {
  color: var(--green);
  font-weight: 750;
}
.dropdown-link-title {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.25;
}
.dropdown-link-desc {
  font-size: 0.76rem;
  color: var(--muted);
  line-height: 1.35;
  margin-top: 2px;
}
.dropdown-link.highlight {
  border-left: 3px solid var(--rust);
}
.dropdown-link.highlight .dropdown-link-title {
  color: var(--rust);
}

.dropdown-menu-settings {
  min-width: 250px;
}
.dropdown-link-simple {
  display: block;
  padding: 8px 12px;
  font-size: 0.88rem;
  font-weight: 550;
  color: var(--ink);
  border-radius: var(--radius-sm);
  text-decoration: none;
  transition: var(--transition);
}
.dropdown-link-simple:hover, .dropdown-link-simple:focus-visible {
  background: var(--soft);
  color: var(--green);
  text-decoration: none;
}
.dropdown-link-simple.active {
  color: var(--green);
  font-weight: 700;
  background: var(--soft);
}
.dropdown-divider {
  height: 1px;
  background: var(--line);
  margin: 4px 6px;
}
.dropdown-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 9px 12px;
  font-size: 0.88rem;
  font-weight: 700;
  color: white;
  background: var(--rust);
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: var(--transition);
  margin-bottom: 4px;
}
.dropdown-action-btn:hover {
  background: var(--rust-hover);
}

/* --- Rechter Bereich & Icon Buttons --- */
.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  margin-left: auto;
}

.header-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: var(--radius-md);
  background: var(--paper);
  border: 1px solid var(--line);
  color: var(--ink);
  cursor: pointer;
  transition: var(--transition);
}
.header-icon-btn:hover {
  border-color: var(--green);
  color: var(--green);
  background: var(--soft);
}
.header-icon-btn.active {
  border-color: var(--green);
  color: var(--green);
  background: var(--soft);
}

/* --- Streak Badge & Offline Badge --- */
.streak-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 0.82rem;
  font-weight: 700;
  background: #fff3e6;
  border: 1px solid #ffd4aa;
  color: #b54708;
  white-space: nowrap;
}
.streak-badge .icon-flame {
  color: #d66c4a;
  flex-shrink: 0;
}
html.dark-theme .streak-badge {
  background: #342215;
  border-color: #60381e;
  color: #f7a26d;
}

.offline-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 700;
  background: var(--bad-bg);
  border: 1px solid var(--bad);
  color: var(--bad);
  white-space: nowrap;
}

/* --- Hamburger Toggle & Mobiles Menü --- */
.mobile-menu-toggle {
  display: none;
}
.mobile-menu-toggle .icon-menu-close {
  display: none;
}
.mobile-menu-toggle[aria-expanded="true"] .icon-menu-open {
  display: none;
}
.mobile-menu-toggle[aria-expanded="true"] .icon-menu-close {
  display: block;
}

.mobile-nav {
  position: absolute;
  top: 100%;
  left: 0;
  width: 100%;
  background: var(--bg);
  background: color-mix(in srgb, var(--bg) 98%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 2px solid var(--line);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.2);
  max-height: calc(100vh - var(--header-height, 64px));
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  animation: slideDown 0.2s ease-out;
  z-index: 99;
}
@keyframes slideDown {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}
.mobile-nav-inner {
  padding: 16px 20px 32px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-width: 600px;
  margin: 0 auto;
}
.mobile-nav-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 10px 12px;
}
.mobile-nav-heading {
  font-size: 0.74rem;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--green);
  padding: 4px 6px 6px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 4px;
}
.mobile-nav-link {
  padding: 8px 10px;
  font-size: 0.95rem;
  font-weight: 650;
  color: var(--ink);
  border-radius: var(--radius-sm);
  text-decoration: none;
  transition: var(--transition);
}
.mobile-nav-link:hover, .mobile-nav-link:focus-visible {
  background: var(--soft);
  color: var(--green);
  text-decoration: none;
}
.mobile-nav-link.active {
  background: var(--green-light);
  color: var(--green);
  font-weight: 750;
}
.mobile-nav-link.highlight {
  color: var(--rust);
}
.mobile-nav-direct {
  font-size: 1rem;
}
.mobile-nav-sub {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  background: transparent;
  border: none;
  padding: 4px 0;
}
.mobile-sub-link {
  font-size: 0.82rem;
  color: var(--muted);
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  text-decoration: none;
}
.mobile-sub-link:hover {
  color: var(--green);
  text-decoration: underline;
}
.mobile-sub-link.active {
  color: var(--green);
  font-weight: 700;
}
body.nav-open {
  overflow: hidden;
}
main.shell {
  flex: 1;
  padding-top: 32px;
  padding-bottom: 48px;
}

/* --- Hero Section --- */
.hero {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: 32px;
  align-items: center;
  margin-bottom: 36px;
}
.eyebrow {
  font-size: 0.75rem;
  letter-spacing: 0.15em;
  color: var(--green);
  font-weight: 750;
  margin-bottom: 12px;
  text-transform: uppercase;
}
.hero p {
  font-size: 1.1rem;
  max-width: 650px;
}
.hero-aside {
  background: var(--green);
  color: #fffaf1;
  border-radius: var(--radius-lg);
  padding: 28px;
  position: relative;
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(52, 84, 61, 0.2);
}
.hero-aside p {
  color: #e0e8d8;
  margin-bottom: 18px;
}
.hero-aside .big {
  font-size: 2.8rem;
  font-family: Georgia, serif;
  margin: 8px 0;
  line-height: 1;
}
.hero-aside button {
  background: #f8f4e8;
  color: var(--green);
  border: none;
}

/* --- Breadcrumbs --- */
.breadcrumbs {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  color: var(--muted);
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.breadcrumbs a {
  color: var(--muted);
  text-decoration: none;
}
.breadcrumbs a:hover {
  color: var(--green);
  text-decoration: underline;
}
.breadcrumbs span.sep {
  opacity: 0.5;
}
.breadcrumbs span.current {
  color: var(--ink);
  font-weight: 600;
}

/* --- Grid & Cards --- */
.row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.between {
  justify-content: space-between;
}
.muted {
  color: var(--muted);
  font-size: 0.85rem;
}
.grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 18px;
}
.grid-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.grid-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.card, .panel {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 22px;
  min-width: 0;
  box-shadow: var(--card-shadow);
  transition: var(--transition);
}
.card:hover {
  border-color: var(--green);
}
.card {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.card .glyph {
  background: var(--soft);
  width: 52px;
  height: 52px;
  border-radius: var(--radius-md);
  display: grid;
  place-items: center;
  color: var(--green);
  font-size: 1.8rem;
  font-family: Georgia, serif;
}
.card h3 {
  margin: 0;
  line-height: 1.25;
}
.card .meta {
  color: var(--muted);
  font-size: 0.8rem;
}
.card button, .card a.btn {
  margin-top: auto;
  width: 100%;
}
.panel {
  max-width: 900px;
  margin: 18px 0;
}
.wide {
  max-width: none;
}
.form {
  display: grid;
  gap: 16px;
  max-width: 580px;
}
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  border: 1px solid var(--line);
  border-radius: 30px;
  padding: 4px 10px;
  color: var(--green);
  background: var(--paper);
  font-weight: 600;
}
.pill.pill-rust {
  color: var(--rust);
  border-color: var(--rust);
}
.pill.pill-good {
  color: var(--good);
  border-color: var(--good);
  background: var(--good-bg);
}
.pill.pill-bad {
  color: var(--bad);
  border-color: var(--bad);
  background: var(--bad-bg);
}
.notice {
  padding: 14px 18px;
  border: 1px solid var(--line);
  background: var(--warn-bg);
  border-radius: var(--radius-md);
  color: var(--warn);
  font-size: 0.88rem;
  margin: 14px 0;
  display: flex;
  align-items: center;
  gap: 12px;
}
.notice-info {
  background: var(--green-light);
  color: var(--green);
  border-color: var(--green);
}

/* --- Filter-Leiste (Horizontale Scroll-Chips) --- */
.filters {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  flex-wrap: nowrap;
  padding-bottom: 6px;
  margin: 16px 0 22px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}
.filters button {
  white-space: nowrap;
  font-size: 0.85rem;
  padding: 8px 16px;
  border-radius: 24px;
  flex-shrink: 0;
  background: var(--paper);
  border: 1px solid var(--line);
  color: var(--ink);
  cursor: pointer;
  transition: var(--transition);
}
.filters button:hover {
  background: var(--soft);
  border-color: var(--green);
}
.filters button.active {
  background: var(--green);
  color: #fff;
  border-color: var(--green);
  font-weight: 700;
}

/* --- Gamification & Streak Banner --- */
.streak-badge {
  background: #fff3e6;
  border: 1px solid #ffd4aa;
  color: #b54708;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.82rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.xp-pill {
  background: #fdf2fa;
  border: 1px solid #fcceee;
  color: #c11574;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.82rem;
  font-weight: 700;
}

/* --- Interactive Games & Exam Bar --- */
.gamebar {
  position: sticky;
  top: var(--header-height, 64px);
  z-index: 20;
  background: var(--bg);
  backdrop-filter: blur(10px);
  padding: 12px 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--line);
}
.progress {
  height: 8px;
  background: var(--line);
  border-radius: 8px;
  overflow: hidden;
  margin: 14px 0;
}
.progress i {
  display: block;
  height: 100%;
  background: var(--green);
  transition: width 0.25s ease;
}
.question {
  max-width: 900px;
  margin: 20px auto;
  padding: 30px;
}
.question h2 {
  font-size: clamp(1.3rem, 2.5vw, 1.85rem);
  line-height: 1.3;
}
.choices {
  display: grid;
  gap: 12px;
  margin: 24px 0;
}
.choices button {
  text-align: left;
  padding: 14px 18px;
  color: var(--ink);
  font-weight: 500;
  border-radius: var(--radius-md);
  justify-content: flex-start;
  line-height: 1.4;
  background: var(--paper);
  border: 1.5px solid var(--line);
}
.choices button:hover:not(:disabled) {
  border-color: var(--green);
  background: var(--soft);
}
.choices button.selected {
  background: var(--soft);
  border-color: var(--green);
  border-width: 2px;
  font-weight: 600;
}
.choices button.choice-correct {
  background: var(--good-bg);
  border-color: var(--good);
  color: var(--good);
}
.choices button.choice-wrong {
  background: var(--bad-bg);
  border-color: var(--bad);
  color: var(--bad);
}
.qnav {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 20px auto;
  max-width: 900px;
}
.qnav button {
  padding: 7px 11px;
  font-size: 0.82rem;
  min-width: 38px;
  position: relative;
}
.qnav button.done {
  background: var(--soft);
  color: var(--green);
}
.qnav button.flagged::after {
  content: "⚑";
  position: absolute;
  top: 1px;
  right: 3px;
  color: var(--rust);
  font-size: 0.7rem;
}
.qnav button.current {
  border: 2px solid var(--green);
  font-weight: 750;
}

/* --- Results Screen --- */
.results {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin: 24px 0;
}
.results div {
  border: 1px solid var(--line);
  background: var(--paper);
  border-radius: var(--radius-md);
  padding: 18px;
  text-align: center;
}
.results strong {
  display: block;
  font-size: 2.4rem;
  font-family: Georgia, serif;
}
.good { color: var(--good); }
.bad { color: var(--bad); }

/* --- TableWrap --- */
.tablewrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 16px 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--paper);
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
  min-width: 520px;
}
th, td {
  text-align: left;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
th {
  background: var(--soft);
  color: var(--green);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 700;
}
tr:last-child td {
  border-bottom: none;
}
.empty {
  padding: 28px;
  color: var(--muted);
  text-align: center;
}

/* --- Groupboard & Memory --- */
.groupboard {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.zone {
  border: 1.5px dashed var(--line);
  border-radius: var(--radius-md);
  background: var(--paper);
  min-height: 120px;
  padding: 14px;
}
.zone.over {
  background: var(--soft);
  border-color: var(--green);
}
.zone h3 {
  color: var(--green);
  margin-top: 0;
}
.tokens {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.token {
  font-weight: 500;
  font-size: 0.84rem;
  padding: 8px 12px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  text-align: left;
}
.token.pick {
  outline: 2px solid var(--focus-ring);
  background: #fff1d8;
}
.pool {
  grid-column: 1 / -1;
}
.memory {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
}
.memory button {
  min-height: 90px;
  font-size: 0.88rem;
  background: var(--green);
  color: white;
  border-radius: var(--radius-md);
}
.memory button.flipped, .memory button.matched {
  background: var(--paper);
  color: var(--ink);
}
.memory button.matched {
  background: var(--soft);
  border-color: var(--green);
}

/* --- Accordion (Details / Summary) --- */
details {
  border: 1px solid var(--line);
  background: var(--paper);
  border-radius: var(--radius-md);
  margin-bottom: 12px;
  overflow: hidden;
  transition: var(--transition);
}
details[open] {
  border-color: var(--green);
}
details summary {
  padding: 16px 20px;
  cursor: pointer;
  font-weight: 700;
  color: var(--green);
  display: flex;
  align-items: center;
  justify-content: space-between;
  user-select: none;
  transition: background-color 0.15s ease;
}
details summary:hover {
  background: var(--soft);
}
details summary::-webkit-details-marker {
  display: none;
}
details summary::after {
  content: "▼";
  font-size: 0.72rem;
  transition: transform 0.2s ease;
  flex-shrink: 0;
}
details[open] summary::after {
  transform: rotate(180deg);
}
details .details-content {
  padding: 0 20px 20px 20px;
  color: var(--ink);
  line-height: 1.6;
}

/* --- FAQ Accordion Layout (Frage links, Kategorie & Pfeil rechts) --- */
.faq-summary {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 14px;
}
.faq-question {
  flex: 1 1 auto;
  font-weight: 700;
  color: var(--green);
  text-align: left;
  line-height: 1.4;
  min-width: 0;
}
.faq-meta {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
  flex-shrink: 0;
}
.faq-category {
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}

/* --- Deliktsaufbau & Lexikontabelle --- */
.delikt-box {
  background: var(--soft);
  border-radius: var(--radius-md);
  padding: 16px;
  margin: 14px 0;
  display: grid;
  gap: 10px;
}
.delikt-step {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 12px;
  font-size: 0.88rem;
}
.delikt-step strong {
  color: var(--green);
}

/* --- Global Search Modal --- */
.search-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  background: rgba(41, 44, 37, 0.65);
  backdrop-filter: blur(4px);
  padding: 20px;
}
.search-box {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  max-width: 680px;
  width: 100%;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
  overflow: hidden;
}
.search-header {
  padding: 18px;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 12px;
  align-items: center;
}
.search-header input {
  flex: 1;
  font-size: 1.1rem;
  border: none;
  background: transparent;
  outline: none;
  padding: 4px;
}
.search-results {
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.search-item {
  padding: 12px 16px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  display: flex;
  gap: 14px;
  align-items: center;
  text-decoration: none;
  color: var(--ink);
  transition: var(--transition);
}
.search-item:hover, .search-item.active {
  background: var(--soft);
  border-color: var(--green);
}
.search-item .badge {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 12px;
  background: var(--green);
  color: white;
}

/* --- Toast Notification --- */
#toast {
  position: fixed;
  bottom: calc(24px + var(--sab));
  right: 24px;
  background: var(--green);
  color: white;
  padding: 14px 20px;
  border-radius: var(--radius-md);
  max-width: 90vw;
  z-index: 1000;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.25);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 12px;
}
#toast[hidden],
#toast:empty {
  display: none !important;
}

/* --- Unified Footer --- */
footer.footer-unified {
  background: var(--paper);
  border-top: 1px solid var(--line);
  margin-top: auto;
  padding-top: 48px;
  padding-bottom: calc(32px + var(--sab));
  color: var(--muted);
}
.footer-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr 1fr;
  gap: 32px;
  margin-bottom: 36px;
}
.footer-col h4 {
  color: var(--green);
  margin-bottom: 14px;
  font-family: Arial, sans-serif;
  font-size: 0.88rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 750;
}
.footer-col ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 10px;
}
.footer-col a {
  color: var(--muted);
  font-size: 0.88rem;
  text-decoration: none;
  transition: var(--transition);
}
.footer-col a:hover {
  color: var(--green);
  text-decoration: underline;
}
.footer-brand {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.footer-brand .brand {
  font-size: 1.15rem;
}
.footer-privacy-note {
  border-top: 1px solid var(--line);
  padding: 24px 0 16px;
  text-align: center;
  font-size: 0.82rem;
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: var(--muted);
}
.footer-legal {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.78rem;
  flex-wrap: wrap;
  gap: 12px;
}

/* --- Back to top button --- */
#back-to-top {
  position: fixed;
  bottom: calc(24px + var(--sab));
  left: 24px;
  background: var(--paper);
  color: var(--green);
  border: 1px solid var(--line);
  border-radius: 50%;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  font-size: 1.2rem;
  box-shadow: var(--card-shadow);
  z-index: 50;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}
#back-to-top.visible {
  opacity: 1;
  pointer-events: auto;
}

/* --- Modale Dialoge (Willkommensdialog & Fehlermeldung) --- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  background: rgba(20, 24, 20, 0.72);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  padding: 18px;
  overflow-y: auto;
}
.modal-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  max-width: 660px;
  width: 100%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.38);
  overflow: hidden;
  animation: modalIn 0.18s ease-out;
}
@keyframes modalIn {
  from { opacity: 0; transform: scale(0.96) translateY(8px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}
.modal-header {
  padding: 22px 24px 16px;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}
.modal-header h2 {
  margin: 0;
  font-size: 1.35rem;
  line-height: 1.3;
}
.modal-close-btn {
  background: transparent;
  border: none;
  font-size: 1.5rem;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
}
.modal-close-btn:hover {
  color: var(--ink);
  background: var(--sand);
}
.modal-body {
  padding: 20px 24px;
  overflow-y: auto;
  font-size: 0.95rem;
  line-height: 1.6;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.modal-body ul {
  padding-left: 20px;
  margin: 8px 0;
}
.modal-body li {
  margin-bottom: 8px;
}
.modal-footer {
  padding: 16px 24px 20px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  background: var(--sand);
  flex-wrap: wrap;
}

/* --- Service Worker Update Notification Banner --- */
.sw-update-banner {
  position: fixed;
  bottom: calc(24px + var(--sab));
  right: 24px;
  z-index: 999;
  max-width: 440px;
  background: var(--paper);
  border: 2px solid var(--green);
  border-radius: var(--radius);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.28);
  padding: 16px 20px;
  animation: slideUp 0.25s ease-out;
}
.sw-update-banner[hidden],
.sw-update-banner:empty {
  display: none !important;
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}
.sw-update-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--ink);
}

/* --- Changelog Kategorien & Badges --- */
.badge-neu { background: #d7edd9; color: #1f5d2b; border: 1px solid #a8d5ad; }
.badge-verbessert { background: #e3effa; color: #1d5288; border: 1px solid #b8d7f2; }
.badge-korrigiert { background: #fff0d4; color: #875000; border: 1px solid #fed28d; }
.badge-sicherheit { background: #faece8; color: var(--rust); border: 1px solid #f4bcaf; }
.badge-datenschutz { background: #ece7f6; color: #523485; border: 1px solid #cfc0e8; }
.badge-recht { background: #e5f2f1; color: #16605b; border: 1px solid #b4dcda; }
.badge-entfernt { background: #f0f0f0; color: #666; border: 1px solid #d0d0d0; }

.changelog-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

/* --- Footer Zusätze --- */
.footer-meta-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.footer-meta-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  background: var(--sand);
  border: 1px solid var(--line);
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--ink);
}
.footer-btn-link {
  background: transparent;
  border: none;
  padding: 0;
  font: inherit;
  color: var(--muted);
  cursor: pointer;
  text-align: left;
  font-size: 0.88rem;
  transition: var(--transition);
}
.footer-btn-link:hover {
  color: var(--green);
  text-decoration: underline;
}

.hide-mobile {
  display: inline;
}

/* ==========================================================================
   Responsive Media Queries
   ========================================================================== */

/* --- Tablet / Kleiner Desktop (<= 1050px) --- */
@media (max-width: 1050px) {
  .grid { grid-template-columns: repeat(3, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
  .footer-grid { grid-template-columns: 1fr 1fr; }
  .hero { grid-template-columns: 1fr; }
  .shell { padding-left: 20px; padding-right: 20px; }
}

/* --- Navigation Breakpoint: Tablet & Mobile (<= 960px) --- */
@media (max-width: 960px) {
  .main-nav {
    display: none !important;
  }
  .mobile-menu-toggle {
    display: inline-flex !important;
  }
}

/* --- Tablet / Großes Smartphone (<= 768px) --- */
@media (max-width: 768px) {
  :root {
    --header-height: 72px;
  }
  .header-inner {
    min-height: 72px;
    padding: max(4px, var(--sat)) 0 4px;
  }
  .brand-logo {
    width: 66px;
    height: 66px;
  }
  .header-actions {
    gap: 6px;
  }
  main.shell {
    padding-top: 20px;
    padding-bottom: 36px;
  }
  .grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
  }
  .grid-3, .grid-2 {
    grid-template-columns: 1fr;
  }
  .results {
    grid-template-columns: repeat(2, 1fr);
  }
  .groupboard {
    grid-template-columns: 1fr;
  }
  .memory {
    grid-template-columns: repeat(3, 1fr);
  }
  .delikt-step {
    grid-template-columns: 1fr;
    gap: 4px;
  }
  .question {
    padding: 20px 16px;
    margin: 14px auto;
  }
}

/* --- Smartphone Standard (<= 600px) --- */
@media (max-width: 600px) {
  .hide-mobile {
    display: none !important;
  }
  .header-actions button, .header-actions a.btn {
    padding: 7px 10px;
    font-size: 0.85rem;
  }
  .streak-badge {
    padding: 3px 8px;
    font-size: 0.76rem;
  }
  .hero .row {
    flex-direction: column;
    align-items: stretch;
  }
  .hero .row > * {
    width: 100%;
    text-align: center;
    justify-content: center;
  }
  .hero-aside {
    padding: 20px 16px;
  }
  .hero-aside .big {
    font-size: 2.2rem;
  }
  .card, .panel {
    padding: 16px 14px;
    border-radius: var(--radius-md);
  }
  .panel > .row.between {
    flex-direction: column;
    align-items: stretch;
    gap: 14px;
  }
  .notice {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding: 12px 14px;
  }
  .notice button {
    margin-left: 0 !important;
    width: 100%;
    justify-content: center;
  }
  .gamebar {
    padding: 8px 0;
    gap: 8px;
  }
  .gamebar .eyebrow {
    font-size: 0.7rem;
  }
  .gamebar h2 {
    font-size: 1.1rem !important;
  }
  .gamebar .row {
    width: 100%;
    justify-content: space-between;
    gap: 6px;
  }
  .gamebar button {
    padding: 6px 10px;
    font-size: 0.8rem;
    flex: 1 1 auto;
    min-width: 0;
    justify-content: center;
  }
  .gamebar .pill {
    padding: 3px 8px;
    font-size: 0.76rem;
  }
  .qnav {
    gap: 4px;
    margin: 14px auto;
  }
  .qnav button {
    padding: 2px 4px;
    min-width: 32px;
    height: 32px;
    font-size: 0.78rem;
  }
  .choices button {
    padding: 12px 14px;
    font-size: 0.92rem;
  }
  .question .row.between:last-child {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }
  .question .row.between:last-child > .row {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }
  .question .row.between:last-child button {
    width: 100%;
    justify-content: center;
  }
  [data-grade] {
    width: 100%;
    justify-content: center;
    min-height: 44px;
  }
  .form .row {
    flex-direction: column;
    align-items: stretch;
  }
  .form .row button {
    width: 100%;
    justify-content: center;
    min-height: 44px;
  }
  .changelog-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }
  .changelog-item .pill {
    min-width: auto !important;
  }
  .modal-backdrop {
    padding: 8px;
    align-items: flex-end;
  }
  .modal-card {
    max-height: 94vh;
    border-radius: var(--radius-lg);
  }
  .modal-header {
    padding: 14px 16px;
  }
  .modal-body {
    padding: 14px 16px;
    font-size: 0.9rem;
    gap: 12px;
  }
  .modal-footer {
    flex-direction: column-reverse;
    gap: 8px;
    padding: 12px 16px 16px;
  }
  .modal-footer button, .modal-footer a.btn {
    width: 100%;
    justify-content: center;
    min-height: 44px;
  }
  .sw-update-banner {
    left: 12px;
    right: 12px;
    bottom: calc(12px + var(--sab));
    max-width: none;
    padding: 14px 16px;
  }
  .sw-update-content {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    text-align: center;
  }
  .sw-update-content button {
    width: 100%;
    min-height: 44px;
    justify-content: center;
  }
  #toast {
    left: 12px;
    right: 12px;
    bottom: calc(12px + var(--sab));
    max-width: calc(100vw - 24px);
    justify-content: center;
    text-align: center;
    font-size: 0.88rem;
    padding: 12px 16px;
  }
  #back-to-top {
    bottom: calc(14px + var(--sab));
    left: 14px;
    width: 40px;
    height: 40px;
  }
  .search-modal {
    padding: 8px;
  }
  .search-box {
    max-height: 92vh;
  }
  .search-header {
    padding: 12px 14px;
  }
  .footer-grid {
    grid-template-columns: 1fr;
    gap: 24px;
  }
  .footer-legal {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
  .faq-summary {
    padding: 14px 16px;
    gap: 10px;
  }
  .faq-question {
    font-size: 0.95rem;
  }
  .faq-category {
    font-size: 0.72rem;
    padding: 3px 8px;
  }
}

/* --- Smartphone Kompakt (<= 480px) --- */
@media (max-width: 480px) {
  .shell {
    padding-left: 12px;
    padding-right: 12px;
  }
  .grid {
    grid-template-columns: 1fr;
  }
  .results {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }
  .results div {
    padding: 12px 6px;
  }
  .results strong {
    font-size: 1.7rem;
  }
  .memory {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }
  .memory button {
    min-height: 72px;
    padding: 6px;
    font-size: 0.82rem;
  }
  h1 {
    font-size: clamp(1.5rem, 6.5vw, 2.1rem);
  }
  h2 {
    font-size: clamp(1.25rem, 5vw, 1.6rem);
  }
  .breadcrumbs {
    font-size: 0.78rem;
    gap: 6px;
  }
  .filters button {
    padding: 6px 12px;
    font-size: 0.8rem;
  }
  :root {
    --header-height: 68px;
  }
  .header-inner {
    min-height: 68px;
  }
  .brand-logo {
    width: 60px;
    height: 60px;
  }
  .header-icon-btn {
    width: 36px;
    height: 36px;
  }
  .streak-badge {
    padding: 4px 8px;
    font-size: 0.74rem;
  }
  .faq-summary {
    padding: 12px 14px;
    gap: 8px;
  }
  .faq-category {
    font-size: 0.7rem;
    padding: 2px 7px;
  }
}

/* --- Ultra-Kompakte Smartphones (<= 360px) --- */
@media (max-width: 360px) {
  :root {
    --header-height: 62px;
  }
  .header-inner {
    min-height: 62px;
  }
  .brand-logo {
    width: 52px;
    height: 52px;
  }
  .header-icon-btn {
    width: 34px;
    height: 34px;
  }
  .streak-badge {
    padding: 3px 6px;
    font-size: 0.7rem;
  }
  .header-actions {
    gap: 4px;
  }
  .results {
    grid-template-columns: 1fr;
  }
  .qnav button {
    min-width: 28px;
    height: 28px;
    font-size: 0.72rem;
  }
}

/* --- Print Stylesheet --- */
@media print {
  body { background: white; color: black; font-size: 12pt; }
  header, footer, .gamebar, .header-actions, #toast, #back-to-top, .no-print, button, nav {
    display: none !important;
  }
  .shell { max-width: 100%; padding: 0; }
  .card, .panel { border: 1px solid #ccc; box-shadow: none; break-inside: avoid; }
  a { text-decoration: none; color: black; }
  a[href^="http"]::after { content: " (" attr(href) ")"; font-size: 0.8em; }
}

/* --- Reduced Motion --- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
html.reduce-motion * {
  transition: none !important;
  animation: none !important;
}
