/* JCOM Wireframe Lab - ui.css
   Implements V2 house token integration, custom ASSET picker, dense 22px slider rows,
   responsive layout modes (Wide / Stacked / No-Room), left node sidebar and bottom drawer.
*/

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 13px;
  background-color: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  margin: 0;
  padding: 0;
  background-color: var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.4;
  overflow-x: hidden;
}

/* Touch action */
#viewport-canvas {
  touch-action: none;
}

button, select, input, a {
  touch-action: manipulation;
}

/* Focus visibility per house standards */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.panel-scroll :focus-visible,
.c-sheet :focus-visible {
  outline-offset: -2px;
}

/* Typography utilities */
.mono {
  font-family: var(--mono);
}

.condensed {
  font-family: var(--font-cond);
  font-stretch: condensed;
}

.muted {
  color: var(--muted);
}

.accent-text {
  color: var(--accent);
}

/* =========================================================================
   BUTTONS & BASE CONTROLS
   ========================================================================= */
.c-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--gap-1);
  height: var(--ctl);
  padding: 0 var(--gap-3);
  font-family: var(--font);
  font-size: var(--fs-body);
  font-weight: 500;
  color: var(--text);
  background: transparent;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-ctl);
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
  transition: background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}

.c-btn:hover {
  background: var(--hover);
  border-color: var(--line-strong);
  color: var(--text);
}

.c-btn:active {
  transform: scale(0.985);
}

.c-btn.c-pri {
  border-color: var(--accent);
  color: var(--accent);
  background: transparent;
}

.c-btn.c-pri:hover {
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  color: var(--text);
}

.c-btn.c-ghost {
  border-color: transparent;
  color: var(--muted);
}

.c-btn.c-ghost:hover {
  border-color: transparent;
  color: var(--text);
  background: var(--hover);
}

.c-btn.c-link {
  border-color: transparent;
  color: var(--muted);
  padding: 0 var(--gap-1);
  height: auto;
  font-size: var(--fs-sub);
}

.c-btn.c-link:hover {
  color: var(--text);
  background: transparent;
  text-decoration: underline;
}

.c-btn.c-sec {
  border: 1px solid var(--line-strong);
  color: var(--text);
  background: transparent;
  height: var(--ctl);
  font-size: 12px;
}

.c-btn.c-sec:hover {
  background: var(--hover);
  color: var(--text);
}

.c-btn.c-compact {
  height: 22px;
  font-size: 11px;
  padding: 0 8px;
}

.c-close-btn {
  width: 20px;
  height: 20px;
}

.c-compact-link {
  padding: 0;
}

.help-glyph {
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
}

.c-banner-btn {
  height: 24px;
  padding: 0 8px;
  font-size: 11px;
}

.c-report-btn {
  margin-top: var(--gap-3);
  width: 100%;
  border: 1px solid var(--line-strong);
}

.c-ico-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--ctl);
  height: var(--ctl);
  padding: 0;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--r-ctl);
  color: var(--muted);
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}

.c-ico-btn:hover {
  background: var(--hover);
  color: var(--text);
}

.c-ico-btn[aria-pressed="true"],
.c-ico-btn.active {
  border-color: var(--accent);
  color: var(--accent);
}

.c-ico-btn svg {
  width: 16px;
  height: 16px;
  stroke-width: 1.5;
  stroke: currentColor;
  fill: none;
  pointer-events: none;
}

/* Segmented pill control */
.c-seg {
  display: inline-flex;
  align-items: center;
  background: var(--field);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-ctl);
  padding: 1px;
  gap: 1px;
}

.c-seg button {
  height: calc(var(--ctl) - 4px);
  padding: 0 var(--gap-2);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--r-ctl);
  font-family: var(--font);
  font-size: var(--fs-sub);
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
  transition: color var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}

.c-seg button:hover {
  color: var(--text);
}

.c-seg button[aria-pressed="true"],
.c-seg button.active {
  background: var(--accent);
  border: 1px solid var(--accent);
  color: var(--of-paper);
  font-weight: 600;
}

/* =========================================================================
   1. CLEARANCE BAND (24px)
   ========================================================================= */
#clearance-band {
  height: var(--band-h);
  background-color: var(--band);
  border-bottom: 1px solid var(--band-line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--gap-4);
  font-family: var(--mono);
  font-size: var(--fs-label);
  color: var(--band-text);
  user-select: none;
}

