:root {
  --bg: #eef2ef;
  --surface: #ffffff;
  --fg: #141b17;
  --muted: #5a675f;
  --line: #d3dbd6;
  --accent: #23683f;
  --accent-soft: #e0eee5;
  --sel: #1867e0;
  --warn: #9a5b06;
  --warn-soft: #fbefd9;
  --danger: #b4232f;
  --shadow: 0 2px 10px rgba(20, 30, 25, .14);
  --font: -apple-system, "SF Pro Text", "Segoe UI", Roboto, system-ui, sans-serif;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--fg); font: 16px/1.4 var(--font); }
body { overscroll-behavior: none; }
button { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; }
button:disabled { opacity: .4; cursor: default; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.warn { color: var(--warn); }
.err { color: var(--danger); min-height: 1.2em; font-size: 14px; }
h1, h2, h3, h4 { margin: 0; line-height: 1.2; }

.ic { display: inline-flex; width: 24px; height: 24px; flex: none; }
.ic svg { width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 0 16px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); font-weight: 500; }
.btn:active { background: var(--accent-soft); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:active { filter: brightness(.9); }
.btn.danger { color: var(--danger); }
.btn.sm { min-height: 38px; padding: 0 12px; font-size: 15px; }
.btn.block { width: 100%; }
.btn .ic { width: 20px; height: 20px; }
.btn:focus-visible, .tool:focus-visible, .tb:focus-visible { outline: 3px solid var(--sel); outline-offset: 1px; }

.inp { width: 100%; min-height: 44px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; font: 16px var(--font); color: var(--fg); }
textarea.inp { min-height: 80px; resize: vertical; }
select.inp { appearance: auto; }
.inp:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }

.form { display: flex; flex-direction: column; gap: 12px; }
.form > label, .row2 > label, .form > .field { display: flex; flex-direction: column; gap: 4px; font-size: 14px; color: var(--muted); }
.combo { display: flex; flex-direction: column; }
.combo-list { margin-top: 4px; max-height: 260px; overflow-y: auto; -webkit-overflow-scrolling: touch; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); }
.combo-list[hidden] { display: none; }
.combo-item { padding: 11px 12px; font-size: 16px; color: var(--fg); border-bottom: 1px solid var(--line); cursor: pointer; }
.combo-item:last-child { border-bottom: 0; }
.combo-item b { color: var(--accent); }
.combo-item.on, .combo-item:active { background: var(--accent-soft); }
.combo-empty { padding: 10px 12px; color: var(--muted); font-size: 14px; }
.form h4 { margin-top: 8px; font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.form p { margin: 0; }
.chosen { font-weight: 600; font-size: 15px; word-break: break-all; }
.chosen:empty { display: none; }
.row { display: flex; flex-wrap: wrap; gap: 8px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.check { display: flex !important; flex-direction: row !important; align-items: center; gap: 10px; color: var(--fg) !important; font-size: 16px !important; min-height: 36px; }
.check input { width: 22px; height: 22px; accent-color: var(--accent); }
.check.sm { font-size: 14px !important; min-height: 0; gap: 6px; }
.check.sm input { width: 18px; height: 18px; }
input[type=range] { width: 100%; accent-color: var(--accent); height: 32px; }

/* ---------- главный экран ---------- */
.home { max-width: 1100px; margin: 0 auto; padding: calc(var(--safe-t) + 24px) max(20px, var(--safe-r)) calc(var(--safe-b) + 40px) max(20px, var(--safe-l)); display: flex; flex-direction: column; gap: 18px; }
.home-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; }
.home-head h1 { font-size: 30px; letter-spacing: -.01em; }
.home-head p { margin: 4px 0 0; }
.boot-fail { max-width: 640px; margin: 0 auto; padding: calc(var(--safe-t) + 32px) max(20px, var(--safe-r)) 32px max(20px, var(--safe-l)); display: flex; flex-direction: column; gap: 12px; }
.boot-fail pre { white-space: pre-wrap; word-break: break-word; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 12px; font-size: 13px; margin: 0; }
.boot-fail .row { display: flex; gap: 10px; flex-wrap: wrap; }
.note { background: var(--warn-soft); color: #5b3a05; padding: 12px 16px; border-radius: 10px; }
.pgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(320px, 100%), 1fr)); gap: 14px; }
.pcard { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; display: flex; flex-direction: column; }
.pcard-main { text-align: left; border: 0; background: none; padding: 16px 16px 10px; display: flex; flex-direction: column; gap: 6px; }
.pcard-main:active { background: var(--accent-soft); }
.pcard-main h3 { font-size: 19px; }
.pcard-main p { margin: 0; color: var(--muted); font-size: 14px; }
.pcard-meta { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 14px; }
.pcard-act { display: flex; gap: 8px; padding: 0 16px 14px; }
.empty { background: var(--surface); border: 1px dashed var(--line); border-radius: 14px; padding: 40px 24px; display: flex; flex-direction: column; align-items: flex-start; gap: 10px; }
.empty p { margin: 0 0 6px; max-width: 60ch; color: var(--muted); }

