/* Hoher Kontrast, grosse Schaltflächen – lesbar bei Sonne, bedienbar mit nassen Händen. */
:root {
  --bg: #ffffff;
  --fg: #0a0a0a;
  --muted: #444;
  --line: #c8ced6;
  --card: #f2f5f8;
  --accent: #0b2a4a;
  --accent-fg: #ffffff;
  --go: #0a6b2f;
  --danger: #a3000b;
  --tab-h: 68px;
  font-size: 18px;
}
body.night {
  --bg: #000;
  --fg: #ff4a3d;
  --muted: #b3352b;
  --line: #4a1410;
  --card: #120302;
  --accent: #3a0b07;
  --accent-fg: #ff4a3d;
  --go: #5a120c;
  --danger: #ff4a3d;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--fg);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  line-height: 1.35;
  -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }

.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 8px;
  padding: calc(8px + env(safe-area-inset-top)) 12px 8px;
  background: var(--accent); color: var(--accent-fg);
}
.trip-btn {
  flex: 1; text-align: left; background: none; border: 0; padding: 4px 0;
  color: inherit; font-weight: 700; font-size: 1.1rem;
  overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
}
.trip-btn .label { display: block; font-size: .7rem; font-weight: 400; opacity: .8; }
.icon-btn {
  width: 48px; height: 48px; border-radius: 50%;
  border: 2px solid currentColor; background: none; color: inherit; font-size: 1.3rem;
}

main { padding: 12px 12px calc(var(--tab-h) + 24px + env(safe-area-inset-bottom)); max-width: 900px; margin: 0 auto; }
.view { display: none; }
.view.active { display: block; }

.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  display: grid; grid-template-columns: repeat(6, 1fr);
  height: calc(var(--tab-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--bg); border-top: 2px solid var(--line);
}
.tabs button {
  border: 0; background: none; font-size: 1.4rem;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
}
.tabs button span { font-size: .7rem; font-weight: 600; }
.tabs button { padding: 0; min-width: 0; }
.tabs button.active { background: var(--card); box-shadow: inset 0 4px 0 var(--accent); }
body.night .tabs button.active { box-shadow: inset 0 4px 0 var(--fg); }

/* Grosser Log-Knopf */
.log-btn {
  display: block; width: 100%; min-height: 34vh;
  border: 0; border-radius: 24px;
  background: var(--go); color: #fff;
  font-size: 2rem; font-weight: 800; letter-spacing: .02em;
  box-shadow: 0 6px 0 rgba(0,0,0,.35);
  touch-action: manipulation;
}
body.night .log-btn { color: var(--fg); border: 3px solid var(--fg); }
.log-btn:active { transform: translateY(4px); box-shadow: 0 2px 0 rgba(0,0,0,.35); }
.log-btn[disabled] { opacity: .6; }
.log-btn small { display: block; font-size: 1rem; font-weight: 500; margin-top: 8px; }

.btn {
  min-height: 56px; padding: 10px 18px; border-radius: 14px;
  border: 2px solid var(--accent); background: var(--bg); font-weight: 700;
}
.btn.primary { background: var(--accent); color: var(--accent-fg); }
.btn.danger { border-color: var(--danger); color: var(--danger); }
.btn.block { display: block; width: 100%; margin-top: 12px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; }
.row > .btn { flex: 1; }

.live { margin: 10px 2px; color: var(--muted); font-size: .9rem; text-align: center; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; margin-top: 12px; }
.card h3 { margin: 0 0 6px; font-size: 1rem; color: var(--muted); font-weight: 600; }
.pos { font-family: ui-monospace, "Roboto Mono", Consolas, monospace; font-size: clamp(.9rem, 4.4vw, 1.15rem); font-weight: 700; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px 14px; margin-top: 8px; }
.kv .k { font-size: .75rem; color: var(--muted); }
.kv .v { font-size: 1.35rem; font-weight: 800; }

.day-head {
  position: sticky; top: 70px; z-index: 2;
  margin: 20px 0 6px; padding: 6px 4px; background: var(--bg);
  font-weight: 800; border-bottom: 2px solid var(--fg);
  display: flex; justify-content: space-between;
}
.entry {
  display: block; width: 100%; text-align: left;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 10px 12px; margin: 8px 0;
}
.entry .t { font-weight: 800; }
.entry .meta { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: .9rem; margin-top: 4px; }
.entry .note { margin-top: 6px; white-space: pre-wrap; }
.entry .wx { margin-top: 4px; font-size: .85rem; color: var(--muted); }
.tag { display: inline-block; padding: 0 8px; border-radius: 8px; background: var(--accent); color: var(--accent-fg); font-size: .75rem; font-weight: 700; margin-left: 6px; }

