:root {
  --ink: #18211d;
  --ink-soft: #344039;
  --paper: #f2ead7;
  --paper-light: #fffaf0;
  --red: #c9432f;
  --red-dark: #8f2b1e;
  --green: #176c4d;
  --green-light: #d9eddf;
  --sun: #f0b936;
  --blue: #2e6590;
  --muted: #706b5e;
  --line: #1d2923;
  --shadow: 7px 7px 0 var(--ink);
  --radius: 2px;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html {
  min-width: 320px;
  scroll-behavior: smooth;
  background: var(--paper);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  font-family: "Courier New", Courier, monospace;
  background:
    radial-gradient(circle at 8% 7%, rgba(240, 185, 54, .32) 0 8%, transparent 8.2%),
    linear-gradient(90deg, transparent 0 51px, rgba(201, 67, 47, .11) 52px 53px, transparent 54px),
    repeating-linear-gradient(0deg, transparent 0 31px, rgba(24, 33, 29, .075) 31px 32px),
    var(--paper);
}

button,
input,
textarea { font: inherit; }

button,
a { touch-action: manipulation; }

a { color: inherit; }

:focus-visible {
  outline: 3px solid var(--blue);
  outline-offset: 3px;
}

.page-shell {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
  padding: 24px 0 72px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 34px;
  padding-bottom: 14px;
  border-bottom: 2px solid var(--ink);
}

.brand,
.topbar a {
  font-weight: 800;
  letter-spacing: .06em;
  text-decoration: none;
  text-transform: uppercase;
}

.top-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 9px;
}

.top-actions a {
  padding-bottom: 3px;
  border-bottom: 2px solid currentColor;
  font-size: .78rem;
}

h1,
h2,
h3,
h4 {
  margin-top: 0;
  font-family: Georgia, "Times New Roman", serif;
}

h1 {
  max-width: 950px;
  margin-bottom: 20px;
  font-size: clamp(3.1rem, 8vw, 7.1rem);
  line-height: .86;
  letter-spacing: -.058em;
}

h2 {
  font-size: clamp(1.75rem, 3.2vw, 2.7rem);
  line-height: 1;
}

h3 { font-size: 1.3rem; }

p { line-height: 1.6; }

code,
pre { font-family: "Courier New", Courier, monospace; }

code {
  padding: .08em .28em;
  background: rgba(24, 33, 29, .09);
}

.eyebrow,
.kicker,
.stamp,
.fact-label {
  font-weight: 800;
  letter-spacing: .07em;
  text-transform: uppercase;
}

.kicker {
  display: inline-block;
  margin-bottom: 18px;
  padding: 6px 9px;
  transform: rotate(-1deg);
  border: 2px solid var(--ink);
  background: var(--sun);
  font-size: .78rem;
}

.lead {
  max-width: 780px;
  margin: 0;
  color: var(--ink-soft);
  font-size: clamp(1.05rem, 2vw, 1.35rem);
}

.hero-note {
  max-width: 760px;
  margin-top: 24px;
  padding: 14px 17px;
  transform: rotate(.3deg);
  border: 2px dashed var(--green);
  background: var(--green-light);
  font-size: .91rem;
}

.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(280px, .65fr);
  gap: 36px;
  align-items: end;
}

.paper-card,
.field-card,
.exam-task,
.sheet-page {
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  background: var(--paper-light);
  box-shadow: var(--shadow);
}

.progress-card { padding: 22px; }

.progress-top {
  display: flex;
  gap: 18px;
  align-items: center;
}

.progress-ring {
  --progress: 0deg;
  display: grid;
  width: 105px;
  height: 105px;
  flex: 0 0 105px;
  place-items: center;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: conic-gradient(var(--green) var(--progress), #ddd2bd 0);
}

.progress-ring::after {
  display: grid;
  width: 78px;
  height: 78px;
  place-items: center;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: var(--paper-light);
  content: attr(data-progress);
  font: 800 1.45rem Georgia, serif;
}

.progress-copy strong {
  display: block;
  margin-bottom: 5px;
  font: 800 1.3rem Georgia, serif;
}

.microcopy,
.tiny {
  color: var(--muted);
  font-size: .78rem;
  line-height: 1.5;
}

.status-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 18px;
}