#clearance-band .band-side {
  opacity: 0.85;
  letter-spacing: 0.05em;
}

#clearance-band .band-center {
  font-weight: 700;
  letter-spacing: 0.14em;
  text-align: center;
}

/* =========================================================================
   2. HEADER (72px)
   ========================================================================= */
#main-header {
  min-height: var(--head-h);
  background-color: var(--bg);
  border-bottom: 1px solid var(--line);
  padding: 0 var(--gap-4);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.header-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}

.header-left {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
}

.directorate-line {
  font-family: var(--mono);
  font-size: var(--fs-label);
  color: var(--muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.brand-title {
  font-family: var(--font-cond);
  font-size: var(--fs-title);
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  line-height: 1;
  color: var(--text);
}

.brand-title .slash {
  color: var(--muted);
  font-weight: 300;
  padding: 0 2px;
}

.header-bottom-bar {
  display: flex;
  align-items: center;
  justify-content: center;
}

@media (min-width: 850px) {
  .header-bottom-bar {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
  }

  .phone-only-icon {
    display: none;
  }
}

/* Custom ASSET Picker (V2.2) */
.asset-select-wrapper {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  position: relative;
}

.asset-select-label {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  line-height: 1;
}

.custom-asset-picker {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.asset-trigger-btn {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
  background: transparent;
  border: none;
  padding: 0;
  margin: 0;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  position: relative;
  letter-spacing: 0.04em;
  text-decoration: none;
}

.asset-trigger-btn:hover {
  text-decoration: underline;
  text-decoration-color: var(--line-strong);
}

.asset-trigger-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: var(--r-ctl);
}

@media (pointer: coarse) {
  .asset-trigger-btn::after {
    content: "";
    position: absolute;
    inset: -14px -8px;
  }
}

.chevron-glyph {
  display: inline-block;
  transition: transform var(--dur-fast) var(--ease);
}

.asset-trigger-btn[aria-expanded="true"] .chevron-glyph {
  transform: rotate(180deg);
}

.asset-listbox {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 220px;
  background: var(--glass-strong);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--line);
  border-radius: var(--overlay-radius, var(--r-ov));
  padding: 4px 0;
  margin: 0;
  list-style: none;
  z-index: 100;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
}

.asset-listbox.open {
  display: block;
}

.asset-option {
  height: 24px;
  padding: 0 12px;
  display: flex;
  align-items: center;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text);
  cursor: pointer;
  user-select: none;
  border-left: 2px solid transparent;
  transition: background var(--dur-fast) var(--ease);
}

@media (pointer: coarse) {
  .asset-option {
    height: 44px;
    padding: 0 16px;
    font-size: 12px;
  }
}

.asset-option:hover,
.asset-option.focused {
  background: var(--hover);
}

.asset-option.selected {
  border-left-color: var(--accent);
  font-weight: 700;
}

.asset-option.disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

.header-right-tools {
  display: flex;
  align-items: center;
  gap: var(--gap-3);
}

.header-doc-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 1px;
  font-family: var(--mono);
  font-size: var(--fs-label);
  color: var(--muted);
  letter-spacing: 0.06em;
}

/* =========================================================================
   3. CONFIGURATION BAR (56px)
   ========================================================================= */
#config-bar {
  min-height: var(--cfg-h);
  background-color: var(--panel);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 0 var(--gap-4);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--gap-3);
  user-select: none;
}

.config-bar-left {
  display: flex;
  align-items: center;
  gap: var(--gap-3);
  flex-wrap: wrap;
}

.sidebar-toggle-btn {
  display: none;
}

.config-label {
  font-family: var(--mono);
  font-size: var(--fs-label);
  color: var(--muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.state-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 62px;
  height: calc(var(--ctl) - 8px);
  padding: 0 var(--gap-2);
  border: 1px solid var(--line);
  border-radius: var(--r-ctl);
  font-family: var(--mono);
  font-size: var(--fs-sub);
  color: var(--text);
  background: var(--field);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.config-bar-right {
  display: flex;
  align-items: center;
  gap: var(--gap-3);
}

/* =========================================================================
   4. VIEWPORT & OVERLAYS
   ========================================================================= */
#viewport-region {
  position: relative;
  width: 100%;
  height: 100%;
  background-color: var(--bg);
}

#viewport-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.viewport-overlay-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.v-glass {
  background: var(--glass);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--line);
  border-radius: var(--r-ov);
  pointer-events: auto;
}

