:root {
  color-scheme: light;
  --ink: #111827;
  --muted: #6b7280;
  --line: rgba(148, 163, 184, 0.3);
  --panel: rgba(255, 255, 255, 0.82);
  --shadow: 0 22px 56px rgba(15, 23, 42, 0.14);
  --shadow-light: 0 12px 34px rgba(15, 23, 42, 0.09);
  --green: #059669;
  --cyan: #0891b2;
  --blue: #2563eb;
  --violet: #7c3aed;
  --rose: #e11d48;
  --amber: #d97706;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: #f8fafc;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  line-height: 1.4;
  background:
    linear-gradient(135deg, rgba(37, 99, 235, 0.08), transparent 34%),
    linear-gradient(315deg, rgba(5, 150, 105, 0.09), transparent 42%),
    #f7f9fc;
}

a {
  color: inherit;
  text-decoration: none;
}

.site-backdrop {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    linear-gradient(rgba(17, 24, 39, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(17, 24, 39, 0.035) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: linear-gradient(to bottom, #000 0%, transparent 82%);
}

.site-header,
.home-shell,
.page-shell {
  width: min(1100px, calc(100% - 44px));
  margin: 0 auto;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 70px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-height: 42px;
  color: #1e293b;
  font-weight: 800;
}

.brand-mark {
  display: inline-grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 8px;
  color: #ffffff;
  background: linear-gradient(135deg, #111827, #2563eb);
  box-shadow: 0 12px 26px rgba(37, 99, 235, 0.22);
  font-size: 0.78rem;
  letter-spacing: 0;
}

.home-shell {
  display: grid;
  min-height: calc(100vh - 70px);
  align-items: center;
  padding: 16px 0 40px;
}

.hero {
  display: grid;
  gap: clamp(22px, 5vh, 38px);
  text-align: center;
  animation: fade-in-up 0.55s ease-out both;
}

h1 {
  margin: 0;
  color: var(--ink);
  font-size: clamp(3.1rem, 8vw, 6.6rem);
  font-weight: 900;
  line-height: 0.95;
  letter-spacing: 0;
}

.subject-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(16px, 3vw, 28px);
  width: min(100%, 920px);
  margin: 0 auto;
}

.subject-button,
.grade-button,
.back-link {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow-light);
  font-weight: 900;
  transition: transform 180ms ease, box-shadow 180ms ease, border-color 180ms ease;
}

.subject-button::before,
.grade-button::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.24), transparent 48%),
    linear-gradient(315deg, rgba(17, 24, 39, 0.12), transparent 52%);
}

.subject-button span,
.grade-button {
  z-index: 1;
}

.subject-button {
  min-height: clamp(170px, 27vh, 260px);
  justify-content: center;
  padding: 34px;
  color: #ffffff;
  font-size: clamp(2.35rem, 5vw, 4.5rem);
  text-align: center;
}

.subject-button.informatik {
  background:
    linear-gradient(135deg, #059669 0%, #0f766e 46%, #2563eb 100%);
}

.subject-button.physik {
  background:
    linear-gradient(135deg, #2563eb 0%, #4f46e5 48%, #d97706 100%);
}

.subject-button:hover,
.subject-button:focus-visible,
.grade-button:hover,
.grade-button:focus-visible,
.back-link:hover,
.back-link:focus-visible {
  border-color: rgba(15, 23, 42, 0.2);
  box-shadow: var(--shadow);
  outline: none;
  transform: translateY(-5px);
}

.page-shell {
  display: grid;
  align-content: start;
  min-height: 100vh;
  padding: 26px 0 54px;
  text-align: center;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: clamp(28px, 5vh, 54px);
}

.back-link {
  min-height: 44px;
  padding: 8px 16px;
  border-color: var(--line);
  color: #334155;
  font-size: 0.95rem;
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.08);
}

.page-header {
  margin-bottom: clamp(22px, 4vh, 34px);
  text-align: center;
  animation: fade-in-up 0.5s ease-out both;
}

.page-header h1 {
  font-size: clamp(3rem, 8vw, 6.2rem);
}

.grade-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(14px, 2vw, 20px);
  width: min(100%, 920px);
  margin: 0 auto;
}

