:root {
  --sign: #00653a;
  --sign-deep: #004f2d;
  --sign-ink: #ffffff;
  --bg: #e9eeea;
  --card: #ffffff;
  --ink: #142019;
  --muted: #56665d;
  --line: #d3dbd5;
  --ok: #1f7a3a;
  --info: #56665d;
  --warn: #f2a900;
  --warn-ink: #6b4700;
  --warn-bg: #fff4d6;
  --bad: #c62828;
  --bad-ink: #ffffff;
  --shield: #ffffff;
  --shield-ink: #14201a;
  --radius: 10px;
  --font: 'Overpass', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --sign: #0a5a35;
    --sign-deep: #08472a;
    --bg: #0c1310;
    --card: #16201b;
    --ink: #e7eee9;
    --muted: #9cada3;
    --line: #2a3830;
    --ok: #4cc26e;
    --info: #9cada3;
    --warn: #f5b82e;
    --warn-ink: #ffd77a;
    --warn-bg: #3a2e10;
    --bad: #e5484d;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --sign: #0a5a35; --sign-deep: #08472a; --bg: #0c1310; --card: #16201b; --ink: #e7eee9; --muted: #9cada3;
  --line: #2a3830; --ok: #4cc26e; --info: #9cada3; --warn: #f5b82e; --warn-ink: #ffd77a; --warn-bg: #3a2e10;
  --bad: #e5484d; color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.35 var(--font);
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}
button { font: inherit; color: inherit; }
a { color: inherit; }
img { display: block; }

/* header: a highway guide sign */
.top {
  background: var(--sign);
  color: var(--sign-ink);
  padding: calc(env(safe-area-inset-top) + 10px) max(12px, env(safe-area-inset-right)) 10px max(12px, env(safe-area-inset-left));
  box-shadow: 0 2px 0 var(--sign-deep);
}
.sign { display: flex; align-items: center; justify-content: space-between; gap: 10px; max-width: 1200px; margin: 0 auto; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 20px; letter-spacing: .06em; }
.mark { width: 28px; height: 28px; }
.refresh {
  display: flex; align-items: center; gap: 6px;
  background: transparent; border: 2px solid rgba(255,255,255,.75); border-radius: 999px;
  color: var(--sign-ink); padding: 4px 10px 3px; font-size: 14px; font-weight: 600; cursor: pointer;
  min-height: 36px;
}
.refresh svg { width: 18px; height: 18px; }
.refresh.spin svg { animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .refresh.spin svg { animation: none; opacity: .6; } }
.trips { display: flex; gap: 8px; max-width: 1200px; margin: 10px auto 0; }
.trips button {
  flex: 1 1 0; min-height: 44px; cursor: pointer;
  background: transparent; color: var(--sign-ink);
  border: 2px solid rgba(255,255,255,.75); border-radius: 8px;
  font-weight: 800; font-size: 17px; letter-spacing: .02em; padding: 6px 8px 4px;
}
.trips button[aria-pressed="true"] { background: var(--sign-ink); color: var(--sign); border-color: var(--sign-ink); }
.trips .arrow { font-weight: 800; margin-right: 4px; }

/* alert banner */
.banner { max-width: 1200px; width: calc(100% - 24px); margin: 10px auto 0; display: grid; gap: 6px; }
.banner[hidden] { display: none; }
.alert {
  display: flex; gap: 10px; align-items: flex-start; text-align: left; width: 100%; cursor: pointer;
  border: 0; border-radius: var(--radius); padding: 10px 12px 9px; font-weight: 600; font-size: 15px;
}
.alert.bad { background: var(--bad); color: var(--bad-ink); }
.alert.warn { background: var(--warn); color: #241a00; }
.alert.note { background: var(--card); color: var(--ink); border: 1px solid var(--line); font-weight: 400; }
.alert svg { width: 20px; height: 20px; flex: none; margin-top: 1px; }
.alert b { font-weight: 800; }

/* board */
.board {
  flex: 1;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 12px max(8px, env(safe-area-inset-right)) 8px max(8px, env(safe-area-inset-left));
  display: grid;
  gap: 8px;
  align-items: start;
}
.board.cols-1 { grid-template-columns: minmax(0, 760px); justify-content: center; }
.board.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 700px) { .board { gap: 14px; padding-left: max(14px, env(safe-area-inset-left)); padding-right: max(14px, env(safe-area-inset-right)); } }

