/* HITL v3: powłoka (start, pasek, mapa, panel decyzji, rogi mapy, okna) i klasy dla trybów. */

#app { height: 100%; height: 100dvh; display: grid; grid-template-rows: var(--top-h) minmax(0, 1fr); }
.ico { flex: none; display: block; }

/* ---------- przyciski: wspólne stany ---------- */
.btn, .tbtn, .ibtn, .chip-btn, .mode, .quiet, .seg button, .sw, .lgd-thumb, .linkbtn, .combo-clear {
  transition: background-color var(--dur) var(--ease), border-color var(--dur) var(--ease), color var(--dur) var(--ease);
  -webkit-tap-highlight-color: transparent;
}
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 20px; border-radius: var(--r-md);
  border: 1px solid var(--rule-strong); background: var(--surface); color: var(--ink);
  font-size: var(--t-md); font-weight: 500; letter-spacing: var(--track-tight); line-height: 1.2; text-align: center;
}
.btn:hover { background: var(--surface-2); }
.btn:active { background: var(--surface-3); }
.btn:disabled { cursor: not-allowed; color: var(--ink-3); background: var(--surface-2); border-color: var(--rule); }
.cta, .btn.cta {
  display: flex; align-items: center; justify-content: center; width: 100%; min-height: 56px; padding: 0 20px;
  border-radius: var(--r-md); border: 1px solid rgb(25 25 25 / 0.08); background: var(--lime); color: var(--ink);
  font-size: var(--t-lg); font-weight: 500; letter-spacing: var(--track-tight);
}
.cta:hover, .btn.cta:hover { background: var(--lime-hover); }
.cta:active, .btn.cta:active { background: var(--lime-active); }
.cta:disabled, .btn.cta:disabled { cursor: not-allowed; background: var(--surface-3); color: var(--ink-3); border-color: transparent; }
.btn.sec { width: 100%; }
.ctas.many .btn { min-height: 52px; font-size: var(--t-lg); }

.linkbtn {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 2px; border: 0; background: none;
  color: var(--ink-2); font-size: var(--t-sm); text-decoration: underline; text-decoration-color: var(--rule-strong);
  text-underline-offset: 3px; text-decoration-thickness: 1px; border-radius: 4px;
}
.linkbtn:hover { color: var(--ink); text-decoration-color: var(--ink); }
.linkbtn:active { color: var(--ink-3); }
.linkbtn:disabled { color: var(--ink-3); text-decoration: none; cursor: default; opacity: .6; }

.ibtn {
  display: inline-grid; place-items: center; width: 36px; height: 36px; padding: 0;
  border: 1px solid var(--rule); border-radius: 10px; background: var(--surface); color: var(--ink);
}
.ibtn:hover { background: var(--surface-2); }
.ibtn:active { background: var(--surface-3); }
.ibtn:disabled { color: var(--ink-3); cursor: not-allowed; }
.ibtn.sm { width: 28px; height: 28px; border-color: transparent; background: transparent; border-radius: 8px; }
.ibtn.sm:hover { background: var(--surface-2); }

/* ---------- pasek górny ---------- */
.top {
  position: relative; display: flex; align-items: center; gap: 12px; min-width: 0;
  padding: 0 12px 0 16px; background: var(--surface); border-bottom: 1px solid var(--rule);
}
.brand { display: flex; align-items: center; height: 32px; padding: 0 4px; border-radius: 6px; flex: none; }
.brand img { height: 17px; width: auto; display: block; }
.top-mode {
  min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  padding-left: 12px; border-left: 1px solid var(--rule); font-size: var(--t-sm); font-weight: 500; letter-spacing: var(--track-tight);
}
.top-prog { flex: none; font-size: var(--t-sm); color: var(--ink-3); font-variant-numeric: tabular-nums; }
.top-gap { flex: 1; }
.tbtn {
  flex: none; display: inline-flex; align-items: center; justify-content: center; height: 32px; padding: 0 12px;
  border: 1px solid var(--rule); border-radius: var(--r-sm); background: var(--surface); font-size: var(--t-sm); font-weight: 500;
}
.tbtn:hover { background: var(--surface-2); }
.tbtn:active { background: var(--surface-3); }
.tbtn.icon { width: 32px; padding: 0; border-color: transparent; color: var(--ink-2); }
.tbtn.icon:hover { color: var(--ink); }
.top-bar { position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; background: transparent; }
.top-bar i { display: block; height: 100%; width: 100%; background: var(--ink); transform: scaleX(0); transform-origin: 0 50%; transition: transform 200ms var(--ease); }

