:root {
  color-scheme: light;

  --bg: #f5f5f7;
  --bg-soft: #eef0f5;
  --bg-elevated: #ffffff;
  --border-subtle: rgba(15, 23, 42, 0.08);
  --text: #0f172a;
  --text-muted: #64748b;
  --accent: #2563eb;
  --accent-soft: rgba(37, 99, 235, 0.12);
  --accent-strong: #1d4ed8;
  --danger: #e11d48;
  --warning: #f97316;
  --success: #16a34a;
  --shadow-soft: 0 18px 45px rgba(15, 23, 42, 0.12);
  --radius-lg: 1.1rem;
  --radius-md: 0.75rem;
  --radius-pill: 999px;
  --transition-fast: 150ms ease-out;
  --transition-med: 220ms ease-out;
}

:root[data-theme="dark"] {
  color-scheme: dark;

  --bg: #020617;
  --bg-soft: #020617;
  --bg-elevated: rgba(15, 23, 42, 0.96);
  --border-subtle: rgba(148, 163, 184, 0.3);
  --text: #e5e7eb;
  --text-muted: #94a3b8;
  --accent: #38bdf8;
  --accent-soft: rgba(56, 189, 248, 0.16);
  --accent-strong: #0ea5e9;
  --danger: #fb7185;
  --warning: #fdba74;
  --success: #22c55e;
  --shadow-soft: 0 24px 60px rgba(15, 23, 42, 0.85);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  min-height: 100vh;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  background:
    radial-gradient(circle at top left, rgba(56, 189, 248, 0.18), transparent 55%),
    radial-gradient(circle at bottom right, rgba(129, 140, 248, 0.2), transparent 55%),
    var(--bg);
  color: var(--text);
  display: flex;
  justify-content: center;
  align-items: stretch;
}

.hidden {
  display: none !important;
}

.app-shell {
  width: 100%;
  max-width: 1120px;
  margin: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

@media (max-width: 640px) {
  .app-shell {
    margin: 0.75rem;
  }
}

/* Topbar */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.9rem 1.2rem;
  border-radius: var(--radius-lg);
  background: linear-gradient(
      120deg,
      rgba(248, 250, 252, 0.9),
      rgba(248, 250, 252, 0.45)
    );
  backdrop-filter: blur(20px);
  border: 1px solid rgba(148, 163, 184, 0.4);
  box-shadow: var(--shadow-soft);
}

:root[data-theme="dark"] .topbar {
  background: linear-gradient(
      120deg,
      rgba(15, 23, 42, 0.9),
      rgba(15, 23, 42, 0.75)
    );
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.9rem;
  height: 1.9rem;
  border-radius: 0.5rem;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 1.1rem;
  font-weight: 700;
}

.brand-text {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  font-size: 0.96rem;
  font-weight: 600;
}

.brand-text small {
  font-size: 0.78rem;
  font-weight: 400;
  color: var(--text-muted);
}

.topbar-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

/* Buttons */

.button {
  border-radius: var(--radius-pill);
  border: none;
  padding: 0.6rem 1.3rem;
  font-size: 0.92rem;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  background: var(--bg-soft);
  color: var(--text);
  transition: background var(--transition-med), transform var(--transition-fast),
    box-shadow var(--transition-fast), border-color var(--transition-fast);
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.16);
}

.button.primary {
  background: linear-gradient(
    135deg,
    var(--accent),
    var(--accent-strong)
  );
  color: #f9fafb;
}

.button.ghost {
  background: transparent;
  border: 1px solid var(--border-subtle);
  box-shadow: none;
}

.button:hover {
  transform: translateY(-1px);
  box-shadow: 0 16px 36px rgba(15, 23, 42, 0.22);
}

.button:active {
  transform: translateY(0);
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.2);
}

.button-print {
  font-size: 0.85rem;
  padding-inline: 0.9rem;
}

/* Theme toggle */

.theme-toggle {
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-subtle);
  background: rgba(248, 250, 252, 0.92);
  padding: 0.45rem 0.9rem;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
  font-size: 0.8rem;
  color: var(--text-muted);
  transition: background var(--transition-fast), transform var(--transition-fast),
    box-shadow var(--transition-fast), border-color var(--transition-fast);
  box-shadow: 0 10px 25px rgba(15, 23, 42, 0.12);
}

:root[data-theme="dark"] .theme-toggle {
  background: rgba(15, 23, 42, 0.9);
}

.theme-toggle:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 32px rgba(15, 23, 42, 0.16);
  border-color: rgba(148, 163, 184, 0.6);
}

