/* =========================================================================
   almawqii — map.css
   Carte, the survey map: the application shell under the slim top bar, the
   floating docks over the imagery, the project bar, the live location and
   every panel the workbench opens. Uses the tokens of site.css; black, white
   and gray only.
   ========================================================================= */

/* ------------------------------------------------------------ app shell */
.is-app { height: 100vh; height: 100dvh; overflow: hidden; }
.is-app .topbar { position: relative; flex: none; background: var(--bg); -webkit-backdrop-filter: none; backdrop-filter: none; }
.is-app .topbar-inner { height: var(--nav-h-app); padding-inline: 12px; gap: 12px; }
.is-app .brand-mark { width: 30px; height: 30px; }
.is-app .brand-word { font-size: 1rem; }
.main-app { position: relative; flex: 1 1 auto; min-height: 0; isolation: isolate; } /* the docks stay under the top bar and its menus */
.carte, .carte-stage { position: absolute; inset: 0; }
#map { position: absolute; inset: 0; background: #1a1a1a; }
.map-boot { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; gap: 12px; color: #d9d9d9; font-size: var(--fs-sm); z-index: 5; }
.map-boot .spinner { border-color: #333333; border-top-color: #ffffff; }

/* -------------------------------------------------- app switch + project */
.app-switch { display: inline-flex; align-items: center; gap: 2px; padding: 3px; border-radius: var(--radius-pill); background: var(--bg-panel); border: 1px solid var(--line); flex: none; }
.app-switch-link { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding-inline: 12px; border-radius: var(--radius-pill); font-size: .86rem; font-weight: 600; color: var(--muted); text-decoration: none; transition: background .15s var(--ease), color .15s var(--ease); }
.app-switch-link .icon { width: 15px; height: 15px; }
.app-switch-link:hover { color: var(--ink); text-decoration: none; }
.app-switch-link.is-active { background: var(--bg-card); color: var(--ink); box-shadow: var(--shadow-sm); }

.projbar { position: relative; display: flex; align-items: center; gap: 10px; min-width: 0; flex: 0 1 auto; }
.projbar-switch { display: inline-flex; align-items: center; gap: 8px; min-width: 0; max-width: 300px; height: 36px; padding: 0 10px 0 8px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--bg-card); color: var(--ink); font: inherit; font-size: .9rem; font-weight: 600; cursor: pointer; transition: border-color .15s var(--ease); }
.projbar-switch:hover, .projbar-switch[aria-expanded="true"] { border-color: var(--ink); }
.projbar-icon { display: inline-flex; color: var(--muted); }
.projbar-icon .icon, .projbar-caret { width: 16px; height: 16px; flex: none; }
.projbar-caret { color: var(--muted); }
.projbar-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.projbar-status { display: inline-flex; align-items: center; gap: 7px; min-width: 0; color: var(--muted); font-size: var(--fs-xs); white-space: nowrap; }
.projbar-status-text { overflow: hidden; text-overflow: ellipsis; max-width: 320px; }
.projbar-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--line-3); flex: none; }
.projbar[data-state="saved"] .projbar-dot { background: var(--ink); }
.projbar[data-state="pending"] .projbar-dot, .projbar[data-state="saving"] .projbar-dot { background: transparent; border: 2px solid var(--ink); border-top-color: transparent; animation: spin .8s linear infinite; }
.projbar[data-state="offline"] .projbar-dot, .projbar[data-state="error"] .projbar-dot,
.projbar[data-state="session"] .projbar-dot, .projbar[data-state="too_big"] .projbar-dot,
.projbar[data-state="storage"] .projbar-dot, .projbar[data-state="limit"] .projbar-dot { background: transparent; border: 2px dashed var(--ink); }
.projbar[data-state="offline"] .projbar-status, .projbar[data-state="error"] .projbar-status,
.projbar[data-state="session"] .projbar-status, .projbar[data-state="too_big"] .projbar-status,
.projbar[data-state="limit"] .projbar-status { color: var(--ink); font-weight: 600; }
.projbar-menu { inset-inline-start: 0; inset-inline-end: auto; width: 320px; max-height: calc(100vh - 90px); overflow-y: auto; }
.projbar-menu-head { padding: 8px 8px 10px; border-bottom: 1px solid var(--line); margin-bottom: 6px; display: grid; gap: 6px; }
.projbar-menu-label { font-family: var(--font-mono); font-size: .72rem; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.projbar-rename { width: 100%; min-height: 38px; padding: 6px 10px; border: 1px solid var(--line-2); border-radius: 8px; background: var(--bg); color: var(--ink); font: inherit; font-weight: 600; }
.projbar-rename:focus { outline: none; border-color: var(--ink); }
.projbar-item { align-items: flex-start; }
.projbar-item-ico { display: inline-flex; margin-top: 2px; color: var(--muted); }
.projbar-item.is-active .projbar-item-ico { color: var(--ink); }
.projbar-item-main { display: grid; min-width: 0; }
.projbar-item-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.projbar-item-sub { color: var(--muted); font-size: var(--fs-xs); }
.projbar-menu .menu-item:disabled { opacity: .45; cursor: not-allowed; }
.projbar-menu-foot { border-top: 1px solid var(--line); margin-top: 6px; padding-top: 6px; }
/* a guest: nothing is kept — the bar says so, and offers the way to keep it */
.projbar[data-state="guest"] .projbar-switch { border-style: dashed; border-color: var(--line-3); }
.projbar[data-state="guest"] .projbar-switch:hover, .projbar[data-state="guest"] .projbar-switch[aria-expanded="true"] { border-style: solid; border-color: var(--ink); }
.projbar[data-state="guest"] .projbar-dot { background: transparent; border: 2px dashed var(--muted); }
.projbar[data-state="guest"].has-content .projbar-status { color: var(--ink); font-weight: 600; }
.projbar[data-state="guest"].has-content .projbar-dot { border-color: var(--ink); }
.guest-menu { display: grid; gap: 12px; padding: 10px 8px 6px; }
.guest-menu-head { display: flex; gap: 12px; align-items: flex-start; }
.guest-menu-icon { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; border-radius: 10px; background: var(--bg-panel); color: var(--ink); flex: none; }
.guest-menu-icon .icon { width: 18px; height: 18px; }
.guest-menu-head strong { display: block; font-size: .95rem; color: var(--ink); }
.guest-menu-head p { margin: 3px 0 0; font-size: var(--fs-xs); line-height: 1.5; color: var(--muted); }
.guest-menu-perks { list-style: none; margin: 0; padding: 10px 12px; display: grid; gap: 7px; border-radius: var(--radius-sm); background: var(--bg-tint); border: 1px solid var(--line); }
.guest-menu-perks li { display: flex; gap: 8px; align-items: flex-start; font-size: var(--fs-xs); color: var(--ink-3); line-height: 1.45; }
.guest-menu-perks .icon { width: 14px; height: 14px; flex: none; margin-top: 2px; }
.guest-menu-actions { display: grid; gap: 8px; }
.guest-menu-actions .button { width: 100%; justify-content: center; }
.guest-menu-note { margin: 0; font-size: .72rem; color: var(--muted); text-align: center; }
.handoff-button .icon:last-child { width: 15px; height: 15px; }

/* ------------------------------------------------------------- leaflet */
.leaflet-container { font-family: var(--font-sans); background: #1a1a1a; outline: none; }
.leaflet-container a { color: inherit; }
.leaflet-bar a { background: var(--bg-card); color: var(--ink); border-color: var(--line); }
.leaflet-bar a:hover { background: var(--bg-panel); color: var(--ink); }
.leaflet-popup-content-wrapper, .leaflet-tooltip { border-radius: var(--radius); background: var(--bg-card); color: var(--ink); box-shadow: var(--shadow-lg); border: 1px solid var(--line); }
.leaflet-popup-tip { background: var(--bg-card); box-shadow: none; border: 1px solid var(--line); }
.leaflet-popup-content { margin: 14px 16px; font-size: .86rem; line-height: 1.55; min-width: 220px; }
.leaflet-popup-content b { font-weight: 600; }
.leaflet-popup-content .dim { color: var(--muted); font-size: var(--fs-xs); }
.leaflet-popup-content .warn { font-weight: 600; }
.leaflet-container a.leaflet-popup-close-button { top: 8px; right: 8px; width: 24px; height: 24px; border-radius: 50%; color: var(--muted); font-size: 18px; line-height: 22px; }
.leaflet-container a.leaflet-popup-close-button:hover { background: var(--bg-panel); color: var(--ink); }
[dir="rtl"] .leaflet-popup-content { text-align: right; }
[dir="rtl"] .leaflet-container a.leaflet-popup-close-button { right: auto; left: 8px; }
body.is-drawing .leaflet-popup-pane { pointer-events: none; }
.leaflet-popup-pane .leaflet-popup.is-stale { display: none; }
.leaflet-tooltip { padding: 4px 8px; font-size: var(--fs-xs); }
.leaflet-tooltip.pt-z-tip { padding: 1px 6px; background: #000000d9; color: #ffffff; border: 0; box-shadow: none; font-family: var(--font-mono); font-size: .72rem; font-weight: 600; border-radius: 6px; }
.leaflet-tooltip.pt-z-tip::before { display: none; }
.leaflet-tooltip.pt-z-tip.is-empty { opacity: .6; }
.pop-btns { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.pop-btns .btn { flex: 1; }
.pop-field { display: grid; gap: 4px; margin: 10px 0 0; font-size: var(--fs-xs); font-weight: 600; color: var(--muted); }
.pop-field select { width: 100%; min-height: 34px; padding: 4px 8px; border: 1px solid var(--line-2); border-radius: 8px; background: var(--bg); color: var(--ink); font: inherit; font-size: .86rem; font-weight: 500; }
.pop-field select:focus { outline: none; border-color: var(--ink); }

.almawqii-pt { background: none; border: 0; }
.pt-dot { display: block; width: 14px; height: 14px; border-radius: 50%; background: var(--pt-color, #ffffff); border: 3px solid #000000; box-shadow: 0 0 0 1.5px #ffffff, 0 2px 6px #00000080; }
.leaflet-tooltip.contour-tip { padding: 3px 8px; background: #000000; color: #ffffff; border: 0; font-family: var(--font-mono); font-size: .74rem; font-weight: 600; white-space: nowrap; }
.leaflet-tooltip.contour-tip::before { display: none; }
.scat { background: none; border: 0; }
.scat-dot { display: block; width: 7px; height: 7px; border-radius: 50%; background: #000000; border: 1.5px solid #ffffff; }
.search-target { background: none; border: 0; }
.search-target span { display: block; width: 26px; height: 26px; border-radius: 50%; border: 2px solid #ffffff; background: #00000040; box-shadow: 0 0 0 2px #000000; position: relative; }
.search-target span::after { content: ""; position: absolute; inset: 9px; border-radius: 50%; background: #ffffff; }

/* a point opened from the converter pages (?at=lat,lng) */
.deep-link-pin { background: none; border: 0; }
.deep-link-pin span { display: block; width: 26px; height: 26px; border-radius: 50%; border: 3px solid #ffffff; background: #000000; box-shadow: 0 0 0 2px #000000, 0 6px 14px #00000059; cursor: pointer; }
.leaflet-tooltip.deep-link-tip { padding: 4px 10px; background: #000000; color: #ffffff; border: 0; font-family: var(--font-mono); font-size: .76rem; font-weight: 600; white-space: nowrap; }
.leaflet-tooltip.deep-link-tip::before { border-top-color: #000000; }

/* live location */
.live-marker { background: none; border: 0; }
.live-dot { position: absolute; inset: 5px; border-radius: 50%; background: #000000; border: 3px solid #ffffff; box-shadow: 0 2px 8px #00000099; }
.live-pulse { position: absolute; inset: -10px; border-radius: 50%; background: #ffffff59; border: 1.5px solid #ffffffb3; animation: live-pulse 2s cubic-bezier(.2, .7, .2, 1) infinite; }
@keyframes live-pulse { 0% { transform: scale(.4); opacity: 1; } 80%, 100% { transform: scale(1.25); opacity: 0; } }

/* ------------------------------------------------------------------ docks */
.dock { position: absolute; z-index: 500; display: flex; gap: 4px; padding: 5px; border-radius: 16px; background: color-mix(in srgb, var(--bg-card) 92%, transparent); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); border: 1px solid var(--line); box-shadow: var(--shadow-md); }
.dock-tools { top: 14px; inset-inline-start: 14px; flex-direction: column; width: 80px; }
.dock-controls { top: 14px; inset-inline-end: 14px; flex-direction: column; width: 80px; }
.dock-nav { bottom: 52px; inset-inline-end: 14px; flex-direction: column; align-items: stretch; padding: 5px; width: 80px; }
.dock-nav-zoom { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
.tool-sep, .ctl-sep { display: block; height: 1px; margin: 3px 6px; background: var(--line); }

.tool, .ctl {
  position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  width: 100%; min-height: 56px; padding: 6px 2px;
  border: 0; border-radius: 12px;
  background: transparent; color: var(--ink);
  font: inherit; font-size: .7rem; font-weight: 600; line-height: 1.15; text-align: center;
  cursor: pointer;
  transition: background .15s var(--ease), color .15s var(--ease);
  -webkit-tap-highlight-color: transparent;
}
.tool:hover, .ctl:hover { background: var(--ink); color: var(--bg); }
.tool.active, .ctl.active { background: var(--ink); color: var(--bg); }
.tool:focus-visible, .ctl:focus-visible { outline: 2px solid var(--ink); outline-offset: 1px; }
.tool .ti, .ctl .ctl-ico { display: inline-flex; width: 22px; height: 22px; }
.tool .ti svg, .ctl .ctl-ico svg { width: 22px; height: 22px; }
.tool .tl, .ctl .ctl-tl { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ctl-proj .ctl-tl { font-family: var(--font-mono); font-size: .7rem; white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.ctl-zoom { min-height: 38px; font-size: .95rem; font-weight: 600; padding: 0; }
.ctl-live { min-height: 58px; }
.ctl-live[data-state="searching"] .ctl-ico { animation: spin 1.4s linear infinite; }
.ctl-live[data-state="free"] { background: var(--bg-panel); color: var(--ink); box-shadow: inset 0 0 0 2px var(--ink); }

.readout { position: absolute; z-index: 500; inset-inline-start: 14px; bottom: 12px; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; max-width: calc(100% - 140px); padding: 5px 6px; border-radius: 12px; background: #000000cc; color: #ffffff; -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); font-family: var(--font-mono); font-size: .76rem; }
.readout .ro { padding: 3px 8px; border-radius: 8px; white-space: nowrap; }
.readout .ro b { color: #b3b3b3; font-weight: 600; }
.ro-clickable { cursor: pointer; }
.ro-clickable:hover, .ro-clickable:focus-visible { background: #ffffff26; outline: none; }
.ro-zone { background: #ffffff1f; }
.map-credit { position: absolute; z-index: 450; bottom: 4px; inset-inline-end: 104px; font-size: .68rem; color: #ffffffb3; text-shadow: 0 1px 3px #000000cc; pointer-events: none; }

.status-pill { position: absolute; z-index: 520; top: 14px; inset-inline-start: 50%; transform: translateX(-50%); max-width: calc(100% - 200px); padding: 8px 16px; border-radius: var(--radius-pill); background: #000000e6; color: #ffffff; font-size: .82rem; font-weight: 500; box-shadow: var(--shadow-md); text-align: center; }
[dir="rtl"] .status-pill { transform: translateX(50%); }
.map-hint { position: absolute; z-index: 480; bottom: 56px; inset-inline-start: 14px; display: flex; align-items: center; gap: 10px; max-width: 420px; padding: 10px 10px 10px 14px; border-radius: 14px; background: var(--bg-card); color: var(--ink-3); border: 1px solid var(--line); box-shadow: var(--shadow-md); font-size: .82rem; }
.map-hint .icon { width: 18px; height: 18px; flex: none; }
.map-hint-close { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; border: 0; border-radius: 50%; background: transparent; color: var(--muted); cursor: pointer; flex: none; }
.map-hint-close:hover { background: var(--bg-panel); color: var(--ink); }
.map-hint-close svg { width: 16px; height: 16px; }

.live-card { position: absolute; z-index: 510; bottom: 52px; inset-inline-end: 106px; display: grid; gap: 8px; width: 250px; padding: 12px 14px; border-radius: 14px; background: var(--bg-card); border: 1px solid var(--line); box-shadow: var(--shadow-lg); }
.live-card-row { display: flex; align-items: center; gap: 8px; font-size: .86rem; }
.live-card-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--ink); box-shadow: 0 0 0 3px var(--bg-soft); }
.live-card-acc { margin-inline-start: auto; color: var(--muted); font-size: var(--fs-xs); font-family: var(--font-mono); }
.live-card-xy { font-family: var(--font-mono); font-size: .76rem; color: var(--ink-3); }

.search-panel { position: absolute; z-index: 560; top: 14px; inset-inline-start: 50%; transform: translateX(-50%); width: min(540px, calc(100% - 200px)); border-radius: 16px; background: var(--bg-card); border: 1px solid var(--line); box-shadow: var(--shadow-lg); overflow: hidden; }
[dir="rtl"] .search-panel { transform: translateX(50%); }
.search-row { display: flex; align-items: center; gap: 6px; padding: 6px; }
.search-ico { display: inline-flex; padding-inline: 8px 2px; color: var(--muted); }
.search-ico svg { width: 18px; height: 18px; }
.search-row input { flex: 1; min-width: 0; min-height: 40px; border: 0; background: transparent; color: var(--ink); font: inherit; font-size: .95rem; padding: 0 4px; }
.search-row input:focus { outline: none; }
.search-results { max-height: 320px; overflow-y: auto; border-top: 1px solid var(--line); }
.search-results:empty { display: none; }
.search-results .sr { display: grid; gap: 2px; padding: 10px 16px; cursor: pointer; border-bottom: 1px solid var(--line); }
.search-results .sr:last-child { border-bottom: 0; }
.search-results .sr:hover { background: var(--bg-panel); }
.search-results .sr b { font-weight: 600; font-size: .9rem; }
.search-results .sr small { color: var(--muted); font-size: var(--fs-xs); }
.search-results .sr-empty { padding: 14px 16px; color: var(--muted); font-size: .86rem; }

/* ------------------------------------------------------- workbench buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: var(--btn-h); padding: var(--btn-pad);
  border: 1px solid var(--ink); border-radius: var(--radius-pill);
  background: var(--ink); color: var(--bg);
  font: inherit; font-size: var(--btn-font); font-weight: 600; line-height: 1;
  text-decoration: none; white-space: nowrap; cursor: pointer;
  transition: background .15s var(--ease), color .15s var(--ease), border-color .15s var(--ease);
}
.btn:hover { background: var(--bg); color: var(--ink); text-decoration: none; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn svg { width: 16px; height: 16px; flex: none; }
.btn > span[data-icon] { display: inline-flex; }
.btn-primary { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.btn-primary:hover { background: var(--bg); color: var(--ink); }
.btn-secondary { background: var(--bg-panel); color: var(--ink); border-color: var(--line-2); }
.btn-secondary:hover { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--line-3); }
.btn-ghost:hover { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.btn-danger { background: transparent; color: var(--ink); border: 1px dashed var(--ink); }
.btn-danger:hover { background: var(--ink); color: var(--bg); }
.btn-sm { min-height: var(--btn-h-sm); padding: var(--btn-pad-sm); font-size: var(--btn-font-sm); }
.btn-block { width: 100%; }
.pop-btns .btn { min-height: 32px; padding: 0 10px; font-size: .78rem; }

/* ------------------------------------------------------------------ modals */
.overlay { position: fixed; inset: 0; z-index: 1000; display: flex; align-items: center; justify-content: center; padding: 16px; background: var(--overlay); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); animation: fade-in .15s var(--ease); }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
.modal { display: flex; flex-direction: column; width: min(520px, 100%); max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px); background: var(--bg-card); color: var(--ink); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); animation: modal-in .2s var(--ease); }
.modal.wide { width: min(860px, 100%); }
@keyframes modal-in { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }
.overlay-pass { pointer-events: none; background: transparent; -webkit-backdrop-filter: none; backdrop-filter: none; }
.overlay-pass .modal { pointer-events: auto; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 18px 12px; border-bottom: 1px solid var(--line); }
.modal-title { font-size: 1.05rem; font-weight: 600; letter-spacing: -.01em; }
.modal-x { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border: 0; border-radius: 50%; background: transparent; color: var(--muted); cursor: pointer; flex: none; }
.modal-x:hover { background: var(--bg-panel); color: var(--ink); }
.modal-body { padding: 16px 18px; overflow-y: auto; font-size: .92rem; }
.modal-foot { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; padding: 12px 18px 16px; border-top: 1px solid var(--line); }

.field { display: grid; gap: 6px; margin-bottom: 12px; }
.field label { margin: 0; font-size: .82rem; font-weight: 600; color: var(--ink-2); }
.input, .modal select.input { width: 100%; min-height: 42px; padding: 8px 12px; border: 1px solid var(--line-2); border-radius: 10px; background: var(--bg); color: var(--ink); font: inherit; font-size: .92rem; }
.input:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 3px var(--bg-soft); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.hint { color: var(--muted); font-size: .84rem; line-height: 1.5; }
.proj-group-title { margin: 14px 0 6px; font-weight: 700; font-size: .72rem; letter-spacing: .1em; text-transform: uppercase; font-family: var(--font-mono); }
.proj-note { margin-top: 14px; }
.range { width: 100%; accent-color: var(--ink); }

.rows { display: grid; gap: 4px; }
.row-item { display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px 12px; border: 1px solid transparent; border-radius: 12px; background: transparent; color: var(--ink); font: inherit; text-align: start; cursor: pointer; }
.row-item:hover { background: var(--bg-panel); }
.row-item.active { border-color: var(--ink); background: var(--bg-tint); }
.row-item .ri-ico { display: inline-flex; width: 36px; height: 36px; align-items: center; justify-content: center; border-radius: 10px; background: var(--bg-panel); flex: none; }
.row-item .ri-ico svg { width: 20px; height: 20px; }
.row-item .ri-main { display: grid; gap: 1px; flex: 1; min-width: 0; }
.row-item .ri-title { font-weight: 600; font-size: .9rem; }
.row-item .ri-sub, .ri-sub { color: var(--muted); font-size: var(--fs-xs); }
.row-item .ri-check { display: inline-flex; }

.tool-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.tool-card { position: relative; display: grid; justify-items: start; gap: 4px; padding: 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--bg-card); color: var(--ink); font: inherit; text-align: start; cursor: pointer; transition: border-color .15s var(--ease), background .15s var(--ease); }
.tool-card:hover { border-color: var(--ink); background: var(--bg-tint); }
.tool-card .tc-ico { display: inline-flex; width: 38px; height: 38px; align-items: center; justify-content: center; border-radius: 10px; background: var(--ink); color: var(--bg); margin-bottom: 6px; }
.tool-card .tc-ico svg { width: 20px; height: 20px; }
.tool-card .tc-lbl { font-weight: 600; font-size: .9rem; }
.tool-card.is-locked .tc-ico { background: var(--bg-panel); color: var(--muted); }
.tool-card .tc-lock { position: absolute; top: 12px; inset-inline-end: 12px; display: inline-flex; color: var(--muted); }
.tool-grid-note { grid-column: 1 / -1; display: flex; align-items: center; gap: 8px; margin: 6px 0 0; }
.tool-grid-note svg { width: 14px; height: 14px; }
.gate-what { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px; background: var(--bg-panel); font-weight: 600; }
.gate-what .tc-ico { display: inline-flex; }
.gate-what svg { width: 18px; height: 18px; }
.gate-list { margin: 12px 0 0; padding-inline-start: 20px; color: var(--ink-3); display: grid; gap: 4px; }

.tabs { display: flex; gap: 4px; padding: 4px; margin-bottom: 14px; border-radius: var(--radius-pill); background: var(--bg-panel); }
.tab { flex: 1; min-height: 34px; padding: 0 12px; border: 0; border-radius: var(--radius-pill); background: transparent; color: var(--muted); font: inherit; font-size: .84rem; font-weight: 600; cursor: pointer; }
.tab:hover { background: var(--bg-card); color: var(--ink); }
.tab.active { background: var(--bg-card); color: var(--ink); box-shadow: var(--shadow-sm); }

.alert { padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line-2); background: var(--bg-tint); font-size: .86rem; margin-bottom: 12px; }
.alert-info { border-style: solid; }
.alert-warn, .alert-danger { border-color: var(--ink); border-style: dashed; }

.busy { position: fixed; inset: 0; z-index: 1200; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; background: var(--overlay); color: #ffffff; font-size: .9rem; font-weight: 500; }
.busy .spinner { width: 28px; height: 28px; border-width: 3px; border-color: #ffffff4d; border-top-color: #ffffff; }
.toast-root { position: fixed; z-index: 1300; bottom: 64px; inset-inline-start: 50%; transform: translateX(-50%); display: grid; gap: 8px; justify-items: center; pointer-events: none; width: max-content; max-width: calc(100vw - 32px); }
[dir="rtl"] .toast-root { transform: translateX(50%); }
.toast { padding: 10px 16px; border-radius: var(--radius-pill); background: #000000; color: #ffffff; font-size: .84rem; font-weight: 500; box-shadow: var(--shadow-lg); border: 1px solid #333333; animation: toast-in .25s var(--ease); text-align: center; }
.toast.warn { background: #ffffff; color: #000000; border: 1px dashed #000000; }
.toast.err { background: #ffffff; color: #000000; border: 2px solid #000000; font-weight: 600; }

/* ------------------------------------------------------ export & profile */
.export-options { margin-top: 14px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg-tint); }
.export-options-title { font-size: .76rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin-bottom: 8px; font-family: var(--font-mono); }
.export-check { display: flex; align-items: center; gap: 8px; padding: 4px 0; font-size: .88rem; font-weight: 500; cursor: pointer; }
.export-check input[type="checkbox"] { width: 17px; height: 17px; accent-color: var(--ink); }
.profile-body { display: grid; gap: 14px; }
.profile-plot { border: 1px solid var(--line); border-radius: 12px; background: var(--bg); overflow: hidden; }
.profile-chart { display: block; width: 100%; height: auto; }
.profile-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; }
.profile-stat { padding: 10px 12px; border-radius: 12px; background: var(--bg-panel); }
.profile-stat .ps-label { display: block; color: var(--muted); font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; }
.profile-stat .ps-value { display: block; font-family: var(--font-mono); font-weight: 600; font-size: .95rem; }

/* zone & X/Y panel */
.zy { display: grid; gap: 14px; }
.zy-block { display: grid; gap: 6px; }
.zy-label { font-size: .78rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.zy-refs { display: flex; flex-wrap: wrap; gap: 6px; }
.zy-ref { display: inline-flex; align-items: center; gap: 6px; min-height: 34px; padding: 0 12px; border: 1px solid var(--line-2); border-radius: var(--radius-pill); background: var(--bg-card); color: var(--ink); font: inherit; font-size: .82rem; font-weight: 600; cursor: pointer; }
.zy-ref:hover { border-color: var(--ink); }
.zy-ref.active { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.zy-ref .zy-ref-ico { display: inline-flex; }
.zy-ref svg { width: 15px; height: 15px; }
.zy-values { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.zy-field { display: grid; gap: 4px; }
.zy-value { width: 100%; min-height: 44px; padding: 8px 12px; border: 1px solid var(--line-2); border-radius: 10px; background: var(--bg); color: var(--ink); font-family: var(--font-mono); font-size: .95rem; }
.zy-value:focus { outline: none; border-color: var(--ink); }
.zy-source { color: var(--muted); font-size: var(--fs-xs); }
.zy-notice { padding: 10px 12px; border-radius: 10px; background: var(--bg-panel); font-size: .82rem; }
.zy-notice.zy-warn { background: transparent; border: 1px dashed var(--ink); }
.zy-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.zy-actions .btn { flex: 1; }
.zone-onboarding { display: grid; gap: 8px; }

/* ------------------------------------------------------------- responsive */
/* ------------------------------------------------------------ calques */
.modal.modal-layers { width: min(580px, 100%); }
.cq-hint { margin: 0 0 12px; color: var(--muted); font-size: .84rem; line-height: 1.5; }
.cq-current { display: grid; gap: 6px; margin-bottom: 14px; font-size: .82rem; font-weight: 600; color: var(--ink-2); }
.cq-list { display: grid; gap: 6px; }
.cq-empty { margin: 0; color: var(--muted); font-size: .86rem; }
.cq-row { display: grid; grid-template-columns: 40px 40px minmax(0, 1fr) 40px 40px; align-items: center; gap: 6px; padding: 5px 6px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); }
.cq-row.is-active { border-color: var(--ink); box-shadow: inset 3px 0 0 var(--ink); }
[dir="rtl"] .cq-row.is-active { box-shadow: inset -3px 0 0 var(--ink); }
.cq-row.is-hidden .cq-text, .cq-row.is-hidden .cq-color { opacity: .45; }
.cq-eye, .cq-del, .cq-tune { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; padding: 0; border: 0; border-radius: 10px; background: transparent; color: var(--ink); cursor: pointer; }
.cq-eye:hover, .cq-del:hover, .cq-tune:hover, .cq-tune.is-open { background: var(--ink); color: var(--bg); }
.cq-eye.is-off { color: var(--muted); }
.cq-color { width: 38px; height: 34px; padding: 2px; border: 1px solid var(--line-2); border-radius: 9px; background: var(--bg); cursor: pointer; }
.cq-text { display: grid; gap: 1px; min-width: 0; }
.cq-name { justify-self: start; max-width: 100%; min-height: 24px; padding: 0; border: 0; background: none; color: var(--ink); font: inherit; font-family: var(--font-mono); font-size: .86rem; font-weight: 700; text-align: start; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: text; }
.cq-name:hover { background: var(--ink); color: var(--bg); }
.cq-meta { color: var(--muted); font-size: .74rem; }
.cq-more { grid-column: 1 / -1; padding: 0 4px 4px; }
.cq-more[hidden] { display: none; }
.cq-style { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 8px 0; }
.cq-style label { display: grid; gap: 4px; font-size: .74rem; font-weight: 600; color: var(--ink-2); }
.modal .cq-style select.input { min-height: 36px; padding: 4px 8px; font-size: .84rem; }
.cq-swatches { display: flex; flex-wrap: wrap; gap: 6px; padding-bottom: 4px; }
.cq-swatch { width: 26px; height: 26px; padding: 0; border-radius: 7px; border: 1px solid var(--line-2); background: var(--sw, #808080); cursor: pointer; }
.cq-swatch:hover, .cq-swatch:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

/* ------------------------------------------- MNT — courbes de niveau */
.modal.modal-cn { width: min(1200px, 100%); height: min(880px, calc(100vh - 32px)); height: min(880px, calc(100dvh - 32px)); }
.modal-cn .modal-title { font-size: .98rem; }
.modal-cn .modal-body { flex: 1; min-height: 0; padding: 0; overflow: hidden; display: flex; flex-direction: column; }
.cn { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.cn-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; padding: 8px 14px; border-bottom: 1px solid var(--line); background: var(--bg-panel); }
.cn-bar .btn .icon, .cn-bar .btn svg { width: 16px; height: 16px; }
.cn-pas { display: inline-flex; align-items: center; gap: 8px; font-size: .84rem; font-weight: 600; }
.modal .cn-pas select.input { width: auto; min-height: 34px; padding: 4px 8px; font-size: .84rem; }
.cn-main { display: grid; grid-template-columns: minmax(0, 1fr) minmax(300px, 410px); flex: 1; min-height: 0; }
.cn-form { min-height: 0; overflow-y: auto; padding: 12px 14px 16px; }
.cn-side { display: flex; flex-direction: column; gap: 8px; min-height: 0; padding: 12px 14px; border-inline-start: 1px solid var(--line); background: var(--bg-card); }
.cn-preview { position: relative; flex: 1; min-height: 240px; border: 1px solid var(--line-2); border-radius: 10px; overflow: hidden; background: #000000; }
.cn-preview canvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; cursor: grab; }
.cn-preview canvas:active { cursor: grabbing; }
.cn-zoom { position: absolute; top: 8px; inset-inline-end: 8px; display: grid; gap: 4px; }
.cn-zbtn { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; padding: 0; border: 1px solid #ffffff4d; border-radius: 9px; background: #000000b3; color: #ffffff; cursor: pointer; }
.cn-zbtn:hover, .cn-zbtn:focus-visible { background: #ffffff; color: #000000; outline: none; }
.cn-loading { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; gap: 10px; padding: 12px; background: #000000b3; color: #ffffff; font-size: .84rem; text-align: center; }
.cn-loading[hidden] { display: none; }
.cn-spinner { width: 18px; height: 18px; flex: none; border: 2px solid #ffffff; border-top-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; }
.cn-status { margin: 0; font-family: var(--font-mono); font-size: .74rem; line-height: 1.5; color: var(--ink-2); }
.cn-status.is-error { color: var(--ink); font-weight: 700; }
.cn-note { margin: 0; color: var(--muted); font-size: .74rem; line-height: 1.45; }
.cn-box { min-width: 0; margin: 0 0 10px; padding: 6px 12px 10px; border: 1px solid var(--line-2); border-radius: 10px; }
.cn-box legend { padding: 0 6px; font-size: .78rem; font-weight: 700; color: var(--ink-2); }
.cn-box legend .cn-check { min-height: 0; font-weight: 700; font-size: .78rem; }
.cn-table { display: grid; gap: 5px; }
.cn-tr { display: grid; grid-template-columns: 30px minmax(72px, 1fr) 76px minmax(92px, 1.15fr) 62px minmax(112px, 1fr) 70px; align-items: center; gap: 6px; }
.cn-th { font-size: .7rem; font-weight: 700; letter-spacing: .02em; text-transform: uppercase; color: var(--muted); }
.cn-th > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cn-th-c { text-align: center; }
.modal .cn-tr .input, .modal .cn-tr select.input { min-height: 34px; padding: 4px 8px; border-radius: 8px; font-size: .84rem; }
.cn-tr.is-off .cn-td:not(.cn-on) { opacity: .45; }
.cn-on { display: flex; justify-content: center; }
.cn-on input, .cn-check input { width: 17px; height: 17px; flex: none; accent-color: var(--ink); }
.cn-color { display: flex; justify-content: center; }
.cn-color input[type="color"] { width: 42px; height: 32px; padding: 2px; border: 1px solid var(--line-2); border-radius: 8px; background: var(--bg); cursor: pointer; }
.cn-cols { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 10px; align-items: start; }
.cn-check { display: flex; align-items: center; gap: 8px; min-height: 30px; font-size: .86rem; cursor: pointer; }
.cn-check input:disabled + span { opacity: .45; }
.cn-inline { display: flex; flex-wrap: wrap; gap: 0 14px; }
.cn-field { display: grid; gap: 3px; margin: 4px 0 6px; font-size: .76rem; font-weight: 600; color: var(--ink-2); }
.modal .cn-field .input, .modal .cn-field select.input { min-height: 34px; padding: 4px 8px; border-radius: 8px; font-size: .86rem; }
.cn-field .input:disabled { opacity: .5; }
.cn-unit { display: flex; align-items: center; gap: 6px; }
.cn-unit i { font-style: normal; font-size: .8rem; color: var(--muted); }
.cn-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

@media (max-width: 1180px) {
  .projbar-status-text { max-width: 140px; }
}
@media (max-width: 980px) {
  .is-app .app-switch-link span { display: none; }
  .is-app .app-switch-link { padding-inline: 9px; }
  .projbar-status-text { display: none; }
  .handoff-button span { display: none; }
  .handoff-button .icon:last-child { display: none; }
  .handoff-button { min-width: var(--btn-h-sm); padding-inline: 0; }
}
@media (max-width: 760px) {
  .is-app .topbar-inner { gap: 8px; padding-inline: 8px; }
  .is-app .brand-word, .is-app .app-switch, .is-app .topbar-login { display: none; }
  .projbar { flex: 1 1 auto; }
  .projbar-switch { max-width: none; flex: 1; }
  .projbar-menu { position: fixed; top: calc(var(--nav-h-app) + 4px); inset-inline: 8px; width: auto; }
  .dock-tools { top: auto; bottom: 46px; inset-inline-start: 8px; inset-inline-end: 84px; width: auto; flex-direction: row; overflow-x: auto; scrollbar-width: none; }
  .dock-tools::-webkit-scrollbar { display: none; }
  .dock-tools .tool { width: 58px; flex: none; min-height: 52px; }
  .dock-tools .tool-sep { width: 1px; height: auto; margin: 6px 2px; flex: none; }
  .dock-controls { top: 8px; inset-inline-end: 8px; width: 58px; }
  .dock-controls .ctl { min-height: 50px; }
  .dock-controls .ctl-tl { font-size: .7rem; }
  .dock-nav { bottom: 46px; inset-inline-end: 8px; width: 68px; }
  .dock-nav .dock-nav-zoom { display: none; }
  .readout { inset-inline-start: 8px; bottom: 6px; max-width: calc(100% - 16px); font-size: .7rem; padding: 3px 4px; }
  .readout .ro { padding: 2px 6px; }
  .readout #ro-wgs, .readout .ro-zoom { display: none; }
  .map-credit { display: none; }
  .map-hint { inset-inline: 8px; bottom: 116px; max-width: none; }
  .live-card { inset-inline: 8px auto; inset-inline-end: 84px; bottom: 116px; width: auto; }
  .search-panel { width: calc(100% - 82px); inset-inline-start: 8px; transform: none; top: 8px; }
  [dir="rtl"] .search-panel { transform: none; }
  .status-pill { top: auto; bottom: 120px; max-width: calc(100% - 24px); }
  .toast-root { bottom: 120px; }
  .tool-grid { grid-template-columns: 1fr 1fr; }
}
/* ---------------------------------------- MNT dialog: tablet, phone */
@media (max-width: 1100px) {
  .modal.modal-cn { height: calc(100vh - 32px); height: calc(100dvh - 32px); }
  .cn-main { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
  .cn-side { order: -1; flex-direction: row; flex-wrap: wrap; align-items: stretch; border-inline-start: 0; border-bottom: 1px solid var(--line); }
  .cn-preview { flex: 1 1 100%; min-height: 0; height: clamp(190px, 30vh, 330px); }
  .cn-status, .cn-note { flex: 1 1 100%; }
  .cn-cols { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 680px) {
  .overlay-modal-cn { padding: 0; }
  .modal.modal-cn { width: 100%; height: 100vh; height: 100dvh; max-height: none; border: 0; border-radius: 0; }
  .modal-cn .modal-head { padding: 10px 12px 8px; }
  .modal-cn .modal-title { font-size: .9rem; line-height: 1.3; }
  .modal-cn .modal-body { overflow-y: auto; display: block; }
  .modal-cn .modal-foot { padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); }
  .modal-cn .modal-foot .btn { flex: 1; }
  .cn { display: block; }
  .cn-main { display: flex; flex-direction: column; }
  /* the preview comes first and stays in sight while the options scroll under it */
  .cn-side { order: -1; position: sticky; top: 0; z-index: 3; padding: 8px 10px; gap: 6px; box-shadow: 0 6px 12px -10px #00000080; }
  .cn-preview { height: clamp(170px, 30vh, 260px); }
  .cn-note { display: none; }
  .cn-form { overflow: visible; padding: 10px 10px 14px; }
  .cn-bar { padding: 8px 10px; }
  .cn-cols { grid-template-columns: minmax(0, 1fr); }
  /* an order is a small card: on, name, step, colour / layer, line type, width */
  .cn-th { display: none; }
  .cn-tr { grid-template-columns: 28px minmax(0, 1fr) minmax(0, 1.25fr) 70px; grid-template-areas: "on name step color" "on layer lt w"; padding: 6px 0; border-bottom: 1px solid var(--line); gap: 6px 6px; }
  .cn-td[data-label] { display: block; min-width: 0; }
  .modal .cn-tr select.input { padding: 4px 4px 4px 6px; font-size: .8rem; }
  .cn-tr:last-child { border-bottom: 0; }
  .cn-on { grid-area: on; align-self: start; padding-top: 18px; }
  .cn-name { grid-area: name; } .cn-step { grid-area: step; } .cn-color { grid-area: color; }
  .cn-layer { grid-area: layer; } .cn-lt { grid-area: lt; } .cn-w { grid-area: w; }
  .cn-td[data-label]::before { content: attr(data-label); display: block; margin-bottom: 2px; font-size: .68rem; font-weight: 700; color: var(--muted); }
  .cn-color input[type="color"] { width: 100%; }
}

/* ------------------------------------------------ Carte on a phone */
@media (max-width: 760px) {
  /* the seven drawing tools share the full width; no strip that scrolls */
  .dock-tools { inset-inline: 8px; gap: 2px; overflow-x: visible; }
  .dock-tools .tool { flex: 1 1 0; width: auto; min-width: 0; min-height: 52px; padding: 6px 0; }
  .dock-tools .tool-sep { display: none; }
  .dock-tools .tool .tl { max-width: 100%; }
  /* the live position sits above the strip, as a button of its own */
  .dock-nav { bottom: 116px; width: 66px; }
  .dock-nav .ctl-live .ctl-tl { white-space: normal; line-height: 1.1; }
  .dock-controls { width: 66px; max-height: calc(100% - 196px); overflow-y: auto; scrollbar-width: none; }
  .dock-controls::-webkit-scrollbar { display: none; }
  .dock-controls .ctl { min-height: 48px; padding: 5px 1px; }
  .dock-controls .ctl-tl { white-space: normal; line-height: 1.1; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
  .map-hint { inset-inline: 8px 82px; bottom: 116px; }
  .live-card { inset-inline-end: 82px; }
  .status-pill { bottom: 190px; }
  .toast-root { bottom: 190px; }
  .modal-layers .cq-style { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .overlay-modal-layers { align-items: flex-end; padding: 0; }
  .modal.modal-layers { width: 100%; max-height: 88vh; max-height: 88dvh; border-radius: 18px 18px 0 0; border-bottom: 0; }
  .modal-layers .modal-foot { padding-bottom: calc(14px + env(safe-area-inset-bottom)); }
}
