/* Layout: eine schmale Handy-Spalte, Reiter oben, grosse Aktionsflächen für den Daumen */
:root {
  color-scheme: light dark;
  --bg: #eceff1;
  --surface: #ffffff;
  --field: #f6f8f9;
  --fg: #14181b;
  --muted: #56626a;
  --line: #d3d9dd;
  --accent: #1d4ed8;
  --accent-fg: #ffffff;
  --open: #a24a05;
  --open-bg: #fdeed6;
  --closed: #0b6e54;
  --closed-bg: #d9f1e7;
  --danger: #b42318;
  --font-display: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-body: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1316; --surface: #181d21; --field: #12171a; --fg: #e8ecef; --muted: #9aa6ae;
    --line: #2a3238; --accent: #7aa2ff; --accent-fg: #0b1220;
    --open: #f0b35a; --open-bg: #3a2a10; --closed: #4fd1a5; --closed-bg: #0f3328; --danger: #ff8a80;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.45;
  padding-top: calc(12px + env(safe-area-inset-top, 0px));
  padding-bottom: calc(40px + env(safe-area-inset-bottom, 0px));
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.wrap { max-width: 480px; margin: 0 auto; display: flex; flex-direction: column; gap: 16px; min-width: 0; }
h1, h2 { font-family: var(--font-display); margin: 0; letter-spacing: -0.01em; text-wrap: balance; }
h1 { font-size: 1.6rem; font-weight: 800; }
h2 { font-size: 1.05rem; font-weight: 700; }
h2.mt { margin-top: 8px; }
p { margin: 0; }
.muted { color: var(--muted); }
header { display: flex; flex-direction: column; gap: 12px; }

.tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; background: var(--line); padding: 4px; border-radius: 14px; }
.tabs a {
  text-align: center; text-decoration: none; color: var(--muted); font-weight: 600; font-size: 0.95rem;
  padding: 11px 6px; border-radius: 10px; min-height: 44px; display: flex; align-items: center; justify-content: center;
}
.tabs a[aria-current="page"] { background: var(--surface); color: var(--fg); }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 18px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.section { display: flex; flex-direction: column; gap: 10px; }

/* Statuskarte */
.status { gap: 16px; }
.srow { display: flex; flex-direction: column; gap: 2px; }
.label { font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.big { font-family: var(--font-display); font-size: 1.9rem; font-weight: 800; line-height: 1.15; overflow-wrap: anywhere; }
.big.free { color: var(--muted); font-size: 1.4rem; }
.sub { color: var(--muted); font-size: 0.92rem; }
.sdiv { height: 1px; background: var(--line); }
.pill { display: inline-flex; align-items: center; gap: 8px; align-self: flex-start; font-family: var(--font-display); font-weight: 800; font-size: 1.25rem; padding: 8px 14px; border-radius: 999px; }
.pill i { width: 10px; height: 10px; border-radius: 50%; background: currentColor; }
.pill.open { background: var(--open-bg); color: var(--open); }
.pill.closed { background: var(--closed-bg); color: var(--closed); }
.pill.unknown { background: var(--field); color: var(--muted); border: 1px solid var(--line); }

/* Bedienelemente */
.btn {
  font: inherit; font-weight: 600; min-height: 56px; border-radius: 14px; border: 1px solid var(--line);
  background: var(--surface); color: var(--fg); padding: 12px 16px; width: 100%; cursor: pointer; touch-action: manipulation;
}
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
.btn.ghost { background: transparent; }
.btn.warn { border-color: var(--danger); color: var(--danger); }
.btn.small { min-height: 44px; width: auto; padding: 8px 14px; }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.door.open { background: var(--open-bg); color: var(--open); border-color: transparent; }
.door.closed { background: var(--closed-bg); color: var(--closed); border-color: transparent; }
.door[aria-pressed="true"] { outline: 3px solid currentColor; outline-offset: 2px; }
body[data-busy="1"] .btn { opacity: 0.6; pointer-events: none; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

form { display: flex; flex-direction: column; gap: 10px; }
label { font-weight: 600; font-size: 0.92rem; }
input[type="text"], input[type="password"], input[type="tel"], input:not([type]) {
  font: inherit; font-size: 16px; min-height: 52px; width: 100%; padding: 10px 14px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--field); color: var(--fg);
}
.linkrow { display: flex; gap: 8px; align-items: center; }
.linkrow input { flex: 1; min-width: 0; font-size: 14px; }

/* Verlauf */
.log { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.log li { display: flex; flex-direction: column; gap: 1px; padding: 11px 0; border-top: 1px solid var(--line); }
.log li:first-child { border-top: 0; }
.log .t { font-size: 0.8rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.log .x { overflow-wrap: anywhere; }
.empty { color: var(--muted); font-size: 0.95rem; }

.qrbox { align-self: center; background: #ffffff; padding: 14px; border-radius: 14px; border: 1px solid var(--line); width: min(100%, 300px); line-height: 0; }
.qrbox svg { width: 100%; height: auto; display: block; }
.note { background: var(--field); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; font-size: 0.92rem; color: var(--muted); }

#toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  background: var(--fg); color: var(--bg); padding: 12px 18px; border-radius: 12px; font-weight: 500; max-width: calc(100% - 32px); z-index: 20;
}
[hidden] { display: none !important; }

/* Aushang: nur die QR-Karte drucken */
@media print {
  body { background: #fff; color: #000; padding: 0; }
  .noprint { display: none !important; }
  .card { border: 0; padding: 0; }
  .qrbox { width: 14cm; border: 0; }
  #toast { display: none; }
}
