:root {
  --grund: #f4f1ea;
  --flaeche: #ffffff;
  --flaeche-2: #efebe2;
  --text: #2b2a27;
  --leise: #6d695f;
  --linie: #d8d2c4;
  --akzent: #2f6f4e;
  --akzent-text: #ffffff;
  --fehler: #b3261e;
  --warnung: #9a6400;
  --schatten: 0 2px 10px rgba(0, 0, 0, 0.12);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --grund: #1b1c1a;
    --flaeche: #252623;
    --flaeche-2: #2e302c;
    --text: #ebe8e1;
    --leise: #a6a297;
    --linie: #42443e;
    --akzent: #5fae86;
    --akzent-text: #10130f;
    --fehler: #ff8a80;
    --warnung: #f0b44c;
    --schatten: 0 2px 10px rgba(0, 0, 0, 0.5);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--grund);
  color: var(--text);
  font: 14px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
[hidden] { display: none !important; }
h1 { font-size: 1.4rem; margin: 0 0 4px; }
h2 { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--leise); margin: 0 0 8px; }
h3 { font-size: 1rem; margin: 14px 0 6px; }
.leise { color: var(--leise); }
.klein { font-size: 12px; }
.fehler { color: var(--fehler); }
.warnung { color: var(--warnung); }

button, input, select, textarea {
  font: inherit;
  color: inherit;
}
button {
  background: var(--flaeche-2);
  border: 1px solid var(--linie);
  border-radius: 6px;
  padding: 5px 10px;
  cursor: pointer;
}
button:hover { border-color: var(--leise); }
button.haupt { background: var(--akzent); color: var(--akzent-text); border-color: var(--akzent); }
button.gefahr { color: var(--fehler); }
button:disabled { opacity: 0.5; cursor: default; }
input, select, textarea {
  background: var(--flaeche);
  border: 1px solid var(--linie);
  border-radius: 6px;
  padding: 5px 8px;
  min-width: 0;
}
textarea { width: 100%; resize: vertical; }
label { display: block; margin: 8px 0; }
label > input:not([type=checkbox]):not([type=radio]), label > select, label > textarea { display: block; width: 100%; margin-top: 3px; }
:focus-visible { outline: 2px solid var(--akzent); outline-offset: 1px; }

/* Anmeldung */
.anmeldung { display: grid; place-items: center; min-height: 100%; padding: 16px; }
.karte-box {
  background: var(--flaeche);
  border: 1px solid var(--linie);
  border-radius: 10px;
  padding: 22px;
  width: min(380px, 100%);
  box-shadow: var(--schatten);
}