.theme-toggle-icon {
  font-size: 1.1rem;
}

.theme-toggle-label {
  display: none;
}

@media (min-width: 768px) {
  .theme-toggle-label {
    display: inline;
  }
}

/* Cards */

.content {
  flex: 1;
}

.card {
  border-radius: var(--radius-lg);
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-soft);
  padding: 1.6rem 1.8rem;
}

.card-large {
  padding: 2rem 2.1rem;
}

.card-summary {
  margin-bottom: 0.4rem;
}

.section-header h2 {
  margin: 0 0 0.35rem;
  font-size: 1.08rem;
}

.section-header p {
  margin: 0 0 0.8rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}

/* Text */

h1 {
  margin: 0 0 0.6rem;
  font-size: clamp(1.6rem, 1.5rem + 0.9vw, 2.1rem);
}

.lead {
  margin: 0 0 1.4rem;
  color: var(--text-muted);
  font-size: 0.95rem;
  max-width: 42rem;
}

.info-grid {
  display: grid;
  gap: 1.1rem;
}

@media (min-width: 880px) {
  .info-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.info-box {
  border-radius: var(--radius-md);
  border: 1px dashed rgba(148, 163, 184, 0.7);
  padding: 1rem 1.1rem;
  background: var(--bg-soft);
}

.info-box h2 {
  margin: 0 0 0.5rem;
  font-size: 0.98rem;
}

.info-box ul {
  padding-left: 1.2rem;
  margin: 0 0 0.6rem;
  font-size: 0.9rem;
}

.info-box li + li {
  margin-top: 0.2rem;
}

.hint {
  margin: 0.25rem 0 0;
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* Wizard Launch */

.wizard-launch {
  margin-bottom: 1.4rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  align-items: flex-start;
}

.wizard-launch-hint {
  margin: 0;
  font-size: 0.85rem;
  color: var(--text-muted);
  max-width: 32rem;
}

/* Legend */

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem 1rem;
  font-size: 0.82rem;
  color: var(--text-muted);
  margin: 0.3rem 0 0.7rem;
}

.pill {
  display: inline-block;
  width: 0.8rem;
  height: 0.8rem;
  border-radius: 0.3rem;
  margin-right: 0.35rem;
}

.pill-mandatory {
  background: rgba(234, 179, 8, 0.16);
  border: 1px solid rgba(234, 179, 8, 0.9);
}

.pill-lk {
  background: rgba(56, 189, 248, 0.16);
  border: 1px solid rgba(56, 189, 248, 0.9);
}

.pill-exam {
  background: rgba(34, 197, 94, 0.16);
  border: 1px solid rgba(34, 197, 94, 0.9);
}

/* Tabelle */

.table-wrapper {
  overflow-x: auto;
  margin: 0.2rem -0.3rem 0;
  padding: 0 0.3rem;
}

.subject-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
  min-width: 640px;
}

.subject-table thead {
  background: rgba(15, 23, 42, 0.03);
}

.subject-table th,
.subject-table td {
  padding: 0.4rem 0.5rem;
  border-bottom: 1px solid rgba(148, 163, 184, 0.35);
}

.subject-table th {
  text-align: left;
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.subject-table td.numeric,
.subject-table th.numeric {
  text-align: right;
}

.subject-row:nth-child(even) td {
  background: rgba(148, 163, 184, 0.05);
}

.group-row td {
  background: rgba(15, 23, 42, 0.04);
  font-weight: 600;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding-top: 0.7rem;
  border-bottom-color: rgba(148, 163, 184, 0.6);
}

:root[data-theme="dark"] .group-row td {
  background: rgba(15, 23, 42, 0.9);
}

.subject-name-main {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.subject-title {
  font-weight: 500;
}

.subject-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.2rem;
  margin-top: 0.15rem;
}

.subject-tag {
  font-size: 0.68rem;
  border-radius: var(--radius-pill);
  padding: 0.05rem 0.45rem;
  border: 1px solid rgba(148, 163, 184, 0.75);
  color: var(--text-muted);
}

.subject-tag.mandatory {
  border-color: rgba(234, 179, 8, 0.9);
  background: rgba(234, 179, 8, 0.16);
}

.subject-tag.lk {
  border-color: rgba(56, 189, 248, 0.9);
  background: rgba(56, 189, 248, 0.16);
}

.subject-tag.exam {
  border-color: rgba(22, 163, 74, 0.95);
  background: rgba(22, 163, 74, 0.16);
}

.subject-obligation {
  font-size: 0.78rem;
  color: var(--text-muted);
}

select {
  border-radius: 0.75rem;
  border: 1px solid var(--border-subtle);
  padding: 0.28rem 1.8rem 0.3rem 0.6rem;
  font-size: 0.82rem;
  background: rgba(248, 250, 252, 0.95);
  color: var(--text);
  outline: none;
  transition: border-color var(--transition-fast),
    box-shadow var(--transition-fast), background var(--transition-fast);
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-muted) 50%),
    linear-gradient(135deg, var(--text-muted) 50%, transparent 50%);
  background-position:
    calc(100% - 14px) calc(50% - 2px),
    calc(100% - 10px) calc(50% - 2px);
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
}

