/* MarSim — ekran projektowany w 1664 × 744 px i skalowany do okna (src/main.js: fit). */
:root {
  /* powierzchnie */
  --bg: #020000; --panel: #060200; --card: #0f0b05; --raised: #0d0905; --hover: #1a130b; --rowHi: #1d170f;
  --line: #17110b; --line2: #2a2117; --line3: #3a2c1d;
  /* tekst */
  --text: #ffffff; --text2: #a5a6a2; --text3: #726e68; --text4: #4c4842;
  /* akcenty */
  --accent: #f17778; --accentDim: #5a2c2d; --accentBg: #3a1c1d;
  --route: #ffdc52; --trail: #f28586; --pick: #5ee6d0;
  --ok: #8fe0a8; --okBg: #12301d; --warn: #ffc24d; --warnBg: #4d3608; --bad: #ff8a70; --badBg: #5a1408;
  --alertTitle: #fab137; --alertBorder: #ebbc98;
  --sans: 'Inter', system-ui, 'Segoe UI', sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, Consolas, monospace;
  --radius: 7px;
}

* { box-sizing: border-box; scrollbar-width: thin; scrollbar-color: var(--line3) transparent; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); overflow: hidden; font-family: var(--sans); }
button, input, select { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; font-weight: inherit; }
button:focus-visible, select:focus-visible, input:focus-visible, a:focus-visible, [tabindex]:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; } }