/* ---------- start ---------- */
.screen { min-height: 0; }
.start { overflow: auto; }
.start-in { max-width: 560px; margin: 0 auto; padding: 56px 20px 64px; display: flex; flex-direction: column; gap: 16px; }
.start h1 { font-size: var(--t-3xl); letter-spacing: -0.03em; margin-bottom: 12px; }
.modes { display: flex; flex-direction: column; gap: 8px; }
.mode {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 16px; width: 100%;
  padding: 16px 18px; text-align: left; background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r-md);
}
.mode:hover:not(:disabled) { border-color: var(--rule-strong); background: var(--surface-2); }
.mode:active:not(:disabled) { background: var(--surface-3); }
.mode[aria-checked="true"], .mode[aria-checked="true"]:hover { background: var(--lime); border-color: var(--ink); }
.mode:disabled { cursor: default; background: transparent; }
.mode:disabled .m-name, .mode:disabled .m-n { color: var(--ink-3); }
.m-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.m-name { font-size: var(--t-lg); font-weight: 500; letter-spacing: var(--track-tight); line-height: 1.25; }
.m-sub { font-size: var(--t-sm); color: var(--ink-3); }
.mode[aria-checked="true"] .m-sub, .mode[aria-checked="true"] .m-l, .mode[aria-checked="true"] .m-today { color: var(--ink-2); }
.m-num { display: flex; flex-direction: column; align-items: flex-end; text-align: right; }
.m-n { font-size: var(--t-xl); font-weight: 500; letter-spacing: var(--track-tight); line-height: 1.1; font-variant-numeric: tabular-nums; }
.m-l, .m-today { font-size: var(--t-xs); color: var(--ink-3); white-space: nowrap; }
.field { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.field label { font-size: var(--t-sm); font-weight: 500; }
.field .opt { color: var(--ink-3); font-weight: 400; }
.combo { position: relative; }
.combo input {
  width: 100%; height: 48px; padding: 0 44px 0 14px; border: 1px solid var(--rule-strong); border-radius: var(--r-md);
  background: var(--surface); font-size: var(--t-md); transition: border-color var(--dur) var(--ease);
}
.combo input::placeholder { color: var(--ink-3); }
.combo input:hover { border-color: rgb(25 25 25 / 0.35); }
.combo input:focus { border-color: var(--ink); }
.combo input:focus-visible { outline: 2px solid var(--ink); outline-offset: 1px; }
.combo-clear {
  position: absolute; right: 8px; top: 8px; width: 32px; height: 32px; display: grid; place-items: center;
  border: 0; border-radius: 8px; background: transparent; color: var(--ink-2);
}
.combo-clear:hover { background: var(--surface-2); color: var(--ink); }
.combo-list {
  position: absolute; z-index: 20; left: 0; right: 0; top: calc(100% + 4px); max-height: 300px; overflow: auto;
  margin: 0; padding: 4px; list-style: none; background: var(--surface); border: 1px solid var(--rule-strong); border-radius: var(--r-md);
}
.combo-list li { display: flex; justify-content: space-between; gap: 12px; padding: 9px 10px; border-radius: 8px; cursor: pointer; font-size: var(--t-sm); }
.combo-list li:hover, .combo-list li[aria-selected="true"] { background: var(--surface-2); }
.po-id { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.po-n { color: var(--ink-3); font-variant-numeric: tabular-nums; }
.combo-list .po-empty { color: var(--ink-3); cursor: default; }
.combo-list .po-empty:hover { background: none; }
#startBtn { margin-top: 8px; }
.start-err { color: var(--danger); font-size: var(--t-sm); }

/* ---------- sesja ---------- */
.session { display: grid; grid-template-columns: minmax(0, 1fr) var(--panel-w); }
.stage { position: relative; overflow: hidden; background: var(--map-bg); min-height: 0; }
#map { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.map-msg {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); max-width: 320px; padding: 12px 16px;
  background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r-md); font-size: var(--t-sm);
}
.mapctl { position: absolute; right: 12px; bottom: 12px; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; z-index: 5; }
.mapctl .fitbtn { margin-bottom: 4px; }

