:root {
  --bg: #0b0d0e;
  --panel: #14181a;
  --panel-2: #1c2124;
  --line: #262d31;
  --text: #e8eef0;
  --muted: #7d8a91;
  --accent: #b6ff3c;
  --accent-soft: #b6ff3c22;
  --danger: #ff5b5b;
  --calib: #ffb13c;
  --topbar-height: 44px;
  --side-width: clamp(240px, 22vw, 300px);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { width: 100%; height: 100%; overflow: hidden; font-family: 'Sora', sans-serif; color: var(--text); background: var(--bg); }

body {
  width: 100vw;
  min-width: 0;
  min-height: 100vh;
  display: grid;
  grid-template-rows: var(--topbar-height) 1fr;
  grid-template-columns: 50px minmax(0, 1fr) var(--side-width);
  grid-template-areas: "top top top" "rail stage side";
}
body.no-document {
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas: "top" "stage";
}
body.no-document aside { display: none; }
body.no-document .left-rail { display: none; }
body.no-document .toolbar.tools-center { display: none; }
body.no-document .toolbar.primary { visibility: visible; pointer-events: auto; }
body.no-document #docTabs,
body.no-document #uploadButton {
  display: none;
}
body.no-document .hud,
body.no-document #status:not(.show) { display: none; }

/* Top toolbar */
header {
  grid-area: top;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  position: relative;
  display: flex; align-items: center; gap: 8px;
  padding: 0 10px;
  z-index: 5;
  overflow-x: auto;
  overflow-y: hidden;
  white-space: nowrap;
  scrollbar-width: none;
}
header::-webkit-scrollbar { display: none; }
.brand {
  display: flex; align-items: center; gap: 10px;
  font-weight: 600; letter-spacing: 0.02em;
  flex: 0 0 auto;
}
.brand .dot { width: 9px; height: 9px; border-radius: 2px; background: var(--accent); box-shadow: 0 0 12px var(--accent); }
.brand small { color: var(--muted); font-weight: 400; font-family: 'JetBrains Mono', monospace; font-size: 10px; text-transform: uppercase; letter-spacing: 0.09em; }

.toolbar { display: flex; gap: 4px; align-items: center; min-width: 0; }
.toolbar.primary { flex: 0 0 auto; }
.toolbar.utility { flex: 0 0 auto; }
.toolbar.tools-center {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  flex: 0 0 auto;
  z-index: 6;
}
.toolbar-spacer { flex: 1 1 14px; min-width: 8px; }
.divider { width: 1px; height: 24px; background: var(--line); margin: 0 3px; flex: 0 0 auto; }
.doc-tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  overflow: hidden;
  flex: 0 1 auto;
}
.tab-strip {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  flex: 1 1 auto;
  overflow: hidden;
}
.doc-tab {
  position: relative;
  min-width: 0;
  width: clamp(116px, 18vw, 210px);
  max-width: 210px;
  min-height: 30px;
  padding: 0 14px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  justify-content: flex-start;
  border-color: transparent;
  background: transparent;
}
.doc-tab-title {
  display: block;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  pointer-events: none;
}
.doc-tab.active {
  background: #1a2024;
  border-color: #30383e;
  color: var(--text);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.04);
}
.doc-tab.active::after {
  content: "";
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 0;
  height: 1px;
  background: #6b7680;
  opacity: 0.7;
}
.doc-tab:hover {
  color: var(--text);
  border-color: #30383e;
  background: #171c20;
}
.doc-tabs:empty::before {
  content: "No document open";
  color: var(--muted);
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
}
.add-doc-tab {
  width: 30px;
  min-height: 30px;
  padding: 0;
  justify-content: center;
  color: var(--muted);
  border-color: transparent;
  background: transparent;
}
.add-doc-tab:hover {
  color: var(--text);
  border-color: var(--line);
  background: var(--panel-2);
}
.top-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 0 0 auto;
  margin-left: auto;
}
.top-action {
  width: 30px;
  min-height: 30px;
  padding: 0;
  justify-content: center;
  color: var(--muted);
  border-color: transparent;
  background: transparent;
}
.top-action:hover:not(:disabled) {
  color: var(--text);
  border-color: var(--line);
  background: var(--panel-2);
}
.top-action[aria-pressed="true"] {
  color: var(--accent);
  border-color: #526d28;
  background: var(--accent-soft);
}
.left-rail {
  grid-area: rail;
  min-width: 0;
  min-height: 0;
  height: calc(100dvh - var(--topbar-height));
  background: var(--panel);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 6px 4px;
  overflow: hidden;
  z-index: 4;
}
.left-rail .toolbar,
.left-rail .toolbar.tools-center,
.left-rail .toolbar.utility,
.left-rail .viewer-controls,
.left-rail .control-cluster {
  position: static;
  transform: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 0 0 auto;
}
.left-rail .toolbar { gap: 5px; }
.left-rail .toolbar.primary { display: none; }
.left-rail .toolbar.tools-center { order: 1; z-index: auto; }
.left-rail .toolbar.utility {
  order: 2;
  gap: 6px;
  margin-top: auto;
  padding-bottom: 2px;
}
.left-rail .toolbar-spacer { display: none; }
.left-rail .divider {
  width: 24px;
  height: 1px;
  margin: 2px 0;
}
.left-rail #uploadButton {
  width: 40px;
  min-height: 36px;
  padding: 0;
  justify-content: center;
  font-size: 0;
  gap: 0;
}
.left-rail #uploadButton svg { width: 16px; height: 16px; }
.left-rail .viewer-controls {
  gap: 2px;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}
.left-rail .control-divider {
  width: 24px;
  height: 1px;
  margin: 1px 0;
}
.left-rail .control-cluster {
  min-width: 0;
  min-height: 0;
  gap: 2px;
}
.left-rail .control-cluster.zoom-group,
.left-rail .control-cluster.page-group-control {
  width: 34px;
  min-width: 34px;
}
.left-rail .zoom-group { flex-direction: column-reverse; }
.left-rail #zoomLabel {
  min-width: 34px;
  min-height: 20px;
  padding: 0 2px;
  font-size: 10px;
}
.left-rail #pageLabel {
  min-width: 30px;
  min-height: 38px;
  flex-direction: column;
  gap: 0;
  line-height: 1.05;
}
.left-rail #pageLabel .page-sep {
  font-size: 12px;
  line-height: 0.9;
}
.left-rail .fit-control {
  width: 36px;
  min-width: 36px;
  min-height: 32px;
  padding: 0;
  font-size: 0;
  justify-content: center;
}
.left-rail .fit-control svg:first-child { width: 19px; height: 19px; }
.left-rail .fit-menu-toggle svg { display: block; width: 8px; height: 8px; }
.left-rail #resetScale {
  width: 36px;
  min-height: 24px;
  padding: 0;
  font-size: 9px;
  justify-content: center;
  text-align: center;
  gap: 0;
}

