/* Ratten – vägskyltarnas formspråk: skyltblått, varningsgult, vitt. */
:root {
  --blue: #00539b;
  --blue-deep: #003e75;
  --yellow: #ffcd00;
  --green: #00703c;
  --ground: #eef1f4;
  --surface: #ffffff;
  --line: #c5ced8;
  --ink: #111c27;
  --muted: #485564;
  --link: #00539b;
  --track: #d6dde5;
  --danger: #a4161a;
  --font: 'Barlow', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --display: 'Barlow Semi Condensed', 'Barlow', system-ui, sans-serif;
  --tab-h: 64px;
}
:root[data-theme='dark'] {
  --ground: #0c1218;
  --surface: #17202a;
  --line: #2c3a48;
  --ink: #eef3f7;
  --muted: #a6b4c3;
  --link: #74b6ff;
  --track: #2c3a48;
  --green: #35c27a;
  --danger: #ff8a8a;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--ground); color: var(--ink);
  font-family: var(--font); font-size: 16px; line-height: 1.45;
  font-variant-numeric: tabular-nums; -webkit-font-smoothing: antialiased;
}
h1, h2, h3, p, ul, ol, dl, dd { margin: 0; }
ul, ol { padding: 0; list-style: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--link); }
:focus-visible { outline: 3px solid var(--yellow); outline-offset: 2px; border-radius: 4px; }

