:root {
  color-scheme: dark;
  --bg-0: #161920;
  --bg-1: #0f1116;
  --glass: #1b1f27e0;
  --glass-solid: #1b1f27;
  --glass-line: #ffffff1f;
  --line-strong: rgba(255, 255, 255, 0.17);
  --text: #e6e9ee;
  --muted: #99a1ad;
  --dim: #6f7885;
  --blue: #3b82f6;
  --blue-soft: #3b82f626;
  --orange: #ff6d00;
  --red: #ff4d4f;
  --green: #52c41a;
  --axis-x: #ff6b6b;
  --axis-y: #69db7c;
  --axis-z: #4dabf7;
  --rhino: #ffd600;
  --topbar-h: 56px;
  --dock-h: 60px;
  --sa-t: env(safe-area-inset-top, 0px);
  --sa-b: env(safe-area-inset-bottom, 0px);
  --sa-l: env(safe-area-inset-left, 0px);
  --sa-r: env(safe-area-inset-right, 0px);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Noto Sans SC", sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
  background: linear-gradient(180deg, var(--bg-0), var(--bg-1));
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

button, input, textarea, select { font: inherit; color: inherit; }
button { -webkit-appearance: none; appearance: none; border: 0; background: none; cursor: pointer; }
button:focus-visible, input:focus-visible {
  outline: 2px solid rgba(59, 130, 246, 0.65);
  outline-offset: 2px;
}
[hidden] { display: none !important; }
.hidden { display: none !important; }

#app, #view {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

#view { touch-action: none; }

#canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: grab;
}
#canvas:active { cursor: grabbing; }

#labels {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 6;
  overflow: hidden;
}

/* ---------- top floating bar ---------- */
.topBar {
  position: fixed;
  z-index: 30;
  top: calc(var(--sa-t) + 12px);
  left: calc(var(--sa-l) + 12px);
  right: calc(var(--sa-r) + 12px);
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 6px 0 4px;
  border-radius: 16px;
  border: 1px solid var(--glass-line);
  background: var(--glass);
  -webkit-backdrop-filter: blur(22px) saturate(140%);
  backdrop-filter: blur(22px) saturate(140%);
  box-shadow: 0 10px 32px rgba(3, 5, 9, 0.32), inset 0 1px 0 rgba(255, 255, 255, 0.035);
}

.iconBtn {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  min-width: 44px;
  display: inline-grid;
  place-items: center;
  border-radius: 12px;
  color: #c8ced7;
  transition: background 0.16s ease, color 0.16s ease, transform 0.12s ease;
}
.iconBtn:hover { background: rgba(255, 255, 255, 0.055); color: #fff; }
.iconBtn:active { transform: scale(0.94); }
.iconBtn.on { color: var(--blue); background: var(--blue-soft); }
.iconBtn svg { width: 21px; height: 21px; display: block; }

#btnBack { margin-left: 1px; }
#btnSearch { margin-left: auto; }
#btnViewMode {
  width: 44px;
  min-width: 44px;
}
#btnViewMode .displayGlyph { width: 22px; height: 22px; }
#btnViewMode[data-mode="shaded"] .dg-shaded,
#btnViewMode[data-mode="wireframe"] .dg-wire,
#btnViewMode[data-mode="ghost"] .dg-ghost { display: block; }
#btnViewMode .dg-shaded, #btnViewMode .dg-wire, #btnViewMode .dg-ghost { display: none; }

.fileName {
  min-width: 0;
  height: 44px;
  flex: 1 1 auto;
  padding: 0 6px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 15px;
  font-weight: 600;
  color: #f1f3f6;
  letter-spacing: 0.1px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  transition: background 0.16s ease;
}
.fileName:hover { background: rgba(255, 255, 255, 0.04); }
.fileName.split { display: flex; justify-content: center; }
.fileName.split .fnStart,
.fileName.split .fnEnd {
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.fileName.split .fnStart { flex: 0 1 auto; }
.fileName.split .fnEnd { flex: 1 1 auto; }

#hudChips { display: none; }

#hudWarn {
  position: fixed;
  z-index: 32;
  top: calc(var(--sa-t) + 74px);
  left: calc(var(--sa-l) + 12px);
  right: calc(var(--sa-r) + 12px);
  padding: 9px 13px;
  border-radius: 12px;
  border: 1px solid rgba(255, 187, 51, 0.22);
  background: rgba(52, 39, 20, 0.82);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  color: #ffcf70;
  font-size: 11.5px;
  line-height: 1.45;
  white-space: normal;
}

/* ---------- top overflow menu ---------- */
.moreMenu {
  position: fixed;
  z-index: 50;
  top: calc(var(--sa-t) + 74px);
  right: calc(var(--sa-r) + 12px);
  width: 218px;
  padding: 6px;
  border-radius: 16px;
  border: 1px solid var(--line-strong);
  background: rgba(24, 28, 36, 0.96);
  -webkit-backdrop-filter: blur(26px) saturate(150%);
  backdrop-filter: blur(26px) saturate(150%);
  box-shadow: 0 18px 48px rgba(3, 5, 9, 0.55);
  animation: menuIn 0.16s ease-out both;
}
@keyframes menuIn { from { opacity: 0; transform: translateY(-5px) scale(0.98); } to { opacity: 1; transform: none; } }