/* ---------- экран объекта ---------- */
.editor { position: fixed; inset: 0; overflow: hidden; background: #d9dfdb; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.plan { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; display: block; }
.topbar { position: absolute; top: calc(var(--safe-t) + 10px); left: max(10px, var(--safe-l)); right: max(10px, var(--safe-r)); display: flex; align-items: center; gap: 10px; pointer-events: none; }
.topbar > * { pointer-events: auto; }
.tb { display: inline-flex; align-items: center; gap: 4px; min-height: 44px; min-width: 44px; padding: 0 10px; border-radius: 12px; border: 0; background: var(--surface); box-shadow: var(--shadow); }
.tb-l { font-size: 15px; }
.title { font-weight: 600; font-size: 16px; background: var(--surface); padding: 0 14px; border-radius: 12px; min-height: 44px; display: flex; align-items: center; box-shadow: var(--shadow); max-width: 26vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search { display: flex; align-items: center; gap: 6px; background: var(--surface); border-radius: 12px; padding: 0 10px; min-height: 44px; box-shadow: var(--shadow); flex: 1 1 200px; max-width: 320px; }
.search .ic { color: var(--muted); width: 20px; height: 20px; }
.search input { border: 0; outline: 0; font: 16px var(--font); width: 100%; min-width: 0; background: none; min-height: 40px; }
form.search > .ic:first-child { display: none; }
.search-go { flex: none; display: grid; place-items: center; width: 40px; height: 36px; margin-right: -6px; border: 0; border-radius: 9px; background: var(--accent, #23683f); color: #fff; cursor: pointer; }
.search-go .ic { width: 20px; height: 20px; color: #fff; }
.status { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.next { background: var(--surface); padding: 0 12px; min-height: 44px; display: flex; align-items: center; border-radius: 12px; box-shadow: var(--shadow); font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.next:empty { display: none; }
.next.ins { background: var(--warn-soft); color: var(--warn); }
.chip-btn { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 12px; border-radius: 12px; border: 0; background: var(--surface); box-shadow: var(--shadow); font-size: 14px; white-space: nowrap; }
.chip-btn .ic { width: 20px; height: 20px; }

.toolbar { position: absolute; top: calc(var(--safe-t) + 66px); bottom: calc(var(--safe-b) + 76px); display: flex; flex-direction: column; gap: 4px; padding: 6px; background: var(--surface); border-radius: 16px; box-shadow: var(--shadow); overflow-y: auto; width: 74px; scrollbar-width: none; }
.toolbar::-webkit-scrollbar { display: none; }
.side-left .toolbar { left: max(10px, var(--safe-l)); }
.side-right .toolbar { right: max(10px, var(--safe-r)); }
.tool { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 58px; border: 0; background: none; border-radius: 12px; color: var(--fg); flex: none; }
.tool small { font-size: 11px; color: var(--muted); }
.tool.on { background: var(--accent); color: #fff; }
.tool.on small { color: #e3f1e8; }
.tool:active:not(.on) { background: var(--accent-soft); }
.toolbar .sep { height: 1px; background: var(--line); margin: 4px 6px; flex: none; }

.floats { position: absolute; bottom: calc(var(--safe-b) + 84px); display: flex; flex-direction: column; gap: 8px; }
.side-left .floats { right: max(12px, var(--safe-r)); }
.side-right .floats { left: max(12px, var(--safe-l)); }
.sheet-open.side-left .floats { right: calc(min(400px, 92vw) + 24px); }
.sheet-open.side-right .floats { left: calc(min(400px, 92vw) + 24px); }
.fbtn { width: 50px; height: 50px; border-radius: 14px; border: 0; background: var(--surface); box-shadow: var(--shadow); display: flex; align-items: center; justify-content: center; }
.fbtn .minus { font-size: 30px; line-height: 1; margin-top: -3px; }
.compass .ic { color: var(--danger); transition: transform .1s; }

.ctxbar { position: absolute; bottom: calc(var(--safe-b) + 12px); left: 50%; transform: translateX(-50%); max-width: calc(100vw - 40px); display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px; padding: 8px 10px; background: var(--surface); border-radius: 16px; box-shadow: var(--shadow); }
.sheet-open.side-left .ctxbar { left: calc(50% - min(200px, 46vw)); max-width: calc(100vw - min(400px, 92vw) - 120px); }
.sheet-open.side-right .ctxbar { left: calc(50% + min(200px, 46vw)); max-width: calc(100vw - min(400px, 92vw) - 120px); }
.ctx-t { font-weight: 600; padding: 0 4px; }
.ctx-t.muted { font-weight: 400; }
.ctx-t.warn { font-weight: 500; }
.seg { display: inline-flex; background: var(--bg); border-radius: 10px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: none; min-height: 38px; padding: 0 12px; border-radius: 8px; font-size: 15px; }
.seg button.on { background: var(--surface); box-shadow: 0 1px 4px rgba(0,0,0,.15); font-weight: 600; color: var(--accent); }
.seg.wide { display: flex; }
.seg.wide button { flex: 1; }
.media-sec { display: flex; flex-direction: column; gap: 8px; border-top: 1px solid var(--line); padding-top: 10px; }
.media-sec h4 { margin: 0; }
.media-strip { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 6px; }
.media-tile { position: relative; aspect-ratio: 1; padding: 0; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #dfe5e1; cursor: pointer; }
.media-tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.media-noimg { display: grid; place-items: center; width: 100%; height: 100%; color: var(--muted); font-size: 13px; }
.media-dur { position: absolute; left: 4px; bottom: 4px; background: rgba(0,0,0,.65); color: #fff; font-size: 12px; font-weight: 600; padding: 1px 6px; border-radius: 6px; }
.media-view { position: fixed; inset: 0; z-index: 40; background: #0b0d0c; display: flex; flex-direction: column; padding: var(--safe-t) var(--safe-r) var(--safe-b) var(--safe-l); }
.mv-top { display: flex; align-items: center; gap: 8px; padding: 8px 10px; flex-wrap: wrap; }
.mv-cap { color: #fff; font-weight: 600; flex: 1; min-width: 120px; }
.mv-stage { flex: 1; min-height: 0; display: grid; place-items: center; }
.mv-stage img, .mv-stage video { max-width: 100%; max-height: 100%; object-fit: contain; }
.mv-miss { color: #ccc; }
.mv-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 48px; height: 64px; border: 0; border-radius: 12px; background: rgba(255,255,255,.18); color: #fff; font-size: 34px; cursor: pointer; }
.mv-nav.prev { left: calc(var(--safe-l) + 8px); } .mv-nav.next { right: calc(var(--safe-r) + 8px); }
.mv-nav[hidden] { display: none; }
.rs-hud { position: absolute; top: calc(var(--safe-t) + 70px); left: 50%; transform: translateX(-50%); z-index: 30; max-width: calc(100vw - 24px); display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px 12px; padding: 8px 12px; background: var(--surface); border-radius: 14px; box-shadow: var(--shadow); font-size: 14px; }
.rs-hud[hidden] { display: none; }
.rs-hud .rs-t { font-weight: 600; font-variant-numeric: tabular-nums; }
.rs-hud .seg button { min-height: 36px; padding: 0 12px; }
.size-row { display: flex; align-items: center; gap: 10px; }
.size-row input[type=range] { flex: 1; min-width: 0; }
.size-row .inp.num { width: 72px; flex: none; text-align: center; }
.swatches { display: inline-flex; gap: 6px; }
.sw { width: 30px; height: 30px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 0 0 1px var(--line); }
.sw.on { box-shadow: 0 0 0 2px var(--fg); }
.swatches.wrap { flex-wrap: wrap; gap: 8px; align-items: center; }
.colorpick { width: 36px; height: 32px; border: 1px solid var(--line); border-radius: 8px; padding: 0; background: none; }

.sheet { position: absolute; top: calc(var(--safe-t) + 66px); bottom: calc(var(--safe-b) + 10px); width: min(400px, 92vw); background: var(--surface); border-radius: 16px; box-shadow: 0 6px 30px rgba(20,30,25,.22); display: flex; flex-direction: column; overflow: hidden; z-index: 5; user-select: text; -webkit-user-select: text; }
.side-left .sheet { right: max(10px, var(--safe-r)); }
.side-right .sheet { left: max(10px, var(--safe-l)); }
.sheet-head { display: flex; align-items: center; gap: 6px; padding: 8px; border-bottom: 1px solid var(--line); }
.sheet-head h3 { flex: 1; font-size: 18px; padding-left: 6px; }
.sheet-head .tb { box-shadow: none; background: none; }
.sheet-body { overflow-y: auto; padding: 14px 16px 24px; -webkit-overflow-scrolling: touch; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.num-big { font-size: 26px; font-weight: 700; border: 0; background: var(--accent-soft); color: var(--accent); border-radius: 12px; padding: 4px 16px; min-height: 48px; font-variant-numeric: tabular-nums; }

.numcheck { background: var(--accent-soft); border-radius: 10px; padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; align-items: flex-start; font-size: 14px; }
.numcheck.bad { background: var(--warn-soft); color: #5b3a05; }
.list { display: flex; flex-direction: column; }
.li { display: grid; grid-template-columns: 56px 90px 1fr 24px; gap: 8px; align-items: center; text-align: left; border: 0; border-bottom: 1px solid var(--line); background: none; min-height: 44px; padding: 0 4px; }
.li:active { background: var(--accent-soft); }
.li-n { font-weight: 700; font-variant-numeric: tabular-nums; }
.li-k { color: var(--muted); font-size: 14px; }
.li-s { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 15px; }
.li-c.ok { color: var(--accent); }
.li-c.no { color: var(--warn); }
.layers { display: flex; flex-direction: column; max-height: 50vh; overflow-y: auto; border: 1px solid var(--line); border-radius: 10px; padding: 4px 10px; }

.menu { display: flex; flex-direction: column; gap: 8px; }
.menu-i { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left; border: 1px solid var(--line); background: #fff; border-radius: 12px; padding: 12px 14px; }
.menu-i span { color: var(--muted); font-size: 14px; }
.menu-i:active { background: var(--accent-soft); }

/* ---------- карта, привязка, GPS ---------- */
.fbtn.gps.on { background: #2f7fe0; color: #fff; }
.gps-chip { color: #1f5fb8; }
.gps-chip.weak { color: var(--warn); }
.gps-chip .x { margin-left: 2px; color: var(--muted); font-size: 18px; line-height: 1; }
.attr { position: absolute; left: 50%; transform: translateX(-50%); bottom: calc(var(--safe-b) + 2px); font-size: 10px; color: #222; background: rgba(255,255,255,.75); padding: 1px 6px; border-radius: 4px; pointer-events: none; }

.editor.georef .plan { width: 50%; right: auto; }
.editor.georef .toolbar, .editor.georef .ctxbar, .editor.georef .floats, .editor.georef .attr,
.editor.georef .topbar .search, .editor.georef .status, .editor.georef .title { display: none !important; }
.map-pane { position: absolute; top: 0; bottom: 0; right: 0; width: 50%; border-left: 3px solid #fff; background: #c9d0cb; }
.map-pane .map { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; display: block; }
.map-top { position: absolute; top: calc(var(--safe-t) + 10px); left: 10px; right: max(10px, var(--safe-r)); display: flex; flex-direction: column; gap: 6px; }
.map-top .search { display: flex; max-width: none; flex: 1 1 auto; min-width: 0; }
.map-top-row { display: flex; gap: 6px; align-items: center; }
.labels-btn { white-space: nowrap; color: var(--muted); }
.labels-btn.on { color: var(--accent); font-weight: 600; }
.labels-btn.on::before { content: "✓ "; }
.geo-results { background: var(--surface); border-radius: 12px; box-shadow: var(--shadow); max-height: 40vh; overflow-y: auto; display: flex; flex-direction: column; }
.geo-results .li { display: block; grid-template-columns: none; padding: 10px 12px; font-size: 14px; min-height: 0; }
.map-btns { position: absolute; right: max(12px, var(--safe-r)); top: 50%; transform: translateY(-50%); display: flex; flex-direction: column; gap: 8px; }
.pane-label { position: absolute; bottom: calc(var(--safe-b) + 150px); right: 12px; background: rgba(20,27,23,.75); color: #fff; font-size: 13px; padding: 3px 10px; border-radius: 8px; pointer-events: none; }
.pane-label.left { right: auto; left: 12px; }
.geo-panel { position: absolute; left: 50%; transform: translateX(-50%); bottom: calc(var(--safe-b) + 12px); width: min(880px, calc(100vw - 24px)); background: var(--surface); border-radius: 16px; box-shadow: 0 6px 30px rgba(20,30,25,.25); padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; z-index: 6; }
.gp-help { margin: 0; font-size: 14px; color: var(--muted); }
.gp-help b { color: var(--fg); }
.gp-list { display: flex; flex-wrap: wrap; gap: 6px; }
.gp-chip { display: inline-flex; align-items: center; gap: 4px; background: var(--warn-soft); color: #7a4400; border-radius: 999px; padding: 2px 4px 2px 12px; font-size: 14px; font-variant-numeric: tabular-nums; }
.gp-chip.bad { background: #fde2e2; color: var(--danger); }
.gp-chip .x { border: 0; background: none; font-size: 18px; width: 28px; height: 28px; border-radius: 50%; }
.gp-btns { align-items: center; }
.gp-rms { font-size: 14px; font-weight: 600; }
.gp-rms.warn { color: var(--warn); }
.spacer { flex: 1; }
.bar { height: 8px; background: var(--bg); border-radius: 4px; overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s; }

@media (max-width: 760px) {
  .editor.georef .plan { width: 100%; height: 50%; bottom: auto; }
  .map-pane { width: 100%; height: 50%; top: auto; border-left: 0; border-top: 3px solid #fff; }
}

/* ---------- окна и уведомления ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(15, 22, 18, .42); display: flex; align-items: center; justify-content: center; z-index: 50; padding: calc(var(--safe-t) + 16px) 16px calc(var(--safe-b) + 16px); }
.modal { background: var(--surface); border-radius: 16px; width: min(480px, 100%); max-height: 100%; display: flex; flex-direction: column; box-shadow: 0 10px 40px rgba(0,0,0,.25); user-select: text; -webkit-user-select: text; }
.modal.wide { width: min(680px, 100%); }
.modal h3 { padding: 18px 20px 0; font-size: 20px; }
.modal-body { padding: 14px 20px; overflow-y: auto; }
.modal-body p { margin: 0 0 8px; }
.modal-btns { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; padding: 12px 20px 18px; border-top: 1px solid var(--line); }
.toasts { position: fixed; top: calc(var(--safe-t) + 66px); left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 6px; z-index: 60; pointer-events: none; align-items: center; width: max-content; max-width: 90vw; }
.toast { background: rgba(20, 27, 23, .92); color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 15px; transition: opacity .3s; text-align: center; }
.toast.out { opacity: 0; }
.loading { position: fixed; inset: 0; background: rgba(238, 242, 239, .82); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; z-index: 70; font-weight: 500; }
.spinner { width: 42px; height: 42px; border-radius: 50%; border: 4px solid var(--line); border-top-color: var(--accent); animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 3s; } }

@media (max-width: 760px) {
  .title, .tb-l { display: none; }
  .row2 { grid-template-columns: 1fr; }
  .toolbar { width: 62px; }
  .tool small { display: none; }
  .tool { min-height: 50px; }
}

/* ---------- iPhone, вертикально: инструменты строкой внизу, панели выезжают снизу ---------- */
@media (max-width: 600px) {
  .home { padding-top: calc(var(--safe-t) + 16px); gap: 14px; }
  .home-head h1 { font-size: 26px; }
  .home-head .row { width: 100%; }
  .home-head .row .btn { flex: 1; }

  .topbar { top: calc(var(--safe-t) + 8px); left: max(8px, var(--safe-l)); right: max(8px, var(--safe-r)); gap: 6px; }
  .topbar .tb { padding: 0 8px; }
  .search { flex: 1 1 auto; max-width: none; min-width: 0; }
  .status { gap: 6px; }
  .next { padding: 0 10px; font-size: 15px; }
  .status .chip-btn:not(.gps-chip) { display: none; }
  .gps-chip span:not(.x) { font-size: 13px; }

  .editor .toolbar, .editor.side-left .toolbar, .editor.side-right .toolbar {
    top: auto; left: max(8px, var(--safe-l)); right: max(8px, var(--safe-r));
    bottom: calc(var(--safe-b) + 8px); width: auto;
    flex-direction: row; padding: 4px; gap: 0; overflow-x: auto; overflow-y: hidden; border-radius: 14px;
  }
  .toolbar .tool { flex: 1 0 30px; min-height: 48px; min-width: 30px; }
  .toolbar .ic { width: 22px; height: 22px; }
  .toolbar .sep { width: 1px; height: auto; margin: 6px 2px; }

  .editor .ctxbar, .editor.sheet-open.side-left .ctxbar, .editor.sheet-open.side-right .ctxbar {
    left: max(8px, var(--safe-l)); right: max(8px, var(--safe-r)); transform: none; max-width: none;
    bottom: calc(var(--safe-b) + 72px);
    flex-wrap: nowrap; justify-content: flex-start; overflow-x: auto; padding: 6px 8px; gap: 6px; border-radius: 14px;
    scrollbar-width: none;
  }
  .ctxbar::-webkit-scrollbar { display: none; }
  .ctxbar > * { flex: none; }
  .ctxbar .seg { flex-wrap: nowrap; }
  .ctxbar .seg button { padding: 0 10px; white-space: nowrap; }
  .ctxbar .btn { white-space: nowrap; }
  .ctx-t { white-space: nowrap; }

  .editor .floats, .editor.side-left .floats, .editor.side-right .floats,
  .editor.sheet-open.side-left .floats, .editor.sheet-open.side-right .floats {
    left: auto; right: max(10px, var(--safe-r)); bottom: calc(var(--safe-b) + 136px);
  }
  .fbtn.zoom { display: none; }
  .fbtn { width: 46px; height: 46px; }

  .attr { bottom: auto; top: calc(var(--safe-t) + 58px); }

  .editor .sheet, .editor.side-left .sheet, .editor.side-right .sheet {
    left: 0; right: 0; top: auto; bottom: 0; width: 100%;
    height: min(78vh, calc(100% - var(--safe-t) - 60px));
    border-radius: 18px 18px 0 0; padding-bottom: var(--safe-b);
  }
  .sheet-head { position: relative; padding-top: 14px; }
  .sheet-head::before { content: ""; position: absolute; top: 5px; left: 50%; width: 40px; height: 5px; margin-left: -20px; border-radius: 3px; background: var(--line); }
  .li { grid-template-columns: 48px 82px 1fr 22px; }

  .modal-back { align-items: flex-end; padding: 0; }
  .modal { width: 100%; border-radius: 18px 18px 0 0; padding-bottom: var(--safe-b); max-height: 92%; }
  .modal-btns { justify-content: stretch; }
  .modal-btns .btn { flex: 1 1 auto; }

  /* привязка: план сверху, спутник посередине, панель снизу */
  .editor.georef .plan { height: 38%; }
  .map-pane { top: 38%; height: auto; bottom: calc(var(--safe-b) + 200px); }
  .geo-panel { width: calc(100vw - 16px); bottom: calc(var(--safe-b) + 6px); padding: 10px; gap: 6px; max-height: 190px; overflow-y: auto; }
  .gp-help { font-size: 12.5px; }
  .gp-help.compact { display: none; }
  .gp-btns { order: 2; }
  .gp-list { order: 3; }
  .gp-btns .btn { min-height: 36px; }
  .gp-chip { font-size: 13px; }
  .pane-label { bottom: auto; top: 8px; }
  .pane-label.left { top: calc(var(--safe-t) + 60px); }
  .map-top { top: 8px; right: 70px; }
  .map-btns { top: 40%; }
  .map-btns .fbtn:not(:first-child) { display: none; }
  .toasts { top: calc(var(--safe-t) + 60px); }
}

/* ---------- iPhone, горизонтально: низкий экран — компактная панель инструментов ---------- */
@media (max-height: 500px) and (orientation: landscape) {
  .topbar { top: calc(var(--safe-t) + 6px); }
  .tb, .title, .search, .next, .chip-btn { min-height: 38px; }
  .search input { min-height: 34px; }
  .editor .toolbar, .editor.side-left .toolbar, .editor.side-right .toolbar {
    top: calc(var(--safe-t) + 50px); bottom: auto; width: 92px; padding: 3px; gap: 2px;
    display: grid; grid-template-columns: 1fr 1fr;
  }
  .tool small { display: none; }
  .tool { min-height: 40px; }
  .tool .ic { width: 22px; height: 22px; }
  .toolbar .sep { display: none; }
  .status .chip-btn:not(.gps-chip) { display: none; }
  .ctxbar { bottom: calc(var(--safe-b) + 6px); padding: 4px 8px; flex-wrap: nowrap; overflow-x: auto; justify-content: flex-start; max-width: calc(100vw - 220px); }
  .ctxbar > * { flex: none; }
  .ctxbar .seg { flex-wrap: nowrap; }
  .floats { bottom: calc(var(--safe-b) + 6px); gap: 6px; }
  .fbtn { width: 42px; height: 42px; }
  .fbtn.zoom { display: none; }
  .sheet { top: calc(var(--safe-t) + 50px); bottom: calc(var(--safe-b) + 6px); }
  .geo-panel { max-height: 55vh; overflow-y: auto; padding: 8px 10px; }
  .gp-help { display: none; }
}
