:root {
  --bg: #f4f1e8;
  --surface: #fffdf7;
  --ink: #17211f;
  --muted: #65706d;
  --line: #d9d4c6;
  --map-empty: #dfe4df;
  --map-active: #1f8a5b;
  --map-active-strong: #11643f;
  --map-stroke: #ffffff;
  --accent: #d9822b;
  --accent-dark: #8f4d14;
  --focus: #2563eb;
  --shadow: 0 18px 45px rgba(31, 38, 35, 0.12);
  --transition-speed: 240ms;
  --pattern-bg: #fff6d8;
  --pattern-stripe: #d9822b;
  --countdown-bg: #e8f4ec;
  --countdown-border: rgba(31, 138, 91, 0.28);
  --pill-bg: #faf7ef;
  --pill-color: #33403d;
  --pill-partial-bg: #fff7df;
  --pill-partial-border: rgba(217, 130, 43, 0.42);
}

.dark-mode {
  --bg: #0d1312;
  --surface: #161f1e;
  --ink: #e3ecea;
  --muted: #889895;
  --line: #2a3835;
  --map-empty: #222f2c;
  --map-active: #10b981;
  --map-active-strong: #34d399;
  --map-stroke: #161f1e;
  --accent: #f59e0b;
  --accent-dark: #fbbf24;
  --focus: #3b82f6;
  --shadow: 0 18px 45px rgba(0, 0, 0, 0.45);
  --pattern-bg: #2b2b24;
  --pattern-stripe: #fbbf24;
  --countdown-bg: rgba(16, 185, 129, 0.12);
  --countdown-border: rgba(16, 185, 129, 0.35);
  --pill-bg: #1f2a28;
  --pill-color: #e3ecea;
  --pill-partial-bg: #322b22;
  --pill-partial-border: rgba(245, 158, 11, 0.35);
}

* {
  box-sizing: border-box;
}