.status-chip,
.certainty,
.error-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 8px;
  border: 1.5px solid var(--ink);
  background: #fff;
  font-size: .74rem;
  font-weight: 800;
}

.status-chip.sits,
.certainty.confirmed { background: var(--green-light); }
.status-chip.wobbles,
.certainty.unknown { background: #ffe0d5; }
.status-chip.open,
.certainty.near { background: #ffedb8; }

.primary-action,
.secondary-action,
.text-action,
.mode-button,
.submit-button,
.reset-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 48px;
  padding: 12px 16px;
  border: 2px solid var(--ink);
  background: #fff;
  box-shadow: 4px 4px 0 var(--ink);
  color: var(--ink);
  cursor: pointer;
  font-weight: 800;
  text-decoration: none;
}

.primary-action,
.submit-button {
  background: var(--red);
  color: #fff;
}

.secondary-action { background: var(--sun); }

.primary-action:hover,
.secondary-action:hover,
.mode-button:hover,
.submit-button:hover,
.reset-button:hover {
  transform: translate(-2px, -2px);
  box-shadow: 6px 6px 0 var(--ink);
}

.text-action {
  min-height: 0;
  padding: 3px 0;
  border: 0;
  border-bottom: 2px solid;
  box-shadow: none;
  background: transparent;
}

[aria-disabled="true"] {
  opacity: .48;
  cursor: not-allowed;
}

.section-block { margin-top: 68px; }

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 22px;
  padding-bottom: 12px;
  border-bottom: 3px solid var(--ink);
}

.section-heading h2 { margin-bottom: 0; }

.section-heading p {
  max-width: 520px;
  margin: 0;
  color: var(--muted);
  font-size: .85rem;
}

.fact-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}

.fact-card {
  min-height: 190px;
  padding: 19px;
  border: 2px solid var(--ink);
  background: var(--paper-light);
}

.fact-card.alert { background: #ffe6dc; }

.fact-card .fact-label {
  display: block;
  margin-bottom: 24px;
  color: var(--red-dark);
  font-size: .72rem;
}

.fact-card strong {
  display: block;
  margin-bottom: 10px;
  font: 800 1.4rem Georgia, serif;
}

.fact-card p {
  margin: 0;
  font-size: .83rem;
}

.now-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(300px, .9fr);
  gap: 22px;
}

.mission-card {
  position: relative;
  overflow: hidden;
  padding: 26px;
}

.mission-card::before {
  position: absolute;
  top: 18px;
  right: -43px;
  width: 170px;
  padding: 5px;
  transform: rotate(38deg);
  background: var(--sun);
  content: "JETZT";
  text-align: center;
  font-weight: 800;
}

.mission-card .task-number {
  color: var(--red);
  font: 800 4.8rem/.8 Georgia, serif;
}

.mission-card h3 {
  margin: 18px 0 8px;
  font-size: 2rem;
}

.mission-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 22px;
}

.route-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.route-list li {
  display: grid;
  grid-template-columns: 36px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 2px solid var(--ink);
  background: rgba(255, 250, 240, .76);
}

.route-list .route-number {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 50%;
  background: var(--ink);
  color: #fff;
  font-weight: 800;
}

.route-state { font-size: .75rem; font-weight: 800; }
.route-state.sitzt { color: var(--green); }
.route-state.wackelt { color: var(--red); }

.gate-grid,
.day-grid,
.media-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.gate-card,
.day-card,
.media-card {
  padding: 22px;
  border: 2px solid var(--ink);
  background: var(--paper-light);
}

