/* =========================================================================
   Vereinsplaner - Design "Vereinsheim-Schichtplan"
   Ruhige Sandflaeche, ein einziger Kiefern-Akzent. Die Wunschfarben der
   Mitglieder sind die eigentlichen Farbtupfer -> Chrome bleibt neutral.
   Systemschriften (kein Font-Download), Wirkung ueber Groesse & Gewicht.
   ========================================================================= */

:root {
  --bg: #e6e9e3;
  --surface: #ffffff;
  --surface-2: #f2f4ef;
  --ink: #1b211c;
  --muted: #586158;
  --line: #cfd5cb;
  --accent: #2f6b4f;
  --accent-hover: #275b43;
  --accent-ink: #ffffff;
  --danger: #a52019;
  --danger-ink: #ffffff;
  --focus: #1f6feb;
  --shadow: 0 1px 2px rgba(20,30,20,.06), 0 6px 20px rgba(20,30,20,.06);

  --scale: 1;              /* Zoom-Regler multipliziert diesen Wert */
  --step: 1rem;
  --radius: 10px;
  --radius-lg: 16px;
  --touch: 44px;           /* Mindest-Touchziel */
  font-size: calc(18px * var(--scale));
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12160f;
    --surface: #1c211b;
    --surface-2: #262c24;
    --ink: #e8ebe4;
    --muted: #a4ad9f;
    --line: #343b31;
    --accent: #63b98c;
    --accent-hover: #74c79a;
    --accent-ink: #0c130d;
    --danger: #f2857c;
    --danger-ink: #1a0c0b;
    --focus: #6ea8ff;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.35);
  }
}
:root[data-theme="dark"] {
  --bg: #12160f; --surface: #1c211b; --surface-2: #262c24;
  --ink: #e8ebe4; --muted: #a4ad9f; --line: #343b31;
  --accent: #63b98c; --accent-hover: #74c79a; --accent-ink: #0c130d;
  --danger: #f2857c; --danger-ink: #1a0c0b; --focus: #6ea8ff;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.35);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

/* --- Fokus immer deutlich sichtbar (a11y) --- */
:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-radius: 6px;
}
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

.skip-link {
  position: absolute; left: -999px; top: 0;
  background: var(--accent); color: var(--accent-ink);
  padding: .6em 1em; border-radius: 0 0 var(--radius) 0; z-index: 100;
}
.skip-link:focus { left: 0; }

/* ---------------------------------------------------------------- Layout */
.wrap { max-width: 1180px; margin: 0 auto; padding: 0 clamp(.75rem, 3vw, 1.5rem) 5rem; }

header.app {
  position: sticky; top: 0; z-index: 40;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.app-bar {
  max-width: 1180px; margin: 0 auto;
  display: flex; align-items: center; gap: .75rem;
  padding: .6rem clamp(.75rem, 3vw, 1.5rem);
}
.brand {
  display: flex; align-items: center; gap: .55rem;
  font-weight: 700; font-size: 1.15rem; letter-spacing: -0.01em;
  text-decoration: none; color: inherit; margin-right: auto;
}
.brand .mark {
  width: 1.7em; height: 1.7em; border-radius: 7px;
  background: var(--accent); color: var(--accent-ink);
  display: grid; place-items: center; font-size: .9em; font-weight: 800;
}
.bar-tools { display: flex; align-items: center; gap: .4rem; }

/* ------------------------------------------------------------- Buttons */
button, .btn {
  font: inherit; cursor: pointer;
  min-height: var(--touch);
  display: inline-flex; align-items: center; justify-content: center; gap: .45em;
  padding: .5em .95em;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  transition: background .12s, border-color .12s, transform .05s;
}
button:hover, .btn:hover { background: var(--surface-2); }
button:active, .btn:active { transform: translateY(1px); }
.btn-primary {
  background: var(--accent); color: var(--accent-ink); border-color: transparent;
  font-weight: 650;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, var(--line)); background: var(--surface); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--surface-2); }