button, label.btn {
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--text);
  min-height: 32px;
  padding: 4px 9px;
  border-radius: 6px;
  font-family: inherit;
  font-size: 11px;
  line-height: 1;
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
  transition: all .12s ease;
  user-select: none;
  white-space: nowrap;
  flex: 0 0 auto;
}
button:hover, label.btn:hover { border-color: #38434a; background: #232a2e; }
button.active { background: var(--accent); color: #0b0d0e; border-color: var(--accent); font-weight: 600; }
button.ghost { background: transparent; }
button.danger:hover { border-color: var(--danger); color: var(--danger); }
button:disabled { opacity: 0.4; cursor: not-allowed; }
.pill {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--muted);
  min-height: 28px;
  padding: 5px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  flex: 0 0 auto;
}
.pill strong { color: var(--text); font-weight: 500; }
#pageLabel {
  min-width: 58px;
  gap: 4px;
}
#pageLabel .page-current { color: var(--accent); }
#pageLabel .page-sep { color: var(--muted); font-size: 14px; line-height: 1; }
#zoomLabel {
  min-width: 6ch;
  font-variant-numeric: tabular-nums;
  text-align: center;
}
.viewer-controls {
  display: flex;
  align-items: center;
  gap: 2px;
  min-height: 34px;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #111619;
  box-shadow: 0 10px 24px rgba(0,0,0,0.28);
}
.control-cluster {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 28px;
  padding: 0 2px;
}
.control-cluster.zoom-group { min-width: 104px; }
.control-cluster.page-group-control { min-width: 110px; }
.control-divider {
  width: 1px;
  height: 24px;
  background: var(--line);
  margin: 0 2px;
}
.control-btn {
  width: 24px;
  min-height: 24px;
  padding-left: 0;
  padding-right: 0;
  justify-content: center;
  border-color: transparent;
  background: transparent;
  color: var(--muted);
}
.control-btn:hover {
  border-color: transparent;
  background: var(--panel-2);
  color: var(--text);
}
.control-btn:disabled {
  pointer-events: none;
  opacity: 0.35;
}
.continuous-scroll-toggle {
  flex: 0 0 28px;
  width: 28px;
}
.continuous-scroll-toggle svg {
  width: 15px;
  height: 15px;
}
.left-rail .continuous-scroll-toggle.active,
.left-rail .continuous-scroll-toggle[aria-pressed="true"] {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
  color: var(--accent);
}
.left-rail .continuous-scroll-toggle[aria-pressed="true"] svg {
  filter: drop-shadow(0 0 5px rgba(182,255,60,0.72));
}
.left-rail .tool-btn.active svg {
  filter: drop-shadow(0 0 5px rgba(182,255,60,0.72));
}
.control-value {
  min-height: 18px;
  padding: 0 4px;
  border: 0;
  background: transparent;
  border-radius: 4px;
  color: var(--muted);
}
.fit-control {
  border-color: transparent;
  background: transparent;
  color: var(--muted);
}
.fit-control:hover,
.fit-menu-toggle:hover {
  border-color: var(--accent);
  background: transparent;
  color: var(--text);
  box-shadow: 0 0 0 1px rgba(177, 255, 64, 0.24);
}
.fit-split {
  position: relative;
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  width: 36px;
  height: 32px;
  min-height: 32px;
  justify-content: center;
}
.left-rail .fit-split:hover {
  border-radius: 7px;
  box-shadow: 0 0 0 1px rgba(177, 255, 64, 0.55), 0 0 0 2px rgba(177, 255, 64, 0.14);
  background: rgba(182,255,60,0.035);
}
.left-rail .fit-split:hover #zoomFit,
.left-rail .fit-split:hover #zoomFit:hover,
.left-rail .fit-split:hover .fit-menu-toggle,
.left-rail .fit-split:hover .fit-menu-toggle:hover {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
  color: var(--text);
}
.fit-split #zoomFit {
  position: relative;
  z-index: 1;
}
.fit-menu-toggle {
  position: absolute;
  left: 25px;
  top: 50%;
  transform: translateY(-50%);
  width: 11px;
  min-width: 11px;
  min-height: 18px;
  padding: 0;
  justify-content: center;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  z-index: 2;
}
.fit-menu {
  position: fixed;
  top: 0;
  left: 0;
  display: none;
  min-width: 124px;
  padding: 6px;
  background: #111619;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 12px 28px rgba(0,0,0,0.45);
  z-index: 40;
}
.fit-menu.show {
  display: grid;
  gap: 2px;
}
.fit-menu-option {
  width: 100%;
  min-height: 30px;
  border: 0;
  background: transparent;
  justify-content: flex-start;
  color: var(--muted);
  padding: 0 9px;
}
.fit-menu-option:hover {
  color: var(--text);
  background: var(--panel-2);
}
.tool-btn {
  width: 36px;
  padding-left: 0;
  padding-right: 0;
  justify-content: center;
}
.left-rail .tool-btn,
.left-rail .measure-menu-toggle {
  background: transparent;
  border-color: transparent;
  color: var(--muted);
  box-shadow: none;
}
.left-rail .tool-btn:hover,
.left-rail .measure-menu-toggle:hover {
  background: transparent;
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(177, 255, 64, 0.24);
  color: var(--text);
}
.left-rail .measure-split:hover {
  border-radius: 7px;
  box-shadow: 0 0 0 1px rgba(177, 255, 64, 0.55), 0 0 0 2px rgba(177, 255, 64, 0.14);
  background: rgba(182,255,60,0.035);
}
.left-rail .measure-split:hover .tool-btn,
.left-rail .measure-split:hover .tool-btn:hover,
.left-rail .measure-split:hover .tool-btn.active,
.left-rail .measure-split:hover .tool-btn.active:hover,
.left-rail .measure-split:hover .measure-menu-toggle,
.left-rail .measure-split:hover .measure-menu-toggle:hover {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
  color: var(--text);
}
.left-rail .tool-btn.active,
.left-rail .tool-btn.active:hover {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
  color: var(--accent);
  font-weight: 600;
}
.left-rail .tool-btn.active:hover {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(177, 255, 64, 0.24);
}
.tool-btn svg {
  width: 18px;
  height: 18px;
}
.measure-split {
  position: relative;
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  width: 36px;
  height: 32px;
  min-height: 32px;
  justify-content: center;
}
.measure-split .tool-btn {
  width: 36px;
}
.measure-split .tool-btn {
  position: relative;
  z-index: 1;
}
.measure-menu-toggle {
  position: absolute;
  left: 25px;
  top: 63%;
  transform: translateY(-50%);
  width: 11px;
  min-width: 11px;
  min-height: 18px;
  padding: 0;
  justify-content: center;
  border: 0;
  border-radius: 6px;
  z-index: 2;
}
.measure-menu-toggle svg {
  width: 8px;
  height: 8px;
}
.measure-mode-menu {
  position: fixed;
  top: 0;
  left: 0;
  display: none;
  min-width: 180px;
  padding: 6px;
  background: #111619;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 12px 28px rgba(0,0,0,0.45);
  z-index: 40;
}
.measure-mode-menu.show {
  display: grid;
  gap: 2px;
}
.measure-mode-option {
  width: 100%;
  min-height: 30px;
  border: 0;
  background: transparent;
  justify-content: flex-start;
  color: var(--muted);
  padding: 0 9px;
}
.measure-mode-option:hover {
  color: var(--text);
  background: var(--panel-2);
}
.measure-mode-option.active {
  color: var(--accent);
  background: var(--accent-soft);
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.tool-tip {
  position: fixed;
  top: 0;
  left: 0;
  transform: translate(-50%, 0);
  z-index: 50;
  display: none;
  pointer-events: none;
  background: #111619;
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 6px;
  padding: 6px 8px;
  font-size: 11px;
  line-height: 1;
  box-shadow: 0 10px 24px rgba(0,0,0,0.42);
  white-space: nowrap;
}
.tool-tip.show { display: block; }

input[type=file].file-picker { display: none; }

@media (max-width: 1180px) {
  #resetScale { display: none; }
}
@media (max-width: 900px) {
  .brand .brand-tag { display: none; }
  button { padding-left: 8px; padding-right: 8px; }
  .toolbar.tools-center {
    position: static;
    transform: none;
  }
}

/* Stage */
main {
  grid-area: stage;
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(circle at 20% 30%, #161b1e 0%, #0b0d0e 60%),
    var(--bg);
}
#stage {
  position: absolute; inset: 0;
  overflow: hidden;
  cursor: crosshair;
  touch-action: none;
}
body.no-document #stage {
  cursor: default;
  touch-action: auto;
}
#stage.selection { cursor: default; }
#stage.pan { cursor: grab; }
#stage.marqueeing { cursor: crosshair !important; }
#stage.dragging { cursor: grabbing !important; }
#stage.erase { cursor: not-allowed; }
#stage.snapped-cursor:not(.dragging) { cursor: none; }

#viewport {
  position: absolute;
  transform-origin: 0 0;
  will-change: transform;
}
#continuousBasePages, #continuousBasePages canvas {
  position: absolute; top: 0; left: 0;
  display: block;
  pointer-events: none;
}
#continuousBasePages[hidden] { display: none; }
#baseCanvas, #pdfDetailCanvas, #drawCanvas, #drawSvg {
  position: absolute; top: 0; left: 0;
  display: block;
  touch-action: none;
}
#pdfDetailCanvas {
  display: none;
  pointer-events: none;
}
#drawCanvas { display: none; }
#drawSvg {
  overflow: visible;
  pointer-events: none;
}
.canvas-length-tag-hit {
  fill: transparent;
  stroke: none;
  pointer-events: none;
}
.canvas-length-tag-body,
.canvas-length-tag-accent,
.canvas-length-tag text {
  pointer-events: none;
}
.canvas-length-tag-nav {
  color: var(--muted);
  opacity: 0;
  pointer-events: auto;
  cursor: pointer;
  transition: opacity .12s ease, color .12s ease;
}
.canvas-length-tag:hover .canvas-length-tag-nav,
.canvas-length-tag-nav.visible,
.canvas-length-tag-nav:focus {
  opacity: 1;
}
.canvas-length-tag-nav-shell {
  fill: rgba(11,13,14,0.96);
  stroke: rgba(182,255,60,0.55);
  stroke-width: 1;
  transition: fill .12s ease, stroke .12s ease;
}
.canvas-length-tag-nav:hover,
.canvas-length-tag-nav:focus {
  color: var(--text);
  outline: none;
}
.canvas-length-tag-nav:hover .canvas-length-tag-nav-shell,
.canvas-length-tag-nav:focus .canvas-length-tag-nav-shell {
  fill: rgba(182,255,60,0.035);
  stroke: var(--accent);
}