/* Upper Left: Asset Card */
.overlay-asset-card {
  position: absolute;
  top: 12px;
  left: 12px;
  max-width: 260px;
  padding: var(--gap-2) var(--gap-3);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.overlay-asset-card .sub-tag {
  font-family: var(--mono);
  font-size: var(--fs-label);
  color: var(--muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.overlay-asset-card .asset-name {
  font-family: var(--font-cond);
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.overlay-asset-card .spec-rows {
  margin-top: 2px;
  display: flex;
  flex-direction: column;
  gap: 1px;
  font-family: var(--mono);
  font-size: var(--fs-label);
  color: var(--muted);
  letter-spacing: 0.04em;
}

/* Upper Center-Left: JCOM Stamp */
.overlay-stamp {
  position: absolute;
  top: 108px;
  left: 12px;
  padding: 4px 8px;
  border: 1px solid var(--band-line);
  background: transparent;
  color: var(--band-text);
  opacity: 0.55;
  font-family: var(--mono);
  font-size: var(--fs-label);
  letter-spacing: 0.12em;
  line-height: 1.35;
  pointer-events: none;
  user-select: none;
}

/* Upper Right: Counts Block & Display Mode */
.overlay-top-right {
  position: absolute;
  top: 12px;
  right: 12px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: var(--gap-2);
}

.counts-card {
  padding: var(--gap-2) var(--gap-3);
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  font-family: var(--mono);
}

.system-counts {
  font-size: var(--fs-label);
  color: var(--muted);
  letter-spacing: 0.06em;
}

.tri-wrapper {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.tri-val {
  font-size: var(--fs-count);
  font-weight: 700;
  color: var(--text);
}

.tri-lbl {
  font-size: var(--fs-label);
  color: var(--muted);
  letter-spacing: 0.08em;
}

.display-mode-bar {
  padding: 2px;
}

/* Lower Left: Selection Card & Axes */
.overlay-bottom-left {
  position: absolute;
  bottom: 12px;
  left: 12px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--gap-2);
}

.selection-card {
  display: none;
  flex-direction: column;
  gap: 3px;
  padding: var(--gap-2) var(--gap-3);
  min-width: 190px;
  max-width: 260px;
}

.selection-card.visible {
  display: flex;
}

.selection-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.selection-name {
  font-family: var(--font-cond);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text);
}

.selection-driven {
  font-family: var(--mono);
  font-size: var(--fs-sub);
  color: var(--muted);
}

.selection-actions {
  margin-top: 2px;
}

.axes-widget {
  width: 64px;
  height: 64px;
  pointer-events: none;
}

.axes-widget canvas {
  width: 100%;
  height: 100%;
}

/* Lower Center: View Caption */
.overlay-bottom-center {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--mono);
  font-size: var(--fs-label);
  color: var(--muted);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  pointer-events: none;
  user-select: none;
  white-space: nowrap;
}

/* Lower Right: Gesture hint & Camera Toolbar */
.overlay-bottom-right {
  position: absolute;
  bottom: 12px;
  right: 12px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: var(--gap-1);
}

.gesture-hint {
  font-family: var(--mono);
  font-size: var(--fs-label);
  color: var(--muted);
  letter-spacing: 0.05em;
  padding: 0 var(--gap-1);
  pointer-events: none;
  user-select: none;
}

.camera-toolbar {
  padding: 2px;
  display: flex;
  align-items: center;
  gap: 2px;
}

/* Assembly Labels (3D projected) */
#labels-container {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.assembly-tag {
  position: absolute;
  transform: translate(-50%, -100%);
  pointer-events: auto;
  font-family: var(--mono);
  font-size: var(--fs-label);
  padding: 2px 6px;
  background: var(--glass-strong);
  border: 1px solid var(--line);
  border-radius: var(--r-ctl);
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
  transition: border-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}

.assembly-tag:hover {
  border-color: var(--line-strong);
}

.assembly-tag.active {
  border-color: var(--accent);
  color: var(--accent);
}

/* Touch hint popup */
.touch-hint-popup {
  position: absolute;
  bottom: 60px;
  left: 50%;
  transform: translateX(-50%);
  max-width: calc(100% - 32px);
  padding: var(--gap-2) var(--gap-3);
  font-size: var(--fs-sub);
  color: var(--text);
  line-height: 1.35;
  text-align: center;
  display: none;
  align-items: center;
  gap: var(--gap-2);
  z-index: 30;
}

.touch-hint-popup.visible {
  display: flex;
}

/* In-viewport loader */
.in-viewport-loader {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(300px, calc(100% - 32px));
  padding: var(--gap-3) var(--gap-4);
  display: flex;
  flex-direction: column;
  gap: var(--gap-2);
  z-index: 25;
}

.loader-status {
  font-family: var(--mono);
  font-size: var(--fs-sub);
  color: var(--text);
}

.determinate-bar {
  width: 100%;
  height: 2px;
  background: var(--line);
  position: relative;
  overflow: hidden;
}

.determinate-fill {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: 0%;
  background: var(--accent);
  transition: width var(--dur-fast) var(--ease);
}

/* Highlight off-banner */
.highlight-banner {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  padding: var(--gap-2) var(--gap-3);
  display: none;
  align-items: center;
  gap: var(--gap-3);
  z-index: 20;
  font-family: var(--mono);
  font-size: var(--fs-sub);
  border: 1px solid var(--hl-fail);
}

.highlight-banner.visible {
  display: flex;
}

.highlight-banner.warn {
  border-color: var(--warn);
}

.highlight-banner.fail {
  border-color: var(--hl-fail);
}

/* =========================================================================
   5. CONTROL PANEL & CONTROLS ROOT
   ========================================================================= */
.controls-root {
  display: flex;
  flex-direction: column;
  height: 100%;
  width: 100%;
}

.panel-tab-bar {
  display: flex;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  min-height: 38px;
}

.panel-tab {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--gap-1);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  font-family: var(--mono);
  font-size: var(--fs-label);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  padding: 0 var(--gap-2);
  transition: color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}

