:root {
  color-scheme: light;
  --ink: #202a35;
  --muted: #667382;
  --line: #e2e8ee;
  --paper: #ffffff;
  --background: #f3f6f8;
  --accent: #1f6f9e;
  --accent-ink: #ffffff;
  --accent-soft: #e3f0f7;
  --yes: #2f8a57;
  --yes-soft: #e2f2e8;
  --no: #b9503d;
  --no-soft: #f7e4df;
  --radius: 14px;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --ink: #e3eaf0;
    --muted: #94a3b0;
    --line: #2a3742;
    --paper: #18222b;
    --background: #10181f;
    --accent: #62b0de;
    --accent-ink: #0b1a24;
    --accent-soft: #1b3445;
    --yes: #5fc28b;
    --yes-soft: #18382a;
    --no: #e17d68;
    --no-soft: #3d241f;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--ink);
  background: var(--background);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
}

h1, h2, h3 { text-wrap: balance; margin: 0; }
h1 { font-size: clamp(1.7rem, 4vw, 2.3rem); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.muted { color: var(--muted); }

/* ---------- Kopfzeile ---------- */
.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 20px;
  padding: 12px max(16px, calc((100% - 1100px) / 2));
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; color: var(--ink); text-decoration: none; }
.topnav { display: flex; align-items: center; gap: 16px; }
.topnav a { color: var(--accent); text-decoration: none; font-weight: 600; }
.who { color: var(--muted); }

main {
  width: min(1100px, 100%);
  margin: 0 auto;
  padding: 32px 16px 56px;
  display: grid;
  gap: 24px;
}

/* ---------- Bausteine ---------- */
.card {
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  box-shadow: 0 8px 24px rgb(31 51 66 / 6%);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  border: 1px solid var(--accent);
  border-radius: 10px;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
  cursor: pointer;
}
.btn:disabled { opacity: 0.6; cursor: default; }
.btn.secondary { background: transparent; color: var(--accent); }

.link {
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent);
  font-weight: 600;
  cursor: pointer;
}

.field { display: grid; gap: 6px; }
.field label { font-weight: 600; font-size: 0.95rem; }
.field input {
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--background);
}

.error {
  margin: 0;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--no-soft);
  color: var(--no);
}

/* ---------- Anmeldung ---------- */
.login {
  width: min(380px, 100%);
  margin: 8vh auto 0;
  display: grid;
  gap: 18px;
}
.login form { display: grid; gap: 14px; }
.m0 { margin: 0; }

/* ---------- Verwaltung ---------- */
h2 { font-size: 1.25rem; }
.stack { display: grid; gap: 16px; }
.section-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 16px; }

.tabs { display: flex; flex-wrap: wrap; gap: 6px; border-bottom: 1px solid var(--line); }
.tab {
  padding: 8px 14px;
  margin-bottom: -1px;
  border-bottom: 3px solid transparent;
  color: var(--muted);
  font-weight: 600;
  text-decoration: none;
}
.tab:hover { color: var(--ink); }
.tab[aria-current="page"] { color: var(--accent); border-bottom-color: var(--accent); }

.row-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)); gap: 14px; }
.input-with-btn { display: flex; gap: 8px; }
.input-with-btn input { flex: 1; min-width: 0; padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--background); }
.inline-form { display: flex; flex-wrap: wrap; align-items: end; gap: 10px; }
.inline-form input { padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--background); width: 100%; }
.grow { flex: 1 1 220px; }

.checks { display: flex; flex-wrap: wrap; gap: 8px 16px; margin: 0; padding: 0; border: 0; }
.checks legend { font-weight: 600; font-size: 0.95rem; margin-bottom: 6px; padding: 0; }
.check { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }

.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 18px; }
.link.danger { color: var(--no); }

.list { list-style: none; margin: 0; padding: 0; display: grid; }
.list-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 10px 20px;
  padding: 14px 0;
  border-top: 1px solid var(--line);
}
.list-row:first-child { border-top: 0; padding-top: 0; }
.list-main { display: grid; gap: 8px; }
.list-title { display: flex; align-items: center; gap: 8px; }
.reset-form { grid-column: 1 / -1; display: grid; gap: 10px; max-width: 460px; }
@media (max-width: 560px) {
  .list-row { grid-template-columns: 1fr; }
}

.badge {
  padding: 1px 8px;
  border-radius: 99px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  padding: 4px 12px;
  border: 1px solid var(--line);
  border-radius: 99px;
  background: var(--background);
  color: var(--muted);
  font-size: 0.9rem;
  cursor: pointer;
}
.chip:hover { border-color: var(--accent); }
.chip[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }

