.spreadsheet-new-page {
  --sheet-accent: #2563eb;
  --sheet-accent-dark: #1d4ed8;
  --sheet-accent-soft: #dbeafe;
  --sheet-grid: #d6dbe3;
  --sheet-header: #f3f5f7;
  --sheet-task: #fff3d6;
  --sheet-success: #15803d;
  --sheet-error: #c2410c;
  max-width: 1500px;
}

.spreadsheet-new-page .spreadsheet-header {
  background: linear-gradient(135deg, #eff6ff 0%, #ffffff 58%, #eefbf5 100%);
  border: 1px solid #dbe5f2;
}

.spreadsheet-new-page .spreadsheet-workspace {
  display: block;
}

.spreadsheet-new-page .spreadsheet-card {
  overflow: hidden;
  border: 1px solid #d7dee8;
  box-shadow: 0 18px 46px rgba(30, 64, 175, 0.09);
}

.spreadsheet-new-page .card-heading {
  align-items: flex-start;
  gap: 1rem;
}

.spreadsheet-new-page .card-heading p {
  max-width: 78ch;
}

.function-hint ul {
  max-width: 78ch;
  margin: 0.35rem 0 0 1.15rem;
  padding: 0;
  line-height: 1.55;
}

.function-hint li + li {
  margin-top: 0.2rem;
}

.work-order {
  margin: 0.8rem 0 0;
  padding: 0.8rem 0.95rem;
  border: 1px solid #f3c76a;
  border-left: 5px solid #d97706;
  border-radius: 9px;
  background: linear-gradient(135deg, #fff7d6, #fffaf0);
  color: #713f12;
  line-height: 1.55;
}

.work-order strong {
  color: #92400e;
}

.work-order ul {
  margin: 0.45rem 0 0 1.15rem;
  padding: 0;
}

.work-order li + li {
  margin-top: 0.2rem;
}

.spreadsheet-task-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(270px, 350px);
  align-items: start;
  gap: 1.25rem;
}

.spreadsheet-task-layout .spreadsheet-card {
  min-width: 0;
}

.spreadsheet-app {
  border-top: 1px solid #dbe2ea;
  background: #fff;
}

.spreadsheet-toolbar {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 42px;
  padding: 0.45rem 0.65rem;
  border-bottom: 1px solid #cfd6df;
  background: #f7f8fa;
}

.spreadsheet-toolbar button {
  min-width: 2.1rem;
  min-height: 2rem;
  padding: 0.25rem 0.55rem;
  border: 1px solid #cbd3dc;
  border-radius: 4px;
  background: #fff;
  color: #334155;
  font: inherit;
  cursor: pointer;
}

.spreadsheet-toolbar button:hover:not(:disabled) {
  border-color: #94a3b8;
  background: #eef2f6;
}

.spreadsheet-toolbar button:disabled {
  opacity: 0.45;
  cursor: default;
}

.spreadsheet-toolbar .zoom-value {
  min-width: 3.4rem;
  text-align: center;
  color: #334155;
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
}

.toolbar-spacer {
  flex: 1;
}

.spreadsheet-toolbar small {
  color: #64748b;
}

.formula-bar {
  display: grid;
  grid-template-columns: minmax(5.7rem, auto) 2.35rem minmax(12rem, 1fr);
  align-items: stretch;
  min-height: 44px;
  border-bottom: 1px solid #bfc7d1;
  background: #fff;
}

.cell-name-box,
.formula-symbol {
  display: grid;
  place-items: center;
  border-right: 1px solid #d3d9e1;
  color: #334155;
  background: #f8fafc;
}

.cell-name-box {
  padding-inline: 0.65rem;
  font-size: 0.82rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.formula-symbol {
  font-family: Georgia, serif;
  font-style: italic;
  font-weight: 700;
}

.formula-input {
  min-width: 0;
  width: 100%;
  border: 0;
  padding: 0.55rem 0.75rem;
  background: #fff;
  color: #111827;
  font: 500 0.95rem/1.35 ui-monospace, SFMono-Regular, Consolas, monospace;
  outline: none;
}

.formula-input:focus {
  box-shadow: inset 0 0 0 2px var(--sheet-accent);
}

.formula-feedback {
  position: relative;
  z-index: 9;
  padding: 0.6rem 0.8rem;
  border-bottom: 1px solid #fdba74;
  background: #fff7ed;
  color: #9a3412;
  font-size: 0.88rem;
  font-weight: 650;
  line-height: 1.4;
}

.formula-feedback[hidden] {
  display: none;
}

.spreadsheet-viewport {
  overflow: auto;
  max-height: min(66vh, 760px);
  background: #eef1f4;
  overscroll-behavior: contain;
}

.spreadsheet-grid {
  width: max-content;
  min-width: 100%;
  transform-origin: top left;
}

.excel-grid {
  table-layout: fixed;
  width: max-content;
  border-collapse: separate;
  border-spacing: 0;
  color: #172033;
  background: #fff;
  font-family: Aptos, Calibri, "Segoe UI", sans-serif;
  font-size: 14px;
  user-select: none;
}

.excel-grid th,
.excel-grid td {
  box-sizing: border-box;
  height: 34px;
  border-right: 1px solid var(--sheet-grid);
  border-bottom: 1px solid var(--sheet-grid);
}

.excel-grid thead th {
  position: sticky;
  z-index: 5;
  top: 0;
  height: 29px;
  background: var(--sheet-header);
  color: #475569;
  text-align: center;
  font-size: 0.78rem;
  font-weight: 600;
}

.excel-grid .corner-cell {
  left: 0;
  z-index: 7;
}

.excel-grid tbody th {
  position: sticky;
  z-index: 4;
  left: 0;
  width: 42px;
  min-width: 42px;
  background: var(--sheet-header);
  color: #64748b;
  text-align: center;
  font-size: 0.76rem;
  font-weight: 500;
}

.sheet-cell {
  position: relative;
  padding: 0;
  overflow: visible;
  background: #fff;
  cursor: cell;
}

.cell-display {
  display: block;
  width: 100%;
  height: 100%;
  padding: 7px 8px 5px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  pointer-events: none;
}

.sheet-cell.center-cell .cell-display,
.sheet-cell.currency-cell .cell-display,
.sheet-cell.percent-cell .cell-display {
  text-align: right;
}

.sheet-cell.sheet-title-cell .cell-display,
.sheet-cell.instruction-text-cell .cell-display,
.sheet-cell.idea-cell .cell-display {
  font-weight: 700;
  color: #1e3a8a;
}

.sheet-cell.workbook-section-cell,
.sheet-cell.matrix-header-cell {
  background: #e8eef7;
  font-weight: 700;
}

.sheet-cell.input-cell {
  background: #fff7cc;
}

.sheet-cell.instruction-cell,
.sheet-cell.user-legend-cell {
  background: #e7f4ff;
  color: #075985;
  font-weight: 700;
}

.sheet-cell.label-cell {
  font-weight: 650;
}

.sheet-cell.wrapped-note-cell .cell-display {
  overflow: auto;
  white-space: normal;
  text-overflow: clip;
  line-height: 1.35;
}

.sheet-cell.task-formula-cell,
.sheet-cell.fill-target-cell {
  background: var(--sheet-task);
}

.sheet-cell.selected-cell {
  background-image: linear-gradient(rgba(37, 99, 235, 0.1), rgba(37, 99, 235, 0.1));
}

.sheet-cell.selection-top {
  border-top: 2px solid var(--sheet-accent);
}

.sheet-cell.selection-bottom {
  border-bottom: 2px solid var(--sheet-accent);
}

.sheet-cell.selection-left {
  border-left: 2px solid var(--sheet-accent);
}

.sheet-cell.selection-right {
  border-right: 2px solid var(--sheet-accent);
}

.sheet-cell.active-cell {
  box-shadow: inset 0 0 0 2px var(--sheet-accent-dark);
}

.sheet-cell.fill-preview-cell {
  background-image: repeating-linear-gradient(
    135deg,
    rgba(37, 99, 235, 0.14),
    rgba(37, 99, 235, 0.14) 6px,
    rgba(255, 255, 255, 0.3) 6px,
    rgba(255, 255, 255, 0.3) 12px
  );
}

.spreadsheet-fill-handle {
  position: absolute;
  z-index: 12;
  right: -6px;
  bottom: -6px;
  width: 12px;
  height: 12px;
  min-width: 0;
  padding: 0;
  border: 2px solid #fff;
  border-radius: 2px;
  background: var(--sheet-accent);
  box-shadow: 0 0 0 1px var(--sheet-accent-dark);
  cursor: crosshair;
  touch-action: none;
}

.cell-check-button {
  position: absolute;
  z-index: 3;
  top: 4px;
  right: 4px;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 1px solid #f0a64d;
  border-radius: 4px;
  background: #fff8ed;
  color: #9a4c00;
  font-size: 0.8rem;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
}

.task-formula-cell .cell-display {
  padding-right: 34px;
}

.cell-check-button:hover,
.cell-check-button:focus-visible {
  border-color: #c26400;
  background: #ffedd5;
  outline: none;
}

.sheet-cell.is-correct {
  box-shadow: inset 0 0 0 2px var(--sheet-success);
}

.sheet-cell.has-error {
  z-index: 20;
  box-shadow: inset 0 0 0 2px var(--sheet-error);
}

.cell-feedback-dot {
  position: absolute;
  z-index: 4;
  left: 4px;
  bottom: 3px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  pointer-events: none;
}

.is-correct .cell-feedback-dot {
  background: var(--sheet-success);
}

.has-error .cell-feedback-dot {
  background: var(--sheet-error);
}

.cell-feedback-message {
  position: absolute;
  z-index: 30;
  top: calc(100% + 6px);
  left: 6px;
  width: max-content;
  min-width: 190px;
  max-width: 310px;
  padding: 0.55rem 0.65rem;
  border: 1px solid #fb923c;
  border-radius: 7px;
  background: #fff7ed;
  box-shadow: 0 8px 24px rgba(124, 45, 18, 0.2);
  color: #9a3412;
  white-space: normal;
  font-size: 0.8rem;
  font-weight: 650;
  line-height: 1.35;
  pointer-events: none;
}

.cell-feedback-message::before {
  content: "";
  position: absolute;
  top: -6px;
  left: 14px;
  width: 10px;
  height: 10px;
  border-top: 1px solid #fb923c;
  border-left: 1px solid #fb923c;
  background: #fff7ed;
  transform: rotate(45deg);
}

.cell-feedback-message[hidden] {
  display: none;
}

.sheet-cell.has-error:not(.active-cell):not(:hover) .cell-feedback-message {
  display: none;
}

.sheet-statusbar {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  min-height: 34px;
  padding: 0.45rem 0.75rem;
  border-top: 1px solid #d2d8e0;
  background: #f7f8fa;
  color: #475569;
  font-size: 0.8rem;
}

.sheet-statusbar strong {
  color: #1e293b;
}

.spreadsheet-new-page .check-panel {
  margin-top: 1.25rem;
}

.solution-download {
  margin-top: 1.5rem;
  padding: 1.25rem 1.4rem;
  border: 1px solid #d7dee8;
  border-left: 5px solid var(--sheet-accent);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.solution-download h2 {
  margin: 0;
  color: var(--sheet-accent-dark);
  font-size: 1.15rem;
}

.solution-reveal {
  margin-top: 0.8rem;
}

.solution-reveal summary {
  width: fit-content;
  cursor: pointer;
  color: var(--sheet-accent-dark);
  font-weight: 700;
}

.solution-reveal[open] summary {
  margin-bottom: 0.9rem;
}

.solution-code-form {
  display: grid;
  gap: 0.7rem;
  max-width: 30rem;
}

.solution-code-form label {
  font-weight: 700;
}

.solution-code-controls {
  display: flex;
  gap: 0.65rem;
}

.solution-code-controls input {
  min-width: 0;
  flex: 1 1 12rem;
  padding: 0.7rem 0.8rem;
  border: 1px solid #d7dee8;
  border-radius: 5px;
  font: inherit;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.solution-code-controls button,
.download-button {
  border: 0;
  border-radius: 5px;
  background: var(--sheet-accent);
  color: #fff;
  font: inherit;
  font-weight: 700;
}

.solution-code-controls button {
  padding: 0.7rem 1rem;
  cursor: pointer;
}

.solution-code-message {
  min-height: 1.3rem;
  margin: 0;
  color: var(--muted);
}

.solution-code-message.error {
  color: #9f2525;
}

.download-button {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.1rem;
  text-decoration: none;
}

.solution-code-controls button:hover,
.solution-code-controls button:focus-visible,
.download-button:hover,
.download-button:focus-visible {
  background: var(--sheet-accent-dark);
  outline: 2px solid rgba(37, 99, 235, 0.25);
  outline-offset: 2px;
}

.download-button[hidden] {
  display: none;
}

.formula-reference-card {
  position: sticky;
  top: 1rem;
  margin-top: 0;
  padding: 1rem;
  border: 1px solid #dbe2ea;
  border-radius: 14px;
  background: #fff;
}

.formula-reference-card img {
  display: block;
  max-width: 100%;
  height: auto;
  margin-inline: auto;
}

.adjacent-task-nav {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 1.25rem;
}

.adjacent-task-nav a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.if-example {
  margin: 0.6rem 0 0;
}

.if-anatomy {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 0.2rem;
  font: 650 1rem/1.3 ui-monospace, SFMono-Regular, Consolas, monospace;
}

.if-anatomy code {
  font: inherit;
  background: none;
  padding: 0;
}

.if-anatomy > code.if-seg {
  padding-top: 0.3rem;
}

.if-anatomy span.if-seg {
  display: grid;
  justify-items: center;
  gap: 0.15rem;
  padding: 0.3rem 0.5rem;
  border: 2px solid;
  border-radius: 8px;
}

.if-anatomy small {
  font: 750 0.72rem/1 system-ui, sans-serif;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.if-seg-condition {
  border-color: #60a5fa;
  background: #eff6ff;
  color: #1e40af;
}

.if-seg-true {
  border-color: #4ade80;
  background: #f0fdf4;
  color: #166534;
}

.if-seg-false {
  border-color: #fb923c;
  background: #fff7ed;
  color: #9a3412;
}

.function-hint .if-cases {
  display: grid;
  gap: 0.35rem;
  margin: 0.55rem 0 0;
  padding: 0;
  list-style: none;
}

.if-cases span,
.if-cases strong {
  display: inline-block;
  padding: 0.1rem 0.45rem;
  border-radius: 6px;
}

.if-case-input {
  background: #f1f5f9;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
}

.ggt-example {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem 1rem;
  margin: 0.6rem 0 0;
}

.ggt-steps {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 0.4rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.ggt-steps li {
  display: flex;
  align-items: stretch;
}

.ggt-steps li + li::before {
  content: "→";
  align-self: center;
  margin: 0 0.4rem 0 0;
  color: #64748b;
  font-weight: 700;
}

.ggt-steps span {
  display: grid;
  align-content: start;
  justify-items: center;
  min-width: 3.2rem;
  padding: 0.3rem 0.4rem;
  border: 1px solid #cbd5e1;
  background: #fff;
  font: 700 1rem/1.25 ui-monospace, SFMono-Regular, Consolas, monospace;
}

.ggt-steps span:first-of-type {
  border-radius: 6px 0 0 6px;
}

.ggt-steps span + span {
  margin-left: -1px;
  border-radius: 0 6px 6px 0;
}

.ggt-steps span.is-changed {
  position: relative;
  border-color: #60a5fa;
  background: #eff6ff;
  color: #1e40af;
}

.ggt-steps small {
  color: #475569;
  font: 600 0.72rem/1.2 system-ui, sans-serif;
  white-space: nowrap;
}

.ggt-example figcaption strong {
  display: inline-block;
  padding: 0.3rem 0.6rem;
  border: 2px solid #4ade80;
  border-radius: 8px;
  background: #f0fdf4;
  color: #166534;
}

.discount-reference-card {
  position: sticky;
  top: 1rem;
  padding: 1.25rem;
  border: 2px solid #334155;
  border-radius: 12px;
  background: #f5f0e8;
  box-shadow: 5px 6px 0 rgba(51, 65, 85, 0.14);
  color: #1f2937;
  text-align: center;
}

.discount-reference-card h2 {
  margin: 0.15rem 0 1rem;
  font-size: 1.65rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.discount-reference-card dl {
  display: grid;
  gap: 0.65rem;
  margin: 0;
}

.discount-reference-card dl div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.7rem 0.8rem;
  border: 1px solid #64748b;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.58);
}

.discount-reference-card dt,
.discount-reference-card dd {
  margin: 0;
  font-weight: 800;
}

.discount-reference-card dd {
  font-size: 1.25rem;
}

.discount-cash {
  margin: 1rem 0 0;
  padding-top: 1rem;
  border-top: 1px dashed #64748b;
}

@media (max-width: 1080px) {
  .spreadsheet-task-layout {
    grid-template-columns: 1fr;
  }

  .formula-reference-card {
    position: static;
  }

  .discount-reference-card {
    position: static;
  }
}

body.is-selecting-sheet,
body.is-filling-sheet {
  cursor: crosshair;
  user-select: none;
}

@media (max-width: 720px) {
  .solution-code-controls {
    align-items: stretch;
    flex-direction: column;
  }

  .download-button {
    justify-content: center;
  }

  .spreadsheet-toolbar small {
    display: none;
  }

  .formula-bar {
    grid-template-columns: 4.9rem 2rem minmax(8rem, 1fr);
  }

  .spreadsheet-viewport {
    max-height: 62vh;
  }

  .sheet-statusbar {
    display: block;
  }

  .adjacent-task-nav {
    display: grid;
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  .spreadsheet-new-page *,
  .spreadsheet-new-page *::before,
  .spreadsheet-new-page *::after {
    scroll-behavior: auto !important;
    transition: none !important;
  }
}

/* Aufgabe 5 – Datenflussdiagramme */

.tool-embed {
  overflow: hidden;
  margin-top: 1rem;
  border: 1px solid #d7dee8;
  border-radius: 6px;
  background: #f9fafb;
}

.tool-placeholder {
  margin: 0;
  padding: 1rem;
  color: var(--muted);
}

.dfd-card {
  margin-top: 1rem;
  padding: 1.3rem;
  background: #fff;
  border: 1px solid #d7dee8;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.dfd-card h2,
.dfd-card h3 {
  margin: 0 0 0.5rem;
  color: var(--sheet-accent-dark);
}

.dfd-card + .dfd-card {
  margin-top: 1.25rem;
}

.dfd-figure {
  margin: 1rem auto;
  text-align: center;
}

.dfd-figure img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 0 auto;
  border: 1px solid #d7dee8;
  border-radius: 8px;
  background: #fff;
}

.dfd-figure figcaption {
  margin-top: 0.5rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.dfd-figure-pair {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 1.25rem;
  align-items: start;
}

.help-stack {
  display: grid;
  gap: 8px;
  margin: 20px 0;
}

.help-stack details {
  padding: 11px 14px;
  border: 1px solid #ead6a7;
  border-radius: 11px;
  background: #fffbef;
}

.help-stack summary {
  cursor: pointer;
  min-height: 44px;
  display: flex;
  align-items: center;
  color: #80530d;
  font-weight: 900;
}

.help-stack p {
  margin: 9px 0 0;
  color: #6f5527;
  line-height: 1.45;
}

.help-stack summary:focus-visible {
  outline: 3px solid rgba(23, 99, 213, 0.35);
  outline-offset: 3px;
  border-radius: 3px;
}

.description-input {
  display: block;
  width: 100%;
  min-height: 150px;
  margin: 0.5rem 0 0.35rem;
  padding: 0.8rem;
  border: 1px solid #aaa;
  border-radius: 6px;
  font: inherit;
  line-height: 1.45;
  resize: vertical;
}

.description-input:focus {
  border-color: var(--sheet-accent);
  outline: 2px solid rgba(37, 99, 235, 0.2);
}

.description-input:disabled {
  background: #f1f1f1;
}

.dfd-card label.description-label {
  display: block;
  margin-top: 0.6rem;
  font-weight: 700;
}

.dfd-card > .primary-action {
  display: inline-block;
  margin: 0.2rem 0 0.4rem;
}

.result {
  margin-top: 1rem;
  padding: 1rem;
  background: #eef3f8;
  border: 1px solid #d7dee8;
  border-radius: 6px;
}

.result[hidden] {
  display: none;
}

.result.high {
  background: #edf7ee;
  border-color: #7aae80;
}

.result.medium {
  background: #fff4df;
  border-color: #d99a3a;
}

.result.low,
.result.error {
  background: #fff0f0;
  border-color: #d38181;
}

.result h3 {
  margin: 0 0 0.6rem;
  color: #172033;
  font-size: 1.05rem;
}

.result h4 {
  margin: 1rem 0 0.35rem;
  color: #172033;
  font-size: 0.95rem;
}

.result p {
  margin: 0.3rem 0;
  color: #172033;
}

.result ul {
  margin: 0.3rem 0;
  padding-left: 1.4rem;
  color: #172033;
}

.result .feedback {
  margin-top: 1rem;
  padding-top: 0.8rem;
  border-top: 1px solid rgba(0, 0, 0, 0.12);
}

.dfd-selfcheck {
  margin-top: 1rem;
  padding: 0.9rem 1.1rem;
  border: 1px solid #d7dee8;
  border-left: 5px solid var(--sheet-accent);
  border-radius: 8px;
  background: #f7f9fc;
}

.dfd-selfcheck summary {
  cursor: pointer;
  min-height: 44px;
  display: flex;
  align-items: center;
  color: var(--sheet-accent-dark);
  font-weight: 700;
}

.dfd-selfcheck summary:focus-visible {
  outline: 3px solid rgba(23, 99, 213, 0.35);
  outline-offset: 3px;
  border-radius: 3px;
}

.dfd-selfcheck[open] summary {
  margin-bottom: 0.75rem;
}

.dfd-terms {
  display: grid;
  grid-template-columns: minmax(140px, 200px) minmax(0, 1fr);
  gap: 0.5rem 1rem;
  margin: 1rem 0;
}

.dfd-terms dt {
  font-weight: 800;
  color: var(--sheet-accent-dark);
}

.dfd-terms dd {
  margin: 0 0 0.6rem;
  line-height: 1.5;
}

.dfd-note {
  margin-top: 0.75rem;
  padding: 0.75rem 0.9rem;
  border: 1px solid #cbdcf5;
  border-radius: 8px;
  background: #eff6ff;
  line-height: 1.5;
}

/* Hinweis direkt unter der Tabelle: gleicher Randabstand wie der Kartenkopf. */
.spreadsheet-card > .dfd-note {
  margin: 0.9rem 1.25rem 1.1rem;
}

.dfd-scenario {
  font-style: normal;
}

.step-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 1rem 0 0;
  padding: 6px;
  border: 1px solid #cbd5e1;
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.8);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.step-tabs [role="tab"] {
  flex: 1 1 150px;
  min-height: 44px;
  min-width: 0;
  padding: 9px 12px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: #475569;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.step-tabs [role="tab"]:hover {
  background: rgba(37, 99, 235, 0.08);
}

.step-tabs [role="tab"][aria-selected="true"] {
  color: #ffffff;
  background: linear-gradient(135deg, var(--sheet-accent), var(--sheet-accent-dark));
}

.step-tabs [role="tab"]:focus-visible {
  outline: 3px solid rgba(23, 99, 213, 0.35);
  outline-offset: 3px;
}

.step-panels {
  margin-top: 0;
}

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

.dfd-bausteine-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(150px, 200px);
  gap: 1.25rem;
  align-items: start;
}

.dfd-diagram-input-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 1.25rem;
  align-items: start;
}

.dfd-diagram-input-layout .primary-action {
  display: inline-block;
  margin: 0.2rem 0 0.4rem;
}

.dfd-svg {
  display: block;
  width: 100%;
  max-width: 520px;
  height: auto;
  margin: 1rem auto;
}

.dfd-svg-node {
  fill: #ffffff;
  stroke: var(--sheet-accent-dark);
  stroke-width: 2;
}

.dfd-svg-edge {
  fill: none;
  stroke: var(--sheet-accent-dark);
  stroke-width: 2;
}

.dfd-svg-label {
  fill: #172033;
  font-family: inherit;
  font-size: 14px;
}

.dfd-token {
  pointer-events: none;
}

.dfd-token[hidden] {
  display: none;
}

.dfd-token rect {
  fill: var(--sheet-accent);
  stroke: var(--sheet-accent-dark);
  stroke-width: 1.5;
}

.dfd-token text {
  fill: #ffffff;
  font-size: 13px;
  font-weight: 800;
}

.dfd-svg-hint {
  fill: var(--sheet-accent-dark);
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
}

.dfd-svg-edge.is-chosen {
  stroke-width: 4;
}

.dfd-value-picker {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
  margin: 0.5rem 0;
  font-weight: 700;
}

.dfd-value-picker select {
  min-width: 5rem;
  min-height: 44px;
  padding: 0.4rem 0.6rem;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #ffffff;
  color: #172033;
  font: inherit;
}

.dfd-speed {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
  margin: 0.5rem 0;
  font-weight: 700;
}

.dfd-speed input[type="range"] {
  width: min(14rem, 100%);
  min-height: 44px;
  accent-color: var(--sheet-accent);
}

.dfd-speed output {
  min-width: 8rem;
  color: #52647a;
  font-weight: 600;
}

.dfd-term {
  display: block;
  margin: 0.6rem 0 1rem;
  padding: 0.85rem 1rem;
  overflow-x: auto;
  border-radius: 10px;
  background: #172033;
  color: #f8fafc;
  font: 650 0.95rem/1.45 ui-monospace, SFMono-Regular, Consolas, monospace;
  white-space: nowrap;
}

.dfd-card .dfd-merke + .dfd-note {
  margin-top: 0.8rem;
}

.simulation-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin: 0.5rem 0;
}

.simulation-status {
  margin: 0.4rem 0 0;
  padding: 0.6rem 0.8rem;
  border: 1px solid #cbdcf5;
  border-radius: 8px;
  background: #eff6ff;
  color: #172033;
  font-weight: 650;
}

.dfd-merke {
  padding: 1rem 1.15rem;
  border: 1px solid #cbdcf5;
  border-left: 5px solid var(--sheet-accent);
  border-radius: 8px;
  background: #eff6ff;
}

.dfd-merke p {
  margin: 0 0 0.55rem;
  line-height: 1.9;
}

.dfd-merke p:last-child {
  margin-bottom: 0;
}

.final-quiz {
  display: grid;
  gap: 1rem;
  margin-top: 0.75rem;
}

.final-quiz fieldset {
  min-width: 0;
  padding: 1rem;
  border: 1px solid #d7dee8;
  border-radius: 10px;
}

.final-quiz legend {
  padding: 0 0.5rem;
  color: var(--sheet-accent-dark);
  font-weight: 800;
}

.final-quiz legend span {
  display: inline-grid;
  place-items: center;
  width: 27px;
  height: 27px;
  margin-right: 6px;
  border-radius: 50%;
  background: #eff6ff;
  color: var(--sheet-accent-dark);
}

.choice-list {
  display: grid;
  gap: 0.6rem;
  margin: 0.9rem 0 0;
}

.choice-option {
  display: flex;
  align-items: flex-start;
  gap: 0.7rem;
  min-height: 44px;
  padding: 0.7rem 0.9rem;
  border: 1px solid #d7dee8;
  border-radius: 10px;
  background: #fbfcfe;
  cursor: pointer;
}

.choice-option:hover {
  border-color: var(--sheet-accent);
  background: #eff6ff;
}

.choice-option:has(input:checked) {
  border-color: var(--sheet-accent);
  background: #eff6ff;
}

.choice-option input {
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  margin-top: 1px;
  accent-color: var(--sheet-accent);
}

.choice-option input:focus-visible {
  outline: 3px solid rgba(23, 99, 213, 0.35);
  outline-offset: 3px;
}

.choice-option span {
  line-height: 1.4;
}

.dfd-quiz-summary {
  margin-top: 1.5rem;
}

.dfd-quiz-summary[hidden] {
  display: none;
}

.summary-section {
  padding: 1rem 1.1rem;
  margin-top: 0.9rem;
  border: 1px solid #d7dee8;
  border-radius: 10px;
  background: #fbfcfe;
}

.summary-section h4 {
  margin: 0 0 0.3rem;
  color: var(--sheet-accent-dark);
}

.summary-section .prompt {
  margin: 0 0 0.7rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.summary-grid {
  display: grid;
  grid-template-columns: minmax(150px, .4fr) minmax(0,1fr);
  gap: .4rem 1rem;
  margin: 0;
}

.summary-grid dt {
  color: #52647a;
  font-weight: 700;
}

.summary-grid dd {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
}

@media (max-width: 760px) {
  .dfd-figure-pair {
    grid-template-columns: 1fr;
  }

  .dfd-terms {
    grid-template-columns: 1fr;
  }

  .dfd-terms dd {
    margin-bottom: 1rem;
  }

  .dfd-bausteine-layout,
  .dfd-diagram-input-layout {
    grid-template-columns: 1fr;
  }

  .summary-grid {
    grid-template-columns: 1fr;
  }

  .summary-grid dt {
    margin-top: .4rem;
  }
}

.step-panel-nav {
  display: flex;
  justify-content: flex-end;
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid #d7dee8;
}

@media (max-width: 620px) {
  .step-panel-nav .primary-action {
    width: 100%;
  }
}