/* Grundaufbau */
.app {
  display: grid;
  grid-template-columns: 250px 1fr 340px;
  grid-template-rows: auto 1fr;
  height: 100%;
}
.kopf {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--flaeche);
  border-bottom: 1px solid var(--linie);
  flex-wrap: wrap;
}
.titel { font-size: 15px; }
.weltinfo { font-size: 12px; }
.suche { display: flex; gap: 6px; margin-left: auto; flex: 0 1 380px; }
.suche input { flex: 1; }
.leiste {
  background: var(--flaeche);
  overflow: auto;
  min-height: 0;
}
.links { border-right: 1px solid var(--linie); padding: 12px; display: flex; flex-direction: column; gap: 16px; }
.rechts { border-left: 1px solid var(--linie); display: flex; flex-direction: column; }
.wachsen { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.zeile { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }
.zeile input { flex: 1; }
.haekchenliste label { display: flex; gap: 8px; align-items: center; margin: 4px 0; }

.krliste { overflow: auto; flex: 1; min-height: 120px; }
.kr {
  display: grid;
  grid-template-columns: auto 14px 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 3px 4px;
  border-radius: 5px;
  margin: 0;
}
.kr:hover { background: var(--flaeche-2); }
.kr.eigenes { font-weight: 600; background: var(--flaeche-2); }
.farbpunkt { width: 14px; height: 14px; border-radius: 3px; border: 1px solid rgba(0, 0, 0, 0.25); }
.zahl { color: var(--leise); font-size: 12px; font-variant-numeric: tabular-nums; }

/* Karte */
.kartenbereich { position: relative; overflow: hidden; min-height: 0; background: #cfd6c4; }
#karte { display: block; width: 100%; height: 100%; touch-action: none; cursor: grab; }
#karte.ziehen { cursor: grabbing; }
.hover {
  position: absolute;
  pointer-events: none;
  background: var(--flaeche);
  border: 1px solid var(--linie);
  border-radius: 6px;
  padding: 6px 8px;
  font-size: 12px;
  box-shadow: var(--schatten);
  max-width: 260px;
}
.zoomknoepfe { position: absolute; right: 12px; bottom: 12px; display: flex; flex-direction: column; gap: 4px; }
.zoomknoepfe button { width: 36px; height: 36px; font-size: 18px; padding: 0; background: var(--flaeche); box-shadow: var(--schatten); }
.meldung {
  position: absolute;
  left: 50%;
  top: 12px;
  transform: translateX(-50%);
  background: var(--flaeche);
  border: 1px solid var(--linie);
  border-radius: 8px;
  padding: 8px 14px;
  box-shadow: var(--schatten);
  max-width: min(520px, calc(100% - 32px));
}
.meldung.fehler { border-color: var(--fehler); }

/* Reiter rechts */
.reiter { display: flex; border-bottom: 1px solid var(--linie); position: sticky; top: 0; background: var(--flaeche); z-index: 1; }
.reiter button { flex: 1; border: 0; border-radius: 0; background: none; padding: 10px 4px; border-bottom: 2px solid transparent; }
.reiter button[aria-selected=true] { border-bottom-color: var(--akzent); font-weight: 600; }
.reiterinhalt { padding: 12px; }
.infotabelle { width: 100%; border-collapse: collapse; }
.infotabelle th { text-align: left; font-weight: normal; color: var(--leise); padding: 2px 8px 2px 0; vertical-align: top; width: 40%; }
.infotabelle td { padding: 2px 0; }
.box { border: 1px solid var(--linie); border-radius: 8px; padding: 10px; margin: 10px 0; background: var(--flaeche-2); }
.knopfzeile { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.liste { list-style: none; margin: 0; padding: 0; }
.liste li { border-bottom: 1px solid var(--linie); }
.liste li > button {
  display: flex; gap: 8px; width: 100%; text-align: left; border: 0; border-radius: 0; background: none; padding: 6px 2px; align-items: center;
}
.liste li > button:hover { background: var(--flaeche-2); }
.liste .rechtsbuendig { margin-left: auto; color: var(--leise); font-variant-numeric: tabular-nums; }
.vorlage { display: grid; grid-template-columns: auto auto 1fr; gap: 6px 8px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--linie); }
.vorlage .beschreibung { grid-column: 3; font-size: 12px; color: var(--leise); }
.marke { display: inline-block; font-size: 11px; padding: 0 6px; border-radius: 9px; background: var(--flaeche-2); border: 1px solid var(--linie); }
.marke.frei { color: var(--akzent); border-color: var(--akzent); }

.nur-schmal { display: none; }

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .nur-schmal { display: inline-block; }
  .weltinfo, #benutzer { display: none; }
  .suche { order: 10; flex-basis: 100%; margin-left: 0; }
  .leiste {
    position: fixed;
    top: 0; bottom: 0;
    width: min(360px, 90vw);
    z-index: 20;
    box-shadow: var(--schatten);
    transform: translateX(-105%);
    transition: transform 0.2s;
  }
  .leiste.links { left: 0; }
  .leiste.rechts { right: 0; left: auto; transform: translateX(105%); }
  .leiste.offen { transform: none; }
  .kartenbereich { grid-column: 1; }
  .links > [data-schliessen] { align-self: flex-start; }
  .schliessen-rechts { margin: 8px 12px; align-self: flex-start; }
  .reiter { top: 0; }
}