.grid-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); gap: 16px; align-items: start; }

.credentials {
  display: grid;
  gap: 10px;
  padding: 14px;
  border-radius: 10px;
  background: var(--yes-soft);
}
.credentials pre {
  margin: 0;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--paper);
  font: 0.95rem/1.5 ui-monospace, "SFMono-Regular", Menlo, monospace;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  max-width: calc(100% - 32px);
  padding: 10px 16px;
  border-radius: 10px;
  background: var(--ink);
  color: var(--paper);
  box-shadow: 0 8px 24px rgb(0 0 0 / 20%);
  z-index: 10;
}
.toast[data-kind="error"] { background: var(--no); color: #fff; }

/* ---------- Abstimmungen verwalten ---------- */
.status-draft { background: var(--line); color: var(--muted); }
.status-open { background: var(--yes-soft); color: var(--yes); }
.status-finished { background: var(--accent-soft); color: var(--accent); }

.back { color: var(--accent); font-weight: 600; text-decoration: none; justify-self: start; }
.poll-link { color: inherit; text-decoration: none; }
.poll-link:hover strong { color: var(--accent); }

.field textarea,
.detail-row input,
.field input {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--background);
}
.field textarea { resize: vertical; line-height: 1.45; }

fieldset.editor { margin: 0; padding: 0; border: 0; min-width: 0; }
fieldset.editor:disabled { opacity: 0.75; }

.poll-image { display: block; width: 100%; max-height: 420px; object-fit: contain; border-radius: 10px; background: var(--background); }
.file-btn { position: relative; overflow: hidden; }
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }

.option-editor { display: grid; gap: 16px; }
.option-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

.move { display: flex; gap: 4px; }
.detail-block { display: grid; gap: 8px; }
.detail-block h3 { margin: 0; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.detail-row { display: grid; gap: 8px; align-items: center; }
.hotel-row { grid-template-columns: 2fr 1fr auto; }
.flight-row { grid-template-columns: 1fr 1fr 0.8fr auto; }
@media (max-width: 640px) {
  .hotel-row, .flight-row { grid-template-columns: 1fr auto; }
  .hotel-row > input:first-child, .flight-row > input { grid-column: 1; }
  .detail-row > .icon-btn { grid-column: 2; grid-row: 1; }
  .detail-row { padding-bottom: 8px; border-bottom: 1px dashed var(--line); }
}

.icon-btn {
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  color: var(--muted);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
}
.icon-btn:hover:not(:disabled) { color: var(--ink); border-color: var(--muted); }
.icon-btn:disabled { opacity: 0.4; cursor: default; }


.savebar {
  position: sticky;
  bottom: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 16px;
  padding: 12px 16px;
  padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  border: 1px solid var(--line);
  border-radius: var(--radius) var(--radius) 0 0;
  background: var(--paper);
  box-shadow: 0 -6px 20px rgb(31 51 66 / 8%);
}
.savebar-text { color: var(--muted); }
.savebar[data-dirty="true"] { border-color: var(--accent); }
.savebar[data-dirty="true"] .savebar-text { color: var(--accent); font-weight: 600; }

.date-fields { display: grid; grid-template-columns: repeat(2, minmax(9.5rem, 1fr)); gap: 4px 12px; }
.date-fields input[type="date"] { min-height: 42px; }
.date-summary { grid-column: 1 / -1; font-weight: 600; color: var(--accent); font-variant-numeric: tabular-nums; }
.date-summary.invalid { color: var(--no); font-weight: 400; }
@media (max-width: 420px) {
  .date-fields { grid-template-columns: 1fr; }
}

/* ---------- Startseite ---------- */
.poll-card { display: grid; gap: 10px; color: inherit; text-decoration: none; transition: border-color 120ms; }
.poll-card:hover { border-color: var(--accent); }
.poll-card h2 { font-size: 1.3rem; }
.poll-card-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; }
.pill { padding: 3px 10px; border-radius: 99px; font-size: 0.85rem; font-weight: 600; }
.pill-yes { background: var(--yes-soft); color: var(--yes); }
.pill-todo { background: var(--no-soft); color: var(--no); }
.pill-accent { background: var(--accent-soft); color: var(--accent); }

/* ---------- Abstimmen ---------- */
.poll-head { gap: 8px; }
.poll-desc { max-width: 65ch; white-space: pre-line; }
.notice { padding: 12px 14px; border-radius: 10px; background: var(--accent-soft); }