.empty { text-align: center; color: var(--muted); padding: 40px 10px; }

/* Dialog */
dialog {
  width: min(600px, 96vw); max-height: 92vh; padding: 0;
  border: 2px solid var(--fg); border-radius: 16px;
  background: var(--bg); color: var(--fg);
}
dialog::backdrop { background: rgba(0,0,0,.6); }
dialog form { padding: 16px; }
dialog h2 { margin: 0 0 12px; font-size: 1.25rem; }
label.f { display: block; margin-top: 12px; font-size: .85rem; font-weight: 600; color: var(--muted); }
label.f input, label.f select, label.f textarea {
  display: block; width: 100%; margin-top: 4px; min-height: 52px;
  padding: 10px 12px; border: 2px solid var(--line); border-radius: 10px;
  background: var(--bg); color: var(--fg); font-size: 1.05rem;
}
label.f textarea { min-height: 110px; resize: vertical; }
.f2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
.dlg-actions { display: flex; gap: 10px; margin-top: 18px; flex-wrap: wrap; }
.dlg-actions .btn { flex: 1; }
fieldset { border: 1px solid var(--line); border-radius: 12px; margin: 14px 0 0; padding: 4px 12px 12px; }
legend { font-weight: 700; padding: 0 6px; }

#toast {
  position: fixed; left: 50%; bottom: calc(var(--tab-h) + 20px); transform: translateX(-50%);
  background: var(--fg); color: var(--bg); padding: 12px 20px; border-radius: 12px;
  font-weight: 700; opacity: 0; pointer-events: none; transition: opacity .2s; max-width: 90vw;
}
#toast.show { opacity: 1; }

/* Umschalter Wachplan / Ämtliplan */
.seg { display: grid; grid-template-columns: 1fr 1fr; border: 2px solid var(--accent); border-radius: 14px; overflow: hidden; }
body.night .seg { border-color: var(--fg); }
.seg button { min-height: 52px; border: 0; background: var(--bg); font-weight: 700; }
.seg button.active { background: var(--accent); color: var(--accent-fg); }
.seg3 { grid-template-columns: 1fr 1fr 1fr; }
.view > .seg { margin-bottom: 10px; }