/* rogi mapy */
.corner { position: absolute; z-index: 6; max-width: calc(100% - 72px); }
.corner.tl { top: 12px; left: 12px; }
.corner.bl { bottom: 12px; left: 12px; }
.chip-btn {
  display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 12px 0 10px;
  background: var(--surface); border: 1px solid var(--rule); border-radius: 10px; font-size: var(--t-sm); font-weight: 500;
}
.chip-btn:hover { background: var(--surface-2); border-color: var(--rule-strong); }
.chip-btn:active { background: var(--surface-3); }
.lgd-body, .lyr-body {
  width: 264px; max-width: 100%; padding: 8px 12px 12px; background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r-md);
}
.corner-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 0 -4px 6px 0; }
.corner-head h3 { font-size: var(--t-sm); font-weight: 500; letter-spacing: var(--track-tight); }
.lgd-thumb {
  display: block; width: 100%; padding: 0; overflow: hidden; background: var(--surface-2);
  border: 1px solid var(--rule); border-radius: var(--r-sm); cursor: zoom-in;
}
.lgd-thumb + .lgd-thumb { margin-top: 6px; }
.lgd-thumb:hover { border-color: var(--ink); }
.lgd-thumb img { display: block; max-width: 100%; max-height: 200px; margin: 0 auto; object-fit: contain; }
.lgd-row { display: flex; gap: 12px; margin-top: 4px; }

/* warstwy */
.lyr-sw { display: flex; flex-direction: column; }
.sw {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; padding: 6px 4px;
  border: 0; border-radius: 8px; background: transparent; font-size: var(--t-sm); text-align: left;
}
.sw:hover { background: var(--surface-2); }
.sw-t { position: relative; flex: none; width: 34px; height: 20px; border-radius: var(--r-pill); background: var(--surface-3); border: 1px solid var(--rule-strong); transition: background-color var(--dur) var(--ease); }
.sw-t i { position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: var(--surface); border: 1px solid var(--rule-strong); transition: transform var(--dur) var(--ease); }
.sw[aria-checked="true"] .sw-t { background: var(--lime); border-color: var(--ink); }
.sw[aria-checked="true"] .sw-t i { transform: translateX(14px); background: var(--ink); border-color: var(--ink); }
.lyr-sl { display: flex; flex-direction: column; gap: 2px; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--rule); }
.sl { display: grid; grid-template-columns: 64px minmax(0, 1fr) 38px; align-items: center; gap: 8px; font-size: var(--t-sm); min-height: 30px; }
.sl.off label, .sl.off output { color: var(--ink-3); }
.sl output { font-size: var(--t-xs); color: var(--ink-3); text-align: right; font-variant-numeric: tabular-nums; }
.sl input[type=range] { width: 100%; margin: 0; background: transparent; accent-color: var(--ink); -webkit-appearance: none; appearance: none; height: 24px; }
.sl input[type=range]::-webkit-slider-runnable-track { height: 4px; border-radius: 4px; background: var(--surface-3); }
.sl input[type=range]::-moz-range-track { height: 4px; border-radius: 4px; background: var(--surface-3); }
.sl input[type=range]::-moz-range-progress { height: 4px; border-radius: 4px; background: var(--ink); }
.sl input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 16px; margin-top: -6px; border-radius: 50%; background: var(--surface); border: 2px solid var(--ink); }
.sl input[type=range]::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: var(--surface); border: 2px solid var(--ink); }
.sl input[type=range]:hover::-webkit-slider-thumb { background: var(--lime); }
.btn.hold { width: 100%; min-height: 40px; margin-top: 10px; font-size: var(--t-sm); user-select: none; -webkit-user-select: none; touch-action: none; }
.btn.hold.is-on { background: var(--lime); border-color: var(--ink); }

/* ---------- panel decyzji ---------- */
.panel { display: flex; flex-direction: column; min-height: 0; background: var(--surface); border-left: 1px solid var(--rule); }
.pbody { flex: 1; min-height: 0; overflow: auto; padding: 28px 24px 20px; display: flex; flex-direction: column; gap: 16px; }
.pfoot { flex: none; padding: 16px 24px 20px; border-top: 1px solid var(--rule); }
.ctas { display: flex; flex-direction: column; gap: 8px; }
.plinks { display: flex; justify-content: space-between; margin-top: 10px; }
.panel-body, .mode-line, .mode-line-style, .edit-body, .pick-box { display: flex; flex-direction: column; gap: 12px; }
.q { font-size: var(--t-xl); font-weight: 500; letter-spacing: var(--track-head); line-height: 1.25; }
.val {
  font-size: var(--t-3xl); font-weight: 500; letter-spacing: -0.03em; line-height: 1.1; font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere; margin-top: -4px;
}
.ctxline, .ctx { font-size: var(--t-sm); color: var(--ink-3); }
.val + .ctxline, .val + .ctx { margin-top: -6px; }
p.hint { font-size: var(--t-sm); color: var(--ink-2); }
.perr { color: var(--danger); font-size: var(--t-sm); }
.pstate { justify-content: flex-start; }
.pstate-t { color: var(--ink-2); }

