/* TachoGen — Werkbank-Optik: Graphit, Millimeterpapier, Zeiger-Orange.
   Abstands-Skala: 4 / 8 / 12 / 16 / 24 px. */

:root {
  --bg-stage: #0e1013;
  --bg-panel: #16181d;
  --bg-raised: #1e2127;
  --bg-inset: #0b0d10;
  --line: #262a31;
  --line-strong: #333943;
  --text: #e7e9ec;
  --muted: #8b93a0;
  --accent: #f0762b;
  --accent-soft: rgba(240, 118, 43, 0.28);
  --err: #e5484d;
  --err-text: #f2b8bb;
  --grid-fine: rgba(139, 147, 160, 0.055);
  --grid-major: rgba(139, 147, 160, 0.10);
  --btn-shade: #191c21;
  --btn-hover-shade: #23262c;
  --stage-vignette: rgba(4, 5, 7, 0.6);
  --overlay-scrim: rgba(8, 9, 11, 0.97);
  --font-ui: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Code", Menlo, Consolas, monospace;
  font-size: 14px;
  color-scheme: dark;
}

/* ---------- Light Mode: jede Farb-Variable der dunklen Palette überschrieben ---------- */
:root[data-theme="light"] {
  --bg-stage: #ececee;
  --bg-panel: #f7f7f8;
  --bg-raised: #ffffff;
  --bg-inset: #eeeef0;
  --line: #d4d4d8;
  --line-strong: #b8b8bf;
  --text: #1b1b1f;
  --muted: #6b6b74;
  /* --accent bleibt identisch (Signalfarbe) */
  --accent-soft: rgba(240, 118, 43, 0.20);
  --err: #d1383d;
  --err-text: #9a2e30;
  --grid-fine: rgba(107, 107, 116, 0.06);
  --grid-major: rgba(107, 107, 116, 0.12);
  --btn-shade: #e2e2e6;
  --btn-hover-shade: #f4f4f6;
  --stage-vignette: rgba(150, 152, 158, 0.35);
  --overlay-scrim: rgba(236, 236, 238, 0.97);
  color-scheme: light;
}

* { box-sizing: border-box; }

/* Nur für Screenreader und Suchmaschinen sichtbar */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg-stage);
  color: var(--text);
  font-family: var(--font-ui);
  display: flex;
  flex-direction: column;
}

button, input, select { transition: border-color 120ms ease, background-color 120ms ease, color 120ms ease; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

:is(button, .filebtn, select, summary):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

/* ---------- Toolbar ---------- */

#toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 16px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--line);
}
#brand {
  font-family: 'Barlow Condensed', var(--font-ui);
  font-weight: normal;
  font-size: 17px;
  text-transform: uppercase;
  display: flex;
  align-items: center;
}
#brand img { width: 22px; height: 22px; display: block; margin-right: 9px; }
#brand span { color: var(--accent); }
#actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

/* ---------- Buttons ---------- */