#app { max-width: 560px; margin: 0 auto; min-height: 100dvh; display: flex; flex-direction: column; }
.page { flex: 1; padding: calc(16px + env(safe-area-inset-top)) 20px calc(var(--tab-h) + 28px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 22px; }

/* Typ */
.h1 { font-family: var(--display); font-weight: 700; font-size: 30px; line-height: 1.1; letter-spacing: -0.005em; }
.h2 { font-family: var(--display); font-weight: 700; font-size: 21px; line-height: 1.15; }
.h3 { font-weight: 700; font-size: 16px; }
.small { font-size: 14px; }
.muted { color: var(--muted); }
.lead { font-size: 17px; }

/* Knappar */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 0 18px; border-radius: 10px; border: 0; font-weight: 700; font-size: 16px; text-decoration: none; }
.btn-go { background: var(--yellow); color: #111c27; }
.btn-go:active { background: #e6b800; }
.btn-blue { background: var(--blue); color: #fff; }
.btn-line { background: transparent; border: 2px solid var(--line); color: var(--ink); }
.btn-ghost { background: transparent; border: 2px solid rgba(255,255,255,.75); color: #fff; }
.btn-text { background: none; border: 0; padding: 0; min-height: 44px; color: var(--link); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
.btn-danger { color: var(--danger); }
.btn-wide { width: 100%; }
.btn[disabled] { opacity: .55; cursor: default; }
.iconbtn { width: 44px; height: 44px; display: grid; place-items: center; border: 0; background: transparent; color: var(--ink); border-radius: 10px; }

/* Topp */
.top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.seg { display: inline-flex; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 3px; }
.seg button { min-height: 40px; padding: 0 14px; border: 0; border-radius: 999px; background: transparent; color: var(--muted); font-weight: 600; font-size: 14px; }
.seg button[aria-pressed='true'] { background: var(--blue); color: #fff; }

/* Skylten: nästa pass */
.sign { background: var(--blue); border-radius: 18px; padding: 5px; color: #fff; }
.sign-in { border: 2.5px solid #fff; border-radius: 14px; padding: 18px 16px 16px; display: flex; flex-direction: column; gap: 10px; }
.sign-kicker { font-weight: 600; font-size: 15px; color: var(--yellow); }
.sign-title { font-family: var(--display); font-weight: 700; font-size: 32px; line-height: 1.05; }
.sign-meta { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 15px; }
.sign-meta span { display: inline-flex; align-items: center; gap: 6px; }
.sign ul { display: flex; flex-direction: column; gap: 4px; font-size: 16px; }
.sign li { padding-left: 16px; position: relative; }
.sign li::before { content: ''; position: absolute; left: 0; top: .6em; width: 7px; height: 7px; background: var(--yellow); border-radius: 1px; transform: rotate(45deg); }
.sign-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 6px; }

/* Siffror */
.stats { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, .8fr) minmax(0, 1fr); border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.stats div { padding: 12px 14px; }
.stats div + div { border-left: 1px solid var(--line); }
.stats b { display: block; font-family: var(--display); font-size: 21px; line-height: 1.15; white-space: nowrap; }
.stats span { font-size: 13px; color: var(--muted); }

/* Vägen */
.sect { display: flex; flex-direction: column; gap: 10px; }
.sect-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.fas { border-top: 1px solid var(--line); }
.fas:last-child { border-bottom: 1px solid var(--line); }
.fas > summary { list-style: none; display: grid; grid-template-columns: 1fr auto 20px; align-items: center; gap: 10px; min-height: 56px; cursor: pointer; }
.fas > summary::-webkit-details-marker { display: none; }
.fas > summary .chev { transition: transform .15s; color: var(--muted); }
.fas[open] > summary .chev { transform: rotate(90deg); }
.fas-name { font-weight: 700; font-size: 17px; }
.fas-count { font-size: 14px; color: var(--muted); }
.road { position: relative; padding-bottom: 10px; }
.road::before { content: ''; position: absolute; left: 14px; top: 16px; bottom: 26px; width: 2px; background: var(--line); }
.step { position: relative; display: grid; grid-template-columns: 30px 1fr auto; align-items: center; gap: 12px; min-height: 48px; padding: 4px 0; color: inherit; text-decoration: none; }
.step-title { font-size: 16px; font-weight: 500; }
.step.is-next .step-title { font-weight: 700; }
.step-lvl { font-size: 13px; color: var(--muted); text-align: right; }
.mk { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 13px; background: var(--ground); border: 2px solid var(--line); color: var(--muted); }
.mk[data-l='1'] { background: var(--yellow); border-color: var(--yellow); color: #111c27; }
.mk[data-l='2'] { background: var(--blue); border-color: var(--blue); color: #fff; }
.mk[data-l='3'] { background: var(--green); border-color: var(--green); color: #fff; }
:root[data-theme='dark'] .mk[data-l='3'] { color: #06140c; }
.step.is-next .mk[data-l='0'] { border: 3px solid var(--link); color: var(--link); background: var(--surface); }

/* Provklar */
.bars { display: grid; grid-template-columns: auto 1fr 40px; align-items: center; column-gap: 12px; row-gap: 8px; font-size: 15px; }
.bar { height: 8px; border-radius: 4px; background: var(--track); overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--link); border-radius: 4px; }
.bars .pct { text-align: right; color: var(--muted); font-size: 14px; }

/* Lektionskort */
.back { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; font-weight: 600; text-decoration: none; }
.meta { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 15px; color: var(--muted); }
.meta span { display: inline-flex; align-items: center; gap: 6px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.card-coach { border-left: 6px solid var(--blue); }
.list { display: flex; flex-direction: column; gap: 8px; }
.list li { padding-left: 18px; position: relative; }
.list li::before { content: ''; position: absolute; left: 2px; top: .62em; width: 6px; height: 6px; border-radius: 50%; background: var(--muted); }
ol.num { counter-reset: n; display: flex; flex-direction: column; gap: 10px; }
ol.num li { counter-increment: n; display: grid; grid-template-columns: 28px 1fr; gap: 10px; }
ol.num li::before { content: counter(n); width: 28px; height: 28px; border-radius: 50%; background: var(--blue); color: #fff; font-weight: 700; font-size: 14px; display: grid; place-items: center; }
.coach-row dt { font-weight: 700; color: var(--link); margin: 10px 0 4px; }
.coach-row dt:first-child { margin-top: 0; }
.fel dt { font-weight: 600; }
.fel dd { color: var(--muted); margin-bottom: 10px; }
.fel dd:last-child { margin-bottom: 0; }
.rule { display: flex; flex-direction: column; gap: 2px; }
.rule + .rule { border-top: 1px solid var(--line); padding-top: 10px; }
.rule cite { font-style: normal; font-size: 14px; color: var(--muted); }
.note { font-size: 14px; color: var(--muted); }

.lvl { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.lvl button { min-height: 46px; border-radius: 10px; border: 2px solid var(--line); background: var(--surface); font-weight: 600; font-size: 15px; display: flex; align-items: center; gap: 8px; padding: 0 12px; text-align: left; }
.lvl button .dot { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--line); flex: none; }
.lvl button[data-l='1'] .dot { background: var(--yellow); border-color: var(--yellow); }
.lvl button[data-l='2'] .dot { background: var(--blue); border-color: var(--blue); }
.lvl button[data-l='3'] .dot { background: var(--green); border-color: var(--green); }
.lvl button[aria-pressed='true'] { border-color: var(--link); box-shadow: inset 0 0 0 1px var(--link); }
.who { display: flex; justify-content: space-between; gap: 12px; font-size: 15px; }

/* Formulär */
label.f { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: 15px; }
.inp, textarea.inp, select.inp { width: 100%; min-height: 48px; padding: 10px 12px; border-radius: 10px; border: 2px solid var(--line); background: var(--surface); font-weight: 400; font-size: 16px; }
textarea.inp { min-height: 84px; resize: vertical; }
.row2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { min-height: 44px; padding: 0 14px; border-radius: 999px; border: 2px solid var(--line); background: var(--surface); font-weight: 600; font-size: 15px; display: inline-flex; align-items: center; gap: 8px; }
.chip[aria-pressed='true'] { background: var(--blue); border-color: var(--blue); color: #fff; }
.picked { display: flex; flex-direction: column; gap: 8px; }
.picked li { display: grid; grid-template-columns: 30px 1fr 44px; align-items: center; gap: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 6px 4px 6px 10px; }
.err { color: var(--danger); font-weight: 600; }

/* Körläge */
.drive { position: fixed; inset: 0; z-index: 20; background: #002b52; color: #fff; display: flex; flex-direction: column; padding: calc(20px + env(safe-area-inset-top)) 22px calc(22px + env(safe-area-inset-bottom)); gap: 18px; overflow: auto; }
.drive-top { display: flex; justify-content: space-between; align-items: baseline; font-size: 16px; color: #c8d9ea; }
.drive-time { font-family: var(--display); font-weight: 700; font-size: 34px; color: #fff; }
.drive-title { font-family: var(--display); font-weight: 700; font-size: 26px; line-height: 1.1; color: var(--yellow); }
.drive ol { flex: 1; display: flex; flex-direction: column; justify-content: center; gap: 22px; }
.drive ol li { font-family: var(--display); font-weight: 700; font-size: clamp(30px, 9vw, 44px); line-height: 1.08; padding-left: 20px; border-left: 6px solid var(--yellow); }
.drive .btn { min-height: 60px; font-size: 18px; }

/* Platser och logg */
.rowlist { display: flex; flex-direction: column; }
.rowlist > li { padding: 14px 0; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 4px; }
.rowlist > li:last-child { border-bottom: 1px solid var(--line); }
.rowhead { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.tag { font-size: 13px; color: var(--muted); border: 1px solid var(--line); border-radius: 6px; padding: 1px 7px; white-space: nowrap; }

/* Flikar */
.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; background: var(--surface); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.tabs nav { max-width: 560px; margin: 0 auto; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.tabs a { height: var(--tab-h); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 12.5px; font-weight: 500; color: var(--muted); text-decoration: none; }
.tabs a[aria-current='page'] { color: var(--link); font-weight: 700; }

/* Inloggning */
.login { flex: 1; display: flex; flex-direction: column; justify-content: center; gap: 22px; padding: 28px 24px; }
.logo { width: 76px; height: 76px; border-radius: 18px; background: var(--blue); padding: 4px; }
.logo div { width: 100%; height: 100%; border: 2.5px solid #fff; border-radius: 14px; display: grid; place-items: center; color: #fff; }
form.stack, .stack { display: flex; flex-direction: column; gap: 14px; }

.toast { position: fixed; left: 50%; bottom: calc(var(--tab-h) + 18px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 30; background: var(--ink); color: var(--ground); padding: 12px 18px; border-radius: 10px; font-weight: 600; max-width: 88vw; text-align: center; }
.banner { background: var(--yellow); color: #111c27; font-weight: 600; font-size: 14px; padding: 8px 20px; text-align: center; }

@media (min-width: 420px) { .lvl { grid-template-columns: repeat(4, minmax(0, 1fr)); } .lvl button { justify-content: center; padding: 0 6px; font-size: 14px; } .sign-actions { flex-direction: row; } .sign-actions .btn { flex: 1; } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