#stage { position: absolute; left: 0; top: 0; width: 1664px; height: 744px; transform-origin: 0 0; background: var(--bg); }
.skip { position: absolute; left: 8px; top: -40px; z-index: 100; background: var(--accent); color: #000; padding: 6px 10px; border-radius: 6px; font: 600 13px var(--sans); }
.skip:focus { top: 8px; }

/* ---------- przyciski i przełączniki ---------- */
.btn, .seg button { background: var(--raised); border: 0; padding: 6px 10px; font: 600 12px var(--mono); letter-spacing: .04em; color: var(--text2); cursor: pointer; white-space: nowrap; }
.btn { border: 1px solid var(--line2); border-radius: var(--radius); }
.btn:hover, .seg button:hover { color: var(--text); background: var(--hover); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.accent { color: var(--accent); border-color: var(--accentDim); }
.btn.primary { color: #140606; background: var(--accent); border-color: var(--accent); }
.btn.primary:hover { background: #f58d8e; color: #140606; }
.btn.on { background: var(--accentBg); color: var(--text); border-color: var(--accent); }
.btn.round { width: 28px; height: 28px; padding: 0; border-radius: 50%; font-size: 14px; }
.seg { display: flex; border: 1px solid var(--line2); border-radius: var(--radius); overflow: hidden; }
.seg button + button { border-left: 1px solid var(--line2); }
.seg button.on { background: #22190f; color: var(--text); }
.seg.lang button { padding: 6px 8px; }

/* ---------- nagłówek ---------- */
#hdr { position: absolute; left: 0; top: 0; width: 1664px; height: 56px; background: var(--panel); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 16px; padding: 0 16px 0 20px; }
.logo { color: var(--accent); font-weight: 600; font-size: 22px; letter-spacing: .2em; }
.missionSel { max-width: 240px; background: var(--raised); color: var(--text); border: 1px solid var(--line2); border-radius: var(--radius); padding: 5px 8px; font: 600 12px var(--mono); }
.title { flex: 1 1 0; min-width: 0; font-size: 16px; color: var(--text2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.controls { flex: none; display: flex; gap: 8px; align-items: center; }

/* ---------- panele boczne ---------- */
.panel { position: absolute; top: 83px; width: 318px; height: 647px; background: var(--panel); border: 1px solid var(--line); border-radius: 11px;
  display: flex; flex-direction: column; padding: 16px; }
#left { left: 15px; padding: 16px 8px 14px; }
#right { left: 1331px; }
.ph { font-family: var(--mono); font-size: 13px; font-weight: 600; letter-spacing: .16em; color: var(--text2); text-transform: uppercase; white-space: nowrap; }

/* lewy panel: warstwy i legenda */
#left > .ph { padding: 0 8px 10px; }
#layerList { flex: 1 1 auto; min-height: 0; overflow: hidden auto; }   /* przy długiej legendzie lista przewija się w ramce panelu */
/* zanikający dół listy, gdy są pod nim jeszcze warstwy (oś przewijania nieaktywna, gdy lista się mieści) */
@supports (animation-timeline: scroll()) {
  #layerList { animation: listMore linear both; animation-timeline: scroll(self); }
  @keyframes listMore { from, 97% { mask-image: linear-gradient(#000 calc(100% - 28px), transparent); } to { mask-image: none; } }
}
.lrow { position: relative; height: 44px; border-radius: 9px; cursor: pointer; user-select: none; }
.lrow:hover { background: var(--hover); }
.lrow.hi { background: var(--rowHi); }
.lrow .sw { position: absolute; left: 14px; top: 10px; width: 11px; height: 11px; border-radius: 2px; }
.lrow .nm { position: absolute; left: 38px; top: 3px; font-size: 16px; color: var(--text3); }
.lrow .ds { position: absolute; left: 38px; top: 24px; font-size: 13px; color: var(--text4); white-space: nowrap; }
.lrow.on .nm { color: var(--text); }
.lrow.on .ds { color: var(--text2); }
.lrow .key { position: absolute; right: 62px; top: 13px; font: 600 10px var(--mono); color: var(--text4); border: 1px solid var(--line2); border-radius: 4px; padding: 1px 5px; }
.tg { position: absolute; right: 12px; top: 12px; width: 38px; height: 20px; border-radius: 10px; background: #3c362e; transition: background .1s; }
.tg::after { content: ''; position: absolute; top: 3px; left: 3px; width: 14px; height: 14px; border-radius: 50%; background: #48413a; transition: transform .1s, background .1s; }
.lrow.on .tg { background: var(--accent); }
.lrow.on .tg::after { transform: translateX(18px); background: #040100; }
#legend { flex: none; margin: 8px 8px 0; border-top: 1px solid var(--line2); padding-top: 10px; min-height: 52px; max-height: 45%; overflow: hidden auto; }
.lg { display: flex; align-items: center; gap: 9px; font-size: 13px; line-height: 1.2; margin-top: 5px; }
.lg:first-child { margin-top: 0; }
.lg i { width: 11px; height: 11px; flex: none; border-radius: 2px; }
.hourpick { display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--text2); margin-bottom: 8px; }
.hourpick b { color: var(--text); font-family: var(--mono); }
.hourpick input { accent-color: var(--accent); width: 100%; }

/* prawy panel: zegar, stan wyjścia, środowisko, załoga */
#right { gap: 0; }
#right > .ph { margin-top: 14px; }
#right > .clock { margin-top: 0; font-size: 15px; color: var(--text); }
.status { display: flex; align-items: center; gap: 8px; margin-top: 8px; padding: 5px 10px; border: 1px solid var(--line2); border-radius: var(--radius);
  background: var(--card); font: 600 12px var(--mono); letter-spacing: .04em; color: var(--text2); white-space: nowrap; overflow: hidden; }
.status .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text3); flex: none; }
.status .txt { overflow: hidden; text-overflow: ellipsis; }
.status.go { color: var(--text); border-color: #25432f; }
.status.go .dot { background: var(--ok); }
.status.hold { color: var(--warn); border-color: var(--warnBg); }
.status.hold .dot { background: var(--warn); }
.status.done { color: var(--ok); border-color: #25432f; }
.status.done .dot { background: var(--ok); }
.cards { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.card { position: relative; height: 68px; background: var(--card); border: 1px solid #18140e; border-radius: 6px; padding: 7px 11px; }
.card .cl { font-size: 13px; color: var(--text2); white-space: nowrap; }
.card .cv { position: absolute; left: 11px; bottom: 6px; font: 700 24px var(--mono); }
.card .csub { position: absolute; right: 9px; bottom: 9px; font: 11px var(--mono); color: var(--text2); }
.card.hi { border-color: #e0c2a5; }
.card.hi .cl { color: #fbbe55; }
#o2Rows { margin-top: 6px; }
.o2 { height: 42px; font: 700 16px var(--mono); }
.o2 .o2top { display: flex; align-items: center; height: 24px; }
.o2 b { min-width: 46px; margin-right: 8px; white-space: nowrap; }   /* miejsce na dłuższe identyfikatory załogi */
.o2 .bar { flex: 1; max-width: 190px; margin-right: 8px; height: 8px; background: #1e1913; position: relative; border-radius: 4px; overflow: hidden; }
.o2 .bar i { position: absolute; left: 0; top: 0; bottom: 0; background: #fff; }
.o2 .bar.low i { background: var(--warn); }
.o2 .bar.crit i { background: var(--bad); }
.o2 span { margin-left: auto; }
.o2 .tele { font: 11px var(--mono); color: var(--text2); white-space: nowrap; font-weight: 400; }
.reserve { margin-top: 2px; font: 700 28px var(--mono); }
.habsys { margin-top: 4px; display: grid; gap: 4px; font-size: 12px; color: var(--text2); }
.habsys .hs-row { display: grid; grid-template-columns: 82px 1fr 46px; align-items: center; gap: 8px; }
.habsys .hs-bar { height: 6px; background: var(--card); border-radius: 3px; overflow: hidden; }
.habsys .hs-bar i { display: block; height: 100%; width: 0; background: var(--ok, #5ee6a0); }
.habsys .hs-bar i.low { background: var(--warn); }
.habsys .hs-bar i.crit { background: var(--bad); }
.habsys b { font: 600 13px var(--mono); color: var(--text); text-align: right; }
.habsys .hs-note { font: 11px var(--mono); color: var(--text3); }
.habsys .hs-note.warn { color: var(--warn); }
.reserve.low { color: var(--warn); }
.reserve.crit { color: var(--bad); }
.wpview { position: relative; flex: 1 1 0; min-height: 0; margin-top: 6px; background: var(--card); border: 1px solid #18140e; border-radius: 6px; overflow: hidden; }
.wpview .locked { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--text2); font-size: 15px; transition: transform 1s ease; }
.wpview .shot { position: absolute; inset: 0; transform: translateY(100%); transition: transform 1s ease; }
.wpview.open .locked { transform: translateY(-100%); }
.wpview.open .shot { transform: translateY(0); }
.wpview img { width: 100%; height: 100%; object-fit: cover; display: block; }
.wpview .cap { position: absolute; left: 0; right: 0; bottom: 0; padding: 4px 8px; background: rgba(0, 0, 0, .7); font: 700 12px var(--mono); }
.sub2 { font-family: var(--sans); font-size: .9em; }

/* ---------- obszar główny ---------- */
#main { position: absolute; left: 346px; top: 82px; width: 972px; height: 648px; border-radius: 11px; overflow: hidden; background: #000; border: 1px solid var(--line); }
#map, #view3d { position: absolute; left: 0; top: 0; width: 972px; height: 648px; }
#view3d { visibility: hidden; }
#view3d.on { visibility: visible; }
#view3d canvas { display: block; }
#main.reporting #map, #main.picking #map, #main.editing #map { cursor: crosshair; }
#loading { position: absolute; inset: 0; display: flex; flex-wrap: wrap; align-content: center; align-items: center; justify-content: center; gap: 8px; color: var(--text2); font: 15px var(--mono); }
#loading .bar { flex: 0 0 100%; display: flex; justify-content: center; }
#loading .bar i { display: block; width: 260px; height: 3px; border-radius: 2px; background: linear-gradient(90deg, var(--accent) calc(var(--p, 0) * 100%), var(--line3) 0); }
#loading b { color: var(--text); font-weight: 600; min-width: 4ch; }

/* edytor punktów wyjścia */
#wpEditor { position: absolute; left: 12px; top: 58px; z-index: 3; width: 360px; max-height: 500px; overflow: hidden auto; background: rgba(11, 8, 5, .96);
  border: 1px solid var(--line2); border-left: 3px solid var(--route); border-radius: 8px; padding: 9px 12px 10px; font-size: 13px; color: var(--text2); }
#wpEditor.low { top: auto; bottom: 58px; }   /* lustrzane położenie, gdy u góry zasłaniałby punkt trasy (map2d.js: placeEditor) */
#wpEditor > b { color: var(--text); font: 700 12px var(--mono); letter-spacing: .1em; text-transform: uppercase; display: block; }
#wpEditor p { margin: 4px 0 8px; }
#wpEditor .muted { color: var(--text3); }
#wpEditor .warn { color: var(--bad); }
.wpe-row { display: grid; grid-template-columns: 38px 1fr auto 26px 26px; align-items: center; gap: 6px; padding: 4px 0; border-bottom: 1px solid #1d160e; }
.wpe-row b { color: var(--route); font: 700 13px var(--mono); }
.wpe-row .xy { font: 12px var(--mono); color: var(--text2); white-space: nowrap; }
.wpe-row label { font-size: 12px; white-space: nowrap; }
.wpe-row input { width: 52px; background: var(--raised); border: 1px solid var(--line2); border-radius: 4px; padding: 2px 4px; color: var(--text); font: 12px var(--mono); }
.btn.mini { padding: 2px 0; width: 26px; text-align: center; font-size: 13px; }
.wpe-sum { color: var(--text); font: 12px var(--mono); min-height: 18px; }

/* „co jeśli”: limit nachylenia i przedział niepewności */
#sensCard { position: absolute; left: 12px; top: 58px; z-index: 3; width: 380px; background: rgba(11, 8, 5, .96); border: 1px solid var(--line2);
  border-left: 3px solid #7fb2ff; border-radius: 8px; padding: 9px 12px 10px; font-size: 13px; color: var(--text2); }
#sensCard > b { color: var(--text); font: 700 12px var(--mono); letter-spacing: .1em; text-transform: uppercase; display: block; margin-bottom: 6px; }
#sensCard h3 { margin: 10px 0 2px; font: 600 11px var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--text3); }
#sensCard p { margin: 6px 0; }
#sensCard .muted, .doc .sens-int + .note { color: var(--text3); }
#sensCard .warn { color: var(--bad); }
#sensCard .ok { color: var(--ok); }
#sensCard b { color: var(--text); }
.sens-slider { display: flex; align-items: center; gap: 10px; }
.sens-slider input { flex: 1; accent-color: #7fb2ff; }
.sens-ticks { display: flex; justify-content: space-between; margin: 0 2px 0 108px; font: 11px var(--mono); color: var(--text3); }
.sens-line { line-height: 1.5; min-height: 38px; }
.sens-int { font: 12px var(--mono); color: var(--text); }
.doc .sens-table { width: auto; min-width: 420px; }
.doc .sens-table tr.cur td { color: var(--text); font-weight: 600; }

/* ręczna jazda łazikiem (F w hełmie) */
#rideHud { position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%); z-index: 3; width: 640px; background: rgba(8, 5, 4, .86); border: 1px solid var(--line2);
  border-left: 3px solid var(--accent); border-radius: 10px; padding: 8px 12px; font-size: 13px; color: var(--text2); }
#rideHud .rh-top { display: flex; gap: 12px; align-items: baseline; }
#rideHud .rh-top b { color: var(--text); font: 700 12px var(--mono); letter-spacing: .1em; text-transform: uppercase; }
#rideHud #rhLine { font: 15px var(--mono); color: var(--text); margin-top: 3px; }
#rideHud .rh-warn { color: var(--warn); font: 700 12px var(--mono); letter-spacing: .08em; margin-top: 3px; }
#rideHud .rh-help { font-size: 11px; color: var(--text3); margin-top: 4px; }

/* habitat od środka: miejsce, ciśnienie, podpowiedź stanowiska (E) */
#habHud { position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%); z-index: 3; width: 640px; background: rgba(6, 10, 12, .84); border: 1px solid var(--line2);
  border-left: 3px solid #68dee0; border-radius: 10px; padding: 8px 12px; font-size: 13px; color: var(--text2); pointer-events: none; }
#habHud.suited { border-left-color: var(--warn); }
#habHud .hh-top { display: flex; gap: 12px; align-items: baseline; flex-wrap: wrap; }
#habHud .hh-top b { color: var(--text); font: 700 12px var(--mono); letter-spacing: .1em; text-transform: uppercase; }
#habHud #hhStatus { font: 13px var(--mono); color: var(--text2); }
#habHud .hh-bar { height: 4px; background: var(--line2); border-radius: 2px; margin-top: 6px; overflow: hidden; }
#habHud .hh-bar i { display: block; height: 100%; width: 0; background: var(--warn); }
#habHud .hh-prompt { font: 600 15px var(--mono); color: #9be8e6; margin-top: 4px; }
#habHud .hh-flash { font: 700 12px var(--mono); color: var(--warn); letter-spacing: .06em; margin-top: 3px; }
#habHud .hh-help { font-size: 11px; color: var(--text3); margin-top: 4px; }

/* odczyt terenu pod kursorem (mapa 2D) */
#hoverRead { position: absolute; right: 12px; bottom: 112px; z-index: 2; pointer-events: none; background: rgba(10, 7, 4, .9); border: 1px solid var(--line2); border-radius: 6px;
  padding: 6px 10px; font: 12px/1.55 var(--mono); color: var(--text2); white-space: nowrap; }
#hoverRead b { color: var(--text); font-weight: 600; }
#hoverRead .z1 { color: var(--warn); }
#hoverRead .rv { color: #6FD3F2; }
#roverCard { position: absolute; left: 12px; top: 64px; z-index: 5; width: 372px; max-height: calc(100% - 80px); overflow: auto; background: rgba(8, 10, 12, .95);
  border: 1px solid var(--line2); border-left: 3px solid #6FD3F2; border-radius: 8px; padding: 9px 12px 10px; font-size: 13px; color: var(--text2); }
#roverCard header { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
#roverCard header b { color: var(--text); font: 700 13px var(--mono); letter-spacing: .08em; }
#roverCard header .btn { padding: 0 9px; font-size: 16px; line-height: 24px; }
#roverCard .rc-meta { margin: 4px 0 8px; font: 12px var(--mono); color: var(--text2); }
#roverCard .rc-photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 6px; }
#roverCard figure { margin: 0; }
#roverCard img { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 4px; background: #111; }
#roverCard a[aria-disabled="true"] { pointer-events: none; }
#roverCard figcaption { margin-top: 3px; font: 11px var(--mono); color: var(--text3); }
#roverCard .rc-none, #roverCard .rc-note { margin: 8px 0 0; font-size: 11.5px; color: var(--text3); }
#hoverRead .z2 { color: var(--bad); }

/* karta „Jak zacząć” */
#intro { position: absolute; left: 12px; bottom: 74px; z-index: 4; width: 430px; background: rgba(11, 8, 5, .96); border: 1px solid var(--line2); border-left: 3px solid var(--accent);
  border-radius: 8px; padding: 12px 16px 12px 14px; box-shadow: 0 12px 30px rgba(0, 0, 0, .55); animation: introIn .45s ease-out; }
#intro h2 { font: 700 13px var(--mono); letter-spacing: .14em; text-transform: uppercase; color: var(--text); }
#intro ol { margin: 8px 0 10px; padding-left: 20px; font-size: 14px; line-height: 1.45; color: var(--text2); }
#intro li { margin: 4px 0; }
#intro li b { color: var(--text); font-weight: 600; }
#intro .intro-btns { display: flex; gap: 8px; }
@keyframes introIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
#fade { position: absolute; inset: 0; background: #000; opacity: 0; pointer-events: none; transition: opacity .5s; z-index: 3; }
#fade.on { opacity: 1; }

/* nakładki mapy */
#alert, #routeCard, #scale, .maplabel, #mapTools { z-index: 2; }
.maplabel { position: absolute; left: 12px; top: 12px; font: 700 14px var(--mono); letter-spacing: .12em; background: rgba(0, 0, 0, .82); border: 1px solid #161411; border-radius: 6px; padding: 8px 12px; white-space: nowrap; }
#alert { position: absolute; left: 12px; top: 58px; width: 420px; background: #0b0805; border: 1px solid var(--alertBorder); border-radius: 6px; padding: 8px 14px 9px; }
#alert .a1 { font: 700 14px var(--mono); letter-spacing: .14em; color: var(--alertTitle); }
#alert .a2 { font-size: 16px; margin-top: 3px; }
#routeCard { position: absolute; right: 12px; top: 12px; min-width: 240px; background: rgba(14, 11, 7, .94); border: 1px solid var(--line); border-radius: 6px; padding: 9px 14px; font: 15px var(--mono); line-height: 1.55; white-space: nowrap;
  pointer-events: none; }   /* sama informacja — nie zasłania punktów trasy przed przeciąganiem */
#routeCard b { font-weight: 700; }
#routeCard .g { color: var(--text2); }
#routeCard .u { color: var(--text2); font-size: 12px; }
#routeCard .warn { color: var(--bad); font-weight: 700; }
#routeCard .why { display: inline-block; max-width: 340px; white-space: normal; font-size: 12px; font-weight: 400; line-height: 1.4; }
#mapTools { position: absolute; right: 12px; top: 176px; display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
#mapTools .btn { background: rgba(13, 9, 5, .92); }
#mapTools .btn.on { background: var(--accentBg); }
#scale { position: absolute; right: 12px; bottom: 74px; background: rgba(0, 0, 0, .62); padding: 5px 10px; font: 700 14px var(--mono); display: flex; align-items: center; gap: 9px; border-radius: 3px; }
#scale .bar { width: 68px; height: 3px; background: #fff; }
#caption { position: absolute; left: 12px; right: 12px; bottom: 13px; height: 50px; z-index: 4; background: rgba(12, 9, 6, .88); border-radius: 8px; display: flex; align-items: center; padding: 0 14px; font-size: 20px; white-space: nowrap; overflow: hidden; }
#caption .n { font-family: var(--mono); color: var(--route); margin-right: 12px; }
#net { position: absolute; left: 50%; top: 12px; transform: translateX(-50%); z-index: 6; display: flex; align-items: center; gap: 8px; padding: 7px 14px;
  background: #2a1206; border: 1px solid var(--bad); border-radius: var(--radius); font: 600 13px var(--mono); color: #ffd9cd; white-space: nowrap; }
#net .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--bad); animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: .25; } }

/* karty narzędzi mapy: własna trasa, jazda łazikiem, zgłoszenie, profil */
#pickCard { position: absolute; right: 12px; top: 352px; z-index: 3; width: 270px; background: rgba(11, 8, 5, .95); border: 1px solid var(--accentDim); border-left: 3px solid var(--pick); border-radius: 8px; padding: 9px 12px; font-size: 13px; color: var(--text2); }
#pickCard b { color: var(--text); font: 700 12px var(--mono); letter-spacing: .1em; text-transform: uppercase; display: block; margin-bottom: 4px; }
#pickCard .big { color: var(--text); font: 700 16px var(--mono); }
#pickCard .warn { color: var(--bad); }
#pickCard .muted { color: var(--text3); }
#pickCard .pc-row, #driveHud .dh-row { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; align-items: center; }
#driveHud { position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); z-index: 3; width: 620px; background: rgba(8, 5, 4, .92); border: 1px solid var(--accentDim); border-left: 3px solid var(--pick); border-radius: 10px; padding: 8px 12px; font-size: 13px; color: var(--text2); }
#driveHud .dh-top { display: flex; gap: 12px; align-items: baseline; flex-wrap: wrap; }
#driveHud .dh-top b { color: var(--text); font: 700 12px var(--mono); letter-spacing: .1em; text-transform: uppercase; }
#driveHud #dhLine { font: 13px var(--mono); color: var(--text); }
#driveHud .dh-row { margin-top: 6px; }
#driveHud .dh-speed { display: inline-flex; align-items: center; gap: 4px; }
#driveHud .dh-x { min-width: 46px; text-align: center; font: 700 14px var(--mono); color: var(--pick); }
#driveHud .dh-help { margin-top: 6px; font-size: 11.5px; color: var(--text3); }
#driveHud .warn { color: var(--warn); }
#driveHud .muted { color: var(--text3); }
#obsForm { position: absolute; z-index: 5; width: 250px; background: #0b0805; border: 1px solid var(--accent); border-radius: 8px; padding: 10px 12px; font-size: 14px; display: flex; flex-direction: column; gap: 7px; }
#obsForm .of-title { font: 700 13px var(--mono); letter-spacing: .12em; color: var(--alertTitle); text-transform: uppercase; }
#obsForm label { display: flex; justify-content: space-between; align-items: center; gap: 8px; color: var(--text2); }
#obsForm select, #obsForm input, .doc input, .doc select { background: #18120b; color: var(--text); border: 1px solid var(--line3); border-radius: 4px; padding: 3px 5px; font: 13px var(--sans); }
#obsForm input { width: 70px; }
.of-btns { display: flex; gap: 8px; justify-content: flex-end; }

/* profil wysokości trasy */
#profile { position: absolute; left: 12px; bottom: 74px; z-index: 3; width: 620px; background: rgba(11, 8, 5, .95); border: 1px solid var(--line2); border-radius: 8px; padding: 9px 12px 8px; }
#profile .pf-head { display: flex; align-items: baseline; gap: 12px; font: 12px var(--mono); color: var(--text2); white-space: nowrap; }
#profile .pf-head b { color: var(--text); font-weight: 700; letter-spacing: .1em; text-transform: uppercase; }
#profile .pf-head .pf-read { margin-left: auto; color: var(--text); }
#profile canvas { display: block; width: 596px; height: 132px; margin-top: 6px; cursor: crosshair; }
#profile .pf-legend { display: flex; gap: 14px; margin-top: 4px; font: 11px var(--mono); color: var(--text3); }
#profile .pf-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }

/* ---------- widoki dokumentów: raport, plan wyjść ---------- */
.pane { position: absolute; inset: 0; z-index: 3; background: #050200; }
.pane.doc { overflow: hidden auto; padding: 18px 22px 40px; font-size: 14px; line-height: 1.45; }
.doc h2 { font: 700 13px var(--mono); letter-spacing: .14em; color: var(--text2); text-transform: uppercase; margin: 22px 0 8px; }
.doc h2:first-child { margin-top: 0; }
.doc table { width: 100%; border-collapse: collapse; font-size: 13px; }
.doc th, .doc td { text-align: left; padding: 5px 7px; border-bottom: 1px solid #1d160e; vertical-align: top; }
.doc td { overflow-wrap: anywhere; }   /* długie nazwy produktów NASA nie rozpychają tabeli */
.doc td:first-child { white-space: nowrap; overflow-wrap: normal; }
.doc td code { overflow-wrap: anywhere; }
.doc th { color: var(--text2); font-weight: 500; white-space: nowrap; }
.doc .lvl { font: 700 11px var(--mono); padding: 2px 6px; border-radius: 3px; white-space: nowrap; }
.doc .summary { background: var(--card); border: 1px solid #18140e; border-radius: 8px; padding: 10px 14px 10px 30px; margin: 0; }
.doc .summary li { margin: 3px 0; }
.doc .kpis { display: flex; gap: 10px; flex-wrap: wrap; }
.doc .kpi { background: var(--card); border: 1px solid #18140e; border-radius: 6px; padding: 8px 12px; min-width: 150px; }
.doc .kpi b { display: block; font: 700 22px var(--mono); }
.doc .kpi span { color: var(--text2); font-size: 12px; }
.doc .two { display: grid; grid-template-columns: minmax(0, 1fr) 230px; gap: 18px; align-items: start; }
.doc .facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px 18px; margin: 0; }
.doc .facts div { display: flex; justify-content: space-between; gap: 10px; border-bottom: 1px solid #1d160e; padding: 4px 0; }
.doc .facts dt { color: var(--text2); }
.doc .facts dd { margin: 0; font: 700 13px var(--mono); white-space: nowrap; }
.matrix { display: grid; grid-template-columns: 70px repeat(5, 30px); gap: 2px; font: 11px var(--mono); }
.matrix div { height: 26px; display: flex; align-items: center; justify-content: center; border-radius: 2px; }
.matrix .ax { color: var(--text2); justify-content: flex-end; padding-right: 4px; }
.matrix .ax.top { justify-content: center; padding: 0; }
.matrix .r-hi { background: var(--badBg); }
.matrix .r-mid { background: var(--warnBg); }
.matrix .r-lo { background: var(--okBg); }
.lvl.wysokie { background: var(--badBg); color: #ffb4a0; }
.lvl.średnie { background: var(--warnBg); color: #ffd27a; }
.lvl.niskie { background: var(--okBg); color: var(--ok); }
.doc .muted { color: var(--text2); }
.doc .note { color: var(--text2); font-size: 12px; }
.doc .warn { color: #ffb48a; }
.doc .ok { color: var(--ok); }
.doc .row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 8px 0; }
.doc .row input.narrow { width: 66px; }
.doc code { font: 12px var(--mono); color: var(--text2); }
.doc a { color: var(--accent); }
.doc .sampleNote { margin: 0 0 16px; padding: 8px 12px; border: 1px solid var(--accentDim); border-left: 3px solid var(--accent); border-radius: 6px; background: #120a0a; color: var(--text2); font-size: 13px; }
.badge { display: inline-block; font: 700 10px var(--mono); letter-spacing: .08em; padding: 2px 7px; border-radius: 4px; text-transform: uppercase; vertical-align: 1px; }
.badge.good { background: var(--okBg); color: var(--ok); }
.badge.poor { background: var(--badBg); color: #ffb4a0; }

/* ---------- urządzenie na przedramieniu: mały ekran 480 × 320 ---------- */
#device { display: flex; align-items: center; justify-content: center; background: radial-gradient(circle at 50% 40%, #1a120b, #050200 70%); }
.dev { width: 480px; height: 320px; background: #000; border: 3px solid var(--line2); border-radius: 14px; box-shadow: 0 0 0 8px var(--raised), 0 20px 60px #000;
  display: grid; grid-template-columns: 1fr 1fr 1fr; grid-template-rows: 26px 1fr 1fr 44px; gap: 6px; padding: 10px; font-family: var(--mono); color: #fff; }
.dev .top { grid-column: 1 / 4; display: flex; justify-content: space-between; font-size: 13px; color: #c9c2b8; }
.dev .cell { background: #0b0b0b; border-radius: 8px; display: flex; flex-direction: column; justify-content: center; align-items: center; }
.dev .cell .k { font-size: 11px; color: #9a948c; letter-spacing: .12em; }
.dev .cell .v { font-size: 34px; font-weight: 700; line-height: 1.05; }
.dev .cell .v.dist { font-size: 24px; }
.dev .cell .s { font-size: 11px; color: #9a948c; }
.dev .nav { grid-row: 2 / 4; grid-column: 3; }
.dev .nav svg { width: 92px; height: 92px; }
.dev .msg { grid-column: 1 / 4; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 16px; font-weight: 700; letter-spacing: .06em; }
.dev .ok { color: #7cffb2; }
.dev .warnc { color: var(--warn); }
.dev .bad { color: #ff5a3c; }
.dev .msg.ok { background: #0b2416; }
.dev .msg.warnc { background: #2e2108; }
.dev .msg.bad { background: #3a0d06; }
.devnote { position: absolute; bottom: 74px; left: 0; right: 0; text-align: center; color: var(--text2); font-size: 13px; }

/* ---------- porównanie tras (zakrywa prawy panel) ---------- */
#altPanel { position: absolute; inset: 0; z-index: 4; overflow: auto; background: var(--panel); border-radius: 11px; padding: 14px 12px; font-size: 12.5px; }
#altPanel h3 { margin: 0 0 4px; font: 700 13px var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--alertTitle); }
#altPanel .why { color: var(--text2); margin: 0 0 6px; line-height: 1.4; font-size: 11.5px; }
#altPanel .why b { color: var(--text); }
#altPanel .row { display: grid; grid-template-columns: 14px 1fr; gap: 2px 8px; padding: 6px; border-radius: 6px; cursor: pointer; border: 1px solid transparent; }
#altPanel .row:hover, #altPanel .row.hi { background: var(--hover); border-color: var(--line3); }
#altPanel .sw { width: 14px; height: 4px; margin-top: 8px; border-radius: 2px; }
#altPanel .nm { font-weight: 600; }
#altPanel .nums { grid-column: 2; font: 12px var(--mono); color: var(--text); white-space: nowrap; }
#altPanel .rs { grid-column: 2; color: var(--text2); line-height: 1.4; }
#altPanel .badge { margin-left: 6px; }
#altPanel .badge.chosen { background: #3d3410; color: var(--route); }
#altPanel .badge.unsafe { background: #4a1208; color: var(--bad); }
#altPanel .badge.worse { background: #2e2414; color: #f2c779; }
#altPanel .badge.impossible, #altPanel .badge.same { background: #222; color: #bbb; }
#altPanel .foot { margin-top: 6px; font-size: 11px; color: var(--text3); }

/* ---------- okno pomocy ---------- */
.overlay { position: absolute; inset: 0; z-index: 50; background: rgba(0, 0, 0, .6); display: flex; align-items: center; justify-content: center; }
.dialog:focus { outline: none; }
.dialog { width: 640px; max-height: 620px; overflow: auto; background: var(--panel); border: 1px solid var(--line2); border-radius: 12px; padding: 18px 22px; box-shadow: 0 24px 80px #000; }
.dlg-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.dlg-head h2 { font: 700 14px var(--mono); letter-spacing: .14em; text-transform: uppercase; }
.keys { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 28px; }
.keys h3 { grid-column: 1 / 3; margin: 12px 0 2px; font: 600 11px var(--mono); letter-spacing: .14em; text-transform: uppercase; color: var(--text3); }
.keys h3:first-child { margin-top: 0; }
.keys div { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 4px 0; border-bottom: 1px solid var(--line); font-size: 13px; color: var(--text2); }
kbd { font: 600 11px var(--mono); color: var(--text); background: var(--card); border: 1px solid var(--line3); border-bottom-width: 2px; border-radius: 4px; padding: 1px 6px; white-space: nowrap; }
.dlg-foot { margin: 14px 0 0; font-size: 12px; color: var(--text3); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.dlg-foot .btn { margin-left: auto; }

/* ---------- układ kompaktowy: telefon i tablet (src/main.js: fitStage) ---------- */
#mainWrap { display: contents; }
#walkPad { position: absolute; left: 50%; bottom: 96px; transform: translateX(-50%); z-index: 4; display: flex; gap: 14px; }
#walkPad .btn { width: 56px; height: 56px; border-radius: 50%; font-size: 24px; background: rgba(13, 9, 5, .75); border-color: var(--line3); touch-action: none; }
html.compact, html.compact body { overflow: hidden auto; height: auto; min-height: 100%; }
#stage.compact { position: relative; width: auto; height: auto; transform: none; display: flex; flex-direction: column; gap: 10px; padding-bottom: 18px; }
#stage.compact #hdr { order: 0; position: relative; width: auto; height: auto; flex-wrap: wrap; gap: 8px; padding: 8px 10px; }
#stage.compact .logo { font-size: 18px; flex: 1 1 auto; }
#stage.compact .missionSel { order: 3; flex: 1 1 100%; max-width: none; min-width: 0; padding: 8px; }
#stage.compact .title { display: none; }
#stage.compact .controls { display: contents; }
#stage.compact #langSeg { order: 1; }
#stage.compact #helpBtn { order: 2; }
#stage.compact #viewSeg { order: 5; flex: 1 1 100%; display: grid; grid-template-columns: repeat(3, 1fr); }
#stage.compact #viewSeg button { padding: 10px 4px; }
#stage.compact #viewSeg button:nth-child(3n + 1) { border-left: 0; }
#stage.compact #viewSeg button:nth-child(n + 4) { border-top: 1px solid var(--line2); }
#stage.compact #evaBtn, #stage.compact #returnBtn, #stage.compact #demoBtn { order: 6; flex: 1 1 0; padding: 10px; }
#stage.compact #mainWrap { order: 1; display: block; position: relative; flex: none; width: calc(972px * var(--ms)); height: calc(var(--mh, 648) * 1px * var(--ms)); margin: 0 auto; }
#stage.compact #main { left: 0; top: 0; height: calc(var(--mh, 648) * 1px); transform: scale(var(--ms)); transform-origin: 0 0; }
#stage.compact .panel { position: relative; left: auto; top: auto; width: auto; height: auto; margin: 0 10px; }
#stage.compact #right { order: 2; }
#stage.compact #left { order: 3; }
#stage.compact .wpview { flex: none; height: 200px; }
#stage.compact #legend { margin-top: 10px; max-height: none; }
#stage.compact #layerList { flex: none; overflow: visible; }
#stage.compact .o2 .bar { flex: 1; width: auto; max-width: none; margin-right: 10px; }
@media (min-width: 700px) {
  #stage.compact #viewSeg { grid-template-columns: repeat(6, 1fr); }
  #stage.compact #viewSeg button:nth-child(n) { border-top: 0; border-left: 1px solid var(--line2); }
  #stage.compact #viewSeg button:first-child { border-left: 0; }
  #stage.compact { display: grid; grid-template-columns: 1fr 1fr; align-items: start; }
  #stage.compact #hdr, #stage.compact #mainWrap { grid-column: 1 / -1; }
  #stage.compact #right { margin-right: 0; }
  #stage.compact #left { margin-left: 0; }
}
/* elementy na mapie: czytelne mimo zmniejszonej mapy */
#stage.compact :is(.maplabel, #alert, #routeCard, #mapTools, #scale, #caption, #pickCard, #wpEditor, #sensCard, #rideHud, #habHud, #intro, #obsForm, #driveHud, #net, #walkPad, #roverCard, .pane.doc) { zoom: var(--uiz); }
#stage.compact #profile { zoom: calc(var(--uiz) * .85); left: 6px; right: 6px; bottom: 6px; width: auto; max-width: 620px; }
#stage.compact #profile canvas { width: 100%; height: auto; aspect-ratio: 596 / 132; }   /* profile.js liczy kursor z getBoundingClientRect */
#stage.compact #profile .pf-head { flex-wrap: wrap; gap: 2px 10px; white-space: normal; }
#stage.compact #profile .pf-legend { flex-wrap: wrap; gap: 2px 12px; }
#stage.compact #locLabel, #stage.compact #hoverRead { display: none; }
#stage.compact #alert { top: 12px; width: 270px; }
#stage.compact #mapTools { top: 124px; z-index: 4; }   /* na telefonie profil trasy sięga przycisków — muszą zostać klikalne (zamknięcie profilu) */
@media (max-width: 699px) {   /* wąski ekran: profil kończy się przed kolumną przycisków mapy (do ok. 130 px × --uiz; profil ma zoom 0,85 × --uiz) */
  #stage.compact #profile { right: 176px; }
}
#stage.compact #routeCard .u, #stage.compact #routeCard br:has(+ .u) { display: none; }   /* bez pustych wierszy po ukrytych liniach */
#stage.compact #scale { right: auto; bottom: auto; left: 10px; top: 10px; }
#stage.compact #alert:not([hidden]) ~ #scale { visibility: hidden; }   /* ten sam róg co alert — alert ma pierwszeństwo */
#stage.compact #caption { white-space: normal; height: auto; min-height: 44px; padding: 6px 12px; font-size: 16px; }
#stage.compact #intro { bottom: 12px; width: 400px; }
#stage.compact #wpEditor { top: 12px; max-height: 300px; }
#stage.compact #wpEditor.low { top: auto; bottom: 12px; }
#stage.compact #sensCard { top: 12px; max-height: 310px; overflow: hidden auto; }
#stage.compact #pickCard { top: auto; right: auto; bottom: 12px; left: 12px; }
#stage.compact #obsForm { left: 12px !important; top: 12px !important; }
#stage.compact #driveHud { width: 500px; bottom: 8px; }
#stage.compact #help { position: fixed; }
#stage.compact .dialog { width: min(640px, 94vw); max-height: 86vh; }
#stage.compact .keys { grid-template-columns: 1fr; }
#stage.compact .keys h3 { grid-column: 1; }
#stage.compact .doc .two { display: block; }
#stage.compact .doc .two > table, #stage.compact .doc table.wide, #stage.compact .doc .sens-table { display: block; overflow-x: auto; }
#stage.compact .doc table.wide td { overflow-wrap: normal; }   /* przewijanie w poziomie zamiast łamania słów po literze */
#stage.compact .doc .matrix { margin-top: 12px; }
#stage.compact .doc .facts { grid-template-columns: 1fr; }
/* telefon: plan wyjść jako karty zamiast 9 kolumn (tabela nie mieściła się w szerokości ekranu) */
@media (max-width: 699px) {
  #stage.compact #schedule table.wide, #stage.compact #schedule table.wide tbody { display: block; overflow: visible; }
  #stage.compact #schedule table.wide tr:has(> th) { display: none; }
  #stage.compact #schedule table.wide tr { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 12px; padding: 7px 0; border-bottom: 1px solid #1d160e; }
  #stage.compact #schedule table.wide td { padding: 0; border: 0; white-space: nowrap; }
  #stage.compact #schedule table.wide td:nth-child(2)::before { content: 'sol '; color: var(--text2); }
  #stage.compact #schedule table.wide td:nth-child(5) { order: 1; flex: 1 1 100%; white-space: normal; }   /* cel */
  #stage.compact #schedule table.wide td:nth-child(n + 8) { order: 2; white-space: normal; }               /* uwagi, przyciski */
  #stage.compact #schedule table.wide td:nth-child(8) { flex: 1 1 auto; min-width: 0; }
}
/* telefon w poziomie: nagłówek w dwóch rzędach, żeby mapa była jak największa */
@media (orientation: landscape) and (max-height: 540px) {
  #stage.compact .logo { flex: 0 0 auto; }
  #stage.compact .missionSel { order: 1; flex: 0 1 220px; }
  #stage.compact #langSeg { order: 2; }
  #stage.compact #helpBtn { order: 3; }
  #stage.compact #evaBtn, #stage.compact #returnBtn, #stage.compact #demoBtn { order: 4; flex: 0 0 auto; padding: 7px 12px; }
  #stage.compact #viewSeg { order: 9; }
  #stage.compact #viewSeg button { padding: 7px 4px; }
}