button, .filebtn {
  background: linear-gradient(180deg, var(--bg-raised), var(--btn-shade));
  color: var(--text);
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  padding: 5px 12px;
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  line-height: 1.45;
  white-space: nowrap;
}
button:hover, .filebtn:hover {
  border-color: var(--muted);
  background: linear-gradient(180deg, var(--btn-hover-shade), var(--bg-raised));
}
button:active:not(:disabled) {
  background: var(--btn-shade);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.22);
}
button:disabled {
  opacity: 0.4;
  cursor: default;
  border-color: var(--line);
  background: var(--bg-raised);
}
button.primary, .filebtn.primary {
  background: linear-gradient(180deg, #f9853d, #e56a1f);
  border-color: #b25017;
  color: #17110c;
  font-weight: 600;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.28), 0 1px 3px rgba(0, 0, 0, 0.25);
}
button.primary:hover, .filebtn.primary:hover {
  background: linear-gradient(180deg, #ff9450, #ef7527);
  border-color: #b25017;
}
button.primary:active:not(:disabled) {
  background: linear-gradient(180deg, #e56a1f, #d96317);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.3);
}
button.primary:focus-visible { outline-offset: 2px; }

/* Toolbar: eine Leiste, eine Höhe */
#actions button, #actions .filebtn {
  height: 30px;
  padding: 0 12px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
#actions #btn-help, #actions #btn-theme {
  width: 30px;
  padding: 0;
  justify-content: center;
  font-size: 14px;
  color: var(--muted);
}
#actions #btn-help:hover, #actions #btn-theme:hover { color: var(--text); }
#actions #btn-help { font-weight: 600; }
#actions #btn-theme { font-size: 15px; }

/* Werkzeug-Icons: gravierte Striche in currentColor (Data-URI-Masken, keine externen Ressourcen) */
#btn-reset::before, #btn-photo-align::before, #btn-preset-save::before, #btn-export-svg::before,
.fb-photo::before, .fb-preset::before {
  content: "";
  width: 13px;
  height: 13px;
  flex: 0 0 auto;
  background: currentColor;
  -webkit-mask: var(--icon) center / contain no-repeat;
  mask: var(--icon) center / contain no-repeat;
}
#btn-reset::before { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M2.5 8a5.5 5.5 0 1 0 1.6-3.9M2.5 2.1v2.6h2.6' fill='none' stroke='%23000' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); }
.fb-photo::before { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cg fill='none' stroke='%23000' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='1.75' y='2.75' width='12.5' height='10.5' rx='1.5'/%3E%3Ccircle cx='5.4' cy='6.2' r='1.1'/%3E%3Cpath d='M2.5 12.2l3.4-3.9 2.7 2.9 2-2.2 3 3.2'/%3E%3C/g%3E%3C/svg%3E"); }
#btn-photo-align::before { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cellipse cx='8' cy='8.5' rx='6' ry='4' fill='none' stroke='%23000' stroke-width='1.5'/%3E%3Ccircle cx='8' cy='8.5' r='1'/%3E%3Ccircle cx='14' cy='8.5' r='1.4'/%3E%3Ccircle cx='8' cy='4.5' r='1.4'/%3E%3C/svg%3E"); }
.fb-preset::before { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M1.75 12.75v-9h4.2l1.5 1.7h6.8v7.3z' fill='none' stroke='%23000' stroke-width='1.5' stroke-linejoin='round'/%3E%3C/svg%3E"); }
#btn-preset-save::before { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cg fill='none' stroke='%23000' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M2.75 13.25v-10.5h8.5l2 2v8.5z'/%3E%3Cpath d='M5.2 2.75v3.3h5v-3.3'/%3E%3Cpath d='M4.9 13.25v-4.3h6.2v4.3'/%3E%3C/g%3E%3C/svg%3E"); }
#btn-export-svg::before { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M8 2.5v7.5M4.9 6.9L8 10l3.1-3.1M3 13.5h10' fill='none' stroke='%23000' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); }

/* ---------- Grundlayout ---------- */

main { flex: 1; display: flex; min-height: 0; }

#sidebar {
  width: 320px;
  flex: 0 0 320px;
  overflow-y: auto;
  background: var(--bg-panel);
  border-right: 1px solid var(--line);
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}
#sidebar::-webkit-scrollbar { width: 8px; }
#sidebar::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 4px; }

#sidebar-resizer {
  flex: 0 0 5px;
  margin-left: -5px; /* liegt auf der Sidebar-Kante */
  cursor: col-resize;
  z-index: 10;
}
#sidebar-resizer:hover, #sidebar-resizer.active { background: var(--accent-soft); }
#sidebar::-webkit-scrollbar-track { background: transparent; }

@media (max-width: 860px) {
  #sidebar { width: 280px; flex-basis: 280px; }
}

/* ---------- Bühne: Millimeterpapier + Vignette ---------- */

#stage {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 24px;
  gap: 16px;
  background-color: var(--bg-stage);
  background-image:
    radial-gradient(120% 95% at 50% 42%, transparent 55%, var(--stage-vignette) 100%),
    linear-gradient(var(--grid-major) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-major) 1px, transparent 1px),
    linear-gradient(var(--grid-fine) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-fine) 1px, transparent 1px);
  background-size: 100% 100%, 70px 70px, 70px 70px, 14px 14px, 14px 14px;
  background-position: center center;
}
#stage-footer {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  pointer-events: none; /* nur die Kinder sind klickbar */
}
#stage-footer a, #stage-footer button { pointer-events: auto; }
#view-controls {
  position: absolute;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 6px;
  pointer-events: none;
}
#view-controls button { pointer-events: auto; }
#zoom-hint { color: var(--muted); font-size: 11.5px; margin-right: 8px; }
#btn-zoom-in, #btn-zoom-out {
  width: 26px;
  padding: 4px 0;
  font-size: 14px;
  line-height: 1;
  border-radius: 999px;
}
#btn-zoom-reset {
  min-width: 58px;
  padding: 4px 8px;
  font-size: 11.5px;
  border-radius: 999px;
  font-variant-numeric: tabular-nums;
}
@media (max-width: 1100px) {
  #zoom-hint { display: none; }
}
#legal-links { display: flex; gap: 14px; }
#legal-links a { color: var(--muted); font-size: 11.5px; text-decoration: none; }
#legal-links a:hover { color: var(--text); text-decoration: underline; }
#btn-donate { font-size: 12px; padding: 4px 14px; border-radius: 999px; }