.route { container-type: inline-size; min-width: 0; }
.route-head {
  width: 100%; text-align: left; cursor: pointer;
  background: var(--sign); color: var(--sign-ink);
  border: 2px solid var(--sign-ink); outline: 2px solid var(--sign); border-radius: var(--radius);
  padding: 8px 10px 8px; display: grid; gap: 4px;
}
.route-name { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-weight: 800; font-size: 19px; line-height: 1.1; }
.shield {
  display: inline-grid; place-items: center; min-width: 30px; height: 28px; padding: 3px 5px 0;
  background: var(--shield); color: var(--shield-ink); font-weight: 800; font-size: 15px;
  border-radius: 4px 4px 12px 12px; border: 1.5px solid var(--shield-ink);
}
.via { font-size: 13px; opacity: .9; }
.status {
  justify-self: start; display: inline-flex; align-items: center; gap: 5px;
  font-size: 13px; font-weight: 800; letter-spacing: .02em; padding: 3px 8px 1px; border-radius: 999px;
  background: rgba(255,255,255,.95); color: var(--sign);
}
.status.warn { background: var(--warn); color: #241a00; }
.status.bad { background: var(--bad); color: #fff; }
.fc { font-size: 13px; line-height: 1.3; opacity: .95; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.fc b { font-weight: 800; }

.cps { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 8px; position: relative; }
.cp {
  width: 100%; text-align: left; cursor: pointer; padding: 0; overflow: hidden;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  border-left: 6px solid var(--ok);
  display: grid; grid-template-columns: 1fr;
}
.cp.l2 { border-left-color: var(--warn); }
.cp.l3 { border-left-color: var(--bad); }
.cp.nodata { border-left-color: var(--line); }
.cam { position: relative; aspect-ratio: 800 / 468; background: #1d2a22; overflow: hidden; }
.cam img { width: 100%; height: 100%; object-fit: cover; }
.cam .none { position: absolute; inset: 0; display: grid; place-items: center; color: #b7c4bc; font-size: 13px; font-weight: 600; text-align: center; padding: 6px; }
.chip {
  position: absolute; bottom: 5px; right: 5px; font-size: 12px; font-weight: 800; line-height: 1;
  padding: 4px 6px 2px; border-radius: 5px; background: rgba(0,0,0,.66); color: #fff;
}
.chip.old { background: var(--warn); color: #241a00; }
.chip.elev { right: auto; left: 5px; }
.info { padding: 7px 9px 8px; display: grid; gap: 3px; min-width: 0; }
.cp-name { font-weight: 800; font-size: 16px; line-height: 1.15; }
.wx { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; font-size: 14px; color: var(--muted); }
.wx .road { font-size: 22px; font-weight: 800; color: var(--ink); line-height: 1; }
.wx .road small { font-size: 12px; font-weight: 600; color: var(--muted); margin-left: 2px; }
.wx .pave { font-weight: 800; color: var(--ink); }
.wx .pave.warn { color: var(--warn-ink); }
.wx.empty { font-size: 13px; }
.tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 2px; }
.tag { font-size: 12px; font-weight: 800; padding: 3px 6px 1px; border-radius: 5px; background: var(--bg); color: var(--muted); border: 1px solid var(--line); }
.tag.warn { background: var(--warn-bg); color: var(--warn-ink); border-color: transparent; }
.tag.bad { background: var(--bad); color: #fff; border-color: transparent; }
.tag.cond { background: var(--warn-bg); color: var(--warn-ink); border-color: transparent; }

.leg {
  width: 100%; cursor: pointer; text-align: left; font-size: 13px; font-weight: 600; color: var(--muted);
  background: transparent; border: 1px dashed var(--line); border-radius: var(--radius); padding: 6px 9px 4px;
}

/* wider columns: camera beside the details */
@container (min-width: 340px) {
  .cp { grid-template-columns: minmax(150px, 46%) 1fr; }
  .cam { aspect-ratio: auto; min-height: 118px; }
  .info { padding: 9px 12px; align-content: start; }
  .cp-name { font-size: 18px; }
}

.foot { max-width: 1200px; width: 100%; margin: 0 auto; padding: 12px 14px calc(env(safe-area-inset-bottom) + 18px); font-size: 13px; color: var(--muted); text-align: center; }
.foot p { margin: 4px 0; }
.linkish { background: none; border: 0; padding: 0; text-decoration: underline; cursor: pointer; color: inherit; }

.skeleton { height: 160px; border-radius: var(--radius); background: var(--card); border: 1px solid var(--line); opacity: .6; }

/* detail sheet */
.sheet {
  border: 0; padding: 0; color: var(--ink); background: var(--card);
  width: min(640px, 100vw); max-width: 100vw; max-height: 92dvh;
  border-radius: 14px; box-shadow: 0 10px 40px rgba(0,0,0,.35);
}
.sheet::backdrop { background: rgba(5,12,8,.55); }
@media (max-width: 640px) {
  .sheet { margin: auto 0 0; width: 100vw; border-radius: 14px 14px 0 0; max-height: 90dvh; }
}
.sheet-bar {
  position: sticky; top: 0; z-index: 1; display: flex; align-items: center; gap: 10px; justify-content: space-between;
  background: var(--sign); color: var(--sign-ink); padding: 10px 10px 8px 14px;
}
.sheet-bar h2 { margin: 0; font-size: 19px; font-weight: 800; line-height: 1.15; }
.close { flex: none; width: 40px; height: 40px; border-radius: 999px; border: 2px solid rgba(255,255,255,.75); background: transparent; color: #fff; cursor: pointer; display: grid; place-items: center; }
.close svg { width: 20px; height: 20px; }
.sheet-body { padding: 0 0 calc(env(safe-area-inset-bottom) + 14px); }
.sheet-body section { padding: 12px 14px 4px; }
.sheet-body h3 { margin: 0 0 6px; font-size: 13px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); font-weight: 800; }
.big-cam { position: relative; background: #1d2a22; aspect-ratio: 800 / 468; }
.big-cam img { width: 100%; height: 100%; object-fit: contain; }
.dirs { display: flex; gap: 6px; padding: 10px 14px 0; flex-wrap: wrap; }
.dirs button { min-height: 36px; min-width: 52px; border-radius: 8px; border: 2px solid var(--sign); background: transparent; color: var(--ink); font-weight: 800; cursor: pointer; padding: 4px 10px 2px; }
.dirs button[aria-pressed="true"] { background: var(--sign); color: #fff; }
.caption { font-size: 14px; color: var(--muted); margin: 8px 0 0; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 8px; }
.stat { background: var(--bg); border-radius: 8px; padding: 8px 10px 6px; }
.stat .k { font-size: 12px; color: var(--muted); font-weight: 600; }
.stat .v { font-size: 20px; font-weight: 800; line-height: 1.2; }
.stat .v.warn { color: var(--warn-ink); }
.src { font-size: 13px; color: var(--muted); margin: 8px 0 0; }
.evs { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.ev { border: 1px solid var(--line); border-left: 5px solid var(--info); border-radius: 8px; padding: 8px 10px 6px; font-size: 14px; }
.ev.l1 { border-left-color: var(--line); }
.ev.l2 { border-left-color: var(--warn); }
.ev.l3 { border-left-color: var(--bad); }
.ev .h { font-weight: 800; font-size: 13px; display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: center; margin-bottom: 3px; }
.ev .t { color: var(--muted); font-weight: 600; }
.empty-note { color: var(--muted); font-size: 14px; margin: 0; }
.out { display: inline-flex; align-items: center; gap: 6px; font-weight: 800; color: var(--ok); text-decoration: none; padding: 8px 0; }
.fcs { display: grid; gap: 10px; }
.fcs .fn { font-weight: 800; margin-bottom: 2px; }
.fcs p { margin: 0 0 4px; font-size: 14px; }
.about { padding: 4px 16px 6px; font-size: 15px; }
.about h3 { margin: 16px 0 4px; }
.about ul { padding-left: 20px; margin: 4px 0; }

:focus-visible { outline: 3px solid var(--warn); outline-offset: 2px; }
.foot a, .foot .linkish { display: inline-block; padding: 6px 2px; }

/* phones on their side: brand, refresh and trips share one row */
@media (orientation: landscape) and (max-height: 500px) {
  .top { display: flex; align-items: center; gap: 12px; padding-top: calc(env(safe-area-inset-top) + 6px); padding-bottom: 6px; }
  .sign { margin: 0; flex: none; gap: 12px; }
  .trips { margin: 0; flex: 1; }
  .trips button { min-height: 40px; padding-top: 4px; padding-bottom: 2px; }
}