.module-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(14px, 2vw, 20px);
  width: min(100%, 920px);
  margin: 0 auto;
}

.topic-list {
  display: grid;
  gap: clamp(34px, 6vh, 58px);
  width: min(100%, 920px);
  margin: 0 auto;
}

.topic-section h2 {
  margin-bottom: 16px;
  color: #1e293b;
  font-size: clamp(1.35rem, 3vw, 2rem);
  line-height: 1.2;
}

.placeholder-card {
  width: min(100%, 620px);
  margin: 0 auto;
  padding: clamp(24px, 5vw, 40px);
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: var(--shadow-light);
  text-align: center;
}

.placeholder-card h2 {
  margin-bottom: 10px;
  color: #1e293b;
  font-size: clamp(1.5rem, 4vw, 2.3rem);
}

.spreadsheet-page {
  width: min(1380px, calc(100% - 44px));
}

.spreadsheet-header {
  display: grid;
  gap: 10px;
}

.spreadsheet-header h1 {
  font-size: clamp(3rem, 7vw, 5.5rem);
}

.spreadsheet-header > p:last-child {
  max-width: 760px;
  margin: 0 auto;
  color: var(--muted);
  font-size: 1.08rem;
}

.eyebrow {
  margin: 0;
  color: var(--blue);
  font-size: 0.85rem;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.spreadsheet-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  gap: 22px;
  align-items: start;
}

.spreadsheet-workspace.spreadsheet-workspace-wide {
  grid-template-columns: minmax(0, 1fr);
}

.spreadsheet-card,
.formula-card,
.check-panel {
  border: 1px solid rgba(255, 255, 255, 0.78);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: var(--shadow-light);
}

.spreadsheet-card {
  min-width: 0;
  overflow: hidden;
  text-align: left;
}

.card-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}

.card-heading h2,
.formula-card h2,
.check-panel h2 {
  margin: 0;
  color: #1e293b;
  font-size: clamp(1.25rem, 2vw, 1.65rem);
}

.card-heading p,
.formula-card p,
.check-panel p {
  margin: 6px 0 0;
  color: var(--muted);
}

.load-status {
  flex: 0 0 auto;
  padding: 6px 10px;
  border-radius: 999px;
  color: #92400e;
  background: #fef3c7;
  font-size: 0.82rem;
  font-weight: 800;
}

.load-status.ready {
  color: #065f46;
  background: #d1fae5;
}

.load-status.error {
  color: #991b1b;
  background: #fee2e2;
}

.spreadsheet-frame {
  overflow: auto;
  background: #ffffff;
}

.spreadsheet-zoom {
  position: sticky;
  top: 0;
  left: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 8px;
  width: max-content;
  min-width: 100%;
  padding: 8px 12px;
  border-bottom: 1px solid #cbd5e1;
  background: rgba(248, 250, 252, 0.96);
}

.spreadsheet-zoom button {
  min-width: 36px;
  border: 1px solid #94a3b8;
  border-radius: 6px;
  padding: 5px 9px;
  color: #1e293b;
  background: #ffffff;
  font: inherit;
  font-weight: 900;
  cursor: pointer;
}

.spreadsheet-zoom button:hover,
.spreadsheet-zoom button:focus-visible {
  background: #dbeafe;
}

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

.spreadsheet-zoom span {
  min-width: 58px;
  color: #1e293b;
  font-weight: 900;
  text-align: center;
}

.spreadsheet-zoom small {
  color: #64748b;
  font-weight: 700;
}

.mini-spreadsheet-table {
  width: 100%;
  min-width: 980px;
  border-collapse: collapse;
  table-layout: fixed;
  color: #1e293b;
  font-size: 0.92rem;
}

.mini-spreadsheet-table.invoice-spreadsheet-table {
  min-width: 1180px;
}

