.tr { max-width: 760px; margin: 0 auto; padding: 12px 16px 50px; --ok-bg: #e3f4e8; --ok-line: #b6dfc2; --warn-bg: #fff5d6;
  --warn-line: #f0dc9a; --bad-bg: #fde4e1; --bad-line: #f3b8b0; --bad-text: #9b1c12; --ok-text: #1f6b3a; }
@media (prefers-color-scheme: dark) {
  .tr { --ok-bg: #16301f; --ok-line: #2c5a3c; --warn-bg: #3a3014; --warn-line: #6b5a24; --bad-bg: #3d1c18; --bad-line: #74342c;
    --bad-text: #ffb4a8; --ok-text: #8fd6a8; }
}
.tr * { min-width: 0; }
.tr .card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; margin-bottom: 12px; }
.tr .muted { color: var(--muted); } .tr .small { font-size: 13px; }
.tr input, .tr select { height: 42px; border: 1px solid var(--line); border-radius: 9px; padding: 0 10px; font: inherit; width: 100%;
  background: var(--surface); color: var(--text); }
.tr input[type="checkbox"] { width: auto; height: auto; }
.tr .btn { height: 42px; border-radius: 9px; border: 1px solid var(--line); background: var(--surface); color: var(--text); padding: 0 12px;
  cursor: pointer; font: inherit; flex: none; }
.tr .btn.sm { height: 34px; padding: 0 10px; font-size: 14px; }
.tr .btn.icon { width: 42px; padding: 0; }
.tr .btn.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); font-weight: 600; }
.tr .btn:disabled { opacity: .5; cursor: default; }
.tr .row { display: flex; gap: 8px; align-items: center; } .tr .row.wrap { flex-wrap: wrap; margin-top: 10px; }
.tr .f { display: block; font-size: 13px; color: var(--muted); margin: 8px 0 4px; }
.tr .foot { margin-top: 24px; }