.icon-btn { min-width: var(--touch); padding: .5em; }
.btn-sm { min-height: 36px; padding: .3em .7em; font-size: .92rem; }
button[disabled], .btn[disabled] { opacity: .5; cursor: not-allowed; }

/* Identitaets-Chip in der Leiste */
.identity {
  display: inline-flex; align-items: center; gap: .5em;
  border: 1px solid var(--line); background: var(--surface);
  border-radius: 999px; padding: .3em .8em .3em .35em; min-height: var(--touch);
}
.identity .swatch {
  width: 1.4em; height: 1.4em; border-radius: 50%;
  border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--line);
}
.identity .who { font-weight: 600; max-width: 8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------------------------------------------------------------- Hero */
.hero { padding: 1.4rem 0 .6rem; }
.hero h1 { font-size: clamp(1.5rem, 5vw, 2rem); line-height: 1.1; margin: 0 0 .2rem; letter-spacing: -0.02em; }
.hero p.sub { color: var(--muted); margin: 0 0 1rem; }

/* Naechster Einsatz - das eine hervorgehobene Element */
.next-shift {
  background: var(--surface); border: 1px solid var(--line);
  border-left: 6px solid var(--accent);
  border-radius: var(--radius-lg); padding: 1.1rem 1.2rem; box-shadow: var(--shadow);
  display: grid; gap: .6rem;
}
.next-shift .when { display: flex; flex-wrap: wrap; align-items: baseline; gap: .5rem 1rem; }
.next-shift .date-big { font-size: 1.5rem; font-weight: 750; letter-spacing: -0.01em; }
.next-shift .time { color: var(--muted); font-variant-numeric: tabular-nums; }
.next-shift h2 { margin: 0; font-size: 1.15rem; }
.next-shift .loc { color: var(--muted); font-size: .95rem; }

/* Teilnehmer-Chips (Wunschfarben!) */
.people { display: flex; flex-wrap: wrap; gap: .4rem; }
.chip {
  display: inline-flex; align-items: center; gap: .4em;
  padding: .28em .7em; border-radius: 999px;
  font-size: .92rem; font-weight: 600; line-height: 1.2;
  border: 1px solid rgba(0,0,0,.08);
}
.chip.empty { background: var(--surface-2); color: var(--muted); font-weight: 500; border-style: dashed; }
.chip .dot { width: .6em; height: .6em; border-radius: 50%; background: currentColor; opacity: .55; }

/* --------------------------------------------------------- View-Umschalter */
.toolbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: .6rem;
  margin: 1.6rem 0 .8rem;
}
.segmented { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 3px; }
.segmented button { border: none; background: transparent; min-height: 38px; padding: .3em .8em; border-radius: 7px; font-weight: 600; }
.segmented button[aria-pressed="true"] { background: var(--surface); box-shadow: var(--shadow); color: var(--accent); }
.nav-week { display: inline-flex; align-items: center; gap: .3rem; margin-left: auto; }
.nav-week .range { min-width: 9rem; text-align: center; font-weight: 600; font-variant-numeric: tabular-nums; }
.spacer { flex: 1; }