.invoice-spreadsheet-table col.row-number-column {
  width: 34px;
}

.invoice-spreadsheet-table col.standard-column {
  width: 100px;
}

.invoice-spreadsheet-table col.description-column {
  width: 190px;
}

.invoice-spreadsheet-table col.price-column {
  width: 120px;
}

.invoice-spreadsheet-table col.total-column {
  width: 145px;
}

.mini-spreadsheet-table th,
.mini-spreadsheet-table td {
  height: 52px;
  border: 1px solid #cbd5e1;
  padding: 7px 9px;
  vertical-align: middle;
}

.mini-spreadsheet-table thead th,
.mini-spreadsheet-table tbody th {
  color: #475569;
  background: #f1f5f9;
  font-size: 0.82rem;
  font-weight: 900;
  text-align: center;
}

.mini-spreadsheet-table thead th:first-child,
.mini-spreadsheet-table tbody th {
  width: 30px;
  padding-right: 4px;
  padding-left: 4px;
}

.spreadsheet-cell {
  position: relative;
  overflow: hidden;
  background: #ffffff;
  word-break: break-word;
}

.spreadsheet-cell.text-overflow-source {
  z-index: 1;
  overflow: visible;
}

.spreadsheet-cell.cell-has-content:not(.text-overflow-source) {
  z-index: 2;
}

.cell-overflow-text {
  position: absolute;
  top: 50%;
  left: 14px;
  z-index: 1;
  display: none;
  width: max-content;
  min-width: calc(100% - 28px);
  color: inherit;
  font: inherit;
  font-weight: inherit;
  line-height: 1.2;
  white-space: nowrap;
  pointer-events: none;
  transform: translateY(-50%);
}

.spreadsheet-cell.text-overflow-source .cell-overflow-text {
  display: block;
}

.spreadsheet-cell.text-overflow-source input:not(:focus) {
  color: transparent;
}

.spreadsheet-cell.text-overflow-source:focus-within .cell-overflow-text {
  display: none;
}

.spreadsheet-cell.note-cell {
  color: #1e3a8a;
  background: #dbeafe;
  font-weight: 900;
}

.spreadsheet-cell.input-cell {
  background: #e2e8f0;
  font-weight: 900;
  text-align: right;
}

.spreadsheet-cell.label-cell {
  min-width: 220px;
  color: #334155;
  font-weight: 800;
}

.spreadsheet-cell.formula-cell {
  position: relative;
  overflow: visible;
  min-width: 180px;
  background: #fef3c7;
  padding: 5px;
}

.spreadsheet-cell.workbook-header-cell {
  color: #7c2d12;
  background: #fed7aa;
  font-weight: 900;
}

.spreadsheet-cell.invoice-formula-cell,
.spreadsheet-cell.instruction-cell {
  background: #ffc000;
}

.spreadsheet-cell.instruction-cell {
  color: #78350f;
  font-weight: 900;
}

.spreadsheet-cell.computed-cell {
  color: #334155;
  background: #fff7ed;
  font-weight: 800;
  text-align: right;
}

.spreadsheet-cell.fill-source-cell {
  box-shadow: inset 0 0 0 2px #2563eb;
}

.spreadsheet-cell.fill-preview-cell {
  background: #dbeafe;
  box-shadow: inset 0 0 0 2px rgba(37, 99, 235, 0.55);
}

.spreadsheet-cell.fill-complete-cell {
  background: #eff6ff;
}

.spreadsheet-fill-handle {
  position: absolute;
  right: -5px;
  bottom: -5px;
  z-index: 4;
  width: 12px;
  height: 12px;
  border: 2px solid #ffffff;
  border-radius: 2px;
  padding: 0;
  background: #2563eb;
  box-shadow: 0 0 0 1px #1d4ed8;
  cursor: ns-resize;
  touch-action: none;
}