body, .map-section, .details, .state-pill, .timeline-button, .today-badge, footer, h1, h2, p, span, svg, path {
  transition: background-color var(--transition-speed) ease, 
              color var(--transition-speed) ease, 
              border-color var(--transition-speed) ease, 
              box-shadow var(--transition-speed) ease,
              fill var(--transition-speed) ease,
              stroke var(--transition-speed) ease,
              filter var(--transition-speed) ease;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button {
  font: inherit;
}

.app {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 20px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  border-radius: 50%;
  cursor: pointer;
  padding: 0;
  transition: background-color var(--transition-speed) ease, 
              border-color var(--transition-speed) ease, 
              color var(--transition-speed) ease, 
              transform 150ms ease;
}

.theme-toggle:hover {
  border-color: var(--map-active);
  transform: scale(1.05);
}

.theme-toggle:active {
  transform: scale(0.95);
}

.theme-toggle:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.theme-toggle svg {
  width: 20px;
  height: 20px;
}

.theme-toggle .sun-icon {
  display: block;
}
.theme-toggle .moon-icon {
  display: none;
}

.dark-mode .theme-toggle .sun-icon {
  display: none;
}
.dark-mode .theme-toggle .moon-icon {
  display: block;
}

.kicker,
.eyebrow {
  margin: 0 0 7px;
  color: var(--accent-dark);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 2rem;
  line-height: 1.1;
}

.today-badge {
  min-width: 178px;
  border: 1px solid var(--line);
  background: var(--surface);
  padding: 10px 12px;
  color: var(--muted);
  font-size: 0.9rem;
  text-align: right;
}

.map-section {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  align-items: center;
  gap: 24px;
  padding: 24px;
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.map-wrap {
  display: grid;
  place-items: center;
  min-height: 540px;
}

.germany-map {
  width: min(100%, 540px);
  height: auto;
  display: block;
}

.state {
  fill: var(--map-empty);
  stroke: var(--map-stroke);
  stroke-width: 1.35;
  vector-effect: non-scaling-stroke;
}

.state[data-status="active"] {
  fill: var(--map-active);
  filter: drop-shadow(0 8px 8px rgba(31, 138, 91, 0.18));
}

.dark-mode .state[data-status="active"] {
  filter: drop-shadow(0 8px 12px rgba(16, 185, 129, 0.25));
}

.state[data-status="partial"] {
  fill: url("#partialPattern");
}

.state:hover {
  filter: brightness(0.95);
}

.dark-mode .state:hover {
  filter: brightness(1.12);
}

.state-label {
  pointer-events: none;
  fill: var(--ink);
  font-size: 11px;
  font-weight: 800;
  text-anchor: middle;
  paint-order: stroke;
  stroke: var(--surface);
  stroke-width: 4px;
  stroke-linejoin: round;
}

.state-label[data-status="active"] {
  fill: #ffffff;
  stroke: var(--map-active-strong);
}

.details {
  align-self: stretch;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 18px;
  border-left: 1px solid var(--line);
  padding-left: 24px;
}

.details h2 {
  margin-bottom: 10px;
  font-size: 1.75rem;
  line-height: 1.12;
}

.selected-date {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.45;
}

.countdown {
  width: fit-content;
  border: 1px solid var(--countdown-border);
  background: var(--countdown-bg);
  color: var(--map-active-strong);
  padding: 9px 11px;
  font-weight: 800;
}

.legend {
  display: grid;
  gap: 9px;
  color: var(--muted);
  font-size: 0.9rem;
}

.legend span {
  display: flex;
  align-items: center;
  gap: 9px;
}

.legend i {
  width: 16px;
  height: 16px;
  border: 1px solid rgba(23, 33, 31, 0.15);
  display: inline-block;
}

.legend-full {
  background: var(--map-active);
}

.legend-partial {
  background: repeating-linear-gradient(45deg, var(--pattern-bg) 0, var(--pattern-bg) 5px, var(--pattern-stripe) 5px, var(--pattern-stripe) 9px);
}

.state-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.state-pill {
  border: 1px solid var(--line);
  background: var(--pill-bg);
  padding: 7px 9px;
  color: var(--pill-color);
  font-size: 0.86rem;
  white-space: nowrap;
}

.state-pill.partial {
  border-color: var(--pill-partial-border);
  background: var(--pill-partial-bg);
  color: var(--accent-dark);
}

.note {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.93rem;
  line-height: 1.5;
}

.timeline-section {
  margin-top: 18px;
  padding: 18px 0 6px;
}

.timeline-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.timeline-head h2 {
  margin-bottom: 0;
  font-size: 1rem;
}

.timeline-head p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.timeline {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(152px, 190px);
  gap: 10px;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  padding: 4px 2px 18px;
  scroll-snap-type: x proximity;
}

.timeline-button {
  min-height: 112px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  padding: 11px;
  text-align: left;
  cursor: pointer;
  scroll-snap-align: center;
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}

.timeline-button:hover {
  border-color: var(--map-active);
  transform: translateY(-1px);
}

.timeline-button:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.timeline-button[aria-pressed="true"] {
  border-color: var(--map-active);
  background: var(--countdown-bg);
}

.timeline-date {
  display: block;
  margin-bottom: 9px;
  color: var(--accent-dark);
  font-size: 0.8rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0;
}

.timeline-name {
  display: block;
  margin-bottom: 8px;
  font-weight: 850;
  line-height: 1.2;
}

.timeline-scope {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.35;
}

.source-note {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 0 0 24px;
  color: var(--muted);
  font-size: 0.82rem;
}

@media (max-width: 900px) {
  .map-section {
    grid-template-columns: 1fr;
    padding: 18px;
  }

  .map-wrap {
    min-height: 430px;
  }

  .details {
    border-left: 0;
    border-top: 1px solid var(--line);
    padding-left: 0;
    padding-top: 18px;
  }
}

@media (max-width: 640px) {
  .app,
  .source-note {
    width: min(100% - 20px, 1180px);
  }

  .topbar {
    display: grid;
  }

  h1 {
    font-size: 1.55rem;
  }

  .today-badge {
    width: 100%;
    min-width: 0;
    text-align: left;
  }

  .map-section {
    padding: 12px;
  }

  .map-wrap {
    min-height: 350px;
  }

  .details h2 {
    font-size: 1.35rem;
  }

  .state-label {
    display: none;
  }

  .timeline-head {
    display: grid;
  }

  .timeline {
    grid-auto-columns: minmax(138px, 168px);
  }
}