.gate-card.is-open { background: var(--green-light); }
.gate-card.is-closed { background: #fff0c7; }

.gate-card .gate-status {
  display: inline-block;
  margin-bottom: 14px;
  padding: 5px 8px;
  border: 1.5px solid var(--ink);
  background: #fff;
  font-size: .72rem;
  font-weight: 800;
  text-transform: uppercase;
}

.gate-confirm {
  display: none;
  margin-top: 14px;
  padding: 13px;
  border: 2px dashed var(--red-dark);
  background: #fff;
}

.gate-confirm.show { display: block; }

.gate-confirm label {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  font-size: .82rem;
  line-height: 1.45;
}

.gate-confirm input { margin-top: 3px; }

.day-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.day-card {
  position: relative;
  min-height: 245px;
}

.day-card.today { box-shadow: var(--shadow); }

.day-card .date {
  display: inline-block;
  margin-bottom: 16px;
  padding: 5px 7px;
  border: 1.5px solid var(--ink);
  background: var(--sun);
  font-size: .74rem;
  font-weight: 800;
}

.day-card ul {
  margin: 0;
  padding-left: 18px;
  font-size: .83rem;
  line-height: 1.55;
}

.frequency-table,
.score-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--paper-light);
}

.frequency-table th,
.frequency-table td,
.score-table th,
.score-table td {
  padding: 12px;
  border: 1.5px solid var(--ink);
  text-align: left;
  vertical-align: top;
}

.frequency-table th,
.score-table th { background: var(--sun); }

.frequency-bar {
  display: block;
  width: 100%;
  height: 12px;
  border: 1.5px solid var(--ink);
  background: #fff;
}

.frequency-bar i {
  display: block;
  height: 100%;
  background: var(--green);
}

.media-card {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 13px;
  align-items: start;
  text-decoration: none;
}

.media-card:hover { background: #ffedb8; }

.media-duration {
  padding: 5px 7px;
  border: 1.5px solid var(--ink);
  background: var(--red);
  color: #fff;
  font-size: .72rem;
  font-weight: 800;
}

.sheet-intro {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
  padding: 16px;
  border: 2px solid var(--red-dark);
  background: #ffe6dc;
}

.sheet-intro p { margin: 0; }

.sheet-pages { display: grid; gap: 24px; }

.sheet-page {
  padding: 28px;
  box-shadow: 5px 5px 0 var(--ink);
}

.sheet-page-header {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 20px;
  padding-bottom: 10px;
  border-bottom: 3px solid var(--ink);
}

.sheet-page-header h3 { margin: 0; font-size: 1.8rem; }

.print-warning {
  margin: 0 0 14px;
  padding: 7px 10px;
  border: 1.5px solid var(--red-dark);
  background: #ffe6dc;
  color: var(--red-dark);
  font-size: .72rem;
  font-weight: 800;
  text-transform: uppercase;
}

.sheet-columns {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.sheet-box {
  break-inside: avoid;
  padding: 14px;
  border: 1.5px solid var(--ink);
  background: #fffdf7;
}

.sheet-box h4 {
  margin-bottom: 10px;
  font-size: 1.05rem;
}

.sheet-box ul,
.sheet-box ol {
  margin: 0;
  padding-left: 19px;
  font-size: .79rem;
  line-height: 1.45;
}

.sheet-box p,
.sheet-box table { font-size: .78rem; }

.sheet-box table {
  width: 100%;
  border-collapse: collapse;
}

.sheet-box th,
.sheet-box td {
  padding: 4px 5px;
  border: 1px solid var(--ink);
  text-align: left;
}

.sheet-box pre {
  margin: 0;
  white-space: pre-wrap;
  font-size: .76rem;
  line-height: 1.45;
}

.footer-note {
  margin-top: 48px;
  padding-top: 16px;
  border-top: 2px solid var(--ink);
  color: var(--muted);
  font-size: .75rem;
}

/* Simulation */
.simulation-hero h1 { max-width: 1060px; }

.exam-warning {
  max-width: 820px;
  margin-top: 22px;
  padding: 14px 17px;
  border: 2px solid var(--ink);
  background: #ffe6dc;
}

.mode-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
  margin-top: 34px;
}

.mode-card {
  padding: 24px;
  border: 2px solid var(--ink);
  background: var(--paper-light);
  box-shadow: 5px 5px 0 var(--ink);
}

.mode-card.active { background: #ffedb8; }

.mode-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 14px 0;
}

.mode-meta span {
  padding: 5px 8px;
  border: 1.5px solid var(--ink);
  background: #fff;
  font-size: .74rem;
  font-weight: 800;
}

.exam-panel { margin-top: 42px; }

.exam-panel[hidden],
.post-submit[hidden] { display: none !important; }

.prestart-note {
  margin-bottom: 22px;
  padding: 24px;
  background: #ffedb8;
}

.prestart-note h2 { margin-bottom: 8px; }

.exam-toolbar {
  position: sticky;
  z-index: 10;
  top: 0;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 16px;
  align-items: center;
  margin-bottom: 22px;
  padding: 13px 16px;
  border: 2px solid var(--ink);
  background: rgba(255, 250, 240, .96);
  box-shadow: 4px 4px 0 var(--ink);
  backdrop-filter: blur(8px);
}

.timer {
  min-width: 138px;
  font: 800 2rem Georgia, serif;
  font-variant-numeric: tabular-nums;
}

.timer.danger { color: var(--red); }

.exam-progress {
  height: 13px;
  border: 1.5px solid var(--ink);
  background: #fff;
}

.exam-progress i {
  display: block;
  width: 0;
  height: 100%;
  background: var(--green);
}

.exam-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
}