.spreadsheet-fill-handle:hover,
.spreadsheet-fill-handle:focus-visible {
  width: 16px;
  height: 16px;
  outline: 3px solid rgba(37, 99, 235, 0.28);
  outline-offset: 2px;
}

body.is-filling-spreadsheet,
body.is-filling-spreadsheet * {
  cursor: ns-resize !important;
  user-select: none !important;
}

.spreadsheet-cell.currency-cell,
.spreadsheet-cell.number-cell,
.spreadsheet-cell.percent-cell {
  text-align: right;
}

.spreadsheet-cell.center-cell {
  text-align: center;
}

.spreadsheet-cell.summary-label-cell {
  color: #7f1d1d;
  background: #ef4444;
  font-weight: 900;
  text-align: right;
}

.spreadsheet-cell.summary-spacer-cell {
  background: #ef4444;
}

.spreadsheet-cell.exercise-label-cell {
  border-color: #475569;
  font-weight: 700;
}

.spreadsheet-cell .cell-static-value {
  display: block;
  width: 100%;
}

.spreadsheet-cell.formula-cell.has-error {
  background: #fee2e2;
}

.spreadsheet-cell.formula-cell.is-correct {
  background: #d1fae5;
}

.spreadsheet-cell input {
  display: block;
  width: 100%;
  min-height: 24px;
  border: 0;
  border-radius: 4px;
  padding: 3px 5px;
  color: #111827;
  background: rgba(255, 255, 255, 0.72);
  font: inherit;
  font-weight: 800;
}

.spreadsheet-cell input:focus {
  outline: 2px solid rgba(37, 99, 235, 0.55);
  outline-offset: 1px;
}

.spreadsheet-cell:not(.formula-cell) input {
  height: 100%;
  min-height: 36px;
  font-weight: inherit;
  text-align: inherit;
  background: transparent;
}

.cell-check-button {
  width: 100%;
  margin-top: 5px;
  border: 1px solid #d97706;
  border-radius: 6px;
  padding: 5px 7px;
  color: #78350f;
  background: #fde68a;
  font: inherit;
  font-size: 0.72rem;
  font-weight: 900;
  cursor: pointer;
}

.cell-check-button:hover,
.cell-check-button:focus-visible {
  background: #fcd34d;
}

.cell-result {
  display: block;
  min-height: 18px;
  margin-top: 3px;
  color: #475569;
  font-size: 0.78rem;
  font-weight: 800;
  text-align: right;
}

.formula-cell.has-error .cell-result {
  color: #991b1b;
}

.cell-feedback {
  min-height: 30px;
  margin-top: 4px;
  color: #64748b;
  font-size: 0.72rem;
  font-weight: 800;
  line-height: 1.2;
}

.cell-feedback.success {
  color: #065f46;
}

.cell-feedback.error {
  color: #991b1b;
}

.formula-card {
  padding: 22px;
  text-align: left;
}

.formula-card img {
  display: block;
  width: 100%;
  max-width: 304px;
  height: auto;
  margin: 18px auto;
  border-radius: 6px;
  background: #ffffff;
}

.check-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px 24px;
  align-items: center;
  margin-top: 22px;
  padding: 22px;
  text-align: left;
}

.check-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.primary-action,
.secondary-action {
  min-height: 46px;
  padding: 10px 18px;
  border: 0;
  border-radius: 8px;
  font: inherit;
  font-weight: 900;
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease, opacity 160ms ease;
}

.primary-action {
  color: #ffffff;
  background: linear-gradient(135deg, var(--green), var(--blue));
  box-shadow: 0 10px 24px rgba(37, 99, 235, 0.2);
}

.secondary-action {
  border: 1px solid var(--line);
  color: #334155;
  background: #ffffff;
}

.primary-action:hover:not(:disabled),
.primary-action:focus-visible:not(:disabled),
.secondary-action:hover:not(:disabled),
.secondary-action:focus-visible:not(:disabled) {
  outline: none;
  transform: translateY(-2px);
}

.primary-action:disabled,
.secondary-action:disabled {
  cursor: wait;
  opacity: 0.5;
}

