/* =========================================================================
   DESIGN TOKENS
   ========================================================================= */
:root {
  --font-display: "Space Grotesk", "Segoe UI", sans-serif;
  --font-body: "Inter", "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", "Consolas", monospace;

  --radius: 10px;
  --radius-sm: 6px;
}

body.dark {
  --bg: #10161b;
  --surface: #182029;
  --surface-2: #202a35;
  --border: #2b3644;
  --text: #eef2f5;
  --text-muted: #8ea0ac;
  --accent: #3b82f6;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

body.light {
  --bg: #f5f3ee;
  --surface: #ffffff;
  --surface-2: #f0efe9;
  --border: #ddd8cd;
  --text: #1a1f24;
  --text-muted: #6b6156;
  --accent: #3b82f6;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  transition: background 0.2s ease, color 0.2s ease;
}

h1,
h2,
h3 {
  font-family: var(--font-display);
  letter-spacing: -0.01em;
}

button {
  font-family: var(--font-body);
  cursor: pointer;
}

/* =========================================================================
   TOPBAR
   ========================================================================= */
.topbar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 24px;
  padding: 14px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.05rem;
  white-space: nowrap;
}

.brand .brand-sub {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-muted);
  font-weight: 400;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* ---- Jahres-Navigation ---- */
.year-nav {
  display: flex;
  gap: 10px;
  justify-self: center;
  flex-wrap: wrap;
  justify-content: center;
}

.year-btn {
  position: relative;
  overflow: hidden;
  min-width: 96px;
  height: 42px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0 14px;
  isolation: isolate;
}

.year-btn .year-fill {
  position: absolute;
  inset: 0;
  width: 0%;
  background: var(--year-color);
  opacity: 0.85;
  z-index: -1;
  transition: width 0.4s ease;
}

.year-btn .year-label {
  position: relative;
  z-index: 1;
  display: inline-block;
  color: #fff;
  padding: 3px 10px;
  border-radius: 5px;
  background: rgba(0, 0, 0, 0.4);
}

.year-btn.locked {
  cursor: not-allowed;
}

.year-btn.locked .year-label {
  opacity: 0.75;
}

.year-btn.active {
  outline: 2px solid var(--text);
  outline-offset: 2px;
}

.year-btn .year-tooltip {
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%) translateY(-4px);
  background: var(--text);
  color: var(--bg);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease, transform 0.15s ease;
  z-index: 30;
}

.year-btn:hover .year-tooltip,
.year-btn:focus-visible .year-tooltip {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ---- Settings ---- */
.settings-wrap {
  position: relative;
  justify-self: end;
}

.settings-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.settings-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 10px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 18px;
  min-width: 200px;
  z-index: 25;
}

.settings-panel label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
}

/* =========================================================================
   MAIN
   ========================================================================= */
main {
  max-width: 880px;
  margin: 0 auto;
  padding: 32px 20px 80px;
}

body.compare-active main {
  padding-bottom: 130px;
}

.locked-hint {
  text-align: center;
  color: var(--text-muted);
  padding: 60px 20px;
}

.locked-hint h2 {
  color: var(--text);
  margin-bottom: 8px;
}

.year-back {
  background: none;
  border: none;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  padding: 0;
  margin-bottom: 18px;
}

.year-back:hover {
  color: var(--text);
}

/* ---- Subnav (Fragen / Übersicht) ---- */
.subnav {
  display: flex;
  gap: 6px;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--border);
}

.tab-btn {
  background: none;
  border: none;
  padding: 10px 4px;
  margin-right: 20px;
  font-size: 0.95rem;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  font-family: var(--font-display);
  font-weight: 600;
}

.tab-btn.active {
  color: var(--text);
  border-bottom-color: var(--accent);
}

/* ---- Fragen ---- */
.category-heading {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 4px;
}

.progress-indicator {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 18px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.question-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.question-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
}

.question-category {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
}

.question-text {
  font-size: 1rem;
  margin-bottom: 12px;
}