.exam-actions button {
  min-height: 39px;
  padding: 8px 10px;
  box-shadow: 3px 3px 0 var(--ink);
  font-size: .78rem;
}

.task-stack { display: grid; gap: 20px; }

.exam-task {
  padding: 24px;
  box-shadow: 4px 4px 0 var(--ink);
}

.task-heading {
  display: grid;
  grid-template-columns: 58px 1fr auto;
  gap: 16px;
  align-items: start;
  margin-bottom: 17px;
}

.task-index {
  display: grid;
  width: 58px;
  height: 58px;
  place-items: center;
  background: var(--ink);
  color: #fff;
  font: 800 1.5rem Georgia, serif;
}

.task-heading h3 { margin: 0 0 4px; }

.task-points {
  padding: 6px 8px;
  border: 1.5px solid var(--ink);
  background: var(--sun);
  font-weight: 800;
  white-space: nowrap;
}

.source-note {
  color: var(--muted);
  font-size: .72rem;
}

.source-note a { font-weight: 800; }

.code-block {
  overflow-x: auto;
  margin: 16px 0;
  padding: 16px;
  border: 2px solid #07100c;
  background: #17231e;
  color: #edf5df;
  font-size: .85rem;
  line-height: 1.55;
}

.question-list {
  padding-left: 22px;
  line-height: 1.55;
}

.exam-answer {
  width: 100%;
  min-height: 150px;
  padding: 14px;
  border: 2px solid var(--ink);
  background: #fffdf7;
  resize: vertical;
  line-height: 1.45;
}

.exam-answer:disabled { opacity: .77; }

.solution-panel {
  margin-top: 18px;
  padding: 17px;
  border: 2px dashed var(--green);
  background: var(--green-light);
}

.solution-panel[hidden] { display: none; }

.solution-panel h4 { margin-bottom: 10px; }

.solution-panel ul {
  margin: 0;
  padding-left: 20px;
  line-height: 1.5;
}

.self-score {
  display: grid;
  grid-template-columns: minmax(180px, .45fr) 1fr;
  gap: 16px;
  align-items: start;
  margin-top: 17px;
  padding-top: 14px;
  border-top: 1.5px solid var(--ink);
}

.score-input {
  width: 90px;
  padding: 9px;
  border: 2px solid var(--ink);
  background: #fff;
}