.menuGroupTitle {
  padding: 9px 10px 5px;
  color: var(--dim);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.9px;
}
.menuItem {
  width: 100%;
  height: 42px;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 0 10px;
  border-radius: 10px;
  color: #d7dce4;
  font-size: 13px;
  text-align: left;
}
.menuItem:hover { background: rgba(255, 255, 255, 0.06); }
.menuItem .miIcon { width: 18px; height: 18px; color: #8f98a6; flex: 0 0 auto; display: grid; place-items: center; }
.menuItem .miIcon svg { width: 18px; height: 18px; }
.menuItem .miText { flex: 1 1 auto; }
.menuItem .miCheck { width: 7px; height: 7px; border-radius: 50%; background: var(--blue); opacity: 0; }
.menuItem.on .miCheck { opacity: 1; }
.menuItem.on { color: #fff; }
.menuDivider { height: 1px; margin: 5px 8px; background: rgba(255, 255, 255, 0.08); }

/* ---------- measure overlay ---------- */
.measureHud {
  position: fixed;
  z-index: 34;
  top: calc(var(--sa-t) + 80px);
  left: calc(var(--sa-l) + 12px);
  right: calc(var(--sa-r) + 12px);
  padding: 11px 13px 12px;
  border-radius: 16px;
  border: 1px solid var(--glass-line);
  background: var(--glass);
  -webkit-backdrop-filter: blur(22px) saturate(145%);
  backdrop-filter: blur(22px) saturate(145%);
  box-shadow: 0 12px 34px rgba(3, 5, 9, 0.35);
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
}
.mhTop { display: flex; align-items: center; gap: 10px; min-height: 32px; }
.mhReadout { min-width: 0; flex: 1 1 auto; display: flex; align-items: baseline; gap: 7px; overflow: hidden; }
.mhLabel { color: var(--muted); font-size: 11px; letter-spacing: 0.4px; white-space: nowrap; }
#measureTotal {
  color: var(--orange);
  font-size: 22px;
  line-height: 1.05;
  font-weight: 700;
  letter-spacing: -0.2px;
  white-space: nowrap;
}
#measureUnit { color: #ffb066; font-size: 12px; font-weight: 600; white-space: nowrap; }
.mhActions { display: flex; gap: 2px; flex: 0 0 auto; }
.mhIcon {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  color: #b7bec9;
}
.mhIcon:hover { background: rgba(255, 255, 255, 0.06); color: #fff; }
.mhIcon svg { width: 18px; height: 18px; }
.mhDeltas {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  margin-top: 8px;
}
.deltaPill {
  min-width: 0;
  height: 30px;
  padding: 0 9px;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid rgba(255, 255, 255, 0.055);
  display: flex;
  align-items: center;
  gap: 6px;
  overflow: hidden;
}
.deltaPill .dLabel { font-size: 11px; font-weight: 700; letter-spacing: 0.5px; flex: 0 0 auto; }
.deltaPill .dValue {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: right;
  color: #f1f3f6;
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
}
.deltaPill.dx .dLabel { color: var(--red); }
.deltaPill.dy .dLabel { color: var(--green); }
.deltaPill.dz .dLabel { color: #4096ff; }

/* legacy list kept for debug compatibility, never painted */
.measurePanel { display: none !important; }
.measurePanel .mtext { display: none; }

/* ---------- transient hint ---------- */
#hint {
  position: fixed;
  z-index: 25;
  left: 50%;
  bottom: calc(var(--sa-b) + 88px);
  transform: translateX(-50%);
  max-width: calc(100vw - 48px);
  padding: 7px 13px;
  border-radius: 999px;
  border: 1px solid var(--glass-line);
  background: rgba(24, 28, 36, 0.85);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  color: #ccd2db;
  font-size: 12px;
  line-height: 1.35;
  white-space: nowrap;
  pointer-events: none;
}
#hint:empty { display: none; }

/* ---------- status / empty state ---------- */
#status {
  position: fixed;
  z-index: 40;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 90px 24px 110px;
  background:
    radial-gradient(ellipse 80% 55% at 50% 42%, rgba(42, 48, 60, 0.38), rgba(15, 17, 22, 0.92) 72%),
    linear-gradient(180deg, #161920, #0f1116);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  overflow: auto;
}
.statusCard {
  width: min(100%, 340px);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  animation: statusIn 0.32s ease-out both;
}
@keyframes statusIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.brandMark {
  width: 66px;
  height: 66px;
  margin-bottom: 18px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}
.brandMark img { width: 100%; height: 100%; display: block; object-fit: contain; }
.brandName {
  margin: 0;
  font-size: 25px;
  line-height: 1.1;
  letter-spacing: -0.4px;
  font-weight: 700;
  color: #f3f5f8;
}
.brandSub {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 1.6px;
  text-transform: uppercase;
}
#statusText {
  margin: 22px 0 0;
  min-height: 21px;
  color: #b9c0ca;
  font-size: 13.5px;
  line-height: 1.6;
  max-width: 300px;
}
#statusText.err { color: #ff8a8c; }
.statusOpen {
  margin-top: 22px;
  min-width: 168px;
  height: 48px;
  padding: 0 24px;
  border-radius: 14px;
  border: 1px solid rgba(89, 152, 255, 0.38);
  background: linear-gradient(180deg, rgba(59, 130, 246, 0.32), rgba(59, 130, 246, 0.18));
  color: #f4f8ff;
  font-size: 14px;
  font-weight: 600;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12), 0 6px 20px rgba(18, 52, 112, 0.3);
  transition: transform 0.14s ease, background 0.14s ease;
}
.statusOpen:hover { background: linear-gradient(180deg, rgba(59, 130, 246, 0.42), rgba(59, 130, 246, 0.24)); }
.statusOpen:active { transform: scale(0.97); }
.statusTip { margin-top: 18px; color: var(--dim); font-size: 11px; letter-spacing: 0.3px; }
#spinner {
  width: 26px;
  height: 26px;
  margin-top: 20px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.1);
  border-top-color: var(--blue);
  animation: spin 0.85s linear infinite;
  display: none;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- bottom capsule ---------- */