.panel-tab:hover {
  color: var(--text);
}

.panel-tab[aria-selected="true"],
.panel-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 700;
}

.panel-tab-count {
  font-size: 9px;
  padding: 1px 4px;
  border-radius: var(--r-ctl);
  background: var(--field);
  border: 1px solid var(--line);
}

.panel-tab-count.fail {
  color: var(--fail);
  border-color: color-mix(in srgb, var(--fail) 40%, transparent);
}

.panel-tab-count.pass {
  color: var(--pass);
  border-color: color-mix(in srgb, var(--pass) 40%, transparent);
}

.panel-scroll {
  flex: 1 1 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.tab-pane {
  display: none;
  flex-direction: column;
  gap: 8px;
}

.tab-pane.active {
  display: flex;
}

/* =========================================================================
   6. DENSE 22PX SLIDER ROWS (V2.3)
   ========================================================================= */
.sliders-container {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.slider-row {
  display: grid;
  grid-template-columns: 18px minmax(84px, 1fr) minmax(96px, 1.4fr) 40px;
  height: 22px;
  gap: 6px;
  align-items: center;
  border-left: 2px solid transparent;
  padding-left: 4px;
  transition: border-color var(--dur-fast) var(--ease);
}

.slider-row.selected {
  border-left-color: var(--accent);
}

.slider-idx {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--muted);
  text-align: left;
}

.slider-name {
  font-family: var(--font);
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
}

.slider-name.sub {
  font-size: 11px;
  font-weight: 400;
  padding-left: 12px;
}

.slider-val {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

/* Range input structure */
.range-wrap {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
  height: 22px;
}

.range-wrap input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 3px;
  background: var(--line-strong);
  outline: none;
  margin: 0;
  cursor: pointer;
  position: relative;
  border-radius: 1.5px;
}

.range-wrap input[type="range"]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.range-wrap input[type="range"]::-webkit-slider-runnable-track {
  height: 3px;
  background: linear-gradient(to right,
    var(--line-strong) 0%,
    var(--line-strong) var(--track-fill-start, 0%),
    var(--accent) var(--track-fill-start, 0%),
    var(--accent) var(--track-fill-end, var(--track-fill, 0%)),
    var(--line-strong) var(--track-fill-end, var(--track-fill, 0%)),
    var(--line-strong) 100%);
  border-radius: 1.5px;
}

.range-wrap input[type="range"]::-moz-range-track {
  height: 3px;
  background: linear-gradient(to right,
    var(--line-strong) 0%,
    var(--line-strong) var(--track-fill-start, 0%),
    var(--accent) var(--track-fill-start, 0%),
    var(--accent) var(--track-fill-end, var(--track-fill, 0%)),
    var(--line-strong) var(--track-fill-end, var(--track-fill, 0%)),
    var(--line-strong) 100%);
  border-radius: 1.5px;
}

.range-wrap input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 10px;
  height: 10px;
  border-radius: var(--r-ctl);
  background: var(--accent);
  cursor: pointer;
  margin-top: -3.5px;
  border: none;
}