.error-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.error-tag { cursor: pointer; }
.error-tag:has(input:checked) { background: #ffe0d5; }

.post-submit {
  margin-top: 26px;
  padding: 25px;
  border: 3px solid var(--ink);
  background: var(--paper-light);
  box-shadow: var(--shadow);
}

.score-display {
  margin: 8px 0;
  color: var(--green);
  font: 800 clamp(2.4rem, 5vw, 4.8rem)/1 Georgia, serif;
}

.repair-list {
  display: grid;
  gap: 10px;
  margin: 18px 0;
}

.repair-card {
  padding: 15px;
  border: 2px solid var(--ink);
  background: #fff;
}

.repair-card h4 { margin-bottom: 6px; }

.repair-card p { margin: 6px 0 10px; }

.repair-answer {
  width: 100%;
  min-height: 110px;
  margin-bottom: 10px;
  padding: 11px;
  border: 2px solid var(--ink);
  background: #fffdf7;
  resize: vertical;
}

.repair-notice {
  padding: 13px;
  border: 2px dashed var(--red-dark);
  background: #ffe6dc;
}

.repair-item {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 12px;
  border: 1.5px solid var(--ink);
  background: #fff;
}

.repair-item input { margin-top: 3px; }

.autosave-note { color: var(--green); font-size: .75rem; }

@media (max-width: 980px) {
  .fact-grid,
  .day-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hero-grid { grid-template-columns: 1fr; }
  .progress-card { max-width: 540px; }
}

@media (max-width: 760px) {
  .page-shell { width: min(100% - 24px, 1180px); padding-top: 14px; }
  .topbar,
  .section-heading,
  .sheet-intro { align-items: flex-start; flex-direction: column; }
  .top-actions { justify-content: flex-start; }
  h1 { font-size: clamp(2.8rem, 15vw, 5rem); }
  .now-grid,
  .gate-grid,
  .media-grid,
  .mode-grid,
  .sheet-columns { grid-template-columns: 1fr; }
  .exam-toolbar { grid-template-columns: 1fr; }
  .exam-toolbar { position: static; }
  .task-heading { grid-template-columns: 48px 1fr; }
  .task-index { width: 48px; height: 48px; }
  .task-points { grid-column: 2; justify-self: start; }
  .self-score { grid-template-columns: 1fr; }
  .frequency-table,
  .frequency-table tbody,
  .frequency-table tr,
  .frequency-table td { display: block; width: 100%; }
  .frequency-table thead { display: none; }
  .frequency-table tr {
    margin-bottom: 12px;
    border: 2px solid var(--ink);
    background: var(--paper-light);
  }
  .frequency-table td {
    display: grid;
    grid-template-columns: minmax(118px, .75fr) 1fr;
    gap: 10px;
    border: 0;
    border-bottom: 1px solid rgba(24, 33, 29, .35);
  }
  .frequency-table td:last-child { border-bottom: 0; }
  .frequency-table td::before { font-weight: 800; }
  .frequency-table td:nth-child(1)::before { content: "Familie"; }
  .frequency-table td:nth-child(2)::before { content: "Aufgaben"; }
  .frequency-table td:nth-child(3)::before { content: "Anzahl"; }
  .frequency-table td:nth-child(4)::before { content: "Signal"; }
}

@media (max-width: 520px) {
  .fact-grid,
  .day-grid { grid-template-columns: 1fr; }
  .progress-top { align-items: flex-start; flex-direction: column; }
  .route-list li { grid-template-columns: 36px 1fr; }
  .route-state { grid-column: 2; }
  .mission-card { padding: 20px; }
  .sheet-page { padding: 18px; }
  .exam-task { padding: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; }
}

@media print {
  @page { size: A4 portrait; margin: 9mm; }

  body {
    background: #fff;
    color: #000;
  }

  body.roadmap-page * { visibility: hidden; }

  body.roadmap-page #lernzettel,
  body.roadmap-page #lernzettel * { visibility: visible; }

  body.roadmap-page #lernzettel {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    margin: 0;
  }

  .screen-only,
  .sheet-intro,
  .section-heading { display: none !important; }

  .sheet-pages { display: block; }

  .sheet-page {
    min-height: 0;
    margin: 0;
    padding: 0;
    border: 0;
    box-shadow: none;
    break-after: page;
    page-break-after: always;
  }

  .sheet-page:last-child {
    break-after: auto;
    page-break-after: auto;
  }

  .sheet-page-header { margin-bottom: 4mm; }
  .sheet-page-header h3 { font-size: 16pt; }
  .sheet-columns { gap: 3mm; }
  .sheet-box { padding: 2.5mm; }
  .sheet-box h4 { margin-bottom: 1.5mm; font-size: 9.5pt; }
  .sheet-box ul,
  .sheet-box ol,
  .sheet-box p,
  .sheet-box table,
  .sheet-box pre { font-size: 7.4pt; line-height: 1.28; }
}
