:root {
  --bg: #121417; --surface: #1D2126; --surface-2: #262B31; --line: #2E343B;
  --text: #ECEAE4; --muted: #9CA3AB; --accent: #F2A33A; --on-accent: #121417;
  --care: #FF7A66; --seen: #CFE3F0; --chk-bg: #3B3420; --chk: #F5D58A;
  --sos-bg: #2A1414; --sos-line: #4A2222; --sos-btn: #3A1B1B; --sos-text: #FFE1DC; --sos-label: #FFB4A8;
  --route: #3A424B; --route-done: #8A6A3A; --ele: #262B31;
  --fs: 19px;
  color-scheme: dark;
}
:root[data-theme="night"] {
  --bg: #000; --surface: #140403; --surface-2: #1E0705; --line: #2A0A07;
  --text: #D9473A; --muted: #9A3328; --accent: #E0402F; --on-accent: #000;
  --care: #FF5A44; --seen: #C2392C; --chk-bg: #2A0A07; --chk: #E0402F;
  --sos-bg: #000; --sos-line: #2A0A07; --sos-btn: #140403; --sos-text: #D9473A; --sos-label: #9A3328;
  --route: #3A0E09; --route-done: #6E1A12; --ele: #1E0705;
}
* { box-sizing: border-box; }
html { height: 100%; background: var(--bg); -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100%; background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", sans-serif;
  font-size: 16px; line-height: 1.4;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  -webkit-tap-highlight-color: transparent;
}
button, a { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* Emergency header */
.sos {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: calc(env(safe-area-inset-top, 0px) + 10px) 12px 10px;
  background: var(--sos-bg); border-bottom: 1px solid var(--sos-line);
}
.sos-label { font-size: 13px; font-weight: 600; color: var(--sos-label); }
.sos-btn {
  display: flex; align-items: center; gap: 6px; text-decoration: none;
  color: var(--sos-text); background: var(--sos-btn); font-size: 15px; font-weight: 600;
  padding: 9px 10px; border-radius: 10px; min-height: 40px; white-space: nowrap;
}
.sos-btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.progress { height: 4px; background: var(--surface); position: sticky; top: calc(env(safe-area-inset-top, 0px) + 61px); z-index: 9; }
.progress-bar { height: 4px; width: 0; background: var(--accent); transition: width .3s; }

main { padding: 18px 16px 0; max-width: 640px; margin: 0 auto; }
.page { display: flex; flex-direction: column; gap: 14px; min-height: calc(100vh - 140px); min-height: calc(100dvh - 140px); }
.row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.sec-name { font-size: 14px; color: var(--muted); }
h1.step-id { margin: 0; font-size: 56px; line-height: 1; font-weight: 800; letter-spacing: -.02em; }
h1.big { margin: 0; font-size: 32px; line-height: 1.1; font-weight: 800; }
h2 { margin: 6px 0 0; font-size: 20px; }
.meta { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; text-align: right; }
.meta strong { font-size: 16px; }

.card { background: var(--surface); border-radius: 16px; padding: 16px 18px; }
.text { font-size: var(--fs); line-height: 1.55; }
.text p { margin: 0 0 .7em; }
.text p:last-child { margin-bottom: 0; }
.text p.opt { padding-left: 1em; text-indent: -1em; }
.text b { color: var(--accent); font-weight: 700; }
.text em { color: var(--seen); }
.text u { text-decoration-thickness: 1px; text-underline-offset: 3px; }
.care { color: var(--care); font-weight: 600; }
:root[data-theme="night"] .care { text-decoration: underline wavy; text-underline-offset: 4px; }
.chk {
  display: inline-block; font-size: .72em; font-weight: 600; line-height: 1.3; text-indent: 0;
  background: var(--chk-bg); color: var(--chk); padding: 1px 7px; border-radius: 6px; vertical-align: 1px;
}
.endref { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 15px; }
.endref svg, .icon { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.ticked-note { color: var(--accent); font-weight: 600; font-size: 15px; }

/* Bottom action bar */
.actions {
  position: sticky; bottom: 0; display: flex; gap: 10px;
  margin: auto -16px 0; padding: 12px 16px calc(env(safe-area-inset-bottom, 0px) + 16px);
  background: linear-gradient(to bottom, transparent, var(--bg) 18px);
}
.btn {
  height: 64px; border-radius: 16px; border: 0; background: var(--surface); color: var(--text);
  display: flex; align-items: center; justify-content: center; gap: 10px; font-size: 18px; font-weight: 600;
  text-decoration: none; padding: 0 14px;
}
.btn.sq { width: 60px; flex: none; padding: 0; }
.btn.main { flex: 1; background: var(--accent); color: var(--on-accent); font-weight: 700; font-size: 19px; }
.btn.done { flex: 1; background: var(--surface-2); color: var(--accent); }
.btn.small { height: 48px; font-size: 16px; border-radius: 12px; }
.btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }

/* Grid tiles */
.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.tile { background: var(--surface); border-radius: 14px; padding: 12px 14px; }
.tile .k { font-size: 13px; color: var(--muted); }
.tile .v { font-size: 26px; font-weight: 700; }
.v.warn { color: var(--accent); } .v.bad { color: var(--care); }
.info { display: flex; flex-direction: column; gap: 6px; font-size: 16px; }
.copy { background: none; border: 0; padding: 0; text-align: left; font-weight: 700; text-decoration: underline; text-decoration-color: var(--line); text-underline-offset: 3px; }

/* Lists */
.list { display: flex; flex-direction: column; gap: 6px; margin: 0; padding: 0; list-style: none; }
.list a {
  display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 10px 14px;
  background: var(--surface); border-radius: 12px; text-decoration: none;
}
.list .lid { font-weight: 800; font-size: 18px; width: 46px; flex: none; }
.list .lmain { flex: 1; min-width: 0; }
.list .lsub { font-size: 14px; color: var(--muted); }
.list .tick { width: 28px; height: 28px; border-radius: 14px; border: 2px solid var(--line); flex: none; display: flex; align-items: center; justify-content: center; }
.list .tick.on { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.list .tick svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.list a.cp { background: var(--surface-2); }
.list a.current { outline: 2px solid var(--accent); outline-offset: -2px; }

table.cps { width: 100%; border-collapse: collapse; font-size: 15px; }
table.cps th { text-align: left; font-weight: 600; color: var(--muted); padding: 6px 4px; font-size: 13px; }
table.cps td { padding: 10px 4px; border-top: 1px solid var(--line); }
table.cps td.num { font-variant-numeric: tabular-nums; }
.warn { color: var(--accent); } .bad { color: var(--care); }

/* Route panel */
.route-toggle { width: 100%; }
.route { display: flex; flex-direction: column; gap: 10px; }
.route svg.map, .route svg.ele { width: 100%; height: auto; display: block; }
.route .where { font-size: 15px; }
.seg { display: flex; background: var(--surface); border-radius: 12px; padding: 4px; gap: 4px; }
.seg button { flex: 1; min-height: 44px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); font-weight: 600; }
.seg button[aria-pressed="true"] { background: var(--surface-2); color: var(--text); }
.settings { display: flex; flex-direction: column; gap: 18px; }
.settings label { font-weight: 600; display: block; margin-bottom: 8px; }
.danger { color: var(--care); }
@media (prefers-reduced-motion: reduce) { .progress-bar { transition: none; } }
.page > .btn.main { flex: none; }
.row > .sec-name:first-child { flex: 1; min-width: 0; }
.row > .sec-name:last-child { white-space: nowrap; }
.chk { display: inline; -webkit-box-decoration-break: clone; box-decoration-break: clone; }