.bottomBar {
  position: fixed;
  z-index: 28;
  left: 50%;
  bottom: calc(var(--sa-b) + 16px);
  transform: translateX(-50%);
  width: min(calc(100vw - 32px), 328px);
  height: var(--dock-h);
  padding: 3px;
  display: flex;
  align-items: stretch;
  border-radius: 30px;
  border: 1px solid var(--glass-line);
  background: var(--glass);
  -webkit-backdrop-filter: blur(24px) saturate(145%);
  backdrop-filter: blur(24px) saturate(145%);
  box-shadow: 0 14px 38px rgba(3, 5, 9, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.035);
}
.dockItem {
  flex: 1 1 25%;
  min-width: 48px;
  min-height: 48px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border-radius: 26px;
  color: #aab2be;
  transition: background 0.16s ease, color 0.16s ease;
}
.dockItem svg { width: 20px; height: 20px; display: block; }
.dockItem span { font-size: 11px; line-height: 1; letter-spacing: 0.2px; white-space: nowrap; }
.dockItem:hover { color: #e8ecf2; background: rgba(255, 255, 255, 0.04); }
.dockItem.on { color: var(--blue); background: var(--blue-soft); }
.dockItem:active { background: rgba(255, 255, 255, 0.075); }

/* ---------- gizmo ---------- */
.gizmo {
  position: fixed;
  z-index: 24;
  left: calc(var(--sa-l) + 12px);
  bottom: calc(var(--sa-b) + 92px);
  width: 56px;
  height: 56px;
  padding: 4px;
  border-radius: 16px;
  touch-action: manipulation;
  opacity: 0.96;
}
.gizmo svg { width: 100%; height: 100%; display: block; overflow: visible; }
.gizmo .gAxisLine { stroke-width: 1.6; stroke-linecap: round; }
.gizmo .gAxisDot { stroke-width: 0.8; }
.gizmo .gAxisText {
  font-family: var(--font);
  font-size: 8px;
  font-weight: 700;
  paint-order: stroke;
  stroke: rgba(17, 20, 26, 0.92);
  stroke-width: 2.2px;
}
.gizmo .gCenter {
  fill: rgba(255, 255, 255, 0.1);
  stroke: rgba(255, 255, 255, 0.28);
  stroke-width: 1;
}
.gizmo:hover { background: rgba(255, 255, 255, 0.035); }

/* ---------- loupe ---------- */
.loupe {
  position: fixed;
  z-index: 60;
  width: 108px;
  height: 108px;
  margin-left: -54px;
  margin-top: -54px;
  border-radius: 50%;
  pointer-events: none;
  overflow: hidden;
  border: 1.5px solid rgba(255, 255, 255, 0.42);
  background: #11141a;
  box-shadow: 0 10px 30px rgba(3, 5, 9, 0.55), inset 0 0 0 1px rgba(255, 255, 255, 0.09);
}
.loupe canvas { width: 108px; height: 108px; display: block; }
.loupe .lCross { position: absolute; inset: 0; pointer-events: none; }
.loupe .lCross::before, .loupe .lCross::after {
  content: "";
  position: absolute;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 0 2px rgba(15, 17, 22, 0.8);
}
.loupe .lCross::before { left: 50%; top: 8px; bottom: 8px; width: 1px; transform: translateX(-0.5px); }
.loupe .lCross::after {
  top: 50%;
  left: 8px;
  right: 8px;
  height: 1px;
  transform: translateY(-0.5px);
  -webkit-mask: linear-gradient(90deg, #000 calc(50% - 2px), transparent calc(50% - 2px), transparent calc(50% + 2px), #000 calc(50% + 2px));
  mask: linear-gradient(90deg, #000 calc(50% - 2px), transparent calc(50% - 2px), transparent calc(50% + 2px), #000 calc(50% + 2px));
}
.loupe .lCross::before {
  -webkit-mask: linear-gradient(180deg, #000 calc(50% - 2px), transparent calc(50% - 2px), transparent calc(50% + 2px), #000 calc(50% + 2px));
  mask: linear-gradient(180deg, #000 calc(50% - 2px), transparent calc(50% - 2px), transparent calc(50% + 2px), #000 calc(50% + 2px));
}
.loupe.snap { border-color: #00e676; box-shadow: 0 10px 30px rgba(3, 5, 9, 0.55), 0 0 0 1px rgba(0, 230, 118, 0.4), 0 0 22px rgba(0, 230, 118, 0.16); }
.loupe .lSnap {
  position: absolute;
  left: 50%;
  bottom: 9px;
  transform: translateX(-50%);
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(0, 230, 118, 0.16);
  border: 1px solid rgba(0, 230, 118, 0.38);
  color: #6cffb2;
  font-size: 10px;
  font-weight: 600;
  line-height: 1.4;
  white-space: nowrap;
  opacity: 0;
}
.loupe.snap .lSnap { opacity: 1; }

/* ---------- search overlay ---------- */
#searchBar[hidden] { display: none !important; }
#searchBar {
  position: fixed;
  z-index: 44;
  left: calc(var(--sa-l) + 12px);
  right: calc(var(--sa-r) + 12px);
  top: calc(var(--sa-t) + 74px);
  max-height: min(62vh, 520px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: 16px;
  border: 1px solid var(--line-strong);
  background: rgba(24, 28, 36, 0.95);
  -webkit-backdrop-filter: blur(26px) saturate(150%);
  backdrop-filter: blur(26px) saturate(150%);
  box-shadow: 0 20px 52px rgba(3, 5, 9, 0.52);
  animation: menuIn 0.18s ease-out both;
}
.searchHead {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 8px 8px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.075);
  flex: 0 0 auto;
}
.searchHead svg { width: 17px; height: 17px; color: var(--dim); flex: 0 0 auto; }
#searchInput {
  flex: 1 1 auto;
  min-width: 0;
  height: 38px;
  border: 0;
  outline: 0;
  background: transparent;
  color: #f1f3f6;
  font-size: 14px;
}
#searchInput::placeholder { color: #717a87; }
.searchClose {
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 10px;
  color: #a4adb9;
}
.searchClose:hover { background: rgba(255, 255, 255, 0.055); color: #fff; }
.searchClose svg { width: 16px; height: 16px; }
#searchResults { overflow: auto; min-height: 0; padding: 5px; overscroll-behavior: contain; }
#searchResults.hidden { display: none !important; }
.srow {
  display: block;
  width: 100%;
  min-height: 44px;
  padding: 8px 10px;
  border-radius: 10px;
  color: #d9dfe7;
  font-size: 14px;
  line-height: 1.4;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.srow:hover, .srow:focus-visible { background: rgba(255, 255, 255, 0.065); }
.srow.empty { color: var(--dim); cursor: default; }
.srow.empty:hover { background: none; }

/* ---------- info drawer ---------- */
#infoCard {
  --drawer-h: 33vh;
  position: fixed;
  z-index: 38;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: min(100%, 640px);
  height: var(--drawer-h);
  min-height: 132px;
  max-height: 65vh;
  display: flex;
  flex-direction: column;
  border-radius: 20px 20px 0 0;
  border: 1px solid var(--line-strong);
  border-bottom: 0;
  background: rgba(24, 28, 36, 0.95);
  -webkit-backdrop-filter: blur(28px) saturate(145%);
  backdrop-filter: blur(28px) saturate(145%);
  box-shadow: 0 -18px 50px rgba(3, 5, 9, 0.5);
  padding-bottom: var(--sa-b);
  animation: drawerIn 0.24s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
@keyframes drawerIn { from { transform: translate(-50%, 30px); opacity: 0.6; } to { transform: translate(-50%, 0); opacity: 1; } }
.drawerGrip {
  flex: 0 0 auto;
  width: 100%;
  height: 24px;
  display: grid;
  place-items: center;
  touch-action: none;
  cursor: ns-resize;
}
.drawerGrip .gripBar { width: 38px; height: 4px; border-radius: 2px; background: rgba(255, 255, 255, 0.18); }
.icHead {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px 11px 18px;
}
.infoKicker {
  margin: 0 0 3px;
  color: var(--dim);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 1.2px;
}
#infoTitle {
  min-width: 0;
  flex: 1 1 auto;
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #f3f5f8;
  font-size: 16px;
  font-weight: 650;
  letter-spacing: -0.1px;
}
#btnInfoClose {
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 10px;
  color: #a4adb9;
}
#btnInfoClose:hover { background: rgba(255, 255, 255, 0.06); color: #fff; }
#btnInfoClose svg { width: 16px; height: 16px; }
#infoBody {
  flex: 1 1 auto;
  overflow: auto;
  padding: 0 18px 8px;
  overscroll-behavior: contain;
}
.irow {
  display: flex;
  align-items: baseline;
  gap: 12px;
  min-height: 33px;
  padding: 6px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.055);
  font-size: 13px;
  line-height: 1.5;
}
.irow:last-child { border-bottom: 0; }
.irow .iLabel {
  flex: 0 0 92px;
  color: var(--muted);
  font-size: 11.5px;
  letter-spacing: 0.15px;
}
.irow .iValue {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 7px;
  color: #eef1f5;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
  overflow-wrap: anywhere;
}
.layerDot, .colorDot {
  width: 9px;
  height: 9px;
  flex: 0 0 auto;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.22);
}
.irow .iValue .mono {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
}
.icActions {
  flex: 0 0 auto;
  display: flex;
  gap: 8px;
  padding: 10px 16px calc(12px + var(--sa-b));
  border-top: 1px solid rgba(255, 255, 255, 0.07);
}
.icBtn {
  flex: 1 1 0;
  height: 42px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.045);
  color: #d8dde5;
  font-size: 12.5px;
  font-weight: 550;
}
.icBtn:hover { background: rgba(255, 255, 255, 0.075); }
.icBtn:active { background: rgba(255, 255, 255, 0.1); }