:root[data-theme="dark"] select {
  background: rgba(15, 23, 42, 0.96);
}

select:focus {
  border-color: var(--accent-strong);
  box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.4);
}

.subject-table td select {
  width: 100%;
}

/* Prüfungsübersicht */

.exam-overview {
  display: grid;
  gap: 1rem;
}

@media (min-width: 720px) {
  .exam-overview {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.exam-column {
  border-radius: var(--radius-md);
  border: 1px dashed rgba(148, 163, 184, 0.8);
  padding: 0.9rem 1rem;
  background: var(--bg-soft);
}

.exam-column h3 {
  margin: 0 0 0.4rem;
  font-size: 0.96rem;
}

.exam-list {
  margin: 0;
  font-size: 0.9rem;
  color: var(--text-muted);
}

/* Summary */

.summary-grid {
  display: grid;
  gap: 0.9rem;
  margin: 0.2rem 0 1.1rem;
}

@media (min-width: 720px) {
  .summary-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

.summary-item {
  padding: 0.85rem 0.9rem;
  border-radius: 0.9rem;
  background: var(--bg-soft);
  border: 1px solid rgba(148, 163, 184, 0.5);
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.summary-label {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.summary-value {
  font-size: 1.15rem;
  font-weight: 600;
}

.summary-item small {
  font-size: 0.76rem;
  color: var(--text-muted);
}

.summary-fields {
  display: grid;
  gap: 1rem;
  margin-bottom: 1rem;
}

@media (min-width: 720px) {
  .summary-fields {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.field-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  padding: 0;
  margin: 0.2rem 0 0;
  list-style: none;
}

.field-tag {
  font-size: 0.78rem;
  border-radius: var(--radius-pill);
  padding: 0.18rem 0.7rem;
  border: 1px solid rgba(148, 163, 184, 0.8);
  color: var(--text-muted);
}

.field-tag.ok {
  border-color: rgba(34, 197, 94, 0.9);
  color: var(--success);
}

.field-tag.missing {
  border-color: rgba(239, 68, 68, 0.9);
  color: var(--danger);
}

/* Messages */

.messages {
  margin-top: 0.5rem;
  font-size: 0.86rem;
}

.message-list {
  list-style: none;
  padding-left: 0;
  margin: 0.3rem 0 0;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.msg {
  border-radius: 0.5rem;
  padding: 0.35rem 0.55rem;
  display: flex;
  gap: 0.35rem;
  align-items: flex-start;
}

.msg-icon {
  font-size: 1rem;
  line-height: 1.2;
}

.msg-text {
  flex: 1;
}

.msg-error {
  background: rgba(248, 113, 113, 0.12);
  border: 1px solid rgba(248, 113, 113, 0.7);
  color: var(--danger);
}

.msg-warning {
  background: rgba(251, 191, 36, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.7);
  color: var(--warning);
}

.msg-ok {
  background: rgba(34, 197, 94, 0.08);
  border: 1px solid rgba(34, 197, 94, 0.7);
  color: var(--success);
}

.summary-actions {
  margin-top: 1.1rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

/* Footer */

.footer {
  font-size: 0.78rem;
  color: var(--text-muted);
  text-align: center;
  padding-bottom: 0.5rem;
}

/* Wizard (geführter Modus) */

.wizard-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 40;
  backdrop-filter: blur(10px);
}

.wizard-panel {
  width: 100%;
  max-width: 720px;
  margin: 1rem;
  border-radius: var(--radius-lg);
  background: var(--bg-elevated);
  border: 1px solid rgba(148, 163, 184, 0.7);
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.45);
  display: flex;
  flex-direction: column;
  max-height: min(640px, 90vh);
}

.wizard-header {
  padding: 1rem 1.3rem 0.6rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.wizard-title {
  margin: 0;
  font-size: 1.1rem;
}

.wizard-close {
  border: none;
  background: transparent;
  font-size: 1.3rem;
  cursor: pointer;
  color: var(--text-muted);
  padding: 0.2rem 0.4rem;
  border-radius: 999px;
}

.wizard-close:hover {
  background: rgba(148, 163, 184, 0.18);
}

.wizard-progress {
  padding: 0 1.3rem 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.wizard-progress-label {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.wizard-progress-bar {
  width: 100%;
  height: 0.3rem;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.35);
  overflow: hidden;
}

.wizard-progress-bar-inner {
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--accent-strong));
  transition: width var(--transition-med);
}

.wizard-body {
  padding: 0.5rem 1.3rem 1rem;
  overflow-y: auto;
  font-size: 0.9rem;
}

.wizard-body p {
  margin-top: 0;
}

.wizard-list {
  padding-left: 1.2rem;
  margin: 0.2rem 0 0.6rem;
}

.wizard-list li + li {
  margin-top: 0.2rem;
}

.wizard-note {
  margin: 0.4rem 0 0.2rem;
  font-size: 0.84rem;
  color: var(--text-muted);
}

.wizard-small {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin: 0.5rem 0 0;
}

.wizard-footer {
  padding: 0.8rem 1.3rem 1rem;
  display: flex;
  justify-content: flex-end;
  gap: 0.6rem;
  border-top: 1px solid rgba(148, 163, 184, 0.3);
}

.wizard-error {
  min-height: 1.1rem;
  padding: 0 1.3rem 0.2rem;
  font-size: 0.84rem;
  color: var(--danger);
}

/* Wizard: LKs */

.wizard-lk-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.45rem;
}

@media (min-width: 640px) {
  .wizard-lk-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.wizard-lk-option {
  border-radius: 0.65rem;
  border: 1px solid rgba(148, 163, 184, 0.7);
  padding: 0.5rem 0.7rem;
  display: flex;
  align-items: flex-start;
  gap: 0.45rem;
  cursor: pointer;
}

.wizard-lk-option input[type="checkbox"] {
  margin-top: 0.12rem;
}

.wizard-lk-main {
  font-size: 0.9rem;
  font-weight: 500;
}

.wizard-lk-sub {
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* Wizard: Radio-Gruppen */

.wizard-radio-group {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  margin: 0.5rem 0 0.4rem;
}

.wizard-radio-option {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  border-radius: 0.65rem;
  border: 1px solid rgba(148, 163, 184, 0.7);
  padding: 0.45rem 0.7rem;
  cursor: pointer;
}

/* Wizard: Sprachen / Naturwissenschaften */

.wizard-lang-grid {
  display: grid;
  gap: 0.8rem;
}

@media (min-width: 640px) {
  .wizard-lang-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.wizard-lang-column h4 {
  margin: 0 0 0.35rem;
  font-size: 0.9rem;
}

.wizard-lang-list {
  list-style: none;
  padding-left: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.wizard-lang-item {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.86rem;
}

.wizard-lang-item small {
  font-size: 0.76rem;
  color: var(--text-muted);
}

/* Wizard: Prüfungsfächer */

.wizard-exam-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.4rem;
}

@media (min-width: 640px) {
  .wizard-exam-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.wizard-exam-option {
  border-radius: 0.65rem;
  border: 1px solid rgba(148, 163, 184, 0.7);
  padding: 0.45rem 0.7rem;
  display: flex;
  align-items: flex-start;
  gap: 0.4rem;
  cursor: pointer;
}

.wizard-exam-option input[type="checkbox"] {
  margin-top: 0.12rem;
}

.wizard-exam-main {
  font-size: 0.9rem;
  font-weight: 500;
}

.wizard-exam-sub {
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* Print */

@media print {
  body {
    background: #ffffff !important;
  }

  .topbar,
  .theme-toggle,
  .button-print,
  .summary-actions,
  .legend,
  .info-grid,
  .exam-overview,
  .hint,
  .wizard-launch,
  .wizard-backdrop {
    display: none !important;
  }

  .app-shell {
    margin: 0.5cm;
  }

  .card,
  .card-large {
    box-shadow: none;
    border-radius: 0;
    border: 1px solid #000000;
    background: #ffffff;
    page-break-inside: avoid;
  }

  .subject-table {
    font-size: 0.8rem;
  }

  .summary-grid,
  .summary-fields {
    page-break-inside: avoid;
  }
}