/* Karte */
.map-search input {
  width: 100%; min-height: 52px; padding: 10px 14px; border: 2px solid var(--line); border-radius: 12px;
  background: var(--bg); color: var(--fg); font-size: 1.05rem;
}
.search-list { max-height: 45vh; overflow-y: auto; margin-top: 6px; }
.search-list small { color: var(--muted); }
.map-wrap { position: relative; margin-top: 8px; }
.map { height: calc(100vh - 380px); min-height: 320px; border-radius: 12px; overflow: hidden; border: 1px solid var(--line); }
.crosshair {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); pointer-events: none;
  font-size: 2rem; font-weight: 300; color: #c62828; text-shadow: 0 0 3px #fff;
}
.idea-pin {
  width: 34px; height: 34px; border-radius: 50% 50% 50% 4px; transform: rotate(-45deg);
  display: flex; align-items: center; justify-content: center; font-size: 1rem; cursor: pointer;
  border: 2px solid #fff; box-shadow: 0 2px 4px rgba(0,0,0,.4);
}
.idea-pin { line-height: 1; }
.wp-pin {
  width: 30px; height: 30px; border-radius: 50%; background: #6a1b9a; color: #fff; border: 3px solid #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: .9rem;
  box-shadow: 0 2px 4px rgba(0,0,0,.4); cursor: pointer;
}
.wp-pin.edit { width: 38px; height: 38px; background: #ef6c00; cursor: grab; }
.map-wrap.drawing .map { outline: 4px solid #ef6c00; outline-offset: -4px; }
.map-wrap.drawing .crosshair { display: none; }
.route-bar { border: 2px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.route-bar.active { border-color: #ef6c00; background: rgba(239,108,0,.08); }
.pos-dot { width: 18px; height: 18px; border-radius: 50%; background: #1e88e5; border: 3px solid #fff; box-shadow: 0 0 0 6px rgba(30,136,229,.3); }
.dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; vertical-align: middle; border: 1px solid #fff; }
.rose { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; max-width: 280px; margin: 6px auto 0; }
.rose-c { display: flex; align-items: center; justify-content: center; font-size: 1.6rem; }
.rose-cb { display: block; }
.rose-cb input { position: absolute; opacity: 0; }
.rose-cb span {
  display: flex; align-items: center; justify-content: center; min-height: 52px; border-radius: 12px;
  border: 2px solid var(--line); font-weight: 800;
}
.rose-cb input:checked + span { background: var(--go); color: #fff; border-color: var(--go); }
body.night .rose-cb input:checked + span { color: #000; background: var(--fg); }

.sub { display: none; }
.sub.active { display: block; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
.chip { display: inline-flex; align-items: center; gap: 6px; font-size: .85rem; font-weight: 700; }
.chip i { width: 14px; height: 14px; border-radius: 4px; display: inline-block; }
.duty-now { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; align-items: baseline; }
.duty-now .p { font-weight: 800; }
table.count { border-collapse: collapse; font-size: .85rem; width: 100%; }
table.count th, table.count td { border: 1px solid var(--line); padding: 4px 4px; text-align: center; white-space: nowrap; }
.count-wrap { overflow-x: auto; }
table.count th:first-child, table.count td:first-child { text-align: left; }
.check { display: flex; align-items: center; gap: 10px; min-height: 48px; font-weight: 600; }
.check input { width: 26px; height: 26px; }

/* Wachplan-Grafik */
.wchart { --night: rgba(11, 42, 74, .13); --grid: rgba(0, 0, 0, .18); }
body.night .wchart { --night: rgba(255, 74, 61, .10); --grid: rgba(255, 74, 61, .25); }
.wc-day { margin: 6px 0 16px; }
.wc-title { font-weight: 800; margin-bottom: 2px; }
.wc-row { display: flex; align-items: stretch; height: 34px; margin-top: 4px; }
.wc-axis { height: 18px; margin-top: 0; }
.wc-name {
  flex: 0 0 82px; padding: 0 6px; font-weight: 700; font-size: .85rem;
  display: flex; align-items: center; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
}
.wc-track, .wc-ticks { position: relative; flex: 1; }
.wc-track {
  border-radius: 6px; border: 1px solid var(--line);
  background:
    repeating-linear-gradient(to right, var(--grid) 0 1px, transparent 1px 12.5%),
    linear-gradient(to right, var(--night) 0 25%, transparent 25% 75%, var(--night) 75%);
}
.wc-ticks span { position: absolute; transform: translateX(-50%); font-size: .7rem; color: var(--muted); }
.wc-ticks span:first-child { transform: none; }
.wc-ticks span:last-child { transform: translateX(-100%); }
.wc-bar {
  position: absolute; top: 3px; bottom: 3px; border-radius: 5px;
  color: #fff; font-size: .7rem; font-weight: 700; overflow: hidden; white-space: nowrap;
  display: flex; align-items: center; justify-content: center;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .5);
}
body.night .wc-bar { background: var(--fg) !important; color: #000; }
.wc-now { position: absolute; top: -4px; bottom: -4px; width: 3px; margin-left: -1px; background: #e00000; border-radius: 2px; }
.wc-legend { font-size: .8rem; color: var(--muted); }
details.wlist > summary { cursor: pointer; font-weight: 700; padding: 14px 4px; min-height: 48px; }

#print { display: none; }
@media print {
  body > *:not(#print) { display: none !important; }
  #print { display: block; color: #000; font-size: 10pt; }
  #print table { width: 100%; border-collapse: collapse; }
  #print th, #print td { border: 1px solid #888; padding: 3px 4px; vertical-align: top; }
  #print th { background: #eee; }
  #print h1 { font-size: 16pt; margin: 0 0 6px; }
  #print h2 { font-size: 12pt; margin: 14px 0 4px; }
  #print .wchart { -webkit-print-color-adjust: exact; print-color-adjust: exact; margin-bottom: 10px; }
  #print .wc-day { break-inside: avoid; }
  #print .wc-row { height: 24px; }
}

@media (min-width: 760px) {
  .log-btn { min-height: 260px; }
}
