:root {
  --bg: #f4f6f8;
  --card: #ffffff;
  --text: #15181e;
  --muted: #5a6272;
  --line: #dde2ea;
  --accent: #2554e8;
  --accent-text: #ffffff;
  --slot: #eef1f5;
  --danger: #b3261e;
  --radius: 14px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1014;
    --card: #171a21;
    --text: #edf0f5;
    --muted: #9ea6b6;
    --line: #2a303b;
    --accent: #7d9bff;
    --accent-text: #0e1014;
    --slot: #20242d;
    --danger: #ff8a80;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}

main { max-width: 560px; margin: 0 auto; padding: 16px 16px 112px; }
h1 { font-size: 1.5rem; margin: 8px 0 2px; letter-spacing: -0.01em; }
h2 { font-size: 1.05rem; margin: 0 0 6px; }
.sub { color: var(--muted); margin: 0 0 8px; }
.hint { color: var(--muted); margin: 0 0 12px; font-size: 0.92rem; }
.hint.after { margin: 10px 0 0; }
.error { color: var(--danger); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

section {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin: 12px 0;
}

button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { opacity: 0.45; cursor: default; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

input[type="password"], input[type="date"], input[type="number"], textarea {
  font: inherit;
  color: inherit;
  background: var(--slot);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  width: 100%;
  min-height: 44px;
}
textarea { resize: vertical; }

.primary {
  background: var(--accent);
  color: var(--accent-text);
  border: 0;
  border-radius: 10px;
  padding: 11px 22px;
  font-weight: 600;
  min-height: 44px;
}
#gate-form { display: flex; gap: 8px; }

/* Availability grid: day labels down the side, 3-hour windows across. */
.grid { display: grid; grid-template-columns: 2.8rem repeat(6, minmax(0, 1fr)); gap: 4px; }
.colhead, .rowhead { background: none; border: 0; padding: 6px 0; }
.colhead { color: var(--muted); font-size: 0.78rem; font-variant-numeric: tabular-nums; }
.rowhead { text-align: left; font-weight: 600; font-size: 0.92rem; }
.slot {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--slot);
  font-weight: 700;
}
.slot.on { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }

.row { display: flex; gap: 8px; align-items: center; }
.row button { border: 1px solid var(--line); background: var(--slot); border-radius: 10px; padding: 0 16px; min-height: 44px; }
.row.narrow input { max-width: 9rem; }
.unit { color: var(--muted); }

.chips { list-style: none; padding: 0; margin: 10px 0 0; display: flex; flex-wrap: wrap; gap: 6px; }
.chips:empty { display: none; }
.chips li {
  display: inline-flex;
  align-items: center;
  background: var(--slot);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 2px 2px 12px;
  font-size: 0.92rem;
}
.chips .remove { border: 0; background: none; color: var(--muted); padding: 6px 10px; font-size: 1.05rem; line-height: 1; }

.stepper { display: flex; align-items: center; gap: 18px; }
.stepper button {
  width: 44px; height: 44px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--slot);
  font-size: 1.3rem;
  line-height: 1;
}
.stepper output { font-size: 1.5rem; font-weight: 700; min-width: 2ch; text-align: center; font-variant-numeric: tabular-nums; }

.segmented { display: flex; border: 1px solid var(--line); border-radius: 11px; overflow: hidden; }
.segmented label { flex: 1; position: relative; }
.segmented input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.segmented span { display: block; text-align: center; padding: 10px 4px; font-size: 0.92rem; }
.segmented label + label span { border-left: 1px solid var(--line); }
.segmented input:checked + span { background: var(--accent); color: var(--accent-text); font-weight: 600; }
.segmented input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: -3px; }

.check { display: flex; gap: 10px; align-items: center; padding: 8px 0; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); margin: 0; }

.savebar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px max(16px, calc((100vw - 560px) / 2 + 16px)) calc(12px + env(safe-area-inset-bottom));
  background: var(--card);
  border-top: 1px solid var(--line);
}
#status { color: var(--muted); font-size: 0.92rem; }

.foot { text-align: center; }
.link { background: none; border: 0; color: var(--muted); text-decoration: underline; padding: 8px; }