/* ---------- layers drawer ---------- */
.sheet {
  position: fixed;
  z-index: 42;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%) translateY(16px);
  width: min(100%, 560px);
  max-height: 62vh;
  display: flex;
  flex-direction: column;
  border-radius: 20px 20px 0 0;
  border: 1px solid var(--line-strong);
  border-bottom: 0;
  background: rgba(24, 28, 36, 0.96);
  -webkit-backdrop-filter: blur(28px) saturate(145%);
  backdrop-filter: blur(28px) saturate(145%);
  box-shadow: 0 -18px 52px rgba(3, 5, 9, 0.54);
  padding-bottom: var(--sa-b);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.24s cubic-bezier(0.2, 0.8, 0.2, 1), visibility 0.2s;
}
.sheet.open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0);
}
.sheet::before {
  content: "";
  position: fixed;
  z-index: -1;
  inset: 0;
  background: rgba(8, 10, 14, 0.4);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}
.sheet.open::before { opacity: 1; }
.sheetHead {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 12px 10px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.075);
}
.sheetTitle {
  margin: 0;
  flex: 0 1 auto;
  color: #f1f3f6;
  font-size: 16px;
  font-weight: 650;
}
#layersCount { color: var(--dim); font-size: 11px; flex: 1 1 auto; }
.sheetBtn {
  height: 34px;
  padding: 0 11px;
  border-radius: 9px;
  border: 1px solid rgba(255, 255, 255, 0.095);
  background: rgba(255, 255, 255, 0.045);
  color: #bcc4cf;
  font-size: 11.5px;
}
.sheetBtn:hover { background: rgba(255, 255, 255, 0.075); color: #fff; }
.sheetClose {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  color: #a4adb9;
}
.sheetClose:hover { background: rgba(255, 255, 255, 0.06); color: #fff; }
.sheetClose svg { width: 15px; height: 15px; }
#layersList {
  list-style: none;
  margin: 0;
  padding: 7px 8px 12px;
  overflow: auto;
  min-height: 0;
  overscroll-behavior: contain;
}
.layer {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 52px;
  padding: 7px 10px;
  border-radius: 11px;
}
.layer:hover { background: rgba(255, 255, 255, 0.045); }
.layer .swatch {
  width: 12px;
  height: 29px;
  flex: 0 0 auto;
  border-radius: 5px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18);
}
.layer .meta { flex: 1 1 auto; min-width: 0; }
.layer .lname {
  color: #e9edf3;
  font-size: 13.5px;
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.layer .lsub { margin-top: 2px; color: var(--dim); font-size: 10.5px; }
.layer input[type="checkbox"] {
  -webkit-appearance: none;
  appearance: none;
  width: 42px;
  height: 25px;
  flex: 0 0 auto;
  margin: 0;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.07);
  position: relative;
  cursor: pointer;
  transition: background 0.18s ease, border-color 0.18s ease;
}
.layer input[type="checkbox"]::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: #858e9b;
  box-shadow: 0 1px 3px rgba(3, 5, 9, 0.4);
  transition: transform 0.18s cubic-bezier(0.2, 0.8, 0.2, 1), background 0.18s ease;
}
.layer input[type="checkbox"]:checked {
  background: rgba(59, 130, 246, 0.28);
  border-color: rgba(80, 150, 255, 0.5);
}
.layer input[type="checkbox"]:checked::after { transform: translateX(17px); background: #4d94ff; }
#layersList .empty { padding: 26px 10px; text-align: center; color: var(--dim); font-size: 12px; }

/* ---------- toast ---------- */
#toast {
  position: fixed;
  z-index: 70;
  left: 50%;
  bottom: calc(var(--sa-b) + 94px);
  transform: translate(-50%, 8px);
  max-width: calc(100vw - 40px);
  padding: 10px 16px;
  border-radius: 12px;
  border: 1px solid var(--line-strong);
  background: rgba(28, 33, 42, 0.96);
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
  color: #e8ecf2;
  font-size: 12.5px;
  line-height: 1.4;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- home ---------- */
#homeScreen {
  position: fixed;
  inset: 0;
  z-index: 46;
  width: 100%;
  height: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  background: #0f1116;
  color: #f3f4f6;
}
#homeScreen::-webkit-scrollbar { display: none; }
#homeScreen[hidden] { display: none !important; }

