/* Departure Buddy configurator.
   Dark by default because the thing being configured is an amber-on-black
   board, and the preview should sit in a sympathetic surround. */

:root {
  --bg: #14161a;
  --card: #1c1f26;
  --card-2: #232733;
  --line: #2f3542;
  --text: #e8eaf0;
  --muted: #9aa3b5;
  --accent: #ffa400;
  --accent-dim: #7a5100;
  --ok: #3ddc84;
  --bad: #ff6b6b;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

main { max-width: 780px; margin: 0 auto; padding: 0 20px 72px; }

.top {
  max-width: 780px;
  margin: 0 auto;
  padding: 44px 20px 20px;
}
.top h1 {
  margin: 0;
  font-size: 2rem;
  letter-spacing: -0.02em;
  color: var(--accent);
}
.sub { color: var(--muted); margin: 8px 0 0; max-width: 52ch; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  margin: 18px 0;
}
.card h2 {
  margin: 0 0 16px;
  font-size: 1.15rem;
  display: flex;
  align-items: center;
  gap: 10px;
}
.step {
  display: grid;
  place-items: center;
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--accent);
  color: #1a1200;
  font-size: 0.85rem;
  font-weight: 700;
  flex: none;
}
.card h3 { margin: 22px 0 10px; font-size: 1rem; }

/* --- fields --------------------------------------------------------------- */
.field { margin: 14px 0; }
label, .group-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.req { color: var(--accent); font-weight: 500; text-transform: none; letter-spacing: 0; }

