:root {
  --bg: #f4f5f8; --card: #fff; --text: #1b1f2a; --muted: #667085; --line: #e3e6ec;
  --accent: #1f6feb; --accent-text: #fff; --danger: #c62828; --ok: #2e7d32; --navy: #1f2a44;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0f1420; --card: #192132; --text: #e8ebf2; --muted: #98a2b3; --line: #2a3448;
          --accent: #4c8dff; --danger: #ef5350; --ok: #66bb6a; }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }   /* our display rules must never un-hide things */
body { margin: 0; background: var(--bg); color: var(--text);
       font: 17px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
       -webkit-text-size-adjust: 100%; }
main { max-width: 720px; margin: 0 auto;
       padding: max(12px, env(safe-area-inset-top)) 14px max(32px, env(safe-area-inset-bottom)); }
h1 { font-size: 1.6rem; margin: .4rem 0; }
h2 { font-size: 1.2rem; margin: 0 0 .6rem; }
h3 { font-size: 1rem; margin: 1.1rem 0 .4rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
h4 { font-size: 1rem; margin: 1rem 0 .3rem; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.small, small { font-size: .85rem; }
.bar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.who { display: flex; gap: .9rem; align-items: center; }
.card { background: var(--card); border-radius: 16px; padding: 16px; margin: 14px 0;
        box-shadow: 0 1px 2px rgba(0,0,0,.06); }
.center { text-align: center; padding-top: 10vh; }
.logo { width: 84px; height: 84px; }
button { font: inherit; padding: .55rem 1rem; border-radius: 10px; border: 1px solid var(--line);
         background: var(--card); color: var(--text); cursor: pointer; }
button:disabled { opacity: .5; }
button.primary { background: var(--accent); color: var(--accent-text); border-color: transparent; font-weight: 600; }
button.big { font-size: 1.1rem; padding: .8rem 1.6rem; margin: 1rem 0; }
button.link { background: none; border: none; padding: .2rem .3rem; color: var(--accent); }
button.danger, .danger { color: var(--danger); }
.row { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; }
.row.end { justify-content: flex-end; margin-top: 1rem; }
input[type=text], input:not([type]), input[type=time], input[type=number] {
  font: inherit; padding: .5rem .6rem; border: 1px solid var(--line); border-radius: 10px;
  background: var(--bg); color: var(--text); }
input.mins { width: 4.2rem; padding: .2rem .4rem; }
.msg { padding: .6rem .8rem; border-radius: 10px; background: rgba(46,125,50,.12); }
.msg.bad { background: rgba(198,40,40,.12); color: var(--danger); }
.steps li { margin: .5rem 0; }

/* switches */
.switch { display: flex; align-items: center; justify-content: space-between; gap: 1rem;
          padding: .65rem 0; border-top: 1px solid var(--line); cursor: pointer; }
.switch span { display: flex; flex-direction: column; }
.switch small { color: var(--muted); }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch i { flex: none; width: 51px; height: 31px; border-radius: 31px; background: var(--line);
            position: relative; transition: background .2s; }
.switch i::after { content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px;
                   border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.3); transition: left .2s; }
.switch input:checked + i { background: #34c759; }
.switch input:checked + i::after { left: 22px; }
.switch input:focus-visible + i { outline: 2px solid var(--accent); outline-offset: 2px; }
.big-switch { border-top: none; }
.all-off #groups { opacity: .45; }

/* lists */
.list { list-style: none; margin: 0 0 .6rem; padding: 0; }
.list li { display: flex; justify-content: space-between; align-items: center; gap: .6rem;
           padding: .55rem 0; border-top: 1px solid var(--line); }
.list li:first-child { border-top: none; }
.person .actions { display: flex; flex-wrap: wrap; justify-content: flex-end; }
.journey-btn { display: flex; flex-direction: column; align-items: flex-start; width: 100%; text-align: left;
               background: var(--bg); border: none; }
.journey.off .journey-btn { opacity: .55; }

/* trains page */
.board-wrap { position: relative; min-height: 60vh; }
#board-loading { position: absolute; top: 1rem; left: 0; right: 0; text-align: center; }
iframe#trains { display: block; width: calc(100% + 28px); margin: 0 -14px; height: 60vh; border: 0;
                opacity: 0; transition: opacity .15s; }
iframe#trains.ready { opacity: 1; }
.banner { display: block; margin: 6px 0 4px; padding: .7rem 1rem; border-radius: 12px; text-decoration: none;
          background: rgba(31,111,235,.12); color: var(--accent); font-weight: 600; }
.center-link { text-align: center; margin: 1rem 0; }

/* bottom tab bar */
body.tabbed main { padding-bottom: calc(84px + env(safe-area-inset-bottom)); }
.tabs-bar { position: fixed; left: 0; right: 0; bottom: 0; display: flex; justify-content: center; z-index: 5;
            background: var(--card); border-top: 1px solid var(--line);
            padding: 6px 0 max(6px, env(safe-area-inset-bottom)); }
.tabs-bar a { flex: 0 1 200px; display: flex; flex-direction: column; align-items: center; gap: 1px;
              font-size: .75rem; color: var(--muted); text-decoration: none; padding: 2px 0; }
.tabs-bar a span { font-size: 1.35rem; line-height: 1.2; filter: grayscale(1); opacity: .7; }
.tabs-bar a[aria-current=page] { color: var(--accent); font-weight: 600; }
.tabs-bar a[aria-current=page] span { filter: none; opacity: 1; }

/* journey dialog */
dialog { border: none; border-radius: 16px; padding: 18px; width: min(560px, 94vw); max-height: 90vh;
         background: var(--card); color: var(--text); }
dialog::backdrop { background: rgba(0,0,0,.45); }
.field { display: block; margin: .8rem 0; border: none; padding: 0; }
.field input:not([type=checkbox]) { display: block; width: 100%; margin-top: .25rem; }
.field.two { display: flex; gap: .8rem; }
.field.two label { flex: 1; }
legend { padding: 0; margin-bottom: .3rem; }
.days { display: flex; flex-wrap: wrap; gap: .35rem; }
.day { border: 1px solid var(--line); border-radius: 8px; padding: .25rem .5rem; }
.checks { display: flex; flex-direction: column; gap: .35rem; }
.station-line { margin: .5rem 0 0; font-size: .8rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.station-line:first-child { margin-top: 0; }

/* admin */
.invite { margin-top: 1rem; padding: 1rem; background: var(--bg); border-radius: 12px; }
.qr svg { width: 220px; height: auto; background: #fff; padding: 8px; border-radius: 8px; }
code { word-break: break-all; }
.inline { display: flex; align-items: center; gap: .3rem; }
.scroll { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: .85rem; }
th, td { text-align: left; padding: .35rem .45rem; border-top: 1px solid var(--line); white-space: nowrap; }
td:nth-child(4) { white-space: normal; }

#toast { position: fixed; left: 50%; bottom: calc(80px + env(safe-area-inset-bottom)); transform: translateX(-50%);
         background: var(--navy); color: #fff; padding: .7rem 1.1rem; border-radius: 12px; max-width: 90vw;
         box-shadow: 0 4px 16px rgba(0,0,0,.25); z-index: 10; }
#toast.bad { background: var(--danger); }
