:root {
  --bg: #f6f5f1;
  --card: #ffffff;
  --ink: #15181c;
  --dim: #5d646c;
  --line: #dddbd3;
  --accent: #1a56b8;
  --accent-ink: #ffffff;
  --good: #17734a;
  --bad: #b3261e;
  --field: #ffffff;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101214;
    --card: #1a1d21;
    --ink: #eceef0;
    --dim: #9aa2ab;
    --line: #2d3238;
    --accent: #7fb0ff;
    --accent-ink: #0b1a30;
    --good: #5fd19a;
    --bad: #ff8a80;
    --field: #121417;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
main { max-width: 620px; margin: 0 auto; padding: 16px 16px 120px; }
main.wide { max-width: 760px; }

h1 { font-size: 1.5rem; margin: 8px 0 2px; letter-spacing: -0.01em; }
h2 { font-size: 1.05rem; margin: 28px 0 10px; }
p { margin: 0 0 12px; }
a { color: var(--accent); }
.dim { color: var(--dim); }
.small { font-size: 0.875rem; }
code, .mono { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 0.9em; }
[hidden] { display: none !important; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  margin: 0 0 12px;
}
.error { border-color: var(--bad); color: var(--bad); }

/* The device, drawn: a dark body with the screen in it. */
.device {
  background: #0c0d0e;
  border: 1px solid #2b2f34;
  border-radius: 14px;
  padding: 10px;
}
.device .glass { background: #000; border-radius: 4px; overflow: hidden; }
.preview { position: sticky; top: 8px; z-index: 5; margin-bottom: 4px; }

button, input, select { font: inherit; color: inherit; }
button {
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  cursor: pointer;
}
button:hover { border-color: var(--dim); }
button:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
button.primary:disabled { opacity: 0.45; cursor: default; }
button.quiet { border-color: transparent; background: none; color: var(--dim); padding: 0 10px; }
button.quiet:hover { color: var(--ink); }

input[type=text], input[type=search], select {
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--field);
}

/* A row of choices where exactly one is on. */
.seg { display: flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--field); }
.seg button {
  flex: 1; border: 0; border-radius: 0; background: none; min-height: 42px; padding: 0 8px; white-space: nowrap;
}
.seg button + button { border-left: 1px solid var(--line); }
.seg button[aria-pressed=true] { background: var(--accent); color: var(--accent-ink); font-weight: 600; }

.field { display: grid; grid-template-columns: 1fr; gap: 6px; margin: 0 0 14px; }
.field > label, .field > .label { font-size: 0.875rem; color: var(--dim); }
@media (min-width: 520px) {
  .field { grid-template-columns: 150px 1fr; align-items: center; gap: 12px; }
}
.check { display: flex; align-items: center; gap: 10px; min-height: 40px; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); flex: none; }

.stepper { display: inline-flex; align-items: center; gap: 4px; }
.stepper button { width: 44px; padding: 0; font-size: 1.2rem; }
.stepper output { min-width: 2.2em; text-align: center; font-variant-numeric: tabular-nums; font-weight: 600; }

.results { list-style: none; margin: 8px 0 0; padding: 0; }
.results button {
  width: 100%; text-align: left; display: flex; justify-content: space-between; gap: 10px; align-items: center;
  border-radius: 0; border-width: 0 0 1px; background: none;
}
.results li:last-child button { border-bottom: 0; }
.results .modes { color: var(--dim); font-size: 0.8rem; white-space: nowrap; }

.stop-head { display: flex; align-items: center; gap: 8px; }
.stop-head strong { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.stop-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 10px; flex-wrap: wrap; }
.lines { margin-top: 10px; border-top: 1px solid var(--line); padding-top: 8px; }
.lines .check span.to { color: var(--dim); }
.pill {
  display: inline-block; min-width: 2.4em; padding: 1px 7px; border-radius: 5px; text-align: center;
  background: var(--line); font-weight: 600; font-size: 0.9rem; white-space: nowrap;
}

.savebar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(8px);
  border-top: 1px solid var(--line);
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
}
.savebar > div { max-width: 588px; margin: 0 auto; display: flex; align-items: center; gap: 12px; }
.savebar .note { flex: 1; font-size: 0.875rem; color: var(--dim); }
.savebar .note.ok { color: var(--good); }
.savebar .note.bad { color: var(--bad); }

/* Simulator */
.sim-device { display: flex; align-items: center; gap: 14px; }
.sim-device .device { flex: 1; min-width: 0; }
/* An upright display would otherwise grow as tall as the page is wide. */
.sim-device.upright .device { flex: 0 1 280px; }
.sim-button {
  flex: none; width: 64px; height: 64px; min-height: 64px; border-radius: 50%; padding: 0;
  background: #24282d; color: #fff; border: 2px solid #4a5058; font-size: 0.75rem; font-weight: 600;
}
.sim-button:active { transform: scale(0.94); background: #353b42; }
.log {
  margin: 0; padding: 10px; max-height: 320px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere;
  font: 12px/1.5 ui-monospace, Menlo, Consolas, monospace; background: var(--field);
  border: 1px solid var(--line); border-radius: 10px;
}
ol.steps { padding-left: 1.2em; margin: 0 0 12px; }
ol.steps li { margin-bottom: 6px; }
.inline { display: flex; gap: 8px; }
.inline input { flex: 1; min-width: 0; }