.range-wrap input[type="range"]::-moz-range-thumb {
  width: 10px;
  height: 10px;
  border-radius: var(--r-ctl);
  background: var(--accent);
  cursor: pointer;
  border: none;
}

/* Signed center tick */
.range-wrap.signed::before {
  content: "";
  position: absolute;
  top: calc(50% - 3px);
  left: 50%;
  width: 1px;
  height: 6px;
  background: var(--line-strong);
  pointer-events: none;
  z-index: 1;
}

@media (pointer: coarse) {
  .slider-row {
    height: 44px;
  }
  .range-wrap {
    height: 44px;
  }
  .range-wrap input[type="range"] {
    height: 3px;
  }
  .range-wrap input[type="range"]::-webkit-slider-thumb {
    width: 16px;
    height: 16px;
    margin-top: -6.5px;
  }
  .range-wrap input[type="range"]::-moz-range-thumb {
    width: 16px;
    height: 16px;
  }
}

/* Group 05 Flight Controls Accordion */
.section-group {
  display: flex;
  flex-direction: column;
}

.section-group-header {
  height: 20px;
  padding: 0 4px;
  display: flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: none;
  border-top: 1px solid var(--line);
  cursor: pointer;
  margin-top: 4px;
  margin-bottom: 2px;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.section-group-header:hover {
  color: var(--text);
}

.section-group-title {
  flex: 1;
  text-align: left;
  font-weight: 700;
}

.section-chevron {
  font-size: 11px;
  transition: transform var(--dur-fast) var(--ease);
}

.section-group-header[aria-expanded="false"] .section-chevron {
  transform: rotate(-90deg);
}

.section-group-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.section-group-body:not(.open) {
  display: none;
}

/* =========================================================================
   7. PLAYBACK DOCK (Dense single row)
   ========================================================================= */
.playback-dock {
  background: var(--panel);
  border-top: 1px solid var(--line);
  padding: 6px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.playback-dense-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 24px;
  gap: 8px;
}

.playback-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.playback-actions .c-btn {
  height: 22px;
  font-size: 11px;
  padding: 0 8px;
}

.playback-meta {
  display: flex;
  align-items: center;
  gap: 4px;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--muted);
}

.playback-meta #playback-status-text {
  font-weight: 700;
  color: var(--text);
}

.playback-progress-wrap {
  width: 100%;
  height: 2px;
  background: var(--line);
  position: relative;
  overflow: hidden;
}

.playback-progress-bar {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: 0%;
  background: var(--accent);
  transition: width 100ms linear;
}

/* =========================================================================
   8. NODE SIDEBAR, BOTTOM DRAWER & THIN BOTTOM BAR (V2.4)
   ========================================================================= */
/* Node Sidebar (Left slide-in) */
.node-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: min(320px, 40vw);
  background: var(--glass);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-right: 1px solid var(--line);
  z-index: 80;
  display: flex;
  flex-direction: column;
  transform: translateX(-100%);
  transition: transform var(--dur-sheet) var(--ease-sheet);
  box-shadow: 4px 0 24px rgba(0, 0, 0, 0.4);
}

.node-sidebar.open,
.node-sidebar[aria-hidden="false"] {
  transform: translateX(0);
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 40px;
  padding: 0 12px;
  border-bottom: 1px solid var(--line);
}

.sidebar-title {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--text);
}

.node-sidebar-content {
  flex: 1 1 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

/* Bottom Drawer */
.bottom-drawer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: 52dvh;
  background: var(--panel);
  border-top: 1px solid var(--line);
  border-radius: var(--overlay-radius, 8px) var(--overlay-radius, 8px) 0 0;
  z-index: 80;
  display: flex;
  flex-direction: column;
  transform: translateY(100%);
  transition: transform var(--dur-sheet) var(--ease-sheet);
  box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.4);
}

