:root {
  --grund: #f4f5f7;
  --flaeche: #ffffff;
  --text: #14181f;
  --leise: #5b6270;
  --linie: #d9dde3;
  --akzent: #1f5fd1;
  --akzent-text: #ffffff;
  --w1: #b3261e; --w1g: #fbe3e1;
  --w2: #b8540c; --w2g: #fde6d4;
  --w3: #8a6a00; --w3g: #fbf0c9;
  --w4: #2c6e31; --w4g: #e2f2e3;
  --w5: #17501b; --w5g: #cfe9d1;
  --wq: #4d4d4d; --wqg: #e9e9e9;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --grund: #101318; --flaeche: #1a1e25; --text: #eef0f3; --leise: #a6adb9; --linie: #323844;
    --akzent: #7aa7ff; --akzent-text: #0c1424;
    --w1: #ff9a92; --w1g: #3d1d1b; --w2: #ffb680; --w2g: #3d2717; --w3: #f0d070; --w3g: #3a3115;
    --w4: #8fd694; --w4g: #1d3420; --w5: #b6ecb9; --w5g: #173019; --wq: #c8c8c8; --wqg: #2e2e2e;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0; background: var(--grund); color: var(--text);
  font: 400 1rem/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: calc(24px + env(safe-area-inset-bottom));
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--akzent); outline-offset: 2px; }
.huelle { width: 100%; max-width: 560px; margin: 0 auto; padding: 0 16px; }
h1, h2, h3 { margin: 0; line-height: 1.2; }

/* Kopf */
.kopf { background: var(--flaeche); border-bottom: 1px solid var(--linie); padding-top: calc(16px + env(safe-area-inset-top)); }
.kopf h1 { font-size: 1.4rem; font-weight: 700; }
.datum { margin: 2px 0 12px; color: var(--leise); font-size: .9rem; }
.reiter { display: flex; }
.reiter button {
  flex: 1; min-height: 48px; border: 0; background: none; color: var(--leise);
  border-bottom: 3px solid transparent; font-weight: 600;
}
.reiter button[aria-pressed="true"] { color: var(--akzent); border-bottom-color: var(--akzent); }

main { padding-top: 16px; display: flex; flex-direction: column; gap: 14px; }

/* Bausteine */
.karte { background: var(--flaeche); border: 1px solid var(--linie); border-radius: 12px; padding: 14px; }
.zeile { display: flex; align-items: center; gap: 8px; }
.zeile > .wachsen { flex: 1; min-width: 0; }
.leise { color: var(--leise); font-size: .9rem; }
.knopf {
  min-height: 48px; padding: 0 18px; border-radius: 10px; border: 1px solid var(--linie);
  background: var(--flaeche); font-weight: 600;
}
.knopf.haupt { background: var(--akzent); color: var(--akzent-text); border-color: var(--akzent); }
.knopf.gefahr { color: var(--w1); border-color: var(--w1); }
.knopf:disabled { opacity: .45; cursor: not-allowed; }
.knopf.klein { min-height: 44px; min-width: 44px; padding: 0 10px; }
.knopfreihe { display: flex; flex-wrap: wrap; gap: 8px; }
.knopfreihe .knopf { flex: 1 1 auto; }

/* Tag */
.tagwahl { display: grid; grid-template-columns: 48px 1fr 48px; align-items: center; gap: 8px; }
.tagwahl strong { text-align: center; }
.zeiten { display: flex; gap: 6px; background: var(--flaeche); border: 1px solid var(--linie); border-radius: 12px; padding: 5px; }
.zeiten button {
  flex: 1; min-height: 56px; border: 0; border-radius: 9px; background: none; color: var(--leise);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
}
.zeiten button strong { color: var(--text); }
.zeiten button[aria-pressed="true"] { background: var(--akzent); }
.zeiten button[aria-pressed="true"], .zeiten button[aria-pressed="true"] strong { color: var(--akzent-text); }
.zeiten small { font-size: .78rem; }

.punkt { margin: 0; border: 1px solid var(--linie); border-radius: 12px; padding: 12px 14px; background: var(--flaeche); }
.punkt legend { padding: 0; font-weight: 600; float: left; width: 100%; margin-bottom: 10px; display: flex; justify-content: space-between; gap: 8px; }
.punkt legend .wert { font-weight: 600; font-size: .85rem; }
.skala { clear: both; display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.skala button {
  min-height: 48px; border-radius: 9px; border: 2px solid var(--linie); background: var(--grund);
  font-weight: 700; color: var(--leise);
}
.skala button[aria-pressed="true"] { border-color: currentColor; }

.w1 { color: var(--w1) !important; background: var(--w1g) !important; }
.w2 { color: var(--w2) !important; background: var(--w2g) !important; }
.w3 { color: var(--w3) !important; background: var(--w3g) !important; }
.w4 { color: var(--w4) !important; background: var(--w4g) !important; }
.w5 { color: var(--w5) !important; background: var(--w5g) !important; }
.wq { color: var(--wq) !important; background: var(--wqg) !important; }

.legende { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: .85rem; color: var(--leise); }
.legende span b { display: inline-block; min-width: 1.6em; text-align: center; border-radius: 5px; margin-right: 4px; }

/* Woche */
.tabelle-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: .85rem; }
caption { text-align: left; font-weight: 700; padding: 0 0 8px; }
th, td { padding: 4px 2px; text-align: center; border-bottom: 1px solid var(--linie); }
th[scope="row"] { text-align: left; font-weight: 500; padding-right: 6px; max-width: 9em; }
thead th { color: var(--leise); font-weight: 600; }
thead th.heute { color: var(--akzent); }
td span { display: inline-flex; width: 28px; height: 28px; align-items: center; justify-content: center; border-radius: 6px; font-weight: 700; }

/* Einstellungen */
.liste { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.liste input { width: 100%; min-height: 44px; padding: 0 10px; border: 1px solid var(--linie); border-radius: 8px; background: var(--grund); }
.feld { display: flex; flex-direction: column; gap: 4px; }
.feld input { min-height: 48px; padding: 0 12px; border: 1px solid var(--linie); border-radius: 8px; background: var(--grund); }
.hinweis { border-left: 4px solid var(--w3); padding: 8px 12px; background: var(--w3g); border-radius: 4px; font-size: .9rem; color: var(--text); }
details summary { cursor: pointer; font-weight: 600; min-height: 44px; display: flex; align-items: center; }

.meldung {
  position: fixed; left: 50%; bottom: calc(16px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  margin: 0; padding: 10px 16px; border-radius: 10px; background: var(--text); color: var(--grund);
  font-weight: 600; opacity: 0; pointer-events: none; transition: opacity .2s;
}
.meldung.an { opacity: 1; }

@media (prefers-reduced-motion: reduce) { .meldung { transition: none; } }