/* ---------------------------------------------------------- Wochenansicht */
.week { display: grid; gap: .7rem; }
.day {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden;
}
.day.today { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.day > .day-head {
  display: flex; align-items: baseline; gap: .5rem;
  padding: .55rem .8rem; background: var(--surface-2); border-bottom: 1px solid var(--line);
}
.day-head .dow { font-weight: 700; }
.day-head .dnum { color: var(--muted); font-variant-numeric: tabular-nums; }
.day-head .badge { margin-left: auto; font-size: .8rem; color: var(--muted); }
.day.today .day-head .dow::after { content: " · heute"; color: var(--accent); font-weight: 700; }
.day-body { padding: .5rem .8rem .7rem; display: grid; gap: .45rem; }
.day-empty { color: var(--muted); font-size: .92rem; padding: .2rem 0; }

.ev {
  width: 100%; text-align: left; display: grid; gap: .35rem;
  padding: .6rem .7rem; border-radius: var(--radius);
  border: 1px solid var(--line); background: var(--surface);
  border-left: 5px solid var(--accent);
}
.ev.note { border-left-color: var(--muted); background: var(--surface-2); }
.ev:hover { background: var(--surface-2); }
.ev .ev-top { display: flex; gap: .5rem; align-items: baseline; }
.ev .ev-time { font-variant-numeric: tabular-nums; color: var(--muted); font-size: .9rem; white-space: nowrap; }
.ev .ev-title { font-weight: 650; }
.ev .mini-people { display: flex; flex-wrap: wrap; gap: .3rem; }
.ev .mini { width: 1.5em; height: 1.5em; border-radius: 50%; display: grid; place-items: center; font-size: .72rem; font-weight: 700; border: 1px solid rgba(0,0,0,.12); }

/* ---------------------------------------------------------- Monatsansicht */
.month-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.month-grid .dow-h { text-align: center; font-size: .8rem; color: var(--muted); font-weight: 700; padding: .3rem 0; }
.mcell {
  min-height: 4.2em; background: var(--surface); border: 1px solid var(--line);
  border-radius: 8px; padding: .3rem; display: flex; flex-direction: column; gap: .2rem;
  text-align: left; align-items: stretch;
}
.mcell.out { opacity: .4; }
.mcell.today { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.mcell .mnum { font-size: .85rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.mcell .dots { display: flex; flex-wrap: wrap; gap: 2px; margin-top: auto; }
.mcell .cdot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
.mcell .more { font-size: .7rem; color: var(--muted); }

/* ---------------------------------------------------------- Schichtplan */
.roster { display: grid; gap: .7rem; }
.roster .slot {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  display: grid; grid-template-columns: 5.5rem 1fr; overflow: hidden;
}
.roster .slot .rail {
  background: var(--accent); color: var(--accent-ink);
  padding: .7rem .5rem; display: grid; align-content: center; text-align: center; gap: .1rem;
}
.roster .slot.note .rail { background: var(--muted); }
.roster .rail .r-day { font-weight: 800; font-size: 1.3rem; line-height: 1; font-variant-numeric: tabular-nums; }
.roster .rail .r-mon { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; opacity: .9; }
.roster .rail .r-time { font-size: .78rem; opacity: .9; margin-top: .2rem; }
.roster .slot .r-body { padding: .7rem .9rem; display: grid; gap: .5rem; align-content: start; }
.roster .r-body h3 { margin: 0; font-size: 1.05rem; }

/* --------------------------------------------------------------- Sektion */
.section { margin-top: 2rem; }
.section > h2 { font-size: 1.1rem; margin: 0 0 .7rem; display: flex; align-items: center; gap: .5rem; }
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: .9rem 1rem;
}
.empty-note { color: var(--muted); background: var(--surface-2); border: 1px dashed var(--line); border-radius: var(--radius); padding: 1rem; }

/* --------------------------------------------------------------- Dialoge */
dialog {
  border: 1px solid var(--line); border-radius: var(--radius-lg);
  padding: 0; background: var(--surface); color: var(--ink);
  width: min(560px, 94vw); box-shadow: var(--shadow);
}
dialog::backdrop { background: rgba(10,15,10,.45); }
.dlg-head { display: flex; align-items: center; gap: .5rem; padding: 1rem 1.1rem .3rem; }
.dlg-head h2 { margin: 0; font-size: 1.2rem; }
.dlg-head .close { margin-left: auto; }
.dlg-body { padding: .6rem 1.1rem 1.1rem; display: grid; gap: .9rem; }
.dlg-foot { display: flex; gap: .6rem; padding: 0 1.1rem 1.1rem; flex-wrap: wrap; }
.dlg-foot .spacer { flex: 1; }

/* --------------------------------------------------------------- Formular */
.field { display: grid; gap: .3rem; }
.field label { font-weight: 600; font-size: .95rem; }
.field .hint { color: var(--muted); font-size: .85rem; }
input[type=text], input[type=datetime-local], input[type=date], input[type=time], textarea, select {
  font: inherit; color: inherit; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: .6em .7em; min-height: var(--touch); width: 100%;
}
textarea { min-height: 4.5em; resize: vertical; }
.row { display: flex; gap: .6rem; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 8rem; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: .6rem .8rem; }
legend { padding: 0 .4rem; font-weight: 600; }

/* Farbwahl */
.colors { display: flex; flex-wrap: wrap; gap: .5rem; }
.colors input[type=radio] { position: absolute; opacity: 0; width: 1px; height: 1px; }
.colors label {
  width: 2.2em; height: 2.2em; border-radius: 50%; cursor: pointer;
  border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--line);
  display: inline-block;
}
.colors input[type=radio]:checked + label { box-shadow: 0 0 0 3px var(--focus); }
.colors input[type=radio]:focus-visible + label { box-shadow: 0 0 0 3px var(--focus); }

/* Poll-Optionen im Formular */
.opt-list { display: grid; gap: .5rem; }
.opt-row { display: flex; gap: .5rem; align-items: end; }
.opt-row > .field { flex: 1; }

/* Poll-Ergebnis-Tabelle */
.poll-table-wrap { overflow-x: auto; }
table.poll { border-collapse: collapse; width: 100%; min-width: 22rem; }
table.poll th, table.poll td { border: 1px solid var(--line); padding: .5rem .6rem; text-align: center; }
table.poll th.name-col, table.poll td.name-col { text-align: left; position: sticky; left: 0; background: var(--surface); }
table.poll thead th { background: var(--surface-2); font-size: .92rem; }
.v-yes { color: #0a7d3f; font-weight: 800; }
.v-maybe { color: #b47500; font-weight: 800; }
.v-no { color: var(--muted); }
:root[data-theme="dark"] .v-yes, :root:not([data-theme="light"]) .v-yes { color: #6fd699; }
:root[data-theme="dark"] .v-maybe, :root:not([data-theme="light"]) .v-maybe { color: #ecc06b; }
table.poll tr.win td { background: color-mix(in srgb, var(--accent) 16%, var(--surface)); }
.tally { font-size: .82rem; color: var(--muted); }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: 1.2rem; transform: translateX(-50%);
  background: var(--ink); color: var(--bg);
  padding: .7em 1.1em; border-radius: 999px; box-shadow: var(--shadow);
  z-index: 200; max-width: 90vw; text-align: center;
}
.toast.err { background: var(--danger); color: var(--danger-ink); }

/* Diverses */
.muted { color: var(--muted); }
.mono { font-variant-numeric: tabular-nums; }
.linklike { color: var(--accent); text-decoration: underline; background: none; border: none; padding: 0; min-height: 0; cursor: pointer; }
.copy-row { display: flex; gap: .5rem; }
.copy-row input { background: var(--surface-2); }
.tag { font-size: .75rem; padding: .1em .5em; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); color: var(--muted); }

/* kurzer/langer Wochentag – Umschaltung je nach Ansicht */
.dow-short { display: none; }

.ev .ev-top { flex-wrap: wrap; }   /* Titel darf unter die Zeit rutschen statt zu klippen */

/* breite Screens: Wochentage nebeneinander, kompakter Kopf */
@media (min-width: 760px) {
  .week.cols { grid-template-columns: repeat(7, 1fr); align-items: start; gap: .5rem; }
  .week.cols .day-body { min-height: 3rem; }
  .week.cols .day-head { padding: .45rem .55rem; gap: .3rem; flex-wrap: wrap; }
  .week.cols .day-head .dow-long { display: none; }
  .week.cols .day-head .dow-short { display: inline; }
  .week.cols .day-head .dnum { font-size: .92rem; }
  .week.cols .day-head .badge { display: none; }
  .week.cols .day.today .day-head .dow::after { content: ""; }
  .week.cols .ev { padding: .5rem .55rem; }
  .week.cols .ev-time { font-size: .82rem; }
}