.check-result {
  display: none;
  grid-column: 1 / -1;
  padding: 14px 16px;
  border-radius: 8px;
  font-weight: 800;
  white-space: pre-line;
}

.check-result.success,
.check-result.error {
  display: block;
}

.check-result.success {
  color: #065f46;
  background: #d1fae5;
}

.check-result.error {
  color: #991b1b;
  background: #fee2e2;
}

.grade-button {
  min-height: 124px;
  padding: 22px;
  color: #ffffff;
  font-size: clamp(1.45rem, 2.8vw, 2.4rem);
  text-align: center;
}

.module-button {
  position: relative;
  display: grid;
  min-height: 150px;
  align-content: center;
  gap: 8px;
  overflow: hidden;
  padding: 24px;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 8px;
  color: #ffffff;
  background: linear-gradient(135deg, var(--green), var(--blue));
  box-shadow: var(--shadow-light);
  text-align: left;
  transition: transform 180ms ease, box-shadow 180ms ease, border-color 180ms ease;
}

.module-button::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.24), transparent 48%),
    linear-gradient(315deg, rgba(17, 24, 39, 0.12), transparent 52%);
}

.module-button strong,
.module-button span {
  position: relative;
  z-index: 1;
}

.module-button strong {
  font-size: clamp(1.45rem, 3vw, 2.3rem);
  line-height: 1.05;
}

.module-button span {
  font-weight: 800;
  opacity: 0.9;
}

.module-button:hover,
.module-button:focus-visible {
  border-color: rgba(15, 23, 42, 0.2);
  box-shadow: var(--shadow);
  outline: none;
  transform: translateY(-5px);
}

.grade-button.green {
  background: linear-gradient(135deg, var(--green), #10b981);
}

.grade-button.cyan {
  background: linear-gradient(135deg, var(--cyan), #22d3ee);
}

.grade-button.blue {
  background: linear-gradient(135deg, var(--blue), #60a5fa);
}

.grade-button.violet {
  background: linear-gradient(135deg, var(--violet), #a78bfa);
}

.grade-button.rose {
  background: linear-gradient(135deg, var(--rose), #fb7185);
}

.grade-button.amber {
  background: linear-gradient(135deg, var(--amber), #fbbf24);
}

.placeholder {
  display: grid;
  align-content: start;
  justify-items: center;
  min-height: 100vh;
  padding: 26px 0 54px;
  gap: 18px;
  text-align: center;
}

.placeholder h1 {
  font-size: clamp(2.8rem, 7vw, 6rem);
}

.placeholder .intro {
  max-width: 650px;
  margin: 0;
  color: var(--muted);
  font-size: 1.08rem;
}

.placeholder-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 10px;
}

@keyframes fade-in-up {
  from {
    opacity: 0;
    transform: translateY(14px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 820px) {
  .site-header,
  .home-shell,
  .page-shell {
    width: min(100% - 32px, 720px);
  }

  .subject-grid {
    gap: 16px;
  }

  .subject-button {
    min-height: 190px;
  }

  .spreadsheet-page {
    width: min(100% - 32px, 720px);
  }

  .spreadsheet-workspace,
  .check-panel {
    grid-template-columns: 1fr;
  }

  .formula-card {
    text-align: center;
  }

  .check-actions {
    justify-content: flex-start;
  }

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

@media (max-width: 560px) {
  .site-header {
    min-height: 64px;
  }

  .home-shell {
    min-height: calc(100vh - 64px);
    padding-top: 12px;
  }

  .subject-grid,
  .grade-grid,
  .module-grid {
    grid-template-columns: 1fr;
  }

  .subject-button {
    min-height: 126px;
    justify-content: center;
    padding: 24px;
    font-size: 2.2rem;
    text-align: center;
  }

  .topbar {
    margin-bottom: 32px;
  }

  .grade-button {
    min-height: 86px;
    padding: 18px;
  }

  .module-button {
    min-height: 118px;
    padding: 20px;
  }

}