.bottom-drawer.open,
.bottom-drawer[aria-hidden="false"] {
  transform: translateY(0);
}

.drawer-grab-handle {
  width: 32px;
  height: 4px;
  background: var(--line-strong);
  border-radius: 2px;
  margin: 8px auto 4px auto;
  flex-shrink: 0;
}

.bottom-drawer-content {
  flex: 1 1 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

/* Thin Bottom Bar */
.no-room-bottom-bar {
  display: none;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: calc(36px + env(safe-area-inset-bottom, 0px));
  padding: 0 12px env(safe-area-inset-bottom, 0px) 12px;
  background: var(--glass-strong);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border-top: 1px solid var(--line);
  z-index: 60;
  align-items: center;
  justify-content: space-between;
}

.nr-playback {
  display: flex;
  align-items: center;
  gap: 8px;
}

.nr-playback .c-btn {
  height: 24px;
  font-size: 11px;
  padding: 0 8px;
}

.nr-status {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--muted);
}

.drawer-trigger-btn {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  color: var(--text);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: var(--r-ctl);
  padding: 2px 8px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.drawer-trigger-btn:hover {
  background: var(--hover);
  border-color: var(--line-strong);
}

/* Scrim */
.panel-scrim {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 75;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur-fast) var(--ease);
}

.panel-scrim.visible {
  opacity: 1;
  pointer-events: auto;
}

/* =========================================================================
   9. FOOTER (32px)
   ========================================================================= */
#main-footer {
  height: var(--foot-h);
  background-color: var(--bg);
  border-top: 1px solid var(--line);
  padding: 0 var(--gap-4);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: var(--mono);
  font-size: var(--fs-label);
  color: var(--muted);
  user-select: none;
}

.phone-footer-text {
  display: none;
}

/* =========================================================================
   10. VALIDATE PANE COMPONENTS
   ========================================================================= */
.validate-verdict-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--gap-2) var(--gap-3);
  background: var(--field);
  border: 1px solid var(--line);
  border-radius: var(--r-ctl);
}

.verdict-left {
  display: flex;
  align-items: center;
  gap: var(--gap-2);
}

.verdict-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
}

.verdict-dot.pass { background: var(--pass); }
.verdict-dot.warn { background: var(--warn); }
.verdict-dot.fail { background: var(--fail); }

.verdict-word {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.verdict-word.pass { color: var(--pass); }
.verdict-word.warn { color: var(--warn); }
.verdict-word.fail { color: var(--fail); }

.verdict-meta {
  font-family: var(--mono);
  font-size: var(--fs-label);
  color: var(--muted);
}

.validate-counts-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--gap-1);
}

.v-count-item {
  display: flex;
  flex-direction: column;
  padding: var(--gap-1) var(--gap-2);
  background: var(--field);
  border: 1px solid var(--line);
  border-radius: var(--r-ctl);
}

.v-count-lbl {
  font-family: var(--mono);
  font-size: 9px;
  color: var(--muted);
  text-transform: uppercase;
}

.v-count-val {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
}

.validate-section-title {
  font-family: var(--mono);
  font-size: var(--fs-label);
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-top: 4px;
}

.check-rows-container {
  display: flex;
  flex-direction: column;
}

.check-row {
  display: flex;
  align-items: flex-start;
  gap: var(--gap-2);
  padding: 6px 4px;
  border-bottom: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 11px;
}

.check-row.clickable {
  cursor: pointer;
}

.check-row.clickable:hover {
  background: var(--hover);
}

.check-status-col {
  width: 44px;
  font-weight: 700;
  flex-shrink: 0;
}

.check-status-col.pass { color: var(--pass); }
.check-status-col.warn { color: var(--warn); }
.check-status-col.fail { color: var(--fail); }

.check-content-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.check-id {
  color: var(--text);
  font-weight: 600;
}

.check-msg {
  color: var(--muted);
  font-size: 10px;
}

/* =========================================================================
   11. DIALOGS & SHEETS
   ========================================================================= */