#stage.pan-ready { cursor: grab; }
#stage.panning { cursor: grabbing; }
#preview { transform-origin: center center; }
#preview svg {
  max-width: min(80vh, 100%);
  height: auto;
  display: block;
  filter: drop-shadow(0 24px 60px rgba(0, 0, 0, 0.55)) drop-shadow(0 3px 12px rgba(0, 0, 0, 0.4));
}
:root[data-theme="light"] #preview svg {
  filter: drop-shadow(0 18px 44px rgba(45, 48, 55, 0.30)) drop-shadow(0 2px 8px rgba(45, 48, 55, 0.18));
}

/* ---------- Fehlerbox: präzise, nicht alarmistisch ---------- */

#errors {
  max-width: 520px;
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-left: 3px solid var(--err);
  border-radius: 4px;
  padding: 12px 16px;
}
#errors::before {
  content: "Eingabe prüfen";
  display: block;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--err);
  margin-bottom: 4px;
}
#errors p { margin: 4px 0; font-size: 13px; color: var(--err-text); }

/* ---------- Sidebar-Gruppen ---------- */

details.group { border-bottom: 1px solid var(--line); }
details.group > summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 11px;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--muted);
  user-select: none;
}
details.group > summary::-webkit-details-marker { display: none; }
details.group > summary::before {
  /* Indexstrich: greift das Skalenstrich-Motiv der Scheibe auf */
  content: "";
  flex: 0 0 8px;
  height: 2px;
  background: var(--line-strong);
}
details.group > summary::after {
  content: "";
  margin-left: auto;
  width: 6px;
  height: 6px;
  border-right: 1.5px solid var(--muted);
  border-bottom: 1.5px solid var(--muted);
  transform: rotate(-45deg);
  transition: transform 120ms ease;
}
details.group > summary:hover { color: var(--text); }
details.group[open] > summary { color: var(--text); }
details.group[open] > summary::before { background: var(--accent); }
details.group[open] > summary::after { transform: rotate(45deg); }
details.group[open] { padding-bottom: 8px; }

.row {
  display: flex;
  flex-wrap: wrap; /* schmale Leiste: Eingabe bricht unter das Label statt zu stauchen */
  align-items: center;
  justify-content: space-between;
  gap: 4px 8px;
  padding: 4px 16px;
}
.row > label { flex: 1; min-width: 130px; font-size: 13px; color: var(--muted); }
.subhead {
  padding: 8px 16px 0;
  font-size: 11px;
  font-family: var(--font-mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
}

/* ---------- Eingabefelder ---------- */

.row input[type="number"], .row select, .row input[type="text"], .modal-row input[type="number"] {
  width: 120px;
  /* background-color (Longhand), damit die Pfeil-Grafik der select-Regel nicht zurückgesetzt wird */
  background-color: var(--bg-inset);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 4px 8px;
  font: inherit;
  font-size: 13px;
}
input[type="number"] {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
  text-align: right;
}
input[type="number"]:focus, input[type="text"]:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='6'%3E%3Cpath d='M1 1l3 3 3-3' fill='none' stroke='%238b93a0' stroke-width='1.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  padding-right: 24px;
}
:root[data-theme="light"] select {
  /* Pfeil-SVG kodiert --muted als Farbstring; var() wird in url()-Strings nicht aufgelöst */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='6'%3E%3Cpath d='M1 1l3 3 3-3' fill='none' stroke='%236b6b74' stroke-width='1.5'/%3E%3C/svg%3E");
}