/* ---------- splash ---------- */
.splashScreen {
  position: fixed;
  inset: 0;
  z-index: 90;
  width: 100%;
  max-width: 100vw;
  height: 100%;
  overflow: hidden;
  display: grid;
  place-items: center;
  padding:
    calc(var(--sa-t) + 28px)
    calc(var(--sa-r) + 24px)
    calc(var(--sa-b) + 28px)
    calc(var(--sa-l) + 24px);
  background: #0f1116;
  color: #f3f4f6;
}
.splashScreen[hidden] { display: none !important; }
.splashGlow {
  position: absolute;
  width: min(92vw, 520px);
  aspect-ratio: 1;
  border-radius: 50%;
  background:
    radial-gradient(circle, rgba(59, 130, 246, 0.18) 0%, rgba(59, 130, 246, 0.04) 42%, transparent 70%);
  filter: blur(8px);
  transform: translateY(-7vh);
  pointer-events: none;
}
.splashContent {
  position: relative;
  width: min(100%, 430px);
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}
.splashMark {
  width: 84px;
  height: 84px;
  margin-bottom: 22px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}
.splashMark img { width: 100%; height: 100%; display: block; object-fit: contain; }
.splashEyebrow {
  margin: 0 0 8px;
  color: #9ca3af;
  font-size: 10px;
  font-weight: 650;
  letter-spacing: 0.2em;
  line-height: 1.4;
}
.splashTitle {
  margin: 0;
  color: #f7f8fa;
  font-size: clamp(36px, 11vw, 48px);
  font-weight: 650;
  letter-spacing: -0.035em;
  line-height: 1.06;
}
.splashLead {
  margin: 14px 0 0;
  color: #c6ccd6;
  font-size: 14px;
  line-height: 1.6;
}
.splashPrivacy {
  margin: 7px 0 0;
  color: #7f8896;
  font-size: 11.5px;
  line-height: 1.6;
}
.splashProgress {
  width: 92px;
  height: 2px;
  margin-top: 34px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
}
.splashProgress span {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, rgba(96, 165, 250, 0.45), #60a5fa);
  transform: scaleX(0);
  transform-origin: left center;
  animation: splashProgress 5s linear forwards;
}
@keyframes splashProgress {
  to { transform: scaleX(1); }
}