.mode-choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); gap: 10px; }
.mode-choice {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--background);
  cursor: pointer;
}
.mode-choice:hover { border-color: var(--accent); }
.mode-choice:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.mode-choice input { margin-top: 3px; width: 18px; height: 18px; accent-color: var(--accent); }
.mode-text { display: grid; gap: 2px; }
.mode-text .muted { font-size: 0.9rem; }

.options-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); gap: 16px; align-items: start; }
.vote-option { display: grid; gap: 14px; transition: border-color 120ms, background-color 120ms, opacity 120ms; }
.vote-option.is-yes { border-color: var(--yes); box-shadow: inset 0 0 0 1px var(--yes); }
.vote-option.is-inactive { opacity: 0.6; }
.vote-option-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}
.vote-option-head h3 { margin: 0; font-size: 1.15rem; }
.option-title { display: flex; align-items: center; gap: 10px; min-width: 0; }
.option-badge {
  flex: none;
  display: inline-grid;
  place-items: center;
  min-width: 2rem;
  height: 2rem;
  padding: 0 6px;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 750;
  font-variant-numeric: tabular-nums;
}
.vote-option-head .dates { font-variant-numeric: tabular-nums; }

.can-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--background);
  font-weight: 600;
  cursor: pointer;
  user-select: none;
}
.can-toggle input { width: 20px; height: 20px; accent-color: var(--yes); }
.can-toggle:has(input:checked) { border-color: var(--yes); background: var(--yes-soft); color: var(--yes); }
.can-toggle:has(input:disabled) { cursor: default; }

.option-note {
  padding: 9px 12px;
  border-left: 3px solid var(--accent);
  border-radius: 6px;
  background: var(--accent-soft);
  white-space: pre-line;
  overflow-wrap: anywhere;
}

.info-block { display: grid; gap: 8px; }
.info-block h4 { margin: 0; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.info-list { display: grid; gap: 6px; }
.info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
}
.price { white-space: nowrap; font-weight: 650; text-align: right; font-variant-numeric: tabular-nums; }
.price small { display: block; color: var(--muted); font-size: 0.75rem; font-weight: 400; }
.flight-times { display: grid; gap: 4px; font-variant-numeric: tabular-nums; }
.leg-label { display: inline-block; min-width: 72px; color: var(--muted); }

/* ---------- Ergebnis ---------- */
.result-list { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }
.result-row {
  display: grid;
  grid-template-columns: 2.2rem 1fr auto;
  align-items: start;
  gap: 4px 10px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--background);
}
.result-row.is-top { border-color: var(--yes); background: var(--yes-soft); box-shadow: inset 0 0 0 1px var(--yes); }
.result-row { cursor: pointer; transition: border-color 120ms, box-shadow 120ms, background-color 120ms; }
.result-row:focus-visible { outline-offset: 2px; }
.result-row.is-linked,
.vote-option.is-linked { border-color: var(--accent); box-shadow: inset 0 0 0 2px var(--accent); }
.result-row.is-linked:not(.is-top),
.vote-option.is-linked { background: var(--accent-soft); }
.vote-option.is-flash { animation: flash 1.6s ease-out; }
@keyframes flash {
  0%, 35% { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft), inset 0 0 0 2px var(--accent); }
  100% { box-shadow: none; }
}
@media (prefers-reduced-motion: reduce) {
  .vote-option.is-flash { animation-duration: 0.01s; }
}
.result-place { font-size: 1.3rem; font-weight: 700; line-height: 1.3; color: var(--muted); font-variant-numeric: tabular-nums; }
.result-row.is-top .result-place { color: var(--yes); }
.result-body { display: grid; gap: 6px; min-width: 0; }
.result-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 12px; }
.result-head .dates { font-variant-numeric: tabular-nums; }
.result-count {
  min-width: 2.6rem;
  padding: 2px 10px;
  border-radius: 10px;
  background: var(--yes-soft);
  color: var(--yes);
  font-size: 1.8rem;
  font-weight: 750;
  line-height: 1.2;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.result-row.is-top .result-count { background: var(--yes); color: var(--background); }
.result-names { font-size: 0.95rem; overflow-wrap: anywhere; }
.yes-label { font-weight: 650; color: var(--yes); }
.no-label { font-weight: 650; color: var(--no); }
.egal-label { color: var(--accent); }
.result-groups { gap: 6px; }