dialog.c-sheet {
  position: fixed;
  inset: 0;
  margin: auto;
  border: 1px solid var(--line);
  border-radius: var(--overlay-radius, var(--r-ov));
  background: var(--panel);
  color: var(--text);
  max-width: 520px;
  width: calc(100% - 32px);
  max-height: 80dvh;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
  z-index: 100;
}

dialog.c-sheet::backdrop {
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(2px);
}

.sheet-inner {
  display: flex;
  flex-direction: column;
  max-height: 80dvh;
}

.sheet-grab-handle {
  display: none;
}

.sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--gap-3) var(--gap-4);
  border-bottom: 1px solid var(--line);
}

.sheet-title-wrap {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sheet-title {
  font-family: var(--font-cond);
  font-size: 16px;
  font-weight: 700;
  text-transform: uppercase;
}

.sheet-subtitle {
  font-family: var(--mono);
  font-size: var(--fs-label);
  color: var(--muted);
}

.sheet-body {
  overflow-y: auto;
  padding: var(--gap-4);
  display: flex;
  flex-direction: column;
  gap: var(--gap-4);
}

.sheet-section {
  display: flex;
  flex-direction: column;
  gap: var(--gap-1);
}

.sheet-section-label {
  font-family: var(--mono);
  font-size: var(--fs-label);
  color: var(--muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.sheet-section-content {
  font-size: var(--fs-body);
  line-height: 1.5;
  color: var(--text);
}

.shortcut-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 16px;
  align-items: center;
  font-family: var(--mono);
  font-size: 11px;
}

.shortcut-grid kbd {
  background: var(--field);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-ctl);
  padding: 1px 6px;
  color: var(--accent);
}

.ref-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 0;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  text-decoration: none;
  font-size: 11.5px;
}

.ref-row:hover {
  color: var(--text);
  text-decoration: underline;
}

.export-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--gap-3);
  padding: var(--gap-2) 0;
  border-bottom: 1px solid var(--line);
}

.export-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.export-info-title {
  font-family: var(--font-cond);
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}

.export-info-desc {
  font-size: 11px;
  color: var(--muted);
}

.sheet-footnote {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--muted);
  margin-top: 4px;
}

/* =========================================================================
   12. LAYOUT MODES (V2.4: Wide / Stacked / No-Room)
   ========================================================================= */

/* Default / Wide Layout (>= 850px and >= 640px) */
@media (min-width: 850px) and (min-height: 640px) {
  body {
    display: grid;
    grid-template-rows: var(--band-h) var(--head-h) var(--cfg-h) minmax(0, 1fr) var(--foot-h);
    grid-template-columns: minmax(0, 1fr) var(--panel-w);
    height: 100dvh;
    overflow: hidden;
  }

  #clearance-band { grid-column: 1 / -1; }
  #main-header { grid-column: 1 / -1; }
  #config-bar { grid-column: 1 / -1; }

  #viewport-region {
    grid-column: 1 / 2;
    grid-row: 4 / 5;
    position: relative;
    overflow: hidden;
  }

  #control-panel {
    grid-column: 2 / 3;
    grid-row: 4 / 5;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    background: var(--panel);
    border-left: 1px solid var(--line);
  }

  #main-footer { grid-column: 1 / -1; }
  .no-room-bottom-bar { display: none !important; }
  .sidebar-toggle-btn { display: none; }
}

/* Stacked Layout (e.g. tablet portrait <= 849.98px and >= 900px) */
@media (max-width: 849.98px) and (min-height: 900px) {
  body {
    display: block;
    height: auto;
    overflow-y: auto;
  }

  #main-header {
    height: auto;
    padding: var(--gap-2) var(--gap-4);
  }

  #viewport-region {
    width: 100%;
    height: clamp(420px, 58vh, 720px);
  }

  #control-panel {
    display: block;
    width: 100%;
    border-left: none;
    border-top: 1px solid var(--line);
  }

  .panel-scroll {
    overflow: visible;
    padding-bottom: calc(var(--ctl) + 72px + env(safe-area-inset-bottom));
  }

  .sliders-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px 16px;
  }

  .section-group {
    grid-column: 1 / -1;
  }

  .section-group-body {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px 16px;
  }

  .playback-dock {
    position: sticky;
    bottom: 0;
    z-index: 40;
    background: var(--glass-strong);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    padding: var(--gap-2) var(--gap-3);
    padding-bottom: calc(env(safe-area-inset-bottom) + 6px);
  }

  .no-room-bottom-bar { display: none !important; }
}