.tabs { display: flex; gap: 4px; margin: 0 0 12px; }
.tabs button { flex: 1 1 auto; min-width: min-content; border: 1px solid var(--line); background: var(--surface); color: var(--text); border-radius: 12px; padding: 8px 4px;
  font: inherit; font-size: 14px; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tabs button[aria-pressed="true"] { background: var(--accent); color: var(--accent-text); border-color: var(--accent); font-weight: 600; }
@media (max-width: 520px) { .tabs button { font-size: 12px; padding: 6px 1px; line-height: 1.25; white-space: normal; letter-spacing: -.01em; }
  .tabs .e { display: block; font-size: 17px; } }
.note { background: var(--warn-bg); border: 1px solid var(--warn-line); border-radius: 10px; padding: 8px 12px; font-size: 14px; margin: 0 0 12px; }

/* from / to */
.ft { display: grid; grid-template-columns: 1fr 42px; grid-template-areas: "a s" "b s"; gap: 4px 8px; align-items: end; }
.ft .fld:first-child { grid-area: a; } .ft .fld:last-child { grid-area: b; } .ft .swap { grid-area: s; align-self: center; }
.fld label { display: block; font-size: 13px; color: var(--muted); margin: 4px 0 3px; }
.sw { position: relative; display: flex; gap: 6px; }
.sugg { position: absolute; left: 0; right: 0; top: 46px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  z-index: 50; box-shadow: 0 8px 24px #0003; max-height: 60vh; overflow-y: auto; }
.sugg div { padding: 9px 12px; cursor: pointer; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
.sugg div:last-child { border-bottom: 0; }
.sugg div:hover, .sugg div.on { background: var(--accent-soft); }
.sugg .sub { display: block; font-size: 12.5px; color: var(--muted); }
.sugg .fz { color: var(--warn); }
.sugg .nohit { cursor: default; color: var(--muted); font-size: 13px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin: 10px 0 0; }
.chip { border: 1px solid var(--line); background: var(--surface); color: var(--text); border-radius: 99px; padding: 5px 11px; font-size: 13px;
  cursor: pointer; font-family: inherit; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip[aria-pressed="true"] { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.chip .x { margin-left: 4px; opacity: .7; }
.seg { display: flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; margin-top: 12px; }
.seg button { flex: 1; border: 0; background: var(--surface); color: var(--text); padding: 9px 4px; font: inherit; font-size: 14px; cursor: pointer; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.when { display: grid; grid-template-columns: 1.4fr 1fr; gap: 8px; margin-top: 8px; }

/* line badges */
.ln { display: inline-flex; align-items: center; justify-content: center; min-width: 30px; height: 22px; padding: 0 6px; border-radius: 6px;
  font-weight: 800; font-size: 13px; color: #fff; background: #555; letter-spacing: -.01em; flex: none; line-height: 1; }
.ln.red { background: #d71d24; } .ln.green { background: #148541; } .ln.blue { background: #0072bc; } .ln.metro { background: #444; }
.ln.pendel { background: #e5338a; } .ln.train { background: #6c4f9e; }
.ln.tvar { background: #d77d00; } .ln.roslag { background: #7f4da2; } .ln.saltsjo { background: #1aa6aa; } .ln.lidingo { background: #b76020; }
.ln.tram { background: #7b7e78; } .ln.bus { background: #c8102e; border-radius: 4px; } .ln.bluebus { background: #0089ca; border-radius: 4px; }
.ln.ship { background: #005b8f; } .ln.walk { background: transparent; color: var(--muted); min-width: 0; padding: 0 2px; font-weight: 600; }

/* options */
.opt { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; margin-bottom: 10px; }
.opt.best { border: 2px solid var(--accent); }
.opt.late { opacity: .8; }
.opt .top { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 12px; cursor: pointer; }
.opt .leave { font-size: 15px; } .opt .leave b { font-size: 24px; letter-spacing: -.02em; }
.opt .arr { color: var(--muted); font-size: 14px; } .opt .arr b { color: var(--text); font-size: 16px; }
.opt .tag { margin-left: auto; font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 99px; background: var(--accent-soft); color: var(--accent); }
.opt .tag.late { background: var(--bad-bg); color: var(--bad-text); }
.opt .why { font-size: 14px; margin: 4px 0 2px; color: var(--ok-text); font-weight: 600; }
.opt .why.bad { color: var(--bad-text); }
.strip { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; margin-top: 6px; font-size: 13px; color: var(--muted); }
.strip .sep { opacity: .6; }
.strip .from { margin-left: 4px; overflow-wrap: anywhere; }
.legs { list-style: none; padding: 0; margin: 10px 0 0; border-left: 3px solid var(--line); }
.legs li { padding: 5px 0 5px 12px; position: relative; font-size: 14.5px; overflow-wrap: anywhere; }
.legs li.ride { display: grid; grid-template-columns: auto 1fr; gap: 0 8px; align-items: start; }
.legs li.ride .t { font-variant-numeric: tabular-nums; }
.legs li.ride .dir { display: block; font-size: 12.5px; color: var(--muted); }
.legs li.walk, .legs li.xfer { color: var(--muted); font-size: 13.5px; }
.legs li.xfer.tight { color: var(--bad-text); font-weight: 600; }
.dl { color: var(--bad-text); font-weight: 700; font-size: 13px; }
.dl.ok { color: var(--ok-text); font-weight: 600; }
.rt { font-size: 11px; color: var(--ok-text); }
.cx { color: var(--bad-text); font-weight: 800; }
.devs { margin-top: 8px; display: grid; gap: 6px; }
details.dev { border-radius: 10px; padding: 7px 10px; font-size: 14px; background: var(--surface-2); border: 1px solid var(--line); }
details.dev.major { background: var(--bad-bg); border-color: var(--bad-line); }
details.dev.minor { background: var(--warn-bg); border-color: var(--warn-line); }
details.dev summary { cursor: pointer; overflow-wrap: anywhere; }
details.dev summary .w { color: var(--muted); font-size: 12.5px; }
details.dev p { white-space: pre-line; margin: 6px 0 2px; font-size: 13.5px; overflow-wrap: anywhere; }
details.dev .meta { font-size: 12px; color: var(--muted); }
.more { margin-top: 6px; }

/* hero for a saved trip */
.hero { border-radius: 16px; padding: 14px 16px; margin-bottom: 12px; background: var(--ok-bg); border: 1px solid var(--ok-line); }
.hero.warn { background: var(--warn-bg); border-color: var(--warn-line); } .hero.bad { background: var(--bad-bg); border-color: var(--bad-line); }
.hero .when { font-size: 13.5px; color: var(--muted); display: block; margin: 0; }
.hero .big { font-size: 30px; font-weight: 800; letter-spacing: -.02em; margin: 2px 0; line-height: 1.15; }
.hero .how { font-size: 15px; margin-bottom: 4px; }
.hero .why { font-size: 14px; font-weight: 600; }
.hero .opt { margin: 10px 0 0; background: color-mix(in srgb, var(--surface) 75%, transparent); }
.trips { display: grid; gap: 10px; }
.tripc { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; display: flex; gap: 10px; align-items: center; }
.tripc .main { flex: 1; cursor: pointer; }
.tripc .nm { font-weight: 700; } .tripc .sub { font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.form .grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
@media (max-width: 480px) { .form .grid2 { grid-template-columns: 1fr; } }
.chk { display: flex; gap: 8px; align-items: center; font-size: 14px; margin: 8px 0; }
.back { margin-bottom: 10px; }
h2.h { font-size: 18px; margin: 14px 0 8px; }

/* departures */
.board { list-style: none; margin: 0; padding: 0; }
.board li { display: grid; grid-template-columns: 46px 1fr auto; gap: 2px 10px; align-items: center; padding: 8px 2px; border-bottom: 1px solid var(--line); }
.board .dst { overflow-wrap: anywhere; } .board .dst .s { display: block; font-size: 12px; color: var(--muted); }
.board .tm { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.board .tm .s { display: block; font-size: 12px; font-weight: 400; color: var(--muted); }
.board .msg { grid-column: 1 / -1; font-size: 12.5px; color: var(--bad-text); }
.spin { color: var(--muted); padding: 10px 0; }
.err { color: var(--bad-text); background: var(--bad-bg); border: 1px solid var(--bad-line); padding: 8px 12px; border-radius: 10px; font-size: 14px; }

/* favourites */
.favs { display: grid; gap: 10px; }
.favbar { justify-content: flex-end; margin: 0 0 10px; }
.favc { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 10px 14px 8px; }
.favc .nm { font-weight: 700; font-size: 16px; overflow-wrap: anywhere; }
.favc .board li:last-child { border-bottom: 0; }
.favc .fnote { font-size: 12px; margin: 2px 0 2px; }
.favc .ctl { display: flex; gap: 6px; flex-wrap: wrap; padding: 8px 0 4px; border-top: 1px solid var(--line); margin-top: 6px; }
.tr .btn.danger { border-color: var(--bad-line); background: var(--bad-bg); color: var(--bad-text); }
.favact { margin: 4px 0 6px; align-items: center; }
.favact .ok { color: var(--ok-text); font-weight: 600; }

/* the favourite sheet (bottom sheet on phones, centred dialog on wide screens) */
.sheet-bg { position: fixed; inset: 0; z-index: 1000; background: #0007; display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: var(--surface); color: var(--text); width: min(560px, 100%); max-height: 90vh; overflow-y: auto; overscroll-behavior: contain;
  border-radius: 18px 18px 0 0; padding: 16px 16px max(20px, env(safe-area-inset-bottom)); box-shadow: 0 -8px 32px #0004; outline: none; }
.sheet h2 { font-size: 19px; margin: 0 0 2px; }
.sheet .chips { margin-top: 2px; }
.sheet .chip .s { margin-left: 6px; font-size: 12px; opacity: .75; }
.sheet .chip .ln { height: 18px; min-width: 24px; font-size: 12px; vertical-align: middle; }
.sheet .chip .ln + .s { margin-left: 8px; }
.sheet .prev { margin-top: 10px; }
.sheet .prev p { margin: 0 0 4px; }
.sheet .pv { display: grid; grid-template-columns: 46px 1fr auto; gap: 0 10px; align-items: center; padding: 4px 0; font-size: 14px; }
.sheet .pv .tm { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.sheet .pv .tm .s { margin-left: 6px; font-size: 12px; font-weight: 400; }
.sheet .err { margin-top: 8px; }
body.sheet-open { overflow: hidden; }
@media (min-width: 640px) { .sheet-bg { align-items: center; } .sheet { border-radius: 18px; } }

/* a departure row opens the map */
.board li.go { cursor: pointer; } .board li.go:active { background: var(--line); } .board li .b { display: contents; }
.trmap { position: fixed; inset: 0; z-index: 2000; display: flex; flex-direction: column; background: var(--bg, var(--surface)); color: var(--text); }
body.trmap-open { overflow: hidden; }
.trmap-top { display: flex; gap: 10px; align-items: center; justify-content: space-between; padding: 10px 12px; background: var(--surface); border-bottom: 1px solid var(--line); }
.trmap-dep { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center; flex: 1; }
.trmap-dep .dst .s { display: block; font-size: 12px; color: var(--muted); } .trmap-dep .tm { font-weight: 700; text-align: right; white-space: nowrap; }
.trmap-dep .tm .s { display: block; font-size: 12px; font-weight: 400; color: var(--muted); }
.trmap-mapwrap { flex: 1; min-height: 0; position: relative; } #trmap-map { position: absolute; inset: 0; }
.trmap-navbar { position: absolute; z-index: 1100; left: 8px; right: 8px; top: 8px; display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; padding: 10px 14px; border-radius: 12px; background: #1d4ed8; color: #fff; box-shadow: 0 4px 16px #0006; }
.trmap-navbar[hidden], .trmap-recenter[hidden] { display: none; }
.trmap-navbar .a { font-size: 34px; line-height: 1; min-width: 40px; text-align: center; } .trmap-navbar .t { font-size: 18px; line-height: 1.25; } .trmap-navbar .t b { font-size: 22px; }
.trmap-navbar .t .s { display: block; font-size: 13px; opacity: .85; } .trmap-navbar .r { text-align: right; opacity: .9; white-space: nowrap; }
.trmap-recenter { position: absolute; z-index: 1100; right: 10px; bottom: 14px; box-shadow: 0 2px 8px #0005; }
.trmap-bot .s { display: block; color: var(--muted); } .trmap-bot .ok { color: var(--ok-text, #15803d); font-weight: 600; } .trmap-bot .warn { color: #b45309; font-weight: 600; } .trmap-bot .bad { color: var(--bad-text); font-weight: 600; }
#trmap-voice[aria-pressed="false"] { opacity: .6; }
.trmap-bot { padding: 10px 14px calc(10px + env(safe-area-inset-bottom)); background: var(--surface); border-top: 1px solid var(--line); display: grid; gap: 2px; }
.trmap-stop { width: 34px; height: 34px; border-radius: 50%; background: #fff; border: 2px solid #1d4ed8; display: grid; place-items: center; font-size: 18px; box-shadow: 0 2px 8px #0005; }

.trmap-me { position: relative; width: 48px; height: 48px; }
.trmap-me .rot { position: absolute; inset: 0; transition: transform .15s linear; }
.trmap-me .cone { position: absolute; left: 50%; top: -14px; width: 0; height: 0; margin-left: -22px; border-left: 22px solid transparent; border-right: 22px solid transparent; border-bottom: 38px solid #2563eb55; }
.trmap-me .arrow { position: absolute; left: 12px; top: 12px; width: 24px; height: 24px; filter: drop-shadow(0 1px 3px #0007); }
.trmap-me .dot { display: none; position: absolute; left: 14px; top: 14px; width: 20px; height: 20px; border-radius: 50%; background: #2563eb; border: 3px solid #fff; box-shadow: 0 0 0 6px #2563eb33, 0 1px 4px #0006; box-sizing: border-box; }
.trmap-me.nohead .rot { display: none; } .trmap-me.nohead .dot { display: block; }