body.splash-mode .topBar,
body.splash-mode .bottomBar,
body.splash-mode #gizmo,
body.splash-mode #status,
body.splash-mode #hint,
body.splash-mode #loupe,
body.splash-mode #moreMenu,
body.splash-mode #searchBar,
body.splash-mode #infoCard,
body.splash-mode #layers,
body.splash-mode #measurePanel,
body.splash-mode .measureHud,
body.splash-mode #hudWarn,
body.splash-mode #toast {
  display: none !important;
}

body.home-mode .topBar,
body.home-mode .bottomBar,
body.home-mode #gizmo,
body.home-mode #status,
body.home-mode #hint,
body.home-mode #loupe,
body.home-mode #moreMenu,
body.home-mode #searchBar,
body.home-mode #infoCard,
body.home-mode #layers,
body.home-mode #measurePanel,
body.home-mode .measureHud,
body.home-mode #hudWarn,
body.home-mode #toast {
  display: none !important;
}

.homeWrap {
  width: 100%;
  max-width: 560px;
  min-height: 100%;
  margin: 0 auto;
  padding: calc(var(--sa-t) + 28px) calc(var(--sa-r) + 20px) calc(var(--sa-b) + 26px) calc(var(--sa-l) + 20px);
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.homeHero { min-width: 0; }
.homeMark {
  width: 56px;
  height: 56px;
  margin-bottom: 18px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}
.homeMark img { width: 100%; height: 100%; display: block; object-fit: contain; }
.homeEyebrow {
  margin: 0 0 5px;
  color: #9ca3af;
  font-size: 10px;
  font-weight: 650;
  letter-spacing: 0.18em;
  line-height: 1.4;
}
.homeTitle {
  margin: 0;
  color: #f3f4f6;
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -0.8px;
  line-height: 1.16;
}
.homeLead {
  margin: 7px 0 0;
  color: #e5e7eb;
  font-size: 15px;
  line-height: 1.45;
}
.homePrivacy {
  margin: 4px 0 0;
  color: #9ca3af;
  font-size: 12px;
  line-height: 1.5;
}

.homeOpen {
  width: 100%;
  min-height: 56px;
  margin-top: 26px;
  padding: 0 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border-radius: 16px;
  background: #3b82f6;
  color: #fff;
  box-shadow: 0 12px 28px rgba(59, 130, 246, 0.24);
  font-size: 15px;
  font-weight: 650;
  line-height: 1.2;
  white-space: nowrap;
  transition: transform 0.16s ease, background 0.16s ease;
}
.homeOpen:hover { background: #2f75e8; }
.homeOpen:active { transform: scale(0.985); }
.homeOpen svg { width: 22px; height: 22px; flex: 0 0 auto; }
.homeOpen span { overflow: hidden; text-overflow: ellipsis; }
.homeOpenNote {
  margin: 9px 0 0;
  color: #9ca3af;
  font-size: 11px;
  line-height: 1.5;
  text-align: center;
}

.homeRecentSection { min-width: 0; margin-top: 28px; }
.homeSectionHead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 22px;
  margin-bottom: 10px;
}
.homeSectionHead h2 {
  margin: 0;
  color: #f3f4f6;
  font-size: 14px;
  font-weight: 650;
  letter-spacing: 0.1px;
  line-height: 1.4;
}
.homeRecentStatus {
  min-width: 0;
  color: #9ca3af;
  font-size: 10.5px;
  line-height: 1.4;
  text-align: right;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.homeRecent {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}
.homeRecentItem {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  min-height: 66px;
  padding: 10px 12px;
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) 16px;
  align-items: center;
  gap: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  background: #171a21;
  color: #f3f4f6;
  text-align: left;
  transition: background 0.16s ease, border-color 0.16s ease;
}
.homeRecentItem:hover { background: #1d212a; border-color: rgba(59, 130, 246, 0.32); }
.homeRecentItem:active { background: #222732; }
.homeRecentItem[aria-busy="true"] { opacity: 0.62; pointer-events: none; }
.homeRecentIcon {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 11px;
  background: rgba(59, 130, 246, 0.12);
  color: #79aaff;
}
.homeRecentIcon svg { width: 20px; height: 20px; }
.homeRecentMain { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.homeRecentName {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #f3f4f6;
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.35;
}
.homeRecentMeta {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #9ca3af;
  font-size: 10.5px;
  line-height: 1.35;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
}
.homeRecentChevron {
  width: 16px;
  height: 16px;
  color: #737c89;
  display: grid;
  place-items: center;
}
.homeRecentChevron svg { width: 16px; height: 16px; }
.homeLoading {
  margin: 0;
  padding: 18px 4px;
  color: #9ca3af;
  font-size: 12px;
  line-height: 1.5;
}
.homeEmpty {
  min-height: 108px;
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px dashed rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.018);
  text-align: center;
}
.homeEmpty strong {
  color: #cbd2dc;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.4;
}
.homeEmpty span {
  min-width: 0;
  color: #9ca3af;
  font-size: 11.5px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.homeCapabilities {
  min-width: 0;
  margin-top: 26px;
  padding-top: 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.075);
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.homeCap {
  min-width: 0;
  min-height: 52px;
  padding: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.025);
  color: #c8ced8;
  font-size: 12px;
  line-height: 1.4;
}
.homeCap svg { width: 18px; height: 18px; flex: 0 0 auto; color: #9ca3af; }
.homeCap span { min-width: 0; overflow-wrap: anywhere; }
.homeFooter {
  margin: 24px 0 0;
  color: #6f7885;
  font-size: 10.5px;
  line-height: 1.5;
  letter-spacing: 0.2px;
  text-align: center;
}
.homeFooter strong {
  color: #9ca8b8;
  font-weight: 650;
}
.homeFooter span { padding: 0 4px; }
.homeFooter a {
  color: #78b7ff;
  text-decoration: none;
  text-underline-offset: 2px;
}
.homeFooter a:hover,
.homeFooter a:focus-visible { color: #b7d8ff; text-decoration: underline; }

/* ---------- about ---------- */
.aboutPanel {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: calc(var(--sa-t) + 10px) calc(var(--sa-r) + 10px) calc(var(--sa-b) + 10px) calc(var(--sa-l) + 10px);
  background: rgba(3, 5, 9, 0.7);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}
.aboutPanel[hidden] { display: none !important; }
.aboutSheet {
  width: 100%;
  max-width: 560px;
  max-height: min(88vh, 780px);
  max-height: min(88dvh, 780px);
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 22px;
  background: #151820;
  box-shadow: 0 -16px 50px rgba(0, 0, 0, 0.48);
}
.aboutHead {
  flex: 0 0 auto;
  padding: 18px 18px 14px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.075);
}
.aboutHeading { min-width: 0; }
.aboutKicker {
  margin: 0 0 2px;
  color: #9ca3af;
  font-size: 10px;
  font-weight: 650;
  letter-spacing: 0.14em;
  line-height: 1.4;
}
.aboutHeading h2 {
  margin: 0;
  color: #f3f4f6;
  font-size: 23px;
  font-weight: 700;
  letter-spacing: -0.4px;
  line-height: 1.25;
}
.aboutClose {
  width: 40px;
  height: 40px;
  margin: -4px -4px 0 0;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 12px;
  color: #aeb6c2;
  background: rgba(255, 255, 255, 0.055);
}
.aboutClose:hover { background: rgba(255, 255, 255, 0.1); color: #fff; }
.aboutClose svg { width: 19px; height: 19px; }
.aboutBody {
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 6px 18px calc(var(--sa-b) + 24px);
}
.aboutVersion {
  margin: 10px 0 14px;
  display: flex;
  align-items: center;
  gap: 9px;
  color: #9ca3af;
  font-size: 11px;
  line-height: 1.4;
}
.aboutVersion strong {
  padding: 4px 9px;
  border-radius: 7px;
  background: rgba(59, 130, 246, 0.12);
  color: #8ab7ff;
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0.3px;
  font-variant-numeric: tabular-nums;
}
.aboutIntro {
  margin: 0;
  color: #d2d7df;
  font-size: 13px;
  line-height: 1.7;
  overflow-wrap: anywhere;
}
.aboutBlock { margin-top: 20px; min-width: 0; }
.aboutBlock h3 {
  margin: 0 0 6px;
  color: #f3f4f6;
  font-size: 13px;
  font-weight: 650;
  line-height: 1.4;
}
.aboutBlock p {
  margin: 0;
  color: #aeb6c2;
  font-size: 12.5px;
  line-height: 1.7;
  overflow-wrap: anywhere;
}
.aboutBlock ul {
  margin: 0;
  padding-left: 18px;
  color: #aeb6c2;
  font-size: 12.5px;
  line-height: 1.7;
}
.aboutBlock li { margin: 0 0 3px; overflow-wrap: anywhere; }
.aboutBlock li::marker { color: #3b82f6; }

/* ---------- responsive ---------- */
@media (max-width: 380px) {
  .homeWrap {
    padding-top: calc(var(--sa-t) + 20px);
    padding-right: calc(var(--sa-r) + 16px);
    padding-left: calc(var(--sa-l) + 16px);
  }
  .homeTitle { font-size: 29px; }
  .homeOpen { min-height: 54px; margin-top: 22px; font-size: 14px; }
  .homeRecentSection { margin-top: 24px; }
  .homeCapabilities { margin-top: 22px; }
  .homeCap { padding: 9px; gap: 7px; font-size: 11.5px; }
  .aboutHead { padding: 16px 15px 12px; }
  .aboutBody { padding-left: 15px; padding-right: 15px; }
}

@media (min-width: 640px) {
  .aboutPanel { align-items: center; }
  .aboutSheet { border-radius: 22px; }
}

@media (max-width: 360px) {
  .dockItem span { font-size: 11px; }
}

::selection { background: rgba(59, 130, 246, 0.32); }

/* ---------- configurable splash link + update gate ---------- */
.splashLink {
  margin-top: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 16px;
  border-radius: 999px;
  border: 1px solid rgba(96, 165, 250, 0.35);
  background: rgba(59, 130, 246, 0.12);
  color: #93c5fd;
  font-size: 12.5px;
  text-decoration: none;
}

.updateGate {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: grid;
  place-items: center;
  padding:
    calc(var(--sa-t) + 24px)
    calc(var(--sa-r) + 20px)
    calc(var(--sa-b) + 24px)
    calc(var(--sa-l) + 20px);
  background: rgba(6, 9, 14, 0.86);
  -webkit-backdrop-filter: blur(16px) saturate(130%);
  backdrop-filter: blur(16px) saturate(130%);
}
.updateGate[hidden] { display: none !important; }
.updateCard {
  width: min(100%, 400px);
  padding: 26px 22px 20px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 22px;
  background: linear-gradient(180deg, #1b2029, #12161d);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.55);
  text-align: center;
}
.updateKicker {
  margin: 0 0 8px;
  color: #8ab7ff;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.updateCard h2 {
  margin: 0;
  color: #f7f8fa;
  font-size: 21px;
  font-weight: 650;
  line-height: 1.3;
}
.updateMessage {
  margin: 12px 0 0;
  color: #c3cad5;
  font-size: 13px;
  line-height: 1.7;
  overflow-wrap: anywhere;
}
.updateVersion {
  margin: 8px 0 18px;
  color: #7f8896;
  font-size: 11.5px;
}
.updatePrimary,
.updateSecondary {
  width: 100%;
  min-height: 48px;
  border-radius: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 650;
  text-decoration: none;
}
.updatePrimary {
  background: linear-gradient(180deg, #4f93ff, #3b82f6);
  color: #fff;
  box-shadow: 0 8px 24px rgba(59, 130, 246, 0.32);
}
.updatePrimary[hidden] { display: none !important; }
.updateSecondary {
  margin-top: 8px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #c7ced8;
}
.updateSecondary[hidden] { display: none !important; }
body.gate-mode { overflow: hidden; }