/* blok „Z uchwały” */
.decree { padding: 12px 14px; border: 1px solid var(--rule); border-radius: var(--r-md); background: var(--page); display: flex; flex-direction: column; gap: 6px; }
.decree-h { font-size: var(--t-sm); font-weight: 500; letter-spacing: 0; word-spacing: 0.08em; }
.decree-sg { font-size: var(--t-md); }
.decree-sg strong { font-weight: 500; }
.decree-why { font-size: var(--t-xs); color: var(--ink-3); }
.decree-q { margin: 0; }
.decree-q + .decree-q { padding-top: 8px; border-top: 1px solid var(--rule); }
.decree-q p { font-size: var(--t-sm); line-height: 1.5; color: var(--ink-2); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.decree.open .decree-q p { display: block; -webkit-line-clamp: none; }
.decree-q cite { display: block; margin-top: 2px; font-size: var(--t-xs); font-style: normal; color: var(--ink-3); }
.decree .linkbtn { align-self: flex-start; padding: 2px 0; }
mark { background: var(--mark); color: var(--ink); padding: 0 2px; border-radius: 3px; box-decoration-break: clone; -webkit-box-decoration-break: clone; }

/* kontrolki trybów */
.seg { display: flex; gap: 2px; padding: 3px; border: 1px solid var(--rule-strong); border-radius: 10px; background: var(--surface); }
.seg button {
  flex: 1 1 0; min-height: 36px; padding: 6px 10px; border: 0; border-radius: 7px; background: transparent;
  font-size: var(--t-sm); font-weight: 500; line-height: 1.2; color: var(--ink-2);
}
.seg button:hover { background: var(--surface-2); color: var(--ink); }
.seg button:active { background: var(--surface-3); }
.seg button[aria-pressed="true"], .seg button[aria-checked="true"] { background: var(--lime); color: var(--ink); }
.seg button:disabled { color: var(--ink-3); cursor: not-allowed; }
.quiet-row { display: flex; flex-wrap: wrap; gap: 8px; }
.quiet {
  min-height: 36px; padding: 6px 12px; border: 1px solid var(--rule-strong); border-radius: 10px; background: var(--surface);
  font-size: var(--t-sm); font-weight: 500;
}
.quiet:hover { background: var(--surface-2); }
.quiet:active { background: var(--surface-3); }
.quiet[aria-pressed="true"] { background: var(--lime); border-color: var(--ink); }
.quiet:disabled { color: var(--ink-3); cursor: not-allowed; }
.pick { border: 1px solid var(--rule-strong); border-radius: var(--r-md); overflow: hidden; background: var(--surface); }
.pick-input { width: 100%; height: 44px; padding: 0 14px; border: 0; border-bottom: 1px solid var(--rule); background: var(--surface); font-size: var(--t-md); }
.pick-input::placeholder { color: var(--ink-3); }
.pick-input:focus-visible { outline: none; background: var(--page); }
.pick-list { list-style: none; margin: 0; padding: 4px; max-height: 300px; overflow: auto; }
.pick-list li[role=option] {
  display: grid; grid-template-columns: 22px minmax(0, 1fr) auto; align-items: baseline; gap: 8px; padding: 8px 10px;
  border-radius: 8px; cursor: pointer; transition: background-color var(--dur) var(--ease);
}
.pick-list li[role=option]:hover { background: var(--surface-2); }
.pick li[aria-selected="true"], .pick li[aria-selected="true"]:hover { background: var(--lime); }
.pick-n { font-size: var(--t-xs); color: var(--ink-3); font-variant-numeric: tabular-nums; }
.pick-d { font-weight: 500; overflow-wrap: anywhere; }
.pick-uses { margin-left: 2px; }
.pick-sep { color: var(--ink-3); font-weight: 400; }
.pick-g { font-size: var(--t-xs); color: var(--ink-3); }
.pick li[aria-selected="true"] .pick-n, .pick li[aria-selected="true"] .pick-g { color: var(--ink-2); }
.pick-note { padding: 10px; font-size: var(--t-sm); color: var(--ink-3); }
.pick-foot { display: flex; justify-content: space-between; gap: 8px; padding: 4px 12px; border-top: 1px solid var(--rule); }
.samples { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.sample { margin: 0; border: 1px solid var(--rule); border-radius: var(--r-sm); overflow: hidden; background: var(--page); }
.sample-svg { display: block; width: 100%; height: auto; }

/* szkielet ładowania */
.sk { border-radius: 8px; background: var(--surface-2); }
.sk-h { height: 26px; width: 70%; }
.sk-v { height: 40px; width: 40%; }
.sk-l { height: 14px; width: 90%; }
.sk-l.short { width: 55%; }

/* ---------- toast ---------- */
.toast {
  position: fixed; z-index: 50; left: calc((100% - var(--panel-w)) / 2); bottom: 24px; transform: translateX(-50%);
  max-width: min(480px, calc(100vw - 32px)); padding: 10px 16px; border-radius: var(--r-md);
  background: var(--ink); color: #fff; font-size: var(--t-sm);
}
#app[data-screen="start"] .toast { left: 50%; }
.toast.err { background: var(--danger); }

/* ---------- okna (pomoc, legenda) ---------- */
.dlg { padding: 0; border: 1px solid var(--rule); border-radius: var(--r-lg); background: var(--surface); color: var(--ink); max-width: calc(100vw - 32px); }
.dlg::backdrop { background: rgb(25 25 25 / 0.4); }
.dlg-head { display: flex; align-items: center; gap: 12px; padding: 12px 12px 12px 20px; border-bottom: 1px solid var(--rule); }
.dlg-head h2 { font-size: var(--t-lg); flex: none; }
.dlg-head > .ibtn:last-child { margin-left: auto; border-color: transparent; }
.help { width: 420px; }
.keys { display: grid; grid-template-columns: max-content 1fr; gap: 10px 20px; margin: 0; padding: 16px 20px 20px; font-size: var(--t-sm); }
.keys dt { font-weight: 500; font-variant-numeric: tabular-nums; }
.keys dd { margin: 0; color: var(--ink-2); }
.viewer[open] { width: min(1100px, calc(100vw - 32px)); height: min(820px, calc(100dvh - 32px)); display: flex; flex-direction: column; }
.vw-sub { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--t-sm); color: var(--ink-3); }
.vw-zoom { display: flex; gap: 4px; margin-left: auto; }
.vw-zoom + .ibtn { margin-left: 4px !important; }
.vw-view { position: relative; flex: 1; min-height: 0; overflow: hidden; background: var(--map-bg); cursor: grab; touch-action: none; }
.vw-view:active { cursor: grabbing; }
.vw-stage { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
.vw-base, .vw-detail { position: absolute; left: 0; top: 0; user-select: none; -webkit-user-drag: none; }
.vw-base { image-rendering: auto; }
.vw-rect { position: absolute; border: calc(2 * var(--inv, 1px)) solid var(--ink); pointer-events: none; }
.vw-rect.cand { border-style: dashed; }
.vw-rect.draft { background: rgb(208 250 152 / 0.3); }
.vw-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px 20px; flex-wrap: wrap; padding: 12px 16px; border-top: 1px solid var(--rule); }
.vw-l, .vw-r { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.vw-l .seg { width: 200px; }
.vw-tip { font-size: var(--t-sm); color: var(--ink-3); }
.vw-r .btn.cta { width: auto; min-height: 44px; font-size: var(--t-md); }

/* ---------- telefon ---------- */
@media (max-width: 759px) {
  .top { gap: 8px; padding: 0 8px 0 12px; }
  .top-mode { padding-left: 8px; }
  .start-in { padding: 32px 16px 40px; }
  .start h1 { font-size: var(--t-2xl); }
  .mode { padding: 14px; }
  .session { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; }
  .panel { border-left: 0; border-top: 1px solid var(--rule); max-height: 45dvh; border-radius: var(--r-lg) var(--r-lg) 0 0; margin-top: -16px; position: relative; z-index: 8; }
  .pbody { padding: 18px 16px 12px; gap: 12px; }
  .q { font-size: var(--t-lg); }
  .val { font-size: var(--t-2xl); }
  .pfoot { padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); }
  .ctas.many { display: grid; grid-template-columns: 1fr 1fr; }
  .ctas.many .btn { min-height: 48px; font-size: var(--t-md); }
  .plinks { margin-top: 4px; }
  .mapctl { bottom: 28px; right: 8px; }
  .corner.tl { top: 8px; left: 8px; }
  .corner.bl { bottom: 28px; left: 8px; }
  .lgd-body, .lyr-body { width: 232px; }
  .lgd-thumb img { max-height: 120px; }
  .toast { left: 50%; bottom: auto; top: calc(var(--top-h) + 12px); }
  .viewer[open] { width: 100vw; height: 100dvh; max-width: 100vw; max-height: 100dvh; border-radius: 0; border: 0; }
  .vw-l .seg { width: 100%; }
}

/* ---------- konto ---------- */
.acct-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 20px 20px; }
.acct-foot .btn { min-height: 40px; }
.keys .dim, .dim { color: var(--ink-3); }

.pick-note-hint { margin: 4px 2px 6px; font-size: var(--t-sm, 12px); color: var(--ink-3); line-height: 1.35; }