.empty {
  position: absolute; inset: 0;
  display: block;
  color: var(--muted);
  pointer-events: none;
  text-align: left;
  padding: 40px;
  overflow: auto;
}
.home-shell {
  width: min(1180px, 100%);
  min-height: 100%;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 200px minmax(0, 1fr);
  align-items: stretch;
  pointer-events: none;
}
.home-sidebar {
  min-width: 0;
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 18px 12px;
  border: 1px solid var(--line);
  border-right: 0;
  border-radius: 8px 0 0 8px;
  background: rgba(20,24,26,0.88);
  box-shadow: 0 18px 48px rgba(0,0,0,0.22);
}
.home-sidebar p {
  margin: 0 0 10px;
  padding: 0 8px;
  color: var(--muted);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.home-nav-item {
  width: 100%;
  min-height: 40px;
  justify-content: space-between;
  padding: 0 10px;
  border-color: transparent;
  border-left: 2px solid transparent;
  background: transparent;
  color: var(--muted);
}
.home-nav-item.active,
.home-nav-item:hover {
  border-color: var(--line);
  border-left-color: var(--accent);
  background: var(--panel-2);
  color: var(--text);
}
.home-nav-item span:last-child {
  color: var(--muted);
  font-size: 10px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.home-main {
  min-width: 0;
  pointer-events: none;
  border: 1px solid var(--line);
  border-radius: 0 8px 8px 0;
  background: rgba(20,24,26,0.55);
  box-shadow: 0 18px 48px rgba(0,0,0,0.22);
  overflow: hidden;
}
.home-panel {
  min-width: 0;
  min-height: 100%;
  padding: 16px;
  pointer-events: auto;
}
.home-panel[hidden] {
  display: none;
}
.home-hero {
  display: grid;
  grid-template-columns: minmax(280px, 0.82fr) minmax(520px, 1.18fr);
  align-items: end;
  gap: 16px;
}
.home-copy {
  min-width: 0;
  pointer-events: auto;
}
.home-eyebrow,
.home-step > span,
.home-file-types {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.home-eyebrow {
  margin: 0;
  color: var(--muted);
}
.home-copy h2 {
  margin: 8px 0 0;
  color: var(--text);
  font-size: 24px;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: 0;
}
.home-deck {
  max-width: 420px;
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}
.home-upload-panel,
.path-template-home {
  pointer-events: auto;
  min-width: 0;
  border: 1px solid var(--line);
  background: rgba(20,24,26,0.88);
}
.home-upload-panel {
  min-height: 260px;
  padding: 0;
  border-radius: 8px;
  overflow: hidden;
}
.empty .empty-upload {
  width: 100%;
  height: 100%;
  min-height: 260px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 13px;
  padding: 32px;
  border: 1px dashed #38434a;
  border-radius: 0;
  background: var(--panel-2);
  color: var(--text);
  pointer-events: auto;
  text-align: center;
  white-space: normal;
  transition: background .15s ease, border-color .15s ease, color .15s ease;
}
.empty .empty-upload:hover {
  border-color: var(--accent);
  background: #232a2e;
}
.home-upload-icon {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 1px solid #38434a;
  border-radius: 6px;
  color: var(--text);
}
.home-upload-icon svg {
  width: 23px;
  height: 23px;
}
.home-upload-copy {
  display: grid;
  gap: 4px;
}
.home-upload-copy strong {
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  line-height: 1.2;
}
.home-upload-copy span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.3;
}
.home-file-types {
  width: min(520px, 100%);
  display: flex;
  justify-content: center;
  gap: 20px;
  margin-top: 2px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 10px;
}
.home-lower {
  min-height: 0;
  display: block;
  margin-top: 16px;
  pointer-events: none;
}
.home-steps {
  pointer-events: auto;
  display: grid;
  grid-template-rows: repeat(3, 1fr);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.home-step {
  display: grid;
  grid-template-columns: 122px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
  padding: 15px 0;
  border-bottom: 1px solid var(--line);
}
.home-step:last-child {
  border-bottom: 0;
}
.home-step > span {
  color: var(--accent);
  line-height: 1.4;
}
.home-step h2 {
  margin: 0;
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.25;
}
.home-step p {
  max-width: none;
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}
.path-template-home {
  min-height: 440px;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.path-template-home-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px;
  border-bottom: 1px solid var(--line);
  background: #111517;
}
.path-template-home-header h2 {
  margin: 0;
  font-size: 15px;
  line-height: 1.2;
}
.path-template-home-header p {
  margin-top: 4px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}
.path-template-new {
  min-width: 58px;
  justify-content: center;
}
.path-template-layout {
  min-height: 0;
  flex: 1;
  display: grid;
  grid-template-columns: 164px minmax(0, 1fr);
}
.path-template-sidebar {
  min-width: 0;
  padding: 8px;
  border-right: 1px solid var(--line);
  background: #101416;
  overflow: auto;
}
.path-template-nav-item {
  width: 100%;
  min-height: 54px;
  justify-content: flex-start;
  align-items: flex-start;
  flex-direction: column;
  gap: 5px;
  padding: 9px 10px;
  background: transparent;
  border-color: transparent;
  white-space: normal;
  text-align: left;
}
.path-template-nav-title,
.path-template-path-name {
  max-width: 100%;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.path-template-nav-title {
  color: var(--text);
  font-size: 12px;
  line-height: 1.2;
}
.path-template-nav-meta,
.path-template-path-meta {
  color: var(--muted);
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  line-height: 1.2;
}
.path-template-nav-item.active {
  border-color: #394248;
  background: #1b2124;
  color: var(--text);
  font-weight: 500;
}
.path-template-editor {
  min-width: 0;
  min-height: 0;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow: auto;
}
.path-template-title-field,
.path-template-field {
  display: grid;
  gap: 6px;
}
.path-template-title-field span,
.path-template-field span,
.path-template-paths-header span {
  color: var(--muted);
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.path-template-title-field input,
.path-template-field input[type=text] {
  width: 100%;
  min-width: 0;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #0f1315;
  color: var(--text);
  padding: 0 10px;
  font-family: inherit;
  font-size: 12px;
}
.path-template-title-field input:focus,
.path-template-field input[type=text]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}
.path-template-paths-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.path-template-path-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.path-template-path-card {
  min-width: 0;
  min-height: 64px;
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  grid-template-rows: auto auto;
  align-items: center;
  column-gap: 8px;
  row-gap: 4px;
  padding: 9px;
  text-align: left;
  white-space: normal;
}
.path-template-path-card.active {
  border-color: var(--accent);
  background: #20272a;
  color: var(--text);
  font-weight: 500;
}
.path-template-nav-item.active .path-template-nav-meta,
.path-template-path-card.active .path-template-path-meta {
  color: var(--muted);
}
.path-template-path-preview {
  grid-row: 1 / 3;
  width: 48px;
  height: 46px;
  display: grid;
  place-items: center;
  overflow: visible;
}
.path-template-path-preview svg {
  width: 46px !important;
  height: 46px !important;
}
.path-template-style-editor {
  margin-top: 2px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.path-template-preview,
.path-template-field-full {
  grid-column: 1 / -1;
}
.path-template-preview {
  min-height: 120px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0c1012;
  overflow: hidden;
}
.path-template-preview svg {
  max-width: min(170px, 100%);
}
.path-template-segmented {
  min-width: 0;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
  background: #0f1315;
}
.path-template-segment {
  min-width: 0;
  min-height: 34px;
  justify-content: center;
  border: 0;
  border-radius: 0;
  background: transparent;
}
.path-template-segment + .path-template-segment {
  border-left: 1px solid var(--line);
}
.path-template-field input[type=color] {
  width: 100%;
  height: 34px;
  min-width: 0;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #0f1315;
  cursor: pointer;
}
.path-template-field input[type=color]:disabled {
  opacity: 0.46;
  cursor: not-allowed;
}
.path-template-check {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-size: 12px;
  line-height: 1.3;
}
.path-template-check input {
  accent-color: var(--accent);
}
.path-template-empty-editor {
  min-height: 120px;
  display: grid;
  place-items: center;
  border: 1px dashed #354047;
  border-radius: 8px;
  color: var(--muted);
  font-size: 12px;
}
.empty,
.path-template-sidebar,
.path-template-editor {
  scrollbar-width: thin;
  scrollbar-color: rgba(125, 138, 145, 0.34) transparent;
}
.empty::-webkit-scrollbar,
.path-template-sidebar::-webkit-scrollbar,
.path-template-editor::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
.empty::-webkit-scrollbar-track,
.path-template-sidebar::-webkit-scrollbar-track,
.path-template-editor::-webkit-scrollbar-track {
  background: transparent;
}
.empty::-webkit-scrollbar-thumb,
.path-template-sidebar::-webkit-scrollbar-thumb,
.path-template-editor::-webkit-scrollbar-thumb {
  background: rgba(125, 138, 145, 0.34);
  border-radius: 999px;
}
.empty::-webkit-scrollbar-thumb:hover,
.path-template-sidebar::-webkit-scrollbar-thumb:hover,
.path-template-editor::-webkit-scrollbar-thumb:hover {
  background: rgba(154, 169, 176, 0.48);
}

@media (max-width: 980px) {
  .home-shell {
    width: min(720px, 100%);
    grid-template-columns: 1fr;
  }
  .home-sidebar {
    flex-direction: row;
    align-items: center;
    border-right: 1px solid var(--line);
    border-bottom: 0;
    border-radius: 8px 8px 0 0;
  }
  .home-sidebar p {
    margin: 0 8px 0 0;
  }
  .home-nav-item {
    width: auto;
    flex: 1 1 0;
  }
  .home-hero,
  .home-lower {
    grid-template-columns: 1fr;
    gap: 24px;
  }
  .home-upload-panel,
  .path-template-home {
    min-height: auto;
  }
  .path-template-home {
    width: 100%;
  }
  .home-main {
    border-radius: 0 0 8px 8px;
  }
}

@media (max-width: 620px) {
  .empty {
    align-items: stretch;
    justify-content: flex-start;
    padding: 14px;
  }
  .home-shell {
    width: 100%;
  }
  .home-sidebar {
    padding: 10px;
  }
  .home-sidebar p {
    display: none;
  }
  .home-panel {
    padding: 12px;
  }
  .home-copy h2 {
    font-size: 24px;
    line-height: 1.2;
  }
  .home-deck {
    max-width: none;
    font-size: 14px;
  }
  .home-upload-panel {
    min-height: 240px;
  }
  .empty .empty-upload {
    min-height: 240px;
    padding: 24px 16px;
  }
  .home-file-types {
    flex-wrap: wrap;
    gap: 10px 14px;
  }
  .home-step {
    grid-template-columns: 1fr;
    gap: 6px;
    padding: 14px 0;
  }
  .path-template-home {
    min-height: 640px;
  }
  .path-template-layout {
    grid-template-columns: 1fr;
  }
  .path-template-sidebar {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(136px, 1fr);
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .path-template-path-grid,
  .path-template-style-editor {
    grid-template-columns: 1fr;
  }
}

/* Walkthru-aligned home shell and template editor */
.empty {
  display: block;
  padding: 0;
  overflow: hidden;
  pointer-events: auto;
  touch-action: auto;
  cursor: default;
}
.home-shell {
  width: 100%;
  height: 100%;
  min-height: 0;
  margin: 0;
  display: flex;
  align-items: stretch;
  pointer-events: auto;
}
.home-sidebar {
  flex: 0 0 200px;
  border: 0;
  border-right: 1px solid var(--line);
  border-radius: 0;
  background: #0f1315;
  box-shadow: none;
  padding: 24px 12px;
}
.home-sidebar p {
  margin: 0;
  padding: 0 8px 12px;
  color: #687279;
  font-size: 10px;
  letter-spacing: 0.14em;
}
.home-nav-item {
  min-height: 39px;
  border: 0;
  border-left: 2px solid transparent;
  border-radius: 2px;
  padding: 0 12px;
  font-size: 13.5px;
}
.home-nav-item.active,
.home-nav-item:hover {
  border-left-color: var(--accent);
  background: var(--panel);
}
.home-main {
  flex: 1 1 auto;
  height: 100%;
  min-width: 0;
  pointer-events: auto;
  border: 0;
  border-radius: 0;
  background: var(--bg);
  box-shadow: none;
  overflow: hidden;
}
.home-panel {
  height: 100%;
  min-height: 0;
  padding: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  scrollbar-width: thin;
  scrollbar-color: rgba(125, 138, 145, 0.34) transparent;
}
.home-panel:focus {
  outline: none;
}
.home-panel[hidden] {
  display: none;
}
.home-panel[data-home-panel="index"] {
  padding: 40px;
}
.home-hero,
.home-lower {
  width: min(1240px, 100%);
  margin-inline: auto;
}
.home-hero {
  grid-template-columns: minmax(0, 1fr) minmax(420px, 1.1fr);
  gap: 48px;
}
.home-copy h2 {
  font-size: 44px;
  line-height: 1.05;
  font-weight: 500;
}
.home-upload-panel {
  min-height: 278px;
  border-radius: 2px;
}
.empty .empty-upload {
  min-height: 278px;
  border-width: 2px;
  border-radius: 2px;
}
.home-lower {
  margin-top: 28px;
}
.path-template-home {
  width: min(1240px, 100%);
  min-height: 100%;
  margin: 0 auto;
  padding: 40px;
  border: 0;
  border-radius: 0;
  background: transparent;
  display: block;
  overflow: visible;
}
.path-template-home-header {
  padding: 0 0 32px;
  border-bottom: 1px solid var(--line);
  background: transparent;
}
.path-template-home-header h2 {
  margin: 8px 0 0;
  color: var(--text);
  font-size: 44px;
  font-weight: 500;
  line-height: 1.05;
}
.path-template-home-header p,
.path-template-home-header span,
.path-template-sidebar > p,
.path-template-editor-header p,
.path-template-category-header p,
.path-template-preview-card > p,
.path-template-name-inline span,
.path-template-field > span,
.path-template-editor-count {
  font-family: 'JetBrains Mono', monospace;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}
.path-template-home-header p {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
}
.path-template-home-header span {
  display: block;
  max-width: 56ch;
  margin-top: 12px;
  color: var(--muted);
  font-family: inherit;
  text-transform: none;
  letter-spacing: 0;
  font-size: 14px;
  line-height: 1.5;
}
.path-template-new {
  min-height: 36px;
  min-width: 112px;
  border-radius: 2px;
  background: var(--text);
  color: var(--bg);
}
.path-template-layout {
  min-height: 0;
  margin-top: 32px;
  display: grid;
  grid-template-columns: 200px minmax(0, 1fr);
  gap: 32px;
}
.path-template-sidebar {
  padding: 0;
  border: 0;
  background: transparent;
  overflow: visible;
}
body.no-document .path-template-sidebar,
body.no-document .path-template-appearance-panel,
body.no-document .path-template-preview-panel {
  display: block;
}
.path-template-sidebar > p,
.path-template-category-header p,
.path-template-preview-card > p {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 10px;
}
.path-template-nav-list {
  display: grid;
  gap: 4px;
}
.path-template-nav-item {
  width: 100%;
  min-height: 84px;
  display: block;
  border: 1px solid transparent;
  border-radius: 2px;
  padding: 12px;
  background: transparent;
  text-align: left;
}
.path-template-nav-item.active {
  border-color: var(--text);
  background: var(--panel);
}
.path-template-nav-title {
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
}
.path-template-nav-meta {
  display: block;
  margin-top: 6px;
}
.path-template-editor {
  min-width: 0;
  padding: 0;
  display: block;
  overflow: visible;
}
.path-template-editor-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line);
}
.path-template-editor-header p {
  margin: 0;
  color: var(--muted);
  font-size: 10px;
}
.path-template-title-field {
  display: block;
}
.path-template-title-field input {
  width: min(460px, 100%);
  min-height: 32px;
  margin-top: 4px;
  padding: 0 0 4px;
  border: 0;
  border-bottom: 1px solid var(--text);
  border-radius: 0;
  background: transparent;
  color: var(--text);
  font-size: 24px;
  font-weight: 500;
  line-height: 1.05;
}
.path-template-editor-count {
  color: var(--muted);
  font-size: 10px;
}
.path-template-detail-grid {
  min-width: 0;
  margin-top: 24px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px 240px;
  column-gap: 32px;
  row-gap: 24px;
  align-items: start;
}
.path-template-path-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.path-template-path-card,
.path-template-add-category {
  min-height: 58px;
  border-radius: 2px;
  background: var(--panel);
}
.path-template-path-card {
  grid-template-columns: 38px minmax(0, 1fr);
  padding: 10px 12px;
  border-color: var(--line);
}
.path-template-path-card.active {
  border-color: var(--accent);
  background: var(--panel);
}
.path-template-path-preview {
  width: 32px;
  height: 32px;
}
.path-template-path-preview svg {
  width: 32px !important;
  height: 32px !important;
}
.path-template-add-category {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px dashed #38434a;
  color: var(--muted);
  font-size: 13px;
}
.path-template-add-category span {
  font-size: 18px;
  line-height: 1;
}
.path-template-appearance-card,
.path-template-preview-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: var(--panel);
}
.path-template-appearance-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}
.path-template-mini-preview {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  background: #0f1315;
}
.path-template-mini-preview svg {
  width: 34px !important;
  height: 34px !important;
}
.path-template-name-inline {
  min-width: 0;
  display: grid;
  gap: 3px;
  flex: 1;
}
.path-template-name-inline span,
.path-template-field > span {
  color: var(--muted);
  font-size: 10px;
}
.path-template-name-inline input {
  width: 100%;
  min-width: 0;
  border: 0;
  border-bottom: 1px solid var(--text);
  border-radius: 0;
  background: transparent;
  color: var(--text);
  padding: 0 0 3px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
}
.path-template-style-tabs {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 4px;
  padding: 8px;
  border-bottom: 1px solid var(--line);
}
.path-template-style-tab {
  min-height: 32px;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: transparent;
}
.path-template-style-tab.active {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--bg);
}
.path-template-style-editor {
  margin: 0;
  display: grid;
  grid-template-columns: 1fr;
  gap: 0;
}
.path-template-style-editor[hidden] {
  display: none;
}
.path-template-field {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}
.path-template-field:last-child {
  border-bottom: 0;
}
.path-template-segmented {
  margin-top: 8px;
  border-radius: 2px;
}
.path-template-segment {
  min-height: 34px;
}
.path-template-segment.active {
  background: var(--accent);
  color: var(--bg);
}
.path-template-color-editor {
  display: grid;
  gap: 8px;
  margin-top: 7px;
}
.path-template-swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.path-template-swatch {
  width: 24px;
  height: 24px;
  min-height: 24px;
  padding: 0;
  border: 2px solid var(--panel);
  border-radius: 999px;
  outline: 1px solid var(--line);
  background: transparent;
}
.path-template-swatch.active {
  border-color: var(--text);
  outline-color: var(--text);
}
.path-template-swatch span {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: inherit;
}
.path-template-color-custom {
  display: grid;
  grid-template-columns: 34px 1fr;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.path-template-color-custom input[type=color] {
  width: 34px;
  height: 28px;
  border-radius: 2px;
}
.path-template-check {
  padding: 8px 12px;
  border-bottom: 0;
}
.path-template-preview-card {
  padding: 12px;
}
.path-template-preview {
  min-height: 188px;
  position: relative;
  display: grid;
  place-items: center;
  border-radius: 2px;
  background: #0f1315;
}
.path-template-preview-grid,
.path-template-preview-line,
.path-template-preview-room {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.path-template-preview-grid {
  background-image:
    linear-gradient(rgba(125,138,145,.12) 1px, transparent 1px),
    linear-gradient(90deg, rgba(125,138,145,.12) 1px, transparent 1px);
  background-size: 22px 22px;
}
.path-template-preview-line {
  inset: 30px 22px auto;
  height: 1px;
  background: rgba(125,138,145,.34);
}
.path-template-preview-room {
  inset: 56px 32px 34px;
  border: 1px solid rgba(125,138,145,.26);
}
.path-template-preview-svg {
  position: relative;
  z-index: 1;
}
.path-template-preview svg {
  max-width: 150px;
}
.path-template-preview-meta {
  display: grid;
  gap: 4px;
  margin-top: 10px;
}
.path-template-preview-meta span:first-child {
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
}
.path-template-preview-meta span:last-child {
  color: var(--muted);
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
}
.home-panel::-webkit-scrollbar,
.path-template-sidebar::-webkit-scrollbar,
.path-template-editor::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
.home-panel::-webkit-scrollbar-track,
.path-template-sidebar::-webkit-scrollbar-track,
.path-template-editor::-webkit-scrollbar-track {
  background: transparent;
}
.home-panel::-webkit-scrollbar-thumb,
.path-template-sidebar::-webkit-scrollbar-thumb,
.path-template-editor::-webkit-scrollbar-thumb {
  background: rgba(125, 138, 145, 0.34);
  border-radius: 999px;
}

@media (max-width: 1320px) {
  .path-template-detail-grid {
    grid-template-columns: minmax(0, 1fr) 260px;
  }
  .path-template-preview-panel {
    grid-column: 2;
  }
}

@media (max-width: 920px) {
  .home-shell {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
  }
  .home-sidebar {
    width: auto;
    flex-basis: auto;
    flex-direction: row;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 10px;
  }
  .home-sidebar p {
    display: none;
  }
  .home-nav-item {
    flex: 1 1 0;
    width: auto;
  }
  .path-template-layout,
  .path-template-detail-grid {
    grid-template-columns: 1fr;
  }
  .path-template-preview-panel {
    grid-column: auto;
  }
}

@media (max-width: 640px) {
  .home-panel[data-home-panel="index"],
  .path-template-home {
    padding: 20px;
  }
  .home-hero {
    grid-template-columns: 1fr;
  }
  .home-copy h2,
  .path-template-home-header h2 {
    font-size: 32px;
  }
  .path-template-path-grid {
    grid-template-columns: 1fr;
  }
}

/* Path Dock */
.path-dock-root[hidden],
body.no-document .path-dock-root {
  display: none;
}
.path-dock-root {
  position: absolute;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  z-index: 6;
  max-width: calc(100% - 28px);
  pointer-events: none;
}
.path-dock {
  position: relative;
  width: max-content;
  max-width: 100%;
  box-sizing: border-box;
  min-width: 0;
  min-height: 0;
  display: flex;
  align-items: stretch;
  justify-content: center;
  gap: 2px;
  padding: 2px;
  overflow: visible;
  border: 1px solid #38434a;
  border-radius: 6px;
  background: rgba(20, 24, 26, 0.92);
  box-shadow: 0 6px 18px rgba(0,0,0,0.55);
  backdrop-filter: blur(8px);
  pointer-events: auto;
}
.path-dock-fallback {
  position: absolute;
  left: 0;
  bottom: calc(100% + 8px);
  max-width: min(360px, calc(100vw - 32px));
  display: grid;
  gap: 3px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #111619;
  box-shadow: 0 14px 32px rgba(0,0,0,0.42);
  font-size: 11px;
  line-height: 1.25;
}
.path-dock-fallback span:first-child {
  color: var(--text);
  font-weight: 600;
}
.path-dock-fallback span:last-child {
  color: var(--muted);
}
.path-dock-template,
.path-dock-overflow {
  position: relative;
  flex: 0 0 auto;
  display: flex;
  align-items: stretch;
}
.path-dock-template {
  padding: 0 4px;
  border-left: 1px solid var(--line);
  border-right: 1px solid var(--line);
}
.path-dock-template-toggle,
.path-dock-overflow-toggle,
.path-dock-path-tile,
.path-dock-template-item {
  border-color: transparent;
  background: transparent;
}
.path-dock-template-toggle {
  position: relative;
  min-width: 64px;
  max-width: 112px;
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 4px 18px 4px 4px;
  border-radius: 4px;
  text-align: left;
}
.path-dock-template-toggle::after,
.path-dock-overflow-toggle::after {
  content: "";
  position: absolute;
  right: 5px;
  top: 50%;
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-bottom: 5px solid currentColor;
  transform: translateY(-50%);
  opacity: 0.72;
}
.path-dock-template-label {
  display: none;
  color: var(--muted);
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  line-height: 1;
  text-transform: uppercase;
}
.path-dock-template-active {
  max-width: 100%;
  min-width: 0;
  color: var(--text);
  font-size: 10px;
  font-weight: 500;
  line-height: 1;
  overflow: hidden;
  text-overflow: ellipsis;
}
.path-dock-paths {
  min-width: 0;
  display: flex;
  align-items: stretch;
  gap: 2px;
}
.path-dock-path-tile {
  position: relative;
  flex: 0 1 56px;
  min-width: 36px;
  max-width: 56px;
  height: 36px;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 2px 4px;
  border-radius: 4px;
  text-align: center;
}
.path-dock-path-tile:hover,
.path-dock-template-toggle:hover,
.path-dock-overflow-toggle:hover,
.path-dock-template-item:hover {
  border-color: #38434a;
  background: #1b2226;
}
.path-dock-path-tile.active,
.path-dock-path-tile.active:hover {
  border-color: transparent;
  background: transparent;
  color: var(--text);
  box-shadow: none;
}
.path-dock-path-tile.active::after {
  content: "";
  position: absolute;
  left: 4px;
  right: 4px;
  bottom: 0;
  height: 2px;
  background: var(--accent);
}
.path-dock-path-preview {
  width: 16px;
  height: 16px;
  display: grid;
  place-items: center;
  overflow: visible;
}
.path-dock-path-preview svg {
  width: 18px !important;
  height: 18px !important;
  overflow: visible;
}
.path-dock-path-name {
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text);
  font-size: 9px;
  font-weight: 500;
  line-height: 1.1;
}
.path-dock-overflow-toggle {
  position: relative;
  min-width: 28px;
  min-height: 36px;
  justify-content: center;
  padding: 2px 4px;
  border-radius: 4px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 600;
}
.path-dock-overflow-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
.path-dock-overflow-toggle:disabled {
  display: none;
}
.path-dock-template-menu,
.path-dock-overflow-menu {
  position: absolute;
  grid-column: 1 / -1;
  bottom: calc(100% + 8px);
  display: grid;
  gap: 3px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #111619;
  box-shadow: 0 18px 42px rgba(0,0,0,0.48);
  z-index: 7;
  max-height: min(330px, calc(100vh - 150px));
  overflow: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(125, 138, 145, 0.34) transparent;
}
.path-dock-template-menu {
  left: 0;
  width: 210px;
}
.path-dock-overflow-menu {
  right: 0;
  width: 178px;
}
.path-dock-template-menu::-webkit-scrollbar,
.path-dock-overflow-menu::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
.path-dock-template-menu::-webkit-scrollbar-track,
.path-dock-overflow-menu::-webkit-scrollbar-track {
  background: transparent;
}
.path-dock-template-menu::-webkit-scrollbar-thumb,
.path-dock-overflow-menu::-webkit-scrollbar-thumb {
  background: rgba(125, 138, 145, 0.34);
  border-radius: 999px;
}
.path-dock-template-item {
  width: 100%;
  min-height: 38px;
  display: grid;
  justify-items: start;
  gap: 3px;
  padding: 7px 9px;
  text-align: left;
}
.path-dock-template-item.active {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.path-dock-template-title,
.path-dock-template-count {
  max-width: 100%;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
.path-dock-template-title {
  color: var(--text);
  font-size: 11px;
}
.path-dock-template-count {
  color: var(--muted);
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
}
.path-dock-overflow-menu .path-dock-path-tile {
  width: 100%;
}

@media (max-width: 820px) {
  .path-dock-root {
    left: 10px;
    right: 10px;
    bottom: 58px;
    width: auto;
    transform: none;
  }
  .path-dock {
    width: 100%;
    display: flex;
    justify-content: flex-start;
    overflow: visible;
  }
  .path-dock-paths {
    flex: 1 1 0;
    max-width: 100%;
    overflow-x: auto;
    scrollbar-width: none;
  }
  .path-dock-paths::-webkit-scrollbar {
    display: none;
  }
  .path-dock-template-toggle {
    max-width: 100px;
  }
  .path-dock-overflow-toggle {
    min-width: 28px;
  }
  .path-dock-overflow-menu {
    position: fixed;
    right: 10px;
    bottom: 108px;
    max-width: calc(100vw - 20px);
  }
  .path-dock-path-tile {
    min-width: 36px;
  }
}

/* HUD overlay */
.hud {
  position: absolute;
  bottom: 16px; left: 16px;
  display: flex; gap: 8px; flex-wrap: wrap;
  z-index: 4;
}
.hud .pill { background: rgba(20,24,26,0.85); backdrop-filter: blur(8px); }
.cursor-hud {
  gap: 10px;
  align-items: center;
}
#cursorPos {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}
#cursorPos .hud-part {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
}
#cursorPos .hud-part + .hud-part {
  padding-left: 10px;
  border-left: 1px solid rgba(132, 148, 158, 0.24);
}
.snap-toggle {
  position: relative;
  width: 24px;
  min-height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: 10px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
}
.snap-toggle::before {
  content: "";
  position: absolute;
  left: -10px;
  top: 4px;
  bottom: 4px;
  width: 1px;
  background: rgba(132, 148, 158, 0.24);
}
.snap-toggle svg {
  width: 17px;
  height: 17px;
  display: block;
}
.snap-toggle:hover {
  border-color: transparent;
  background: var(--panel-2);
  color: var(--text);
}
.snap-toggle[aria-pressed="true"] {
  background: transparent;
  color: var(--accent);
}
.snap-toggle[aria-pressed="true"] svg {
  filter: drop-shadow(0 0 5px rgba(182,255,60,0.72));
}
#polarLock.snap-toggle { margin-left: 10px; }
#snapToPaths.snap-toggle { margin-left: 6px; }
.buy-list-empty {
  margin: 12px 10px;
  padding: 12px 10px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
  border: 1px dashed rgba(125,138,145,0.28);
  border-radius: 8px;
}
.buy-list-row { padding: 8px 8px 10px; }

.status {
  position: absolute;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  max-width: min(760px, calc(100% - 32px));
  background: rgba(20,24,26,0.92);
  backdrop-filter: blur(8px);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 12px;
  line-height: 1;
  z-index: 4;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  display: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.status.show { display: block; }
.status .key { font-family: 'JetBrains Mono', monospace; color: var(--accent); }

.draft-prompt {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 6;
  min-width: 186px;
  max-width: min(280px, calc(100vw - 24px));
  padding: 8px 10px 8px 12px;
  pointer-events: none;
  color: var(--text);
  background: rgba(13, 17, 19, 0.91);
  border: 1px solid rgba(132, 148, 158, 0.28);
  border-left: 2px solid var(--accent);
  border-radius: 7px;
  box-shadow: 0 12px 30px rgba(0,0,0,0.38);
  backdrop-filter: blur(8px);
}
.draft-prompt[hidden] { display: none; }
.draft-prompt-title {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  line-height: 1.2;
  color: var(--accent);
  text-transform: uppercase;
}
.draft-prompt-step {
  margin-top: 3px;
  font-size: 12px;
  line-height: 1.25;
  font-weight: 600;
}
.draft-prompt-metric {
  margin-top: 5px;
  padding-top: 5px;
  border-top: 1px solid rgba(132, 148, 158, 0.22);
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  line-height: 1.2;
  color: var(--muted);
}
.draft-prompt-metric:empty { display: none; }

.context-menu {
  position: fixed;
  display: none;
  min-width: 136px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #111619;
  box-shadow: 0 18px 40px rgba(0,0,0,0.48);
  z-index: 80;
  max-width: calc(100vw - 16px);
  max-height: calc(100vh - 16px);
  overflow: auto;
  overscroll-behavior: contain;
}
.context-menu.show { display: grid; gap: 2px; }
.context-menu button {
  width: 100%;
  justify-content: flex-start;
  min-height: 30px;
  border: 0;
  background: transparent;
  color: var(--text);
  padding: 0 9px;
}
.context-menu button:hover { background: var(--panel-2); }
.context-menu button:disabled { color: var(--muted); opacity: 0.45; }
.context-menu button[hidden] { display: none; }

.rotation-pill {
  position: fixed;
  display: none;
  width: 64px;
  height: 28px;
  z-index: 75;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 0 8px;
  border: 1px solid #3a444b;
  border-radius: 6px;
  background: #111619;
  box-shadow: 0 10px 24px rgba(0,0,0,0.42);
}
.rotation-pill.show { display: flex; }
.rotation-pill input {
  width: 38px;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--text);
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  font-weight: 600;
  text-align: right;
}
.rotation-pill span {
  color: var(--muted);
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
}
.canvas-length-tag-editor {
  overflow: visible;
  pointer-events: auto;
}
.canvas-length-tag-edit {
  box-sizing: border-box;
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: nowrap;
  gap: 3px;
  padding: 0 8px 0 17px;
  border: 1px solid var(--length-tag-color);
  border-radius: 5px;
  background: rgba(11,13,14,0.96);
  pointer-events: auto;
}
.canvas-length-tag-edit::before {
  content: "";
  position: absolute;
  left: 4px;
  top: 4px;
  bottom: 4px;
  width: var(--length-tag-accent-width);
  min-width: 3px;
  border-radius: 1.5px;
  background: var(--length-tag-color);
  pointer-events: none;
}
.canvas-length-tag-edit:has(.canvas-length-tag-input.invalid) {
  min-width: 190px;
  min-height: 48px;
  border-color: var(--danger);
  align-content: center;
  flex-wrap: wrap;
  gap: 4px 6px;
}
.canvas-length-tag-input {
  width: 4ch;
  min-width: 4ch;
  max-width: 14ch;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--text);
  font-family: 'JetBrains Mono', monospace;
  font-size: var(--length-tag-font-size);
  font-weight: 700;
  line-height: var(--length-tag-font-size);
  font-variant-numeric: tabular-nums;
  text-align: right;
  pointer-events: auto;
}
.canvas-length-tag-input::selection {
  color: var(--text);
  background: color-mix(in srgb, var(--length-tag-color) 38%, transparent);
}
.canvas-length-tag-unit {
  color: var(--text);
  font-family: 'JetBrains Mono', monospace;
  font-size: var(--length-tag-font-size);
  font-weight: 700;
  line-height: var(--length-tag-font-size);
  pointer-events: none;
}
.canvas-length-tag-input.invalid { color: var(--danger); }
.canvas-length-edit-error {
  flex-basis: 100%;
  color: var(--danger);
  font-size: 10px;
  font-weight: 700;
  line-height: 1.1;
  white-space: nowrap;
}
.canvas-length-edit-error[hidden] { display: none; }

/* Side panel */
aside {
  grid-area: side;
  background: var(--panel);
  border-left: 1px solid var(--line);
  display: flex; flex-direction: column;
  min-width: 0;
  overflow: hidden;
}
.side-h {
  padding: 14px 18px 12px;
  border-bottom: 1px solid var(--line);
  position: relative;
}
.side-h-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.side-h h3 {
  font-size: 10px; font-family: 'JetBrains Mono', monospace;
  text-transform: uppercase; letter-spacing: 0.16em; color: var(--muted);
  font-weight: 500;
}
.side-h .total {
  margin-top: 8px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 25px;
  font-weight: 500;
  letter-spacing: -0.01em;
}
.side-h .total .unit { font-size: 13px; color: var(--muted); margin-left: 6px; }
.side-h .entire-total {
  position: absolute;
  right: 18px;
  bottom: 32px;
  margin-top: 0;
  color: var(--muted);
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  line-height: 1.25;
  text-align: right;
  white-space: nowrap;
}
.side-h .sub {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 11px;
  margin-top: 2px;
  padding-right: 0;
  font-family: 'JetBrains Mono', monospace;
}
.side-h:has(.entire-total:not([hidden])) .sub {
  padding-right: 0;
}
.side-h .sub #runCount {
  flex: 0 0 auto;
  white-space: nowrap;
}
.side-h .average-metric {
  flex: 0 1 auto;
  min-width: 0;
  color: #aab6bd;
  text-align: right;
  white-space: nowrap;
}
.export-wrap {
  position: relative;
  flex: 0 0 auto;
}
.export-trigger {
  width: 34px;
  min-width: 34px;
  height: 34px;
  padding: 0;
  border-radius: 7px;
  justify-content: center;
}
.export-trigger svg {
  width: 15px;
  height: 15px;
}
.export-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  display: none;
  min-width: 160px;
  padding: 6px;
  background: #111619;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 12px 28px rgba(0,0,0,0.45);
  z-index: 12;
}
.export-wrap.open .export-menu { display: grid; gap: 2px; }
.export-menu button {
  width: 100%;
  min-height: 32px;
  border: 0;
  background: transparent;
  color: var(--text);
  justify-content: flex-start;
  padding: 0 10px;
}
.export-menu button:hover { background: var(--panel-2); }