/* No-Room Layout (Phone <= 600px, landscape <= 640px height, etc.) */
@media (max-width: 599.98px), ((max-width: 849.98px) and (max-height: 899.98px)), ((min-width: 850px) and (max-height: 639.98px)) {
  :root {
    --menu-alpha: 0.6;
  }

  body {
    display: flex;
    flex-direction: column;
    height: 100dvh;
    overflow: hidden;
  }

  #control-panel {
    display: none !important;
  }

  .no-room-bottom-bar {
    display: flex !important;
  }

  .sidebar-toggle-btn {
    display: inline-flex !important;
  }

  #viewport-region {
    flex: 1 1 0;
    min-height: 0;
    height: auto;
  }

  #main-footer {
    display: none;
  }

  /* Thin header */
  #main-header {
    min-height: 48px;
    height: auto;
    padding: 6px 12px;
    flex-direction: column;
    gap: 4px;
  }

  .header-doc-meta {
    display: none;
  }

  .header-top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
  }

  .brand-title {
    font-size: 16px;
  }

  .export-btn-text {
    display: none;
  }

  .phone-only-icon {
    display: inline-block;
  }

  #btn-open-export {
    width: var(--ctl);
    height: var(--ctl);
    padding: 0;
  }

  /* Thin config bar */
  #config-bar {
    min-height: 38px;
    height: auto;
    padding: 4px 12px;
    flex-direction: row;
    gap: 6px;
  }

  .config-bar-right {
    display: none;
  }

  /* Viewport overlays on phone */
  .overlay-asset-card .sub-tag,
  .overlay-asset-card .spec-rows {
    display: none;
  }

  .overlay-asset-card {
    padding: 4px 8px;
    font-size: 11px;
    top: 8px;
    left: 8px;
  }

  .overlay-stamp {
    display: none;
  }

  .counts-card .system-counts {
    display: none;
  }

  .counts-card {
    padding: 4px 8px;
  }

  .overlay-top-right {
    top: 8px;
    right: 8px;
    gap: 4px;
  }

  .axes-widget {
    width: 44px;
    height: 44px;
  }

  .gesture-hint {
    display: none;
  }

  .overlay-bottom-center {
    display: none;
  }

  /* Node sidebar at 40vw */
  .node-sidebar {
    width: 40vw;
    min-width: 220px;
    background: var(--glass-phone);
  }

  /* Phone bottom sheet dialog */
  dialog.c-sheet {
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    max-width: 100%;
    border-bottom: none;
    border-radius: var(--overlay-radius, 8px) var(--overlay-radius, 8px) 0 0;
    max-height: 60dvh;
  }

  .sheet-grab-handle {
    display: block;
    width: 32px;
    height: 4px;
    background: var(--line-strong);
    border-radius: 2px;
    margin: 8px auto 0 auto;
    flex-shrink: 0;
  }
}

/* Explicit data-layout attribute overrides */
body[data-layout="wide"] {
  display: grid !important;
  grid-template-rows: var(--band-h) var(--head-h) var(--cfg-h) minmax(0, 1fr) var(--foot-h) !important;
  grid-template-columns: minmax(0, 1fr) var(--panel-w) !important;
  height: 100dvh !important;
  overflow: hidden !important;
}

body[data-layout="wide"] #control-panel {
  display: flex !important;
}

body[data-layout="wide"] .no-room-bottom-bar {
  display: none !important;
}

body[data-layout="wide"] .sidebar-toggle-btn {
  display: none !important;
}

body[data-layout="stacked"] {
  display: block !important;
  height: auto !important;
  overflow-y: auto !important;
}

body[data-layout="stacked"] #control-panel {
  display: block !important;
  width: 100% !important;
  border-left: none !important;
  border-top: 1px solid var(--line) !important;
}

body[data-layout="stacked"] .no-room-bottom-bar {
  display: none !important;
}

body[data-layout="no-room"] {
  display: flex !important;
  flex-direction: column !important;
  height: 100dvh !important;
  overflow: hidden !important;
}

body[data-layout="no-room"] #control-panel {
  display: none !important;
}

body[data-layout="no-room"] .no-room-bottom-bar {
  display: flex !important;
}

body[data-layout="no-room"] .sidebar-toggle-btn {
  display: inline-flex !important;
}