/* Schieberegler: dünne Laufbahn, gefräster Griff */
input[type="range"] {
  appearance: none;
  -webkit-appearance: none;
  width: 90px;
  height: 16px;
  background: transparent;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 2px;
  background: var(--line-strong);
  border-radius: 1px;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 8px;
  height: 16px;
  margin-top: -7px;
  border-radius: 2px;
  background: linear-gradient(180deg, #e3e6ea, #b6bcc4);
  border: 1px solid var(--bg-inset);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}
input[type="range"]::-moz-range-track {
  height: 2px;
  background: var(--line-strong);
  border-radius: 1px;
}
input[type="range"]::-moz-range-thumb {
  width: 8px;
  height: 16px;
  border-radius: 2px;
  background: linear-gradient(180deg, #e3e6ea, #b6bcc4);
  border: 1px solid var(--bg-inset);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}
input[type="range"]:hover::-webkit-slider-thumb { background: linear-gradient(180deg, #f2f4f6, #c9cfd6); }
input[type="range"]:hover::-moz-range-thumb { background: linear-gradient(180deg, #f2f4f6, #c9cfd6); }
input[type="range"]:focus-visible {
  outline: none;
}
input[type="range"]:focus-visible::-webkit-slider-thumb {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
input[type="range"]:focus-visible::-moz-range-thumb {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
/* Light Mode: dunkler Stahlgriff, hebt sich klar von der hellen Laufbahn ab */
:root[data-theme="light"] input[type="range"]::-webkit-slider-thumb {
  background: linear-gradient(180deg, #78808c, #4b525c);
  border-color: #fdfdfe;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}
:root[data-theme="light"] input[type="range"]::-moz-range-thumb {
  background: linear-gradient(180deg, #78808c, #4b525c);
  border-color: #fdfdfe;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}
:root[data-theme="light"] input[type="range"]:hover::-webkit-slider-thumb {
  background: linear-gradient(180deg, #8b93a0, #5a626d);
}
:root[data-theme="light"] input[type="range"]:hover::-moz-range-thumb {
  background: linear-gradient(180deg, #8b93a0, #5a626d);
}

.row .rangewrap { display: flex; align-items: center; gap: 8px; }
.row .rangewrap input[type="number"] { width: 64px; }

/* Checkbox: Schalterfeld statt Browser-Häkchen */
input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 15px;
  height: 15px;
  margin: 0;
  background: var(--bg-inset);
  border: 1px solid var(--line-strong);
  border-radius: 3px;
  cursor: pointer;
  flex: 0 0 auto;
}
input[type="checkbox"]:hover { border-color: var(--muted); }
input[type="checkbox"]:checked {
  background-color: var(--accent);
  border-color: var(--accent);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='8'%3E%3Cpath d='M1 4l3 3 5-6' fill='none' stroke='%2317110c' stroke-width='2'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
}
input[type="checkbox"]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

/* Farbfelder: gefasste Muster-Chips */
input[type="color"] {
  appearance: none;
  -webkit-appearance: none;
  width: 36px;
  height: 22px;
  padding: 2px;
  background: var(--bg-inset);
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  cursor: pointer;
}
input[type="color"]:hover { border-color: var(--muted); }
input[type="color"]:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
input[type="color"]::-webkit-color-swatch { border: none; border-radius: 2px; }
input[type="color"]::-moz-color-swatch { border: none; border-radius: 2px; }

/* ---------- Listen-Editoren (Zonen, Texte, Stützpunkte) ---------- */

.listeditor {
  padding: 8px 16px 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
/* Karte pro Eintrag: jedes Feld trägt sein eigenes Label */
.listitem {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 10px;
  padding: 10px 30px 10px 10px; /* rechts Platz für den Entfernen-Knopf */
  border: 1px solid var(--line);
  border-radius: 8px;
}
.fielditem {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1 1 56px;
  min-width: 56px;
  cursor: pointer;
}
.fielditem.wide { flex: 1 1 100%; }
.fieldlabel {
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.fielditem input {
  width: 100%;
  min-width: 0;
  background: var(--bg-inset);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 3px 6px;
  font-size: 12px;
}
.fielditem input[type="color"] { height: 24px; padding: 2px; }
.fielditem input[type="checkbox"] { width: 15px; height: 15px; padding: 0; }
.listitem .logothumb {
  flex: 0 0 34px;
  width: 34px;
  height: 34px;
  align-self: center;
  object-fit: contain;
  background: var(--bg-inset);
  border: 1px solid var(--line);
  border-radius: 4px;
}
.listitem .del {
  position: absolute;
  top: 3px;
  right: 3px;
  padding: 1px 7px;
  background: transparent;
  border-color: transparent;
  color: var(--muted);
}
.listitem .del:hover {
  color: var(--err);
  border-color: var(--err);
  background: transparent;
}
.listeditor .add {
  align-self: flex-start;
  margin-top: 4px;
  font-size: 12px;
  padding: 4px 12px;
  background: transparent;
  border: 1px dashed var(--line-strong);
  color: var(--muted);
}
.listeditor .add:hover {
  color: var(--text);
  border-style: solid;
  border-color: var(--muted);
  background: transparent;
}

/* ---------- Foto-Ausrichter ---------- */

#aligner {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: var(--overlay-scrim);
  display: flex;
  flex-direction: column;
}
#aligner .aligner-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 16px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
}
#aligner svg {
  flex: 1;
  width: 100%;
  min-height: 0;
  touch-action: none;
  cursor: crosshair;
}

/* ---------- Segment-Gruppen: Sprache, Hilfe/Theme ---------- */

#lang-switch, #actions .seg, .welcome-lang { display: flex; }
#lang-switch button, #actions .seg button, .welcome-lang button { border-radius: 0; }
#lang-switch button:first-child, #actions .seg button:first-child, .welcome-lang button:first-child { border-radius: 4px 0 0 4px; }
#lang-switch button:last-child, #actions .seg button:last-child, .welcome-lang button:last-child { border-radius: 0 4px 4px 0; margin-left: -1px; }
#lang-switch button { padding: 0 10px; font-size: 12px; font-weight: 600; letter-spacing: 0.04em; }
#lang-switch button.active, .welcome-lang button.active {
  position: relative;
  z-index: 1;
  background: var(--accent);
  border-color: var(--accent);
  color: #17110c;
  opacity: 1;
}

/* ---------- Welcome ---------- */

#welcome {
  position: fixed; inset: 0; z-index: 200;
  background: color-mix(in srgb, var(--bg-stage) 88%, transparent);
  backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
.welcome-card {
  position: relative; isolation: isolate; overflow: hidden;
  max-width: 480px; width: 100%;
  background: var(--bg-panel); border: 1px solid var(--line); border-radius: 12px;
  padding: 32px; display: flex; flex-direction: column; gap: 16px;
  box-shadow: 0 32px 80px rgba(0, 0, 0, 0.5), 0 4px 16px rgba(0, 0, 0, 0.3);
}
:root[data-theme="light"] .welcome-card {
  box-shadow: 0 32px 80px rgba(63, 66, 74, 0.30), 0 4px 16px rgba(63, 66, 74, 0.16);
}
/* Dezente Tacho-Deko: Skalenstrich-Ring als Data-URI-Maske in Themefarbe */
.welcome-card::before {
  content: "";
  position: absolute;
  z-index: -1;
  top: -60px;
  right: -55px;
  width: 230px;
  height: 230px;
  pointer-events: none;
  background: var(--muted);
  opacity: 0.14;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 120 120'%3E%3Cg stroke='%23000' stroke-width='2' stroke-linecap='round' fill='none'%3E%3Cpath d='M33.0 106.8L38.5 97.2M25.3 101.4L28.8 97.2M18.6 94.7L22.8 91.2M13.2 87.0L22.8 81.5M9.3 78.5L14.4 76.6M6.8 69.4L12.2 68.4M6.0 60.0L17.0 60.0M6.8 50.6L12.2 51.6M9.3 41.5L14.4 43.4M13.2 33.0L22.8 38.5M18.6 25.3L22.8 28.8M25.3 18.6L28.8 22.8M33.0 13.2L38.5 22.8M41.5 9.3L43.4 14.4M50.6 6.8L51.6 12.2M60.0 6.0L60.0 17.0M69.4 6.8L68.4 12.2M78.5 9.3L76.6 14.4M87.0 13.2L81.5 22.8M94.7 18.6L91.2 22.8M101.4 25.3L97.2 28.8M106.8 33.0L97.2 38.5M110.7 41.5L105.6 43.4M113.2 50.6L107.8 51.6M114.0 60.0L103.0 60.0M113.2 69.4L107.8 68.4M110.7 78.5L105.6 76.6M106.8 87.0L97.2 81.5M101.4 94.7L97.2 91.2M94.7 101.4L91.2 97.2M87.0 106.8L81.5 97.2' /%3E%3Cpath d='M60 60L47 24.3' stroke-width='2.5'/%3E%3C/g%3E%3Ccircle cx='60' cy='60' r='3.5' fill='%23000'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 120 120'%3E%3Cg stroke='%23000' stroke-width='2' stroke-linecap='round' fill='none'%3E%3Cpath d='M33.0 106.8L38.5 97.2M25.3 101.4L28.8 97.2M18.6 94.7L22.8 91.2M13.2 87.0L22.8 81.5M9.3 78.5L14.4 76.6M6.8 69.4L12.2 68.4M6.0 60.0L17.0 60.0M6.8 50.6L12.2 51.6M9.3 41.5L14.4 43.4M13.2 33.0L22.8 38.5M18.6 25.3L22.8 28.8M25.3 18.6L28.8 22.8M33.0 13.2L38.5 22.8M41.5 9.3L43.4 14.4M50.6 6.8L51.6 12.2M60.0 6.0L60.0 17.0M69.4 6.8L68.4 12.2M78.5 9.3L76.6 14.4M87.0 13.2L81.5 22.8M94.7 18.6L91.2 22.8M101.4 25.3L97.2 28.8M106.8 33.0L97.2 38.5M110.7 41.5L105.6 43.4M113.2 50.6L107.8 51.6M114.0 60.0L103.0 60.0M113.2 69.4L107.8 68.4M110.7 78.5L105.6 76.6M106.8 87.0L97.2 81.5M101.4 94.7L97.2 91.2M94.7 101.4L91.2 97.2M87.0 106.8L81.5 97.2' /%3E%3Cpath d='M60 60L47 24.3' stroke-width='2.5'/%3E%3C/g%3E%3Ccircle cx='60' cy='60' r='3.5' fill='%23000'/%3E%3C/svg%3E") center / contain no-repeat;
}
/* ---------- Export-Modal ---------- */

#export-modal {
  position: fixed; inset: 0; z-index: 200;
  background: color-mix(in srgb, var(--bg-stage) 88%, transparent);
  backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center; padding: 24px;
  animation: modal-fade 150ms ease-out;
}
.modal-card {
  max-width: 420px; width: 100%;
  background: var(--bg-panel); border: 1px solid var(--line); border-radius: 12px;
  padding: 24px; display: flex; flex-direction: column; gap: 14px;
  box-shadow: 0 32px 80px rgba(0, 0, 0, 0.5), 0 4px 16px rgba(0, 0, 0, 0.3);
  animation: modal-rise 190ms cubic-bezier(0.2, 0.8, 0.3, 1);
}
:root[data-theme="light"] .modal-card {
  box-shadow: 0 32px 80px rgba(63, 66, 74, 0.30), 0 4px 16px rgba(63, 66, 74, 0.16);
}
@keyframes modal-fade { from { opacity: 0; } }
@keyframes modal-rise { from { opacity: 0; transform: translateY(10px) scale(0.98); } }
.modal-card h2 {
  margin: 0;
  font-family: 'Barlow Condensed', var(--font-ui);
  font-size: 21px;
  font-weight: normal;
  text-transform: uppercase;
}

/* Formatwahl: zwei Kacheln — derselbe Tacho als Vektor und als Pixel */
.exp-formats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.exp-tile {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  padding: 14px 14px 12px;
  background: var(--bg-inset);
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  white-space: normal;
  text-align: left;
  color: var(--muted);
  transition: border-color 120ms ease, box-shadow 120ms ease, color 120ms ease;
}
.exp-tile:hover { background: var(--bg-inset); border-color: var(--muted); }
.exp-tile:active:not(:disabled) { background: var(--bg-inset); box-shadow: none; }
.exp-tile .exp-icon { width: 44px; height: 44px; margin-bottom: 8px; }
.exp-tile .exp-ext {
  font-family: 'Barlow Condensed', var(--font-ui);
  font-size: 19px;
  letter-spacing: 0.04em;
  color: var(--text);
}
.exp-tile .exp-desc { font-size: 11.5px; line-height: 1.45; }
.exp-tile[aria-pressed="true"] {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent), 0 0 0 4px var(--accent-soft);
  color: var(--text);
}
.exp-tile[aria-pressed="true"] .exp-desc { color: var(--muted); }
.exp-tile[aria-pressed="true"] .exp-ext { color: var(--accent); }

/* Spenden-Dialog: Popover über dem Spenden-Button unten rechts */
#donate-modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  padding: 16px 16px 56px; /* Karte landet über dem ♥-Button */
  animation: modal-fade 150ms ease-out;
}
#donate-modal .modal-card { max-width: 360px; }
#donate-modal h2 { display: flex; align-items: center; font-size: 18px; }
#donate-modal .donate-logo { width: 26px; height: 26px; margin-right: 10px; }
#donate-modal .donate-text { margin: 0; font-size: 13px; line-height: 1.6; color: var(--muted); }
#donate-modal a.filebtn { text-decoration: none; display: inline-flex; align-items: center; }

.exp-options { border-top: 1px solid var(--line); padding-top: 14px; }
.modal-row { display: flex; align-items: center; gap: 10px; font-size: 13px; cursor: pointer; min-height: 29px; }
.modal-row[hidden] { display: none; }
.modal-row input[type="number"] { width: 84px; margin-left: auto; }

/* Toggle-Schalter im Modal: Knauf in Slider-Optik, Track im Primär-Orange */
.modal-row input[type="checkbox"] {
  width: 34px;
  height: 20px;
  border-radius: 10px;
  position: relative;
  transition: background-color 140ms ease, border-color 140ms ease;
}
.modal-row input[type="checkbox"]::before {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: linear-gradient(180deg, #f2f4f6, #c9cfd6);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
  transition: transform 140ms cubic-bezier(0.2, 0.8, 0.3, 1);
}
.modal-row input[type="checkbox"]:checked {
  background: linear-gradient(180deg, #f9853d, #e56a1f);
  border-color: #b25017;
}
.modal-row input[type="checkbox"]:checked::before {
  transform: translateX(14px);
  background: linear-gradient(180deg, #fffdfb, #f4e3d4);
}
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }

.welcome-card h1 {
  margin: 0;
  font-family: 'Barlow Condensed', var(--font-ui);
  font-size: 27px;
  font-weight: normal;
  text-transform: uppercase;
  display: flex;
  align-items: center;
}
.welcome-card h1 .welcome-logo { width: 40px; height: 40px; display: block; margin-right: 12px; }
.welcome-card h1 span { color: var(--accent); }
.welcome-lang { position: absolute; top: 16px; right: 16px; }
.welcome-lang button {
  height: 26px;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
}
.welcome-tagline { margin: 0; color: var(--text); font-size: 15px; line-height: 1.55; }
.welcome-privacy {
  margin: 0;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12.5px;
}
.welcome-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.welcome-actions button { flex: 1; height: 32px; }
.welcome-card > .primary { height: 36px; font-size: 14px; }