input[type=text], input[type=password], select {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  font: inherit;
}
input:focus, select:focus, button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: transparent;
}
input[type=range] { width: 100%; accent-color: var(--accent); }
input[type=color] {
  width: 100%; height: 42px; padding: 3px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.hint { font-size: 0.85rem; color: var(--muted); margin: 6px 0 0; }
.hint code { background: var(--card-2); padding: 1px 5px; border-radius: 4px; }
.privacy { color: var(--ok); }
.warn-note { color: var(--accent); }
.secrets-warning { color: var(--accent); }
.chosen {
  margin: 10px 0 0; padding: 10px 12px;
  background: var(--card-2);
  border-left: 3px solid var(--ok);
  border-radius: 0 8px 8px 0;
  font-size: 0.9rem;
}

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
@media (max-width: 560px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}

/* --- services ------------------------------------------------------------- */
.services { display: grid; gap: 10px; }
.svc-toggle {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 13px 15px;
  background: var(--card-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
}
.svc-toggle:hover { border-color: var(--accent-dim); }
.svc-toggle input { margin: 3px 0 0; accent-color: var(--accent); flex: none; }
.svc-toggle strong { display: block; font-size: 0.98rem; }
.svc-toggle span { font-size: 0.84rem; color: var(--muted); }
.svc-toggle.on { border-color: var(--accent); }

.bus-slot + .bus-slot {
  margin-top: 14px; padding-top: 12px;
  border-top: 1px dashed var(--line);
}
.bus-slot-head {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-bottom: 4px;
}

.svc {
  margin-top: 6px;
  padding: 4px 0 4px 16px;
  border-left: 2px solid var(--line);
}

/* --- results lists -------------------------------------------------------- */
.results { margin-top: 8px; display: grid; gap: 6px; max-height: 320px; overflow-y: auto; }
.result {
  display: block; width: 100%; text-align: left;
  padding: 9px 12px;
  background: var(--card-2);
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--text);
  font: inherit;
  cursor: pointer;
}
.result:hover { border-color: var(--accent); }
.result .meta { display: block; font-size: 0.8rem; color: var(--muted); }
.results:empty { display: none; }

/* --- themes --------------------------------------------------------------- */
.themes { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
@media (max-width: 560px) { .themes { grid-template-columns: repeat(2, 1fr); } }
.theme {
  padding: 10px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: #000;
  cursor: pointer;
  font: inherit;
  color: inherit;
}
.theme.on { border-color: var(--accent); }
.theme .swatch {
  height: 30px; border-radius: 4px;
  display: grid; place-items: center;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 0.8rem; font-weight: 700;
  margin-bottom: 7px;
}
.theme .tname { font-size: 0.78rem; color: var(--muted); }

/* --- preview -------------------------------------------------------------- */
.preview-wrap { display: grid; place-items: center; }
.board {
  width: 100%; max-width: 480px; aspect-ratio: 320 / 170;
  border-radius: 8px;
  padding: 3.2% 3.5%;
  display: flex; flex-direction: column;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  container-type: inline-size;
  overflow: hidden;
}
.b-head { display: flex; align-items: baseline; gap: 2.5%; }
/* The tag never wraps and never shrinks: drawHeader() measures it first and
   gives the name whatever is left, so a long one ("TUBE VICTORIA") squeezes
   the name rather than folding onto a second line the board does not have. */
.b-tag { font-size: 4.2cqw; letter-spacing: 0.06em; white-space: nowrap; flex-shrink: 0; }
.b-name { font-size: 6.4cqw; font-weight: 700; white-space: nowrap; overflow: hidden; }
.b-rows { margin-top: 2.4%; display: grid; gap: 1.1%; }
.b-row { display: flex; align-items: baseline; gap: 2.5%; font-size: 5.4cqw; white-space: nowrap; }
.b-time { font-size: 4.4cqw; }
.b-dest { flex: 1; overflow: hidden; text-overflow: clip; }
.b-right { font-size: 4.4cqw; }
.b-clock {
  margin-top: auto; text-align: center;
  font-size: 11cqw; font-weight: 700; letter-spacing: 0.06em;
}
.b-empty { text-align: center; font-size: 6cqw; margin: 6% 0; }

.preview-tabs { display: flex; gap: 8px; justify-content: center; margin-top: 14px; }
.ptab {
  padding: 6px 14px; font: inherit; font-size: 0.85rem;
  background: var(--card-2); color: var(--muted);
  border: 1px solid var(--line); border-radius: 999px; cursor: pointer;
}
.ptab.on { color: var(--text); border-color: var(--accent); }

/* --- install -------------------------------------------------------------- */
.install-lead {
  margin: 0 0 18px;
  font-size: 0.9rem;
  color: var(--dim);
}
.install-lead strong { color: var(--text); }

/* The two numbered actions. A board needs either one or both depending on
   whether it has ever been flashed, and the numbering is what makes that
   choice legible without reading a paragraph first. */
.install-step {
  display: flex;
  gap: 14px;
  padding: 16px 0;
  border-top: 1px solid var(--line);
}
.install-step:first-of-type { border-top: 0; padding-top: 0; }
.step-num {
  display: grid;
  place-items: center;
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--accent);
  color: #1a1200;
  font-size: 0.85rem;
  font-weight: 700;
  flex: none;
  margin-top: 6px;
}
.install-step-body { flex: 1; min-width: 0; }
.install-step-body .hint { margin: 8px 0 0; }

.install-option {
  padding: 16px 0;
  border-top: 1px solid var(--line);
}
.install-option:first-of-type { border-top: 0; padding-top: 0; }
.badge {
  font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.06em;
  background: var(--accent); color: #1a1200;
  padding: 2px 7px; border-radius: 999px; vertical-align: 2px;
}

button {
  padding: 11px 20px;
  background: var(--card-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit; font-weight: 600;
  cursor: pointer;
}
button:hover:not(:disabled) { border-color: var(--accent); }
button:disabled { opacity: 0.5; cursor: not-allowed; }
button.primary { background: var(--accent); color: #1a1200; border-color: var(--accent); }
button.link {
  background: none; border: 0; padding: 0;
  color: var(--accent); text-decoration: underline;
  font-weight: 600; font-size: inherit;
}

.status { font-size: 0.85rem; margin-left: 6px; }
.status.ok { color: var(--ok); }
.status.bad { color: var(--bad); }

.problems {
  padding: 12px 14px; margin-bottom: 16px;
  background: #2a1f16;
  border: 1px solid var(--accent-dim);
  border-radius: 8px;
  font-size: 0.9rem;
}
.problems ul { margin: 6px 0 0; padding-left: 20px; }

.log {
  margin-top: 14px; padding: 12px 14px;
  background: #0e1013;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 0.82rem;
  max-height: 260px; overflow-y: auto;
  white-space: pre-wrap;
}
.log .ok { color: var(--ok); }
.log .bad { color: var(--bad); }

details { margin: 14px 0; }
summary { cursor: pointer; color: var(--muted); font-size: 0.88rem; }
summary:hover { color: var(--text); }

footer {
  max-width: 780px; margin: 0 auto; padding: 8px 20px 60px;
  color: var(--muted); font-size: 0.8rem;
}
footer p { margin: 6px 0; }
a { color: var(--accent); }

/* The big-clock preview is a single centred time rather than the shared
   header-and-rows board, so it gets its own rule. */
.board.bigclock { align-items: center; justify-content: center; }
.bc-time {
  font-size: 34cqw;
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1;
}