.answer-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.answer-option {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  font-size: 0.82rem;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.answer-option input[type="radio"] {
  accent-color: var(--accent);
  margin: 0;
  cursor: pointer;
}

.answer-option:hover {
  border-color: var(--accent);
}

.answer-option.selected {
  border-color: var(--accent);
  background: rgba(59, 130, 246, 0.16);
}

.answer-readonly {
  display: inline-block;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  font-size: 0.9rem;
  font-family: var(--font-mono);
}

.group-actions {
  margin-top: 22px;
  display: flex;
  justify-content: flex-end;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 11px 22px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.9rem;
}

.btn-primary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-secondary {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  margin-top: 26px;
}

.btn-secondary:hover {
  color: var(--text);
}

/* ---- Ergebnis / Radar ---- */
.radar-wrap {
  display: flex;
  justify-content: center;
  margin: 10px 0 24px;
}

.save-panel {
  max-width: 380px;
  margin: 0 auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  text-align: left;
}

.save-panel label {
  display: block;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.save-panel input {
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  margin-bottom: 12px;
  font-size: 0.9rem;
}

.save-msg {
  margin-top: 10px;
  font-size: 0.82rem;
  color: var(--accent);
  min-height: 1.2em;
}

/* ---- Übersicht ---- */
.entries-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.entries-table th,
.entries-table td {
  text-align: left;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}

.entries-table th {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.04em;
}

.entry-row {
  cursor: pointer;
  transition: background 0.15s ease;
}

.entry-row:hover {
  background: var(--surface-2);
}

.entry-row:last-child td {
  border-bottom: none;
}

.compare-check-cell {
  width: 36px;
}

.compare-checkbox {
  width: 17px;
  height: 17px;
  accent-color: var(--accent);
  cursor: pointer;
}

.empty-state {
  color: var(--text-muted);
  text-align: center;
  padding: 40px 0;
}

/* ---- Vergleichsleiste ---- */
.compare-tray {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  box-shadow: 0 -8px 20px rgba(0, 0, 0, 0.15);
  z-index: 35;
}

.compare-tray-inner {
  max-width: 880px;
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.compare-tray-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  flex: 1;
}

.compare-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--border);
  border-left-width: 4px;
  border-radius: var(--radius-sm);
  padding: 5px 8px 5px 10px;
  font-size: 0.8rem;
  background: var(--surface-2);
}

.compare-chip small {
  color: var(--text-muted);
}

.compare-chip-remove {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.85rem;
  padding: 0 2px;
  line-height: 1;
}

.compare-chip-remove:hover {
  color: var(--text);
}

.compare-tray-actions {
  display: flex;
  gap: 10px;
  flex-shrink: 0;
}

.compare-legend {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}

.compare-legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.88rem;
}

.compare-legend-year {
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.78rem;
}

.compare-swatch {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  flex-shrink: 0;
}

/* ---- Modal ---- */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 16px;
  overflow-y: auto;
  z-index: 50;
}

.modal[hidden] {
  display: none;
}

.modal-panel {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-width: 640px;
  width: 100%;
  padding: 28px 26px 34px;
  position: relative;
  box-shadow: var(--shadow);
}

.modal-close {
  position: absolute;
  top: 14px;
  right: 16px;
  background: none;
  border: none;
  font-size: 1.3rem;
  color: var(--text-muted);
  line-height: 1;
}

.modal-close:hover {
  color: var(--text);
}

.modal-date {
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  margin-top: -8px;
}

@media (max-width: 640px) {
  .topbar {
    grid-template-columns: 1fr auto;
    grid-template-areas: "brand settings" "nav nav";
    row-gap: 12px;
  }

  .brand {
    grid-area: brand;
  }

  .settings-wrap {
    grid-area: settings;
  }

  .year-nav {
    grid-area: nav;
    justify-self: stretch;
    justify-content: flex-start;
    overflow-x: auto;
  }
}