/* Light and dark follow the device (prefers-color-scheme). */

:root {
  --bg: #f6f7f7; --surface: #ffffff; --fg: #1a1a1a; --muted: #5f6368; --border: #cfd3d4;
  --accent: #0f766e; --accent-fg: #ffffff; --link: #0f5f99; --error: #b3261e; --ok: #1b6e36; --focus: #1a73e8;
  --warn: #8a5a00; --warn-bg: #fdf3dc;
  --tap: 2.75rem; --max: 40rem;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1c1c1e; --surface: #2a2a2d; --fg: #ececee; --muted: #a3a3ab; --border: #48484e;
    --accent: #2dd4bf; --accent-fg: #06201d; --link: #8ab4f8; --error: #ff8a80; --ok: #7ee0a0; --focus: #8ab4f8;
    --warn: #f5c26b; --warn-bg: #3a2f14;
    color-scheme: dark;
  }
}

html { font-family: system-ui, -apple-system, sans-serif; line-height: 1.45; }
body {
  margin: 0 auto; max-width: var(--max); box-sizing: border-box; background: var(--bg); color: var(--fg);
  padding: 0 max(1rem, env(safe-area-inset-right)) env(safe-area-inset-bottom) max(1rem, env(safe-area-inset-left));
}
a { color: var(--link); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* iOS zooms into inputs below 16px, so controls keep 16px. */
input, button, select, textarea, .button { font: inherit; font-size: 16px; color: var(--fg); background: var(--surface);
  border: 1px solid var(--border); border-radius: .5rem; padding: .3rem .8rem; box-sizing: border-box; max-width: 100%; }
button, .button { min-height: var(--tap); cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
  text-decoration: none; }
input[type=text], input:not([type]), input[type=password], input[type=search], input[type=number], select { min-height: var(--tap); width: 100%; }
textarea { width: 100%; resize: vertical; }
label { display: block; font-size: .9rem; margin-bottom: .15rem; }
button.primary { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); font-weight: 600; }
button.quiet { border-color: transparent; background: none; color: var(--muted); }

header { display: flex; justify-content: space-between; align-items: center;
  padding: .75rem 0; padding-top: max(.75rem, env(safe-area-inset-top)); border-bottom: 1px solid var(--border); }
.brand { font-weight: bold; font-size: 1.15rem; text-decoration: none; color: var(--fg); letter-spacing: .02em; }
h1 { font-size: 1.4rem; margin: 1rem 0 .5rem; }
h2 { font-size: 1rem; margin: 1.25rem 0 .25rem; color: var(--muted); }
.error { color: var(--error); }
.ok { color: var(--ok); }
.note, .hint, .empty { color: var(--muted); }
.hint { font-size: .85rem; margin: .25rem 0 0; min-height: 1.2em; }
.empty { padding: 1rem 0; list-style: none; }

[hidden] { display: none !important; }
.warn { color: var(--warn); background: var(--warn-bg); border-radius: .5rem; padding: .5rem .75rem; }
.acts { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin: .5rem 0; }
.acts form { margin: 0; }

/* the calculations */
.tabs { display: flex; flex-direction: column; gap: .35rem; margin: .75rem 0; }
.tabs a { display: flex; align-items: center; min-height: var(--tap); padding: .3rem .8rem; border: 1px solid var(--border); border-radius: .5rem;
  background: var(--surface); color: var(--fg); text-decoration: none; overflow-wrap: anywhere; }
.tabs a[aria-current] { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); font-weight: 600; }

/* departure time and sort order */
.controls { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start; gap: .5rem; }
.when, .sort { display: flex; flex-wrap: wrap; gap: .35rem; align-items: flex-start; }
.seg { display: inline-flex; align-items: center; justify-content: center; min-height: var(--tap); padding: .3rem .8rem; box-sizing: border-box;
  border: 1px solid var(--border); border-radius: .5rem; background: var(--surface); color: var(--fg); text-decoration: none; font-size: 16px; cursor: pointer; }
.seg[aria-current], .seg[aria-pressed=true] { border-color: var(--fg); font-weight: 600; box-shadow: inset 0 0 0 1px var(--fg); }
summary.seg { list-style: none; }
summary.seg::-webkit-details-marker { display: none; }
.later[open] { display: contents; }
.pick { display: flex; gap: .35rem; flex-basis: 100%; order: 3; }
.pick input { min-height: var(--tap); flex: 1 1 auto; min-width: 7rem; }

/* the results */
.status { display: flex; justify-content: space-between; align-items: center; gap: .5rem; margin: .75rem 0 .5rem; font-size: .9rem; color: var(--muted); }
.status #age { flex: 1 1 auto; }
.auto { display: inline-flex; align-items: center; gap: .35rem; min-height: var(--tap); white-space: nowrap; cursor: pointer; }
.auto[hidden] { display: none; }
.auto input { width: 1.25rem; height: 1.25rem; margin: 0; accent-color: var(--accent); }
.refresh.loading { opacity: .6; pointer-events: none; }
.loading-note { padding: 1rem 0; }
.routes, .journeys, .editroutes { list-style: none; margin: 0; padding: 0; }
.routes { display: flex; flex-direction: column; gap: .6rem; padding-bottom: 1.5rem; }
.route { background: var(--surface); border: 1px solid var(--border); border-radius: .75rem; padding: .6rem .75rem; }
.route-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 0 .75rem; }
.route-head h2 { margin: 0; font-size: 1.05rem; color: var(--fg); }
.best { color: var(--ok); font-size: .85rem; font-weight: 600; }
.lines { margin: 0 0 .25rem; color: var(--muted); font-size: .85rem; }
.none { margin: .25rem 0; color: var(--muted); font-weight: 600; }
.note-cancel { margin: .25rem 0; color: var(--error); font-size: .85rem; }
.route > .error { margin: .25rem 0; }
.journey { padding: .35rem 0; border-top: 1px solid var(--border); }
.journey .times { display: flex; justify-content: space-between; gap: .5rem; align-items: baseline; }
.journey .dur { color: var(--muted); font-size: .85rem; white-space: nowrap; }
.journey .legs { display: flex; flex-wrap: wrap; gap: 0 .6rem; font-size: .8rem; color: var(--muted); }
.journey:first-child { border-top: 0; }
.journey:first-child .times strong { font-size: 1.25rem; }
.late { color: var(--error); font-weight: 600; }
.change.tight { color: var(--warn); font-weight: 600; }

/* the route editor */
.editcalc { border-bottom: 1px solid var(--border); padding-bottom: .75rem; margin-bottom: .75rem; }
.editrow { display: flex; justify-content: space-between; align-items: center; gap: .5rem; }
.editrow h2 { margin: .5rem 0; color: var(--fg); font-size: 1.05rem; overflow-wrap: anywhere; }
.editroutes .editrow { border-top: 1px solid var(--border); padding: .35rem 0; }
.routename { display: block; color: var(--fg); text-decoration: none; font-weight: 600; min-width: 0; overflow-wrap: anywhere; }
.routename .hint { display: block; font-weight: 400; min-height: 0; margin: 0; }
.rowbtns { display: flex; flex: none; gap: .3rem; }
.rowbtns form { margin: 0; }
.rowbtns button { padding: .3rem .7rem; }
.stoppick { margin: 0 0 .75rem; }
.stopresults { display: flex; flex-direction: column; gap: .25rem; margin-top: .25rem; }
.stopresult { justify-content: flex-start; text-align: left; width: 100%; overflow-wrap: anywhere; }
.danger { margin-top: 1rem; }

/* profile menu */
.profile { position: relative; }
.profile summary { list-style: none; cursor: pointer; display: flex; align-items: center; justify-content: center;
  width: var(--tap); height: var(--tap); border: 1px solid var(--border); border-radius: 50%; background: var(--surface); color: var(--fg); }
.profile summary::-webkit-details-marker { display: none; }
.profile summary svg { width: 1.3rem; height: 1.3rem; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; }
.profile[open] summary, .profile.current summary { border-color: var(--fg); }
.profile .menu { position: absolute; right: 0; top: calc(100% + .35rem); z-index: 10; min-width: 11rem; display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--border); border-radius: .5rem; padding: .3rem; }
.profile .who { margin: 0; padding: .3rem .7rem; font-size: .85rem; color: var(--muted); }
.profile .menu form { margin: 0; }
.profile .menu a, .profile .menu button { display: block; width: 100%; box-sizing: border-box; text-align: left; min-height: 0;
  padding: .5rem .7rem; border: 0; border-radius: .35rem; background: none; color: var(--fg); text-decoration: none; }
.profile .menu a:hover, .profile .menu button:hover { background: var(--bg); }