.tabs {
  display: grid;
  grid-template-columns: repeat(var(--scope-tab-count, 3), minmax(0, 1fr));
  gap: 0;
  padding: 0 10px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}
.tab {
  min-width: 0;
  background: transparent;
  border: none;
  border-radius: 0;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  min-height: 34px;
  padding: 0 3px;
  font-size: 10px;
  font-family: 'JetBrains Mono', monospace;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  justify-content: center;
  cursor: pointer;
  transition: all .15s;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tab:hover { color: var(--text); background: transparent; }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); background: transparent; }
.tab[hidden] { display: none !important; }
.tabs[hidden] { display: none !important; }

.path-category-visibility-toolbar {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
  padding: 6px 7px;
  border: 1px solid rgba(125,138,145,0.16);
  border-radius: 6px;
  background: rgba(255,255,255,0.018);
}
.path-category-visibility-status {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
}
.path-category-visibility-actions {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.path-category-bulk-toggle {
  width: 24px;
  min-width: 24px;
  min-height: 24px;
  padding: 0;
  justify-content: center;
  border: 0 !important;
  background: transparent !important;
  color: var(--muted);
}
.path-category-visibility-toggle {
  width: 24px;
  min-width: 24px;
  min-height: 24px;
  padding: 0;
  justify-content: center;
  border-color: rgba(125,138,145,0.18);
  background: transparent;
  color: var(--muted);
}
.path-category-bulk-toggle:hover:not(:disabled),
.path-category-visibility-toggle:hover {
  color: var(--text);
  border-color: rgba(125,138,145,0.34);
  background: rgba(255,255,255,0.035);
}
.path-category-bulk-toggle:disabled {
  opacity: 0.38;
  cursor: default;
}
.path-category-bulk-toggle .path-category-bulb {
  width: 15px;
  height: 15px;
}
.path-category-visibility-toggle svg {
  width: 14px;
  height: 14px;
}

.path-category-section {
  min-width: 0;
  display: grid;
  gap: 6px;
  margin-bottom: 10px;
}
.path-category-header {
  min-width: 0;
  display: flex;
  justify-content: space-between;
  padding-bottom: 5px;
  border-bottom: 1px solid rgba(125,138,145,0.16);
}
.path-category-row {
  width: 100%;
  min-width: 0;
  height: 44px;
  min-height: 44px;
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 5px 3px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: inherit;
  text-align: left;
}
.path-category-row:hover,
.path-category-row:focus {
  border-color: rgba(125,138,145,0.25);
  background: rgba(255,255,255,0.025);
  outline: none;
}
.path-category-icon {
  width: 28px;
  height: 28px;
  display: inline-grid;
  place-items: center;
  border-radius: 6px;
  border: 1px solid var(--path-color, #7d8a91);
  background: color-mix(in srgb, var(--path-color, #7d8a91) 14%, transparent);
  color: var(--path-color, #7d8a91);
  overflow: hidden;
}
.path-category-icon.hidden-icon {
  border-color: transparent;
  background: transparent;
  box-shadow: none;
}
.path-category-icon-template,
.path-category-icon-manual {
  color: var(--path-color, #7d8a91);
}
.path-category-icon svg {
  width: 26px !important;
  height: 26px !important;
  display: block;
  overflow: visible;
}
.path-category-icon .tail {
  fill: none;
  stroke: var(--path-color, currentColor);
  stroke-width: 8;
  stroke-linecap: round;
}
.path-category-icon .anchor-dot {
  fill: #0b0f11;
  stroke: var(--path-color, currentColor);
  stroke-width: 5;
}
.path-category-icon.hidden-icon .tail {
  stroke: #5a666e;
}
.path-category-icon.hidden-icon .anchor-dot {
  fill: transparent;
  stroke: #5a666e;
}
.path-category-square {
  width: 13px;
  height: 13px;
  display: block;
  border-radius: 4px;
  background: var(--path-color, #7d8a91);
  box-shadow: 0 0 10px var(--path-color, #7d8a91);
}
.path-category-icon.hidden-icon .path-category-square {
  background: transparent;
  border: 1px solid #5a666e;
  box-shadow: none;
}
.path-category-copy {
  min-width: 0;
  display: grid;
  gap: 3px;
}
.path-category-title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #aab6bd;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.path-category-meta {
  min-width: 0;
  display: grid;
  align-items: start;
  gap: 2px;
}
.path-category-summary {
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
}
.path-category-hidden {
  color: #8f9aa0;
  font-family: 'JetBrains Mono', monospace;
  font-size: 8px;
  line-height: 1;
}
.path-category-controls {
  position: relative;
  flex: 0 0 74px;
  width: 74px;
  min-width: 74px;
  height: 30px;
}
.path-category-control-top {
  position: absolute;
  top: 0;
  right: 0;
  width: 74px;
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
}
.path-category-total {
  max-width: 50px;
  display: inline-flex;
  align-items: baseline;
  justify-content: flex-end;
  gap: 3px;
  color: var(--accent);
  font-family: 'JetBrains Mono', monospace;
  line-height: 1;
}
.path-category-total strong {
  max-width: 8ch;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 11px;
  font-weight: 700;
}
.path-category-total span {
  color: var(--muted);
  font-size: 8px;
  font-weight: 600;
}
.path-category-hidden-total {
  position: absolute;
  right: 0;
  bottom: 0;
  max-width: 74px;
  text-align: right;
  white-space: nowrap;
}
.path-category-status {
  justify-self: end;
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  border: 1px solid rgba(182,255,60,0.22);
  background: rgba(182,255,60,0.055);
  border-radius: 4px;
  padding: 0;
  font-size: 0;
  line-height: 1;
}
.path-category-status.off {
  color: #8f9aa0;
  border-color: #3c474e;
  background: rgba(255,255,255,0.035);
}
.path-category-bulb {
  width: 14px;
  height: 14px;
  display: block;
  fill: none;
}
.path-category-row .path-category-status {
  width: 18px;
  height: 18px;
}
.path-category-row .path-category-bulb {
  width: 11px;
  height: 11px;
}
.path-category-row .path-category-control-top {
  gap: 3px;
}
.path-category-row .path-category-total {
  max-width: 53px;
  gap: 2px;
}
.path-category-row .path-category-total strong {
  font-size: 10px;
}
.path-category-row .path-category-total span {
  font-size: 7px;
}
.path-category-bulb-outline,
.path-category-bulb-bolt {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
}
.path-category-bulb-bolt {
  stroke-linecap: round;
  stroke-linejoin: round;
}
.path-group {
  min-width: 0;
  max-width: 100%;
  margin: 0 0 7px;
  border: 1px solid #26343a;
  border-radius: 6px;
  background: rgba(255,255,255,0.018);
  overflow: hidden;
}
.path-category-section .path-group { margin-bottom: 0; }
.path-group-row {
  min-width: 0;
  padding: 7px;
  border-bottom: 1px solid rgba(125,138,145,0.12);
  background: #151d20;
}
.page-group-row {
  min-width: 0;
  padding: 0;
  border-bottom: 1px solid rgba(125,138,145,0.12);
  background: #151d20;
}
.page-group-toggle {
  width: 100%;
  min-width: 0;
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr) minmax(46px, auto);
  align-items: center;
  gap: 7px;
  min-height: 42px;
  padding: 7px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
}
.page-group-toggle:hover,
.page-group-toggle:focus {
  background: rgba(255,255,255,0.03);
  outline: none;
}
.page-group-chevron {
  width: 18px;
  height: 18px;
  display: inline-grid;
  place-items: center;
  color: var(--muted);
  transition: transform .15s ease;
}
.page-group.collapsed .page-group-chevron {
  transform: rotate(-90deg);
}
.page-group-chevron svg {
  width: 15px;
  height: 15px;
}
.page-group-chevron path {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.page-group-copy {
  min-width: 0;
  display: grid;
  justify-items: start;
  gap: 4px;
}
.page-group-title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
}
.path-group-meta.page-group-meta {
  margin-top: 0;
  padding-left: 0;
  display: block;
  align-items: baseline;
  gap: 4px 7px;
  text-align: left;
}
.path-group-meta.page-group-meta .path-group-chip {
  display: block;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  white-space: nowrap;
}
.page-group-summary {
  min-width: 62px;
  display: grid;
  justify-items: end;
  gap: 4px;
  text-align: right;
}
.page-group-total {
  min-width: 0;
  max-width: 74px;
  display: inline-flex;
  align-items: baseline;
  justify-content: flex-end;
  gap: 3px;
  color: var(--accent);
  font-family: 'JetBrains Mono', monospace;
  line-height: 1;
}
.page-group-total strong {
  min-width: 0;
  max-width: 8ch;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 700;
}
.page-group-total span {
  color: var(--muted);
  font-size: 9px;
  font-weight: 600;
}
.page-group-average {
  display: block;
  text-align: right;
}
.path-group-summary {
  min-width: 0;
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr) minmax(46px, auto);
  align-items: center;
  gap: 7px;
}
.path-group-summary:has(.path-group-settings) {
  grid-template-columns: 20px minmax(0, 1fr) minmax(46px, auto) 26px;
}
.path-group-marker {
  width: 20px;
  height: 20px;
  border-radius: 5px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--path-color, #7d8a91);
  background: color-mix(in srgb, var(--path-color, #7d8a91) 14%, transparent);
  color: var(--path-color, #7d8a91);
  box-shadow: 0 0 8px color-mix(in srgb, var(--path-color, #7d8a91) 45%, transparent);
  overflow: visible;
}
.path-group-marker svg {
  width: 19px;
  height: 19px;
  display: block;
  overflow: visible;
}
.path-group-marker .tail {
  fill: none;
  stroke: var(--path-color, currentColor);
  stroke-width: 8;
  stroke-linecap: round;
}
.path-group-marker .anchor-dot {
  fill: #0b0f11;
  stroke: var(--path-color, currentColor);
  stroke-width: 5;
}
.path-group-copy {
  min-width: 0;
  display: grid;
  gap: 2px;
}
.path-group-title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
}
.path-group-subtitle {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.1;
}
.path-group-total {
  min-width: 0;
  max-width: 74px;
  display: inline-flex;
  align-items: baseline;
  justify-content: flex-end;
  gap: 3px;
  color: var(--accent);
  font-family: 'JetBrains Mono', monospace;
  line-height: 1;
}
.path-group-total strong {
  min-width: 0;
  max-width: 8ch;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 700;
}
.path-group-total span {
  color: var(--muted);
  font-size: 9px;
  font-weight: 600;
}
.path-group-settings {
  width: 24px;
  min-width: 24px;
  min-height: 24px;
  padding: 0;
  justify-content: center;
  border-color: rgba(125,138,145,0.18);
  background: transparent;
  color: var(--muted);
}
.path-group-settings:hover,
.path-group-settings:focus {
  color: var(--text);
  border-color: rgba(125,138,145,0.36);
  background: rgba(255,255,255,0.035);
  outline: none;
}
.path-group-settings svg {
  width: 14px;
  height: 14px;
}
.path-group-meta {
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
  padding-left: 27px;
}
.path-group-chip {
  min-width: 0;
  max-width: 100%;
  min-height: 16px;
  display: inline-flex;
  align-items: center;
  padding: 2px 5px;
  border: 1px solid rgba(125,138,145,0.22);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(255,255,255,0.025);
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  line-height: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.path-group-chip-warn {
  color: var(--calib);
  border-color: rgba(255,177,60,0.3);
}
.path-group-chip-muted {
  color: #8f9aa0;
  border-color: rgba(125,138,145,0.2);
}
.path-group-average {
  min-width: 0;
  color: #aab6bd;
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  line-height: 1;
  white-space: nowrap;
}
.path-category-average {
  color: #aab6bd;
}
.path-group-runs {
  min-width: 0;
  display: grid;
  gap: 3px;
  padding: 4px;
}
.page-group.collapsed .path-group-runs {
  display: none;
}
.path-group .meas-item {
  width: 100%;
  min-height: 31px;
  margin-bottom: 0;
  padding: 3px 5px;
  border-radius: 5px;
}
.path-group .meas-item .row {
  grid-template-columns: 18px minmax(0, 1fr) minmax(20px, auto) minmax(46px, auto) 18px 18px;
  gap: 5px;
  min-height: 27px;
}
.path-group .meas-item .measurement-path-icon {
  width: 18px;
  height: 18px;
}
.path-group .meas-item .measurement-path-icon svg {
  width: 18px !important;
  height: 18px !important;
}
.path-group .meas-item .measurement-category {
  font-size: 8px;
}
.path-group .meas-item .point-count {
  min-width: 20px;
  height: 17px;
  min-height: 17px;
  padding: 0 5px;
  font-size: 9px;
}
.path-group .meas-item .len { font-size: 11px; }
.path-group .meas-item .len .unit { font-size: 9px; }
.path-group .meas-item .del {
  width: 18px;
  height: 17px;
  min-height: 17px;
  font-size: 12px;
}
.path-group .meas-item .run-details-action {
  width: 18px;
  height: 17px;
  min-height: 17px;
}
.path-group .meas-item .run-details-action svg {
  width: 11px;
  height: 11px;
}

.meas-list {
  flex: 1;
  min-width: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 10px 12px;
  scrollbar-width: thin;
  scrollbar-color: rgba(125, 138, 145, 0.34) transparent;
}
.meas-list::-webkit-scrollbar {
  width: 6px;
}
.meas-list::-webkit-scrollbar-track {
  background: transparent;
}
.meas-list::-webkit-scrollbar-thumb {
  background: rgba(125, 138, 145, 0.34);
  border-radius: 999px;
}
.meas-list::-webkit-scrollbar-thumb:hover {
  background: rgba(182, 255, 60, 0.38);
}
.meas-list:empty::before {
  content: 'Nothing measured yet.';
  display: block;
  color: var(--muted);
  text-align: center;
  font-size: 13px;
  padding: 24px 16px;
}
.meas-item {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 5px 6px;
  margin-bottom: 8px;
  transition: border-color .15s ease;
  position: relative;
  display: flex;
  align-items: center;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
}
.meas-item:hover { border-color: #38434a; }
.meas-item.selected { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent), 0 0 14px rgba(182,255,60,0.12); }
.meas-item.unscaled {
  border-color: rgba(255,177,60,0.34);
  background: rgba(255,177,60,0.045);
}
.meas-item.selected.unscaled {
  border-color: var(--accent);
  background: rgba(182,255,60,0.055);
  box-shadow: 0 0 0 1px var(--accent), 0 0 14px rgba(182,255,60,0.12);
}
.meas-item.visibility-hidden {
  opacity: 0.58;
  background: rgba(255,255,255,0.018);
  border-color: rgba(125,138,145,0.18);
}
.meas-item.visibility-hidden :is(.measurement-path-icon, .point-count, .len, .measurement-category) {
  filter: grayscale(1);
  color: #8f9aa0;
}
.meas-item .measurement-path-icon {
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  overflow: visible;
  color: var(--path-color, var(--accent));
}
.meas-item .measurement-path-icon svg {
  width: 20px !important;
  height: 20px !important;
  display: block;
  overflow: visible;
}
.meas-item .measurement-path-icon .tail {
  fill: none;
  stroke: var(--path-color, var(--accent));
  stroke-width: 8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.meas-item .measurement-path-icon .anchor-dot {
  fill: var(--panel);
  stroke: var(--path-color, var(--accent));
  stroke-width: 5;
}
.meas-item .row.head { cursor: pointer; }
.meas-item .row {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr) minmax(22px, auto) minmax(50px, auto) 18px 18px;
  align-items: center;
  gap: 5px;
  width: 100%;
  min-height: 30px;
  min-width: 0;
}
.meas-item .measurement-copy {
  min-width: 0;
  display: grid;
  gap: 1px;
}
.meas-item input.name {
  background: transparent;
  border: none;
  color: var(--text);
  font-family: inherit;
  font-size: 11px;
  font-weight: 500;
  min-width: 0;
  width: 100%;
  outline: none;
  padding: 0;
  height: 18px;
  line-height: 18px;
  border-bottom: 1px solid transparent;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.meas-item input.name { cursor: default; }
.meas-item input.name:not([readonly]) { cursor: text; }
.meas-item input.name:focus:not([readonly]) { border-bottom-color: var(--accent); }
.meas-item input.name:focus[readonly] { outline: none; }
.meas-item .measurement-category {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-family: 'JetBrains Mono', monospace;
  font-size: 8px;
  font-weight: 700;
  line-height: 1.1;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.meas-item .len {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  white-space: nowrap;
  max-width: 9ch;
  overflow: hidden;
  text-overflow: ellipsis;
  justify-self: end;
  text-align: right;
  line-height: 1;
  min-height: 18px;
  display: inline-flex;
  align-items: center;
  gap: 3px;
}
.meas-item .len:has(input.length.invalid) {
  max-width: 22ch;
  color: var(--danger);
}
.meas-item input.length {
  width: 6ch;
  min-width: 0;
  height: 18px;
  line-height: 18px;
  padding: 0;
  border: 0;
  border-bottom: 1px solid transparent;
  outline: none;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: inherit;
  text-align: right;
}
.meas-item input.length { cursor: default; }
.meas-item input.length:not([readonly]) { cursor: text; border-bottom-color: var(--accent); }
.meas-item input.length.invalid { border-bottom-color: var(--danger); color: var(--danger); }
.meas-item input.length:focus[readonly] { outline: none; }
.meas-item .len .unit { color: var(--muted); font-size: 9px; font-weight: 500; }
.meas-item .length-error {
  color: var(--danger);
  font-family: 'Sora', sans-serif;
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
}
.meas-item .length-error[hidden] { display: none; }
.meas-item.unscaled .len { color: var(--calib); max-width: none; }
.meas-item.unscaled input.length { width: 7ch; }
.meas-item .point-count {
  color: var(--muted);
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  min-width: 22px;
  min-height: 18px;
  padding: 0 5px;
  border: 1px solid var(--line);
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
}
.meas-item .del {
  background: transparent; border: none; color: var(--muted);
  cursor: pointer; padding: 0; border-radius: 4px;
  width: 18px;
  height: 18px;
  min-height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  line-height: 1;
  flex: 0 0 auto;
}
.meas-item .del:hover { color: var(--danger); background: rgba(255,91,91,0.1); }
.meas-item .run-details-action {
  position: relative;
  width: 18px;
  height: 18px;
  min-height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.meas-item .run-details-action:hover,
.meas-item .run-details-action:focus {
  color: var(--text);
  background: rgba(255,255,255,0.055);
  outline: none;
}
.meas-item .run-details-action.has-details {
  color: var(--accent);
}
.meas-item .run-details-action.has-details::after {
  content: "";
  position: absolute;
  top: 3px;
  right: 3px;
  width: 5px;
  height: 5px;
  border: 1px solid var(--panel-2);
  border-radius: 999px;
  background: var(--accent);
}
.meas-item .run-details-action svg {
  width: 11px;
  height: 11px;
}

.footer {
  padding: 12px 20px;
  border-top: 1px solid var(--line);
  display: flex; gap: 8px;
}
.select-wrap {
  position: relative;
  min-width: 0;
  flex: 1.1;
}
.select-wrap::after {
  content: '';
  position: absolute;
  right: 12px;
  top: 50%;
  width: 7px;
  height: 7px;
  border-right: 1.5px solid var(--muted);
  border-bottom: 1.5px solid var(--muted);
  transform: translateY(-65%) rotate(45deg);
  pointer-events: none;
}
.unit-select-native { display: none; }
.unit-select-button {
  width: 100%;
  min-height: 34px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  justify-content: flex-start;
  padding: 0 34px 0 12px;
}
.unit-select-button:hover { border-color: #38434a; background: #232a2e; }
.unit-select-button:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}
.footer .unit-select-button { justify-content: flex-start; }
.unit-menu {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(100% + 8px);
  display: none;
  padding: 6px;
  background: #111619;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 12px 28px rgba(0,0,0,0.45);
  z-index: 8;
}
.select-wrap.open .unit-menu {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  justify-items: stretch;
  gap: 2px;
}
.unit-option {
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
  min-height: 30px;
  border: 0;
  background: transparent;
  justify-content: center;
  color: var(--muted);
  padding: 0 10px;
  text-align: center;
}
.unit-option:hover { color: var(--text); background: var(--panel-2); }
.unit-option.active { color: var(--accent); background: var(--accent-soft); }
.footer button { flex: 1; justify-content: center; }

/* Modal */
.modal-bg {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center; justify-content: center;
  z-index: 100;
}
.modal-bg.show { display: flex; }
.modal {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 24px;
  width: 380px;
  max-width: calc(100vw - 32px);
  box-shadow: 0 20px 60px rgba(0,0,0,0.6);
}
.modal h3 { font-size: 18px; margin-bottom: 4px; font-weight: 600; }
.modal p { color: var(--muted); font-size: 13px; margin-bottom: 16px; }
.calib-verdict {
  margin: 0 0 4px;
  font-size: 12px;
  line-height: 1.4;
  color: var(--muted);
}
.calib-verdict[data-kind="good"] { color: var(--accent); }
.calib-verdict[data-kind="warn"] { color: #ffb13c; }
.calib-verdict[data-kind="bad"] { color: #ff5b5b; }
.modal p.modal-help {
  margin: -2px 0 0;
  color: var(--muted);
}
.modal .field { display: flex; gap: 8px; align-items: center; }
.modal .field[hidden] { display: none !important; }
.modal .field > label {
  color: var(--muted);
  flex: 0 0 64px;
  font-size: 12px;
}
.modal input[type=number], .modal input[type=text] {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 6px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 15px;
  outline: none;
}
.modal input:focus,
.modal select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}
.modal select {
  appearance: none;
  -webkit-appearance: none;
  background-color: var(--bg);
  background-image: url("data:image/svg+xml,%3Csvg width='12' height='12' viewBox='0 0 12 12' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M2.5 4.5 6 8l3.5-3.5' stroke='%237d8a91' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-position: calc(100% - 14px) 50%;
  background-repeat: no-repeat;
  background-size: 12px 12px;
  border: 1px solid var(--line);
  color: var(--text);
  min-width: 74px;
  padding: 10px 34px 10px 12px;
  border-radius: 6px;
  font-family: inherit;
  font-size: 14px;
  outline: none;
  cursor: pointer;
}
.modal input:disabled,
.modal select:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}
.modal .field.calibration-source-field {
  display: block;
  margin-top: 14px;
}
.calib-source-control {
  position: relative;
  width: 100%;
  min-width: 0;
}
.calib-source-display {
  width: 100%;
  min-height: 42px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 28px;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  padding: 8px 8px 8px 10px;
  text-align: left;
}
.calib-source-display::after {
  content: "";
  justify-self: center;
  width: 8px;
  height: 8px;
  border-right: 1.5px solid var(--muted);
  border-bottom: 1.5px solid var(--muted);
  transform: translateY(-2px) rotate(45deg);
}
.calib-source-display:hover,
.calib-source-display:focus {
  border-color: var(--accent);
  outline: none;
}
.calib-source-main,
.calib-source-option-main {
  width: 100%;
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(68px, 1fr) minmax(120px, 1fr) max-content;
  align-items: center;
  column-gap: 12px;
}
.calib-source-main:has(.calib-source-badge[hidden]),
.calib-source-option-main:has(.calib-source-badge[hidden]) {
  grid-template-columns: minmax(0, 1fr);
}
.calib-source-title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 700;
}
.calib-source-badge {
  justify-self: stretch;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel-2);
  color: var(--muted);
  padding: 2px 6px;
  font-size: 10px;
  font-weight: 650;
  line-height: 1.2;
  text-align: center;
}
.calib-source-badge:last-child {
  justify-self: end;
}
.calib-source-options {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 5px);
  z-index: 7;
  display: none;
  max-height: 250px;
  overflow-y: auto;
  overflow-x: hidden;
  gap: 2px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #0b0d0e;
  box-shadow: 0 16px 34px rgba(0,0,0,0.45);
  scrollbar-width: thin;
  scrollbar-color: rgba(125, 138, 145, 0.34) transparent;
}
.calib-source-control.open .calib-source-options { display: grid; }
.calib-source-options::-webkit-scrollbar { width: 6px; }
.calib-source-options::-webkit-scrollbar-track { background: transparent; }
.calib-source-options::-webkit-scrollbar-thumb {
  background: rgba(125, 138, 145, 0.34);
  border-radius: 999px;
}
.calib-source-option {
  width: 100%;
  min-height: 38px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--text);
  padding: 8px;
  text-align: left;
}
.calib-source-option:hover,
.calib-source-option:focus {
  background: #222a2e;
  outline: none;
}
.calib-source-option.active {
  background: rgba(182,255,60,0.10);
  color: var(--accent);
}
.calib-source-helper {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.3;
  margin-top: 6px;
}
.calibration-apply-field { margin-top: 14px; }
.calib-scope-combo {
  position: relative;
  display: grid;
  flex: 1;
  grid-template-columns: minmax(0, 1fr) 38px;
  min-width: 0;
}
.calib-scope-display,
.modal input[type=text].calib-scope-range {
  grid-column: 1 / 3;
  grid-row: 1;
  width: 100%;
  min-width: 0;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  padding: 10px 46px 10px 12px;
  outline: none;
}
.calib-scope-display {
  overflow: hidden;
  font-size: 13px;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.modal input[type=text].calib-scope-range {
  display: none;
  font-size: 15px;
}
.calib-scope-combo.custom .calib-scope-display { display: none; }
.modal .calib-scope-combo.custom input[type=text].calib-scope-range { display: block; }
.calib-scope-display:focus,
.modal input[type=text].calib-scope-range:focus {
  border-color: var(--accent);
}
.calib-scope-menu {
  grid-column: 2;
  grid-row: 1;
  z-index: 2;
  min-width: 38px;
  min-height: 42px;
  border: 1px solid transparent;
  border-left-color: var(--line);
  border-radius: 0 6px 6px 0;
  background: transparent;
  color: var(--muted);
  padding: 0;
  justify-content: center;
}
.calib-scope-menu::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: translateY(-2px) rotate(45deg);
}
.calib-scope-menu:hover,
.calib-scope-menu:focus {
  background: rgba(255,255,255,0.04);
  color: var(--text);
  outline: none;
}
.calib-scope-options {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 6px);
  z-index: 6;
  display: none;
  gap: 2px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0b0d0e;
  box-shadow: 0 16px 34px rgba(0,0,0,0.45);
}
.calib-scope-combo.open .calib-scope-options { display: grid; }
.calib-scope-option {
  min-height: 34px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--muted);
  padding: 0 10px;
  text-align: left;
}
.calib-scope-option:hover,
.calib-scope-option:focus {
  background: #222a2e;
  color: var(--text);
  outline: none;
}
.calib-scope-option.active {
  background: rgba(182,255,60,0.10);
  color: var(--accent);
}
.path-settings-modal {
  width: 520px;
  max-height: calc(100vh - 36px);
  overflow: auto;
  padding: 20px;
  scrollbar-width: thin;
  scrollbar-color: rgba(125, 138, 145, 0.34) transparent;
}
.path-settings-modal::-webkit-scrollbar { width: 6px; }
.path-settings-modal::-webkit-scrollbar-track { background: transparent; }
.path-settings-modal::-webkit-scrollbar-thumb {
  background: rgba(125, 138, 145, 0.34);
  border-radius: 999px;
}
.path-settings-preview {
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
  border: 1px solid rgba(125,138,145,0.18);
  border-radius: 8px;
  background: #111619;
  overflow: hidden;
}
.path-settings-preview svg {
  width: 132px !important;
  height: 76px !important;
}
.path-settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.path-settings-field {
  min-width: 0;
  display: grid;
  gap: 5px;
}
.path-settings-field[hidden] { display: none !important; }
.path-settings-field-full {
  grid-column: 1 / -1;
}
.path-settings-field > span,
.path-settings-section h4 {
  color: var(--muted);
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}
.path-settings-field input[type=text],
.path-settings-field select {
  width: 100%;
  min-width: 0;
  min-height: 36px;
  font-size: 13px;
}
.path-settings-field input[type=color] {
  width: 100%;
  min-width: 0;
  min-height: 36px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg);
  cursor: pointer;
}
.path-settings-field input[type=color]:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}
.path-settings-sections {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}
.path-settings-section {
  display: grid;
  gap: 9px;
  padding: 10px;
  border: 1px solid rgba(125,138,145,0.18);
  border-radius: 8px;
  background: rgba(255,255,255,0.018);
}
.path-settings-section h4 {
  margin: 0;
}
.path-settings-check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 28px;
  color: var(--text);
  font-size: 12px;
}
.path-settings-check input {
  width: 14px;
  height: 14px;
  accent-color: var(--accent);
}
.run-details-modal {
  width: 560px;
  max-height: calc(100vh - 32px);
  overflow: auto;
  padding: 20px;
  scrollbar-width: thin;
  scrollbar-color: rgba(125, 138, 145, 0.34) transparent;
}
.run-details-modal::-webkit-scrollbar { width: 6px; }
.run-details-modal::-webkit-scrollbar-track { background: transparent; }
.run-details-modal::-webkit-scrollbar-thumb {
  background: rgba(125, 138, 145, 0.34);
  border-radius: 999px;
}
.run-details-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
}
.run-details-close {
  width: 30px;
  min-width: 30px;
  min-height: 30px;
  justify-content: center;
  padding: 0;
  border-color: rgba(125,138,145,0.2);
  background: transparent;
  color: var(--muted);
}
.run-details-close:hover,
.run-details-close:focus {
  color: var(--text);
  border-color: rgba(125,138,145,0.36);
  background: rgba(255,255,255,0.04);
  outline: none;
}
.run-details-field {
  display: grid;
  gap: 6px;
}
.run-details-field > span,
.run-details-media-section h4 {
  color: var(--muted);
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}
.run-details-field textarea {
  width: 100%;
  min-width: 0;
  min-height: 116px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  padding: 10px 12px;
  font-family: inherit;
  font-size: 13px;
  line-height: 1.45;
  outline: none;
}
.run-details-field textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}
.run-details-upload-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}
.run-details-upload-row button {
  min-height: 34px;
  justify-content: center;
  gap: 7px;
}
.run-details-media-section {
  display: grid;
  gap: 7px;
  margin-top: 14px;
}
.run-details-media-section h4 {
  margin: 0;
}
.run-details-media-list {
  display: grid;
  gap: 7px;
  min-width: 0;
}
.run-details-empty {
  margin: 0;
  padding: 10px;
  border: 1px dashed rgba(125,138,145,0.24);
  border-radius: 7px;
  color: var(--muted);
  background: rgba(255,255,255,0.018);
}
.run-details-media-item {
  min-width: 0;
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border: 1px solid rgba(125,138,145,0.18);
  border-radius: 8px;
  background: rgba(255,255,255,0.02);
}
.run-details-preview {
  width: 58px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border: 1px solid rgba(125,138,145,0.22);
  border-radius: 6px;
  background: #0b0d0e;
  color: var(--muted);
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  font-weight: 700;
}
.run-details-preview img,
.run-details-preview video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.run-details-media-copy {
  min-width: 0;
  display: grid;
  gap: 2px;
}
.run-details-media-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
}
.run-details-media-meta {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
}
.run-details-remove {
  min-height: 28px;
  padding: 0 9px;
  color: var(--muted);
}
.run-details-remove:hover,
.run-details-remove:focus {
  color: var(--danger);
  border-color: rgba(255,91,91,0.28);
  background: rgba(255,91,91,0.08);
  outline: none;
}
.modal .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }
.unmerge-actions {
  display: grid;
  gap: 8px;
}
.unmerge-actions button {
  justify-content: center;
}
.modal button.primary { background: var(--accent); color: #0b0d0e; border-color: var(--accent); font-weight: 600; }
.modal button.primary:hover { filter: brightness(1.1); }

@media (max-width: 520px) {
  .run-details-modal {
    width: calc(100vw - 20px);
    max-height: calc(100vh - 20px);
    padding: 16px;
  }
  .run-details-media-item {
    grid-template-columns: 48px minmax(0, 1fr);
  }
  .run-details-preview {
    width: 48px;
    height: 38px;
  }
  .run-details-remove {
    grid-column: 1 / -1;
    justify-content: center;
  }
}

/* SVG icons sized inline */
svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; flex: 0 0 auto; }
.control-btn svg, .fit-control svg { width: 13px; height: 13px; }
