/* Neutral desktop surfaces and compact geometry controls. */
:root {
  --cad-topbar-height: 48px;
  --cad-tool-width: 0px;
  --cad-browser-width: 224px;
  --cad-left-width: 224px;
  --cad-inspector-width: 304px;
  --page-background: #646463;
  --workspace-background: #646463;
  --toolbar-color: #7C7C7C;
  --cad-chrome: #6F6F6E;
  --cad-panel: #5F5E5E;
  --cad-panel-raised: #646463;
  --cad-panel-deep: #4E4D4D;
  --cad-line: #383838;
  --cad-line-soft: #4E4D4D;
  --cad-accent: #3285E5;
  --canvas-background: #616060;
  --surface: var(--cad-panel);
  --surface-solid: var(--cad-panel-raised);
  --surface-muted: var(--cad-panel-deep);
  --surface-hover: #6F6F6E;
  --text-primary: #DDDDDD;
  --text-secondary: #CCCCCC;
  --text-tertiary: #B7B7B7;
  --accent: #3285E5;
  --accent-hover: #559CEB;
  --accent-soft: #526B84;
  --accent-soft-strong: #3285E5;
  --accent-strong: #FFFFFF;
  --accent-contrast: #162b42;
  --focus-ring: #3285E5;
  --control-face: #646463;
  --input-background: #383838;
  --action-background: #276BB8;
  --action-hover: #225D9F;
}
#viewportCanvas {
  inset: 0;
  width: 100%;
  height: 100%;
}
.topbar {
  height: var(--cad-topbar-height);
  background: var(--toolbar-color);
  color: #111111;
  border-bottom-color: #333333;
}
.brand {
  width: auto;
  min-width: 170px;
  color: #111111;
  font-size: 16px;
}
:root .brand img {
  filter: none;
}
.header-actions {
  gap: 6px;
}
.action-button,
.theme-toggle {
  height: 28px;
  border-radius: 4px;
  background: #A3A3A3;
  border-color: #4E4D4D;
  color: #191919;
}
.action-button {
  min-width: 92px;
  font-size: 11px;
}
.theme-toggle {
  width: 28px;
}
#importButton .icon {
  color: inherit;
}
.action-button:not(:disabled):hover,
.theme-toggle:hover {
  background: #B2B2B2;
  color: #222222;
}
.scene-toggle {
  display: none;
}
/* Model commands stay centered in the window while the side groups fit. */
.topbar {
  display: grid;
  grid-template-columns: minmax(max-content, 1fr) minmax(0, auto) minmax(max-content, 1fr);
}
.topbar-start {
  grid-column: 1;
}
.header-actions {
  grid-column: 3;
  justify-self: end;
}
.command-strip {
  display: flex;
  grid-column: 2;
  min-width: 0;
  height: 100%;
  padding: 0 10px;
  align-items: center;
  overflow-x: auto;
  overflow-y: hidden;
  pointer-events: auto;
  scrollbar-color: var(--border-strong) transparent;
  scrollbar-width: thin;
}
.command-strip .tool-panel {
  display: flex;
  flex-direction: row;
  height: 100%;
  width: 100%;
  padding: 5px 10px;
  gap: 5px;
  border: 0;
  border-radius: 0;
  background: transparent;
  overflow: visible;
  align-items: center;
}
.command-strip .rail-button,
.command-strip .gizmo-option {
  width: auto;
  min-width: max-content;
  min-height: 36px;
  height: 36px;
  flex: 0 0 auto;
  flex-direction: row;
  gap: 7px;
  padding: 0 10px;
  border-radius: 4px;
  font-size: 11px;
  color: var(--text-primary);
}
.command-strip .rail-button .icon,
.command-strip .gizmo-option .icon {
  width: 18px;
  height: 18px;
}
.command-strip .rail-button span {
  position: static;
  width: auto;
  height: auto;
  clip-path: none;
}
.command-strip .tool-gizmo-slot {
  display: flex;
}
.command-strip .gizmo-segment {
  display: flex;
  gap: 4px;
}
.command-strip .rail-button.is-active,
.command-strip .gizmo-option.is-active {
  background: var(--accent-soft);
  border-color: var(--accent-soft-strong);
  color: var(--accent-strong);
}
.command-strip .rail-button:hover,
.command-strip .gizmo-option:hover {
  background: var(--surface-hover);
}
.left-rail,
.left-rail.is-workbench-mode,
.left-rail.has-active-workbench {
  top: var(--cad-topbar-height);
  width: var(--cad-browser-width);
  grid-template-columns: 1fr;
}
.browser-panel {
  grid-column: 1;
}
.browser-header,
.browser-group > h3 {
  background: var(--control-face);
  border-bottom: 1px solid var(--cad-line);
}
.browser-header h2 {
  font-size: 13px;
}
.browser-model-row {
  background: var(--surface-hover);
}
.browser-model-row strong {
  font-size: 12px;
  font-weight: 550;
}
#browserHistorySlot .history-entry {
  border-radius: 3px;
}
.right-rail {
  top: var(--cad-topbar-height);
  bottom: 168px;
}
.right-rail .transform-card {
  max-height: 52%;
  flex-basis: 330px;
}
.right-rail:not(.has-active-workbench) .inspector-panel {
  display: none;
}
.right-rail:not(.has-active-workbench) .transform-card {
  max-height: 100%;
  flex: 1;
}
.workbench-header {
  min-height: 43px;
  background: var(--control-face);
}
.workbench-header h2 {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 14px;
  font-weight: 550;
}
.workbench-header .eyebrow {
  display: none;
}
.workbench-scroll {
  padding: 12px 14px;
}
.choice-icon {
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
  stroke-width: 1.5;
}
.choice-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.choice-label .icon {
  width: 15px;
  height: 15px;
}
.plane-methods {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 5px;
}
.plane-methods[data-plane-mode-panel="automatic"] {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.method-button {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 4px;
  min-height: 53px;
  padding: 5px 3px;
  font-size: 10px;
  font-weight: 500;
  border-radius: 4px;
  background: var(--control-face);
  border: 1px solid var(--border-strong);
}
.method-button[data-plane-method="perpendicular"] {
  grid-column: 1 / -1;
  flex-direction: row;
  min-height: 32px;
}
.method-button.is-active,
.plane-mode-button.is-active {
  background: var(--accent-soft);
  color: var(--accent-strong);
  border-color: var(--accent-soft-strong);
}
.method-button:hover:not(.is-active) {
  background: var(--surface-hover);
}
.plane-mode-button {
  display: grid;
  grid-template-columns: 21px 1fr;
  column-gap: 6px;
  padding: 7px 9px;
  border-radius: 4px;
}
.plane-mode-button .icon {
  grid-row: span 2;
  align-self: center;
}
.plane-mode-button strong {
  font-size: 11px;
}
.plane-mode-button small {
  font-size: 9px;
}
.workbench-label {
  font-size: 10px;
  letter-spacing: 0;
  text-transform: none;
  font-weight: 500;
}
.workbench-field input,
.workbench-field select,
.axis-field,
.unit-input,
.gizmo-snap-value {
  background: var(--input-background);
  border-radius: 4px;
  border-color: var(--cad-line);
}
.icon-button,
.text-button,
.plane-mode-switch,
.model-center-card,
.model-center-use,
.reference-selection,
.bounds-readout,
.orientation-candidate,
.alignment-summary,
.alignment-adjust-button,
.level-mode-button,
.alignment-empty,
.inspect-reference-section,
.inspect-primary-result,
.inspect-value-grid > div,
.inspect-detail-list,
.origin-plane-toggle,
.gizmo-segment,
.gizmo-option,
.inspect-axis-buttons button,
.orientation-target-buttons button {
  border-radius: 4px;
}
.primary-button,
.create-plane-button,
.alignment-analyze-button,
.alignment-apply-button {
  border-radius: 4px;
  background: var(--action-background);
  color: #ffffff;
  font-weight: 550;
}
.primary-button:hover,
.create-plane-button:hover,
.alignment-analyze-button:hover,
.alignment-apply-button:hover {
  background: var(--action-hover);
}
.toggle-track span {
  background: #e5e5e5;
}
.viewport-display-slot {
  top: calc(var(--cad-topbar-height) + 10px);
}
.viewport-display-slot .display-tabs {
  border-radius: 4px;
}
.viewport-display-slot .display-tab {
  border-radius: 3px;
}
.display-tab.is-active {
  background: var(--control-face);
  color: var(--text-primary);
}
.view-toolbar {
  border-radius: 32px;
}
.view-button,
.history-button {
  border-radius: 3px;
}
.cad-statusbar {
  overflow: visible;
  height: 36px;
  padding-right: 0;
}
.coordinate-dock {
  position: relative;
  flex: 0 0 var(--cad-inspector-width);
  height: 168px;
  align-self: flex-end;
  margin-left: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 10px 8px;
  background: var(--cad-panel);
  border-left: 1px solid var(--cad-line);
}
.coordinate-dock .view-cube {
  position: relative;
  inset: auto;
  display: grid;
  width: 88px;
  height: 110px;
  margin: 0;
}
.coordinate-dock .view-cube-canvas {
  width: 88px;
  height: 88px;
}
.coordinate-dock .status-position {
  width: 100%;
  min-width: 0;
  padding: 0;
  margin: 0;
  text-align: center;
  font-size: 10px;
}
.snap-settings-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 11px;
  cursor: pointer;
}
.snap-settings-button .icon {
  width: 16px;
  height: 16px;
}
.settings-dialog {
  width: min(420px, calc(100vw - 24px));
  max-height: calc(100svh - 32px);
  padding: 0;
  border: 1px solid var(--cad-line);
  border-radius: 7px;
  color: var(--text-primary);
  background: var(--surface);
}
.settings-dialog::backdrop {
  background: rgba(0, 0, 0, 0.4);
}
.settings-dialog[open] {
  display: flex;
  flex-direction: column;
}
.settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--cad-line);
  background: var(--cad-panel-deep);
}
.settings-header h2 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-size: 14px;
  font-weight: 550;
}
.settings-content {
  padding: 16px;
  overflow-y: auto;
  min-height: 0;
}
.settings-content h3 {
  margin: 0 0 7px;
  font-size: 12px;
}
.settings-content p {
  color: var(--text-secondary);
  font-size: 11px;
  line-height: 1.6;
}
.settings-content .status-space-slot,
.settings-content .status-snap-slot,
.settings-content .status-snap-modes {
  display: flex;
  height: auto;
  padding: 0;
  margin: 12px 0;
  border: 0;
}
.settings-content .gizmo-space-segment {
  width: 100%;
  gap: 3px;
}
.settings-content .gizmo-option {
  min-height: 32px;
  gap: 7px;
}
.settings-content .gizmo-snap-grid {
  display: grid;
  grid-template-columns: 1fr;
  width: 100%;
  gap: 10px;
}
.settings-content .gizmo-toggle-track {
  width: 26px;
  height: 15px;
  border: 0;
  background: var(--border-strong);
}
.settings-content .gizmo-toggle-track > span {
  top: 2px;
  left: 2px;
  width: 11px;
  height: 11px;
  background: #d8d8d8;
}
.settings-content .gizmo-snap-heading input:checked + .gizmo-toggle-track {
  background: var(--accent);
}
.settings-content .gizmo-snap-heading input:checked + .gizmo-toggle-track > span {
  background: #d8d8d8;
  transform: translateX(11px);
}
.settings-content .gizmo-snap-control {
  justify-content: space-between;
  height: 36px;
}
.settings-content .gizmo-snap-value {
  width: 90px;
  height: 30px;
}
.settings-content .status-snap-modes {
  flex-wrap: wrap;
  gap: 5px;
  overflow: visible;
  white-space: normal;
}
.settings-content .status-snap-modes > span {
  width: 100%;
  padding: 0 0 5px;
}
.settings-content .status-snap-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--cad-line);
  border-radius: 4px;
  padding: 7px 9px;
  font-size: 11px;
  text-transform: none;
  background: var(--surface-muted);
}
.settings-content .status-snap-button.is-active {
  background: var(--accent-soft);
  border-color: var(--accent-soft-strong);
}
.settings-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 16px;
  border-top: 1px solid var(--cad-line);
  font-size: 10px;
}
.settings-footer button {
  border-radius: 4px;
  padding: 7px 20px;
  background: var(--action-background);
  color: white;
  cursor: pointer;
}
@media (max-width: 1180px) {
  :root {
    --cad-left-width: 0px;
    --cad-inspector-width: 290px;
  }
  .left-rail {
    display: none;
  }
  .scene-toggle {
    display: inline-flex;
  }
  .left-rail.scene-open {
    display: grid;
    z-index: 36;
    width: 224px;
  }
  .left-rail.scene-open .browser-panel {
    display: flex;
  }
  .status-help-slot {
    display: none;
  }
  .command-strip .rail-button,
  .command-strip .gizmo-option {
    padding: 0 8px;
  }
}
@media (max-width: 700px) {
  :root {
    --cad-inspector-width: 188px;
  }
  .brand {
    min-width: 0;
    padding: 0 8px;
  }
  .header-actions {
    gap: 4px;
  }
  .theme-toggle,
  .action-button {
    width: 28px;
    min-width: 28px;
    height: 28px;
  }
  .command-strip .tool-panel {
    padding: 5px;
  }
  .command-strip .rail-button,
  .command-strip .gizmo-option {
    font-size: 10px;
  }
  .left-rail.scene-open {
    bottom: 36px;
    height: auto;
  }
  .right-rail,
  .right-rail.has-active-workbench {
    top: auto;
    left: auto;
    right: 0;
    bottom: 148px;
    width: min(304px, 100%);
    height: min(290px, 38svh);
  }
  .right-rail.has-active-workbench {
    height: min(400px, 48svh);
  }
  .right-rail .transform-card {
    max-height: 100%;
  }
  .viewport-display-slot {
    left: 8px;
    top: calc(var(--cad-topbar-height) + 10px);
  }
  .view-toolbar {
    bottom: auto;
    top: calc(var(--cad-topbar-height) + 52px);
    left: 8px;
    right: auto;
    margin: 0;
  }
  .coordinate-dock {
    height: 148px;
  }
  .coordinate-dock .view-cube {
    top: auto;
    right: auto;
    bottom: auto;
  }
  .coordinate-dock .status-position {
    font-size: 9px;
  }
  .cad-statusbar {
    padding-left: 4px;
  }
  .model-status {
    top: calc(var(--cad-topbar-height) + 100px);
    left: 8px;
    max-width: calc(100% - 24px);
  }
  .toast {
    top: calc(var(--cad-topbar-height) + 100px);
    bottom: auto;
  }
  .drop-overlay {
    inset: calc(var(--cad-topbar-height) + 4px) 8px 44px;
  }
}

/* Match command order to the positioning workflow. */
.command-strip [data-section="rotation"] {
  order: 2;
}
.command-strip #layFlatButton {
  order: 3;
}
.command-strip [data-section="level"] {
  order: 4;
}
.command-strip #dropToBedButton {
  order: 5;
}
.command-strip #planeButton {
  order: 6;
}
.command-strip #inspectButton {
  order: 7;
}
.coordinate-dock .view-cube[hidden] {
  display: none;
}

.right-rail.has-active-workbench .transform-card {
  display: none;
}
.orientation-target-buttons button,
.inspect-axis-buttons button {
  justify-items: center;
}
.level-mode-button {
  grid-template-columns: 20px 1fr;
  column-gap: 7px;
}
.level-mode-button .choice-icon {
  grid-row: span 2;
  align-self: center;
}
@media (max-width: 700px) {
  .theme-toggle {
    display: inline-flex;
  }
}

@media (max-width: 700px) {
  .right-rail,
  .right-rail.has-active-workbench {
    max-height: calc(100svh - 240px);
  }
}

/* --------------------------------------------------------------------------
   Single Logic-inspired neutral gray theme
   One permanent interface theme: no light/dark variants, no glow, no gradients.
   Palette is intentionally limited to the gray values sampled from the reference.
   -------------------------------------------------------------------------- */
:root,
:root[data-theme] {
  color-scheme: dark;

  --page-background: #616161;
  --workspace-background: #616161;
  --canvas-background: #616060;

  --toolbar-color: #7c7c7c;
  --cad-chrome: #484848;
  --cad-panel: #616161;
  --cad-panel-raised: #858585;
  --cad-panel-deep: #545454;
  --cad-line: #434343;
  --cad-line-soft: #808080;

  --surface: #616161;
  --surface-solid: #858585;
  --surface-muted: #545454;
  --surface-hover: #707070;

  --control-face: #545454;
  --input-background: #484848;

  --text-primary: #f2f2f2;
  --text-secondary: #dedede;
  --text-tertiary: #bcbcbc;

  --border: #484848;
  --border-strong: #434343;

  --accent: #2f80d9;
  --accent-hover: #3f8fe5;
  --accent-soft: #4f7198;
  --accent-soft-strong: #2f80d9;
  --accent-strong: #ffffff;
  --accent-contrast: #ffffff;

  --action-background: #2f80d9;
  --action-hover: #3f8fe5;
  --focus-ring: rgba(47, 128, 217, 0.42);

  --grid-minor: rgba(255, 255, 255, 0.075);
  --grid-major: rgba(255, 255, 255, 0.15);
  --cube-light: #d8d8d8;
  --cube-mid: #b4b4b4;
  --cube-dark: #858585;
  --cube-edge: rgba(48, 48, 48, 0.68);
  --drop-overlay: rgba(97, 97, 97, 0.94);
}

body {
  background: #616161;
  color: var(--text-primary);
  transition: none;
}

.workspace,
#viewportCanvas {
  background: var(--canvas-background);
  transition: none;
}

.workspace {
  border-color: #434343;
}

/* Compact application bar above the full-page viewport. */
.topbar {
  background: #7c7c7c;
  color: #171717;
  border-bottom: 1px solid #646463;
}

.brand {
  color: #171717;
}

.topbar .brand {
  border-right: 0;
  font-weight: 600;
}

.topbar .header-actions {
  gap: 8px;
  padding-right: 10px;
}

.brand img {
  filter: none !important;
}

.header-actions .action-button,
.header-actions .theme-toggle {
  background: #929292;
  border-color: #646463;
  border-radius: 6px;
  color: #171717;
  box-shadow: none;
  background-image: none;
}

.header-actions .action-button:not(:disabled):hover,
.header-actions .theme-toggle:hover {
  background: #949494;
  border-color: #545454;
  color: #1f1f1f;
  transform: none;
}

.header-actions .action-button:active,
.header-actions .theme-toggle:active {
  background: #808080;
  transform: none;
}

/* Grouped commands inside the application bar. */
/* Auto margins center the commands and collapse once the strip scrolls. */
.command-strip .tool-panel {
  flex: 0 0 auto;
  width: max-content;
  max-width: none;
  height: 34px;
  margin: 0 auto;
  padding: 3px;
  background: #545454;
  border: 1px solid #484848;
  border-radius: 8px;
  gap: 4px;
}

.command-strip .gizmo-segment {
  padding: 0;
  border: 0;
  background: transparent;
}

.command-strip .tool-gizmo-slot {
  flex: 0 0 auto;
}

.command-strip [data-section="rotation"],
.command-strip #planeButton {
  position: relative;
  margin-left: 16px;
}

.command-strip [data-section="rotation"]::before,
.command-strip #planeButton::before {
  content: "";
  position: absolute;
  left: -11px;
  top: 5px;
  bottom: 5px;
  width: 1px;
  background: #707070;
  pointer-events: none;
}

@supports (backdrop-filter: blur(6px)) {
  .topbar {
    background: rgb(124 124 124 / 96%);
    backdrop-filter: blur(6px);
  }
}

@media (prefers-reduced-transparency: reduce) {
  .topbar {
    background: #7c7c7c;
    backdrop-filter: none;
  }
}

.command-strip .rail-button,
.command-strip .gizmo-option {
  min-height: 26px;
  height: 26px;
  color: #f5f5f5;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  box-shadow: none;
  background-image: none;
}

.command-strip .rail-button:hover,
.command-strip .gizmo-option:hover {
  background: #646463;
  color: #ffffff;
}

.command-strip .rail-button.is-active,
.command-strip .gizmo-option.is-active {
  background: #858585;
  border-color: #a3a3a3;
  color: #171717;
}

.command-strip .rail-button:focus-visible,
.command-strip .gizmo-option:focus-visible {
  outline: 2px solid #dddddd;
  outline-offset: -2px;
}

/* Scene browser and inspector use the same permanent middle-gray surface. */
.browser-panel,
.transform-card,
.inspector-panel,
.plane-workbench,
.alignment-workbench,
.coordinate-dock {
  background: #616161;
  border-color: #434343;
  color: #f2f2f2;
  box-shadow: none;
  background-image: none;
}

.browser-header,
.browser-group > h3,
.workbench-header,
.settings-header {
  background: #545454;
  border-color: #434343;
  color: #f2f2f2;
}

.browser-tree,
.browser-group,
.workbench-scroll {
  background: #616161;
}

.browser-model-row {
  background: #707070;
  color: #f2f2f2;
}

.browser-model-row:hover {
  background: #808080;
}

#browserHistorySlot .history-entry {
  color: #f2f2f2;
}

#browserHistorySlot .history-entry:hover {
  background: #707070;
}

#browserHistorySlot .history-entry.is-current,
#browserHistorySlot .history-entry[aria-current="true"] {
  background: #4f7198;
  color: #ffffff;
}

/* Compact control faces: flat medium/dark grays, no gradients or glow. */
.method-button,
.plane-mode-button,
.icon-button,
.text-button,
.model-center-card,
.model-center-use,
.reference-selection,
.bounds-readout,
.orientation-candidate,
.alignment-summary,
.alignment-adjust-button,
.level-mode-button,
.alignment-empty,
.inspect-reference-section,
.inspect-primary-result,
.inspect-value-grid > div,
.inspect-detail-list,
.origin-plane-toggle,
.gizmo-segment,
.gizmo-option,
.inspect-axis-buttons button,
.orientation-target-buttons button,
.snap-settings-button,
.settings-content .status-snap-button {
  background: #545454;
  border-color: #434343;
  color: #f2f2f2;
  box-shadow: none;
  background-image: none;
}

.method-button:hover:not(.is-active),
.plane-mode-button:hover:not(.is-active),
.icon-button:hover,
.text-button:hover,
.origin-plane-toggle:hover,
.gizmo-option:hover {
  background: #616161;
}

.method-button.is-active,
.plane-mode-button.is-active,
.settings-content .status-snap-button.is-active {
  background: #2f80d9;
  border-color: #246cad;
  color: #ffffff;
}

.workbench-field input,
.workbench-field select,
.axis-field,
.unit-input,
.gizmo-snap-value,
.transform-card input,
.transform-card select {
  background: #484848;
  border-color: #434343;
  color: #f2f2f2;
  box-shadow: none;
  background-image: none;
}

.workbench-field input:focus,
.workbench-field select:focus,
.axis-field:focus,
.unit-input:focus,
.gizmo-snap-value:focus,
.transform-card input:focus,
.transform-card select:focus {
  border-color: #2f80d9;
  outline-color: rgba(47, 128, 217, 0.42);
}

.primary-button,
.create-plane-button,
.alignment-analyze-button,
.alignment-apply-button {
  background: #2f80d9;
  border-color: #246cad;
  color: #ffffff;
  box-shadow: none;
  background-image: none;
}

.primary-button:hover,
.create-plane-button:hover,
.alignment-analyze-button:hover,
.alignment-apply-button:hover {
  background: #3f8fe5;
}

/* View/display controls follow Logic's segmented control treatment. */
.viewport-display-slot .display-tabs,
.view-toolbar {
  background: #545454;
  border-color: #434343;
  box-shadow: none;
  background-image: none;
}

.viewport-display-slot .display-tab,
.view-button,
.history-button {
  color: #eeeeee;
  background: transparent;
  border-color: transparent;
  box-shadow: none;
}

.viewport-display-slot .display-tab:hover,
.view-button:hover:not(:disabled),
.history-button:hover:not(:disabled) {
  background: #616161;
  color: #ffffff;
}

.viewport-display-slot .display-tab.is-active {
  background: #2f80d9;
  border-color: #246cad;
  color: #ffffff;
}

/* Status bar and coordinate dock mirror the same medium-gray system. */
.cad-statusbar {
  background: #545454;
  border-top: 1px solid #434343;
  color: #eeeeee;
}

.coordinate-dock {
  background: #616161;
}

.status-position,
.shortcut-hint,
.status-help-slot {
  color: #dedede;
}

.snap-settings-button {
  background: #616161;
}

.toggle-track {
  background: #434343;
}

.toggle-track span {
  background: #d8d8d8;
}

input:checked + .toggle-track,
.toggle-track.is-active {
  background: #2f80d9;
}

/* Keep dialogs/popovers in the same single gray theme. */
.settings-dialog {
  background: #616161;
  border-color: #434343;
  color: #f2f2f2;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.28);
}

.settings-dialog::backdrop {
  background: rgba(49, 49, 49, 0.58);
}

.settings-footer {
  border-color: #434343;
}

/* Theme UI is intentionally absent: the site has one permanent gray theme. */
#themeToggle,
.theme-icon {
  display: none !important;
}


/* Match target-plane faces to the viewport axis colors. */
.orientation-target-buttons [data-orientation-target="x"],
.inspect-axis-buttons [data-inspect-reference-plane="world-yz"] {
  --target-axis-color: #ef4444;
}
.orientation-target-buttons [data-orientation-target="y"],
.inspect-axis-buttons [data-inspect-reference-plane="world-xz"] {
  --target-axis-color: #2aad54;
}
.orientation-target-buttons [data-orientation-target="z"],
.inspect-axis-buttons [data-inspect-reference-plane="world-xy"] {
  --target-axis-color: #2386ff;
}
:is(.orientation-target-buttons, .inspect-axis-buttons) button {
  gap: 5px;
  border: 2px solid #484848;
  border-radius: 6px;
}
:is(.orientation-target-buttons, .inspect-axis-buttons) .choice-icon {
  width: 30px;
  height: 30px;
  color: var(--target-axis-color);
}
:is(.orientation-target-buttons, .inspect-axis-buttons) button:hover {
  background: #616161;
  border-color: var(--target-axis-color);
}
:is(.orientation-target-buttons, .inspect-axis-buttons) button.is-active {
  --target-face-opacity: 0.65;
  background: #646463;
  border-color: var(--target-axis-color);
  color: #ffffff;
}
:is(.orientation-target-buttons, .inspect-axis-buttons) small {
  color: #dddddd;
  font-size: 9px;
}

/* Surface selection, reference, and comparison form a single inspection flow. */
.inspect-workbench .inspect-step-number {
  background: #707070;
  border-color: #858585;
  color: #ffffff;
}
.inspect-workbench .inspect-empty {
  gap: 6px;
  padding: 12px;
  border-radius: 6px;
}
.inspect-workbench .inspect-empty[data-state="ready"] {
  background: #545454;
  border-color: #858585;
}
.inspect-repick {
  border-radius: 6px;
  width: 100%;
  margin-top: 6px;
}
.inspect-primary-result {
  gap: 6px;
  padding: 14px;
  border-radius: 6px;
}
.inspect-primary-result strong {
  font-size: 26px;
}
.inspect-primary-result small {
  color: #dddddd;
  font-size: 10px;
  line-height: 1.5;
}
.inspect-primary-result .inspect-alignment-label {
  color: #ffffff;
  font-size: 12px;
}
.inspect-technical-details {
  border: 1px solid #484848;
  border-radius: 6px;
  padding: 10px;
  background: #545454;
}
.inspect-technical-details summary {
  cursor: pointer;
  color: #eeeeee;
  font-size: 11px;
}
.inspect-technical-details[open] summary {
  margin-bottom: 10px;
}
.inspect-technical-details .inspect-detail-list {
  margin-bottom: 0;
}

.repository-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 32px;
  flex: 0 0 auto;
  color: #dddddd;
  border-radius: 5px;
}
.repository-link:hover { background: #707070; color: #ffffff; }
.mobile-panel-toggle { display: none; }

/* The application bar drops the logo image, file action labels, then the
   brand name, but only while the bar would otherwise overflow. */
.topbar .brand { width: auto; min-width: 0; padding: 0 14px; }
.topbar .brand span { display: inline; }
.topbar.is-brand-text-only .brand img { display: none; }
.topbar.is-brand-icon-only .brand { padding: 0 8px; }
.topbar.is-brand-icon-only .brand span { display: none; }
.topbar:not(.is-actions-compact) .header-actions .action-button { width: auto; min-width: 92px; padding: 0 10px; }
.topbar:not(.is-actions-compact) .action-button span {
  position: static; width: auto; height: auto; overflow: visible; clip-path: none;
}
.topbar.is-actions-compact .header-actions .action-button { width: 28px; min-width: 28px; padding: 0; justify-content: center; }
.topbar.is-actions-compact .action-button span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.topbar.is-actions-in-statusbar .topbar-start { display: none; }
.topbar.is-transform-labels-hidden .select-tool-button,
.topbar.is-transform-labels-hidden .tool-gizmo-slot .gizmo-option { padding: 0 7px; }
.topbar.is-transform-labels-hidden .select-tool-button span,
.topbar.is-transform-labels-hidden .tool-gizmo-slot .gizmo-option span {
  position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%);
}
/* Short labels replace long command names before the strip would scroll. */
.topbar.is-short-labels .rail-button[data-short-label] span {
  position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%);
}
.topbar.is-short-labels .rail-button[data-short-label]::after {
  content: attr(data-short-label) / "";
}
/* Narrowest bars stack every command's icon over its short label in equal columns. */
.topbar.is-stacked-labels { grid-template-columns: minmax(0, 1fr); }
.topbar.is-stacked-labels .command-strip { grid-column: 1; }
.topbar.is-stacked-labels .tool-panel { width: 100%; }
.topbar.is-stacked-labels .tool-gizmo-slot,
.topbar.is-stacked-labels .tool-gizmo-slot .gizmo-segment { display: contents; }
.topbar.is-stacked-labels .command-strip .rail-button,
.topbar.is-stacked-labels .command-strip .gizmo-option {
  flex: 1 1 0; min-width: max-content; flex-direction: column; justify-content: center;
  gap: 2px; padding: 0 2px; font-size: 9px; line-height: 11px; letter-spacing: -0.01em;
}
.topbar.is-stacked-labels .command-strip .rail-button .icon,
.topbar.is-stacked-labels .command-strip .gizmo-option .icon { width: 18px; height: 18px; }
.topbar.is-stacked-labels .select-tool-button span,
.topbar.is-stacked-labels .tool-gizmo-slot .gizmo-option span {
  position: static; width: auto; height: auto; overflow: visible; clip-path: none; font-size: inherit;
}
.topbar.is-stacked-labels .command-strip [data-section="rotation"],
.topbar.is-stacked-labels .command-strip #planeButton { margin-left: 7px; }
.topbar.is-stacked-labels .command-strip [data-section="rotation"]::before,
.topbar.is-stacked-labels .command-strip #planeButton::before { left: -5px; }

/* File actions moved out of a narrow application bar sit at the status bar's end. */
.status-brand {
  flex: 0 0 auto;
  padding: 0 6px 0 2px;
  color: #eeeeee;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.02em;
  white-space: nowrap;
}
.status-actions-slot {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
}
.status-actions-slot { margin-left: auto; }
.status-actions-slot:empty { display: none; }
.status-actions-slot:not(:empty) + .coordinate-dock { margin-left: 0; }
.status-actions-slot .header-actions { gap: 2px; height: 100%; padding: 0 6px; }
.status-actions-slot .header-actions .action-button,
.status-actions-slot .header-actions .theme-toggle {
  width: 32px; min-width: 32px; height: 28px; padding: 0; justify-content: center;
  background: transparent; border-color: transparent; color: #dddddd;
}
.status-actions-slot .header-actions .action-button:not(:disabled):hover,
.status-actions-slot .header-actions .theme-toggle:hover {
  background: #707070; border-color: transparent; color: #ffffff;
}
.status-actions-slot .action-button span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }

/* Phone panels overlay the viewport without displacing its bottom controls. */
@media (max-width: 700px), (max-width: 900px) and (max-height: 500px) {
  :root { --cad-inspector-width: 0px; --cad-left-width: 0px; }
  .app-shell, .workspace { height: 100dvh; min-height: 100dvh; }
  :root { --cad-topbar-height: calc(56px + env(safe-area-inset-top)); }
  .topbar { padding-top: env(safe-area-inset-top); }
  .topbar .header-actions { margin-left: auto; gap: 4px; padding-right: 6px; }
  .header-actions .action-button, .header-actions .theme-toggle {
    display: inline-flex; width: 40px; min-width: 40px; height: 40px; padding: 0; justify-content: center;
  }
  .action-button span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .topbar.is-actions-compact .header-actions .action-button { width: 40px; min-width: 40px; }
  /* Phone commands and display modes share one height, inset, and corner radius. */
  .command-strip { padding: 0 8px; touch-action: pan-x; }
  .command-strip .tool-panel { height: 44px; padding: 2px; }
  .command-strip .rail-button, .command-strip .gizmo-option { height: 38px; min-height: 38px; font-size: 11px; }
  .command-strip .rail-button .icon, .command-strip .gizmo-option .icon { width: 20px; height: 20px; }
  .viewport-display-slot .display-tabs { height: 44px; padding: 2px; border-radius: 8px; }
  .viewport-display-slot .display-tab { min-height: 38px; height: 38px; border-radius: 6px; }
  .viewport-display-slot .display-tab .icon { width: 18px; height: 18px; }
  .viewport-display-slot { top: calc(var(--cad-topbar-height) + 8px); left: 8px; }
  .view-toolbar {
    top: auto; bottom: calc(48px + env(safe-area-inset-bottom)); left: 6px; right: 88px;
    height: 44px; max-width: calc(100% - 94px); margin-inline: auto; padding: 0 2px;
  }
  .view-toolbar .view-button, .view-toolbar .history-button {
    width: clamp(32px, calc((100vw - 140px) / 7), 40px); height: 40px; flex: 0 0 auto;
  }
  .view-toolbar .history-actions { height: 40px; }
  .cad-statusbar { height: calc(40px + env(safe-area-inset-bottom)); padding: 0 4px env(safe-area-inset-bottom); align-items: center; }
  .repository-link { width: 40px; height: 40px; }
  /* Properties shares the view navigation row, under the view cube. */
  .mobile-panel-toggle {
    position: absolute; z-index: 1; right: 6px; bottom: calc(100% + 8px); display: block;
    width: 76px; height: 44px; padding: 0 4px; border: 1px solid #434343; border-radius: 8px;
    background: #545454; color: #eeeeee; font-size: 11px; white-space: nowrap;
  }
  .mobile-panel-toggle:hover { background: #616161; color: #ffffff; }
  .coordinate-dock { position: static; height: auto; flex: 1; min-width: 0; align-self: center; padding: 0 4px; border: 0; background: transparent; }
  .coordinate-dock .status-position { font-size: 8px; white-space: normal; }
  .coordinate-dock .view-cube { position: absolute; right: 8px; bottom: calc(100px + env(safe-area-inset-bottom)); width: 72px; height: 96px; }
  .coordinate-dock .view-cube-canvas { width: 72px; height: 72px; }
  .right-rail, .right-rail.has-active-workbench {
    display: none; top: auto; left: 6px; right: 6px; bottom: calc(100px + env(safe-area-inset-bottom));
    width: auto; height: min(42dvh, 360px); max-height: calc(100dvh - 264px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    border: 1px solid #434343; border-radius: 8px; overflow: hidden;
  }
  .right-rail.mobile-inspector-open { display: flex; }
  .right-rail .inspector-panel { min-height: 0; }
  .right-rail .transform-card { max-height: 100%; overflow-y: auto; }
  .right-rail.mobile-inspector-open ~ .cad-statusbar .view-cube { display: none; }
  .left-rail { display: none; }
  .left-rail.scene-open { top: calc(var(--cad-topbar-height) + 8px); bottom: calc(100px + env(safe-area-inset-bottom)); left: 6px; width: min(280px, calc(100% - 12px)); height: auto; border-radius: 8px; overflow-y: auto; }
  .workbench-scroll, .settings-content { overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
  .right-rail input, .right-rail select, .settings-dialog input { font-size: 16px; }
  .right-rail .icon-button { width: 40px; height: 40px; }
  .right-rail .workbench-header { min-height: 48px; }
  .status-help-slot { display: none; }
  .status-actions-slot { order: 1; margin-left: 0; }
  .toast { top: calc(var(--cad-topbar-height) + 56px); bottom: auto; max-width: calc(100% - 24px); }
}

/* Phones keep display mode names; stacked commands also stack the display modes. */
@media (max-width: 700px), (max-width: 900px) and (max-height: 500px) {
  .viewport-display-slot .display-tabs { width: auto; }
  .viewport-display-slot .display-tab span { display: inline; }
  .workspace:has(.topbar.is-stacked-labels) .viewport-display-slot .display-tab {
    flex-direction: column; justify-content: center; gap: 2px; min-width: 52px; padding: 0 4px;
    font-size: 9px; line-height: 11px;
  }
}

@media (max-width: 900px) and (max-height: 500px) {
  .right-rail, .right-rail.has-active-workbench {
    top: calc(var(--cad-topbar-height) + 8px);
    left: auto;
    right: 6px;
    width: min(340px, calc(100% - 12px));
    height: auto;
    max-height: none;
  }
}

.plane-mode-switch [data-plane-mode="pick"] { grid-column: 1 / -1; }
.smart-plane-toolbar[hidden], .smart-plane-toolbar [hidden] { display: none; }
.smart-plane-toolbar { display: grid; gap: 6px; width: 100%; min-width: 0; }
.smart-plane-header { position: sticky; top: 0; z-index: 1; background: #545454; display: flex; align-items: center; gap: 8px; min-width: 0; }
.smart-plane-heading { display: flex; align-items: center; gap: 7px; min-width: 0; margin-right: auto; }
.smart-plane-heading-icon { display: grid; place-items: center; flex: 0 0 26px; height: 26px; border-radius: 6px; background: #484848; color: #dddddd; }
.smart-plane-heading-icon .icon { width: 17px; height: 17px; }
.smart-plane-heading-copy { display: flex; flex-wrap: wrap; align-items: center; gap: 3px 8px; min-width: 0; }
#smartPlaneTitle { color: #eeeeee; font-size: 13px; line-height: 1.2; font-weight: 600; }
#smartPlaneSelectionSummary { min-width: 0; color: #c8c8c8; font-size: 11px; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.smart-plane-actions { display: flex; align-items: center; gap: 5px; flex: 0 0 auto; }
.smart-plane-toolbar button, .smart-plane-toolbar select, .smart-plane-toolbar input {
  min-height: 32px; border: 1px solid #777777; border-radius: 6px;
  padding: 5px 8px; background: #646463; color: #eeeeee; font: inherit; font-size: 12px;
}
.smart-plane-toolbar button { display: inline-flex; justify-content: center; align-items: center; gap: 6px; cursor: pointer; }
.smart-plane-toolbar button:hover:not(:disabled) { background: #70706f; border-color: #929292; }
.smart-plane-toolbar :is(button, input, select):focus-visible { outline: 2px solid #dddddd; outline-offset: 2px; }
.smart-plane-toolbar button .icon { width: 16px; height: 16px; flex: 0 0 auto; }
.smart-plane-toolbar button:disabled { opacity: .45; cursor: not-allowed; }
.smart-plane-toolbar button[aria-pressed="true"] { background: #858585; color: #171717; border-color: #aaaaaa; }
.smart-plane-toolbar .smart-plane-icon-button { width: 30px; padding: 0; background: transparent; border-color: transparent; }
.smart-plane-toolbar #smartPlaneSave:not(:disabled) { background: #bcbcbc; border-color: #cccccc; color: #202020; }
.smart-plane-toolbar #smartPlaneSave:hover:not(:disabled) { background: #cccccc; }
.smart-plane-toolbar #smartPlaneSave { font-weight: 600; white-space: nowrap; }
.smart-plane-toolbar label { display: flex; flex-direction: column; align-items: stretch; gap: 4px; min-width: 0; color: #dddddd; font-size: 11px; line-height: 1.25; }
.smart-plane-toolbar :is(input, select) { min-width: 0; width: 100%; background: #484848; border-color: #727272; }
.smart-plane-toolbar #smartPickFilter { width: auto; max-width: 130px; }
.smart-plane-toolbar input[type="number"] { font-variant-numeric: tabular-nums; }
.smart-plane-pick-reference, .smart-plane-parameters, .smart-plane-advanced { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; min-width: 0; }
.smart-plane-advanced { padding: 12px; border-radius: 9px; background: #4e4d4d; }
.smart-plane-pick-reference label { flex-direction: row; align-items: center; white-space: nowrap; }
.smart-plane-pick-reference select { flex: 1; }
#smartReferenceField { flex: 2 1 190px; }
.smart-plane-method-row { min-width: 0; }
.smart-plane-section-label, .smart-plane-method-copy small {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0;
}
.smart-plane-methods { display: flex; flex-wrap: wrap; gap: 5px; }
.smart-plane-methods button { flex: 0 0 auto; gap: 6px; min-height: 32px; padding: 5px 8px; text-align: left; border-radius: 6px; background: #484848; border-color: #707070; }
.smart-plane-methods button .icon { width: 16px; height: 16px; }
.smart-plane-method-copy { min-width: 0; }
.smart-plane-method-copy strong { font-size: 12px; font-weight: 500; line-height: 1.3; white-space: nowrap; }
.smart-plane-parameters label { flex-direction: row; align-items: center; gap: 6px; white-space: nowrap; }
.smart-plane-parameters :is(input, select) { flex: 1; }
.smart-plane-parameters .smart-plane-reference-field { flex: 1 1 220px; }
.smart-plane-parameters .smart-plane-number-field { flex-basis: 150px; }
.smart-plane-number-field, #smartPrimaryOffsetSlot, #smartExtraOffsetSlot { flex: 0 1 130px; min-width: 0; }
#smartPrimaryOffsetSlot { flex: 1 1 240px; max-width: 360px; }
#smartPrimaryOffsetSlot:empty, #smartExtraOffsetSlot:empty { display: none; }
.smart-plane-name-field { flex: 1 1 160px; }
.smart-plane-toolbar[data-step="choose"] .smart-plane-footer,
.smart-plane-toolbar[data-step="pick"][data-empty="true"] .smart-plane-footer { display: none; }
.smart-plane-footer { display: flex; align-items: center; gap: 12px; min-width: 0; }
#smartToolbarStatus { flex: 1; min-width: 0; color: #d2d2d2; font-size: 11px; line-height: 1.45; }
#smartToolbarStatus[data-state="error"] { color: #f1d0a0; }
.smart-plane-toolbar #smartPlaneAdvancedToggle { min-height: 24px; padding: 2px 4px; flex: 0 0 auto; border-color: transparent; background: transparent; color: #dddddd; font-size: 11px; }
#smartPlaneStatus { font-size: 12px; color: #eeeeee; }
.view-navigation { display: flex; align-items: center; gap: 1px; flex: 0 0 auto; }
.view-toolbar.is-plane-picking .view-navigation { display: none; }
.view-toolbar.is-plane-picking {
  top: auto; bottom: calc(var(--cad-statusbar-height) + 12px);
  container: plane-toolbar / inline-size;
  display: flex; flex-direction: column; height: auto;
  width: min(640px, calc(100% - var(--cad-left-width) - var(--cad-inspector-width) - 20px));
  max-height: calc(100dvh - 180px); scroll-padding-top: 90px; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin;
  padding: 8px; border-radius: 14px; background: #545454; border-color: #777777;
}
@media (max-width: 700px), (max-width: 900px) and (max-height: 500px) {
  .smart-plane-toolbar button, .smart-plane-toolbar select, .smart-plane-toolbar input { min-height: 40px; }
  .smart-plane-toolbar input, .smart-plane-toolbar select { font-size: 16px; }
  .smart-plane-toolbar .smart-plane-icon-button { width: 40px; }
  .view-toolbar.is-plane-picking { bottom: calc(48px + env(safe-area-inset-bottom)); left: 6px; right: 6px; width: calc(100% - 12px); max-width: calc(100% - 12px); margin-inline: auto; padding: 8px; }
  .workspace:has(.view-toolbar.is-plane-picking) .right-rail { bottom: calc(108px + var(--plane-toolbar-height, 130px) + env(safe-area-inset-bottom)); }
  .workspace:has(.view-toolbar.is-plane-picking) .mobile-panel-toggle { bottom: calc(100% + 16px + var(--plane-toolbar-height, 130px)); }
  .workspace:has(.view-toolbar.is-plane-picking) .coordinate-dock .view-cube { bottom: calc(112px + var(--plane-toolbar-height, 130px) + env(safe-area-inset-bottom)); }
}
@container plane-toolbar (max-width: 600px) {
  .smart-plane-header { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 6px; }
  .smart-plane-header:has(#smartPlaneBack[hidden]) .smart-plane-heading { grid-column: 1 / -1; }
  .smart-plane-actions { grid-column: 1 / -1; }
  #smartPickFilter { margin-right: auto; }
  #smartPlaneSave { margin-left: auto; }
  .smart-plane-parameters label { flex-direction: column; align-items: stretch; white-space: normal; }
  .smart-plane-parameters .smart-plane-reference-field { flex-basis: 155px; }
  .smart-plane-parameters .smart-plane-number-field { flex-basis: 96px; }
  .smart-plane-footer { gap: 6px; }
}
@media (max-width: 900px) and (max-height: 500px) {
  .view-toolbar.is-plane-picking { max-height: 150px; scroll-padding-top: 50px; padding: 8px; }
  .smart-plane-toolbar { gap: 6px; }
  .smart-plane-header { gap: 8px; }
  .smart-plane-heading-copy { gap: 2px; }
  #smartPlaneSelectionSummary { font-size: 10px; }
  .smart-plane-parameters label { flex-direction: row; align-items: center; white-space: nowrap; gap: 8px; }
  .smart-plane-parameters .smart-plane-number-field { flex-basis: 140px; }
  .smart-plane-parameters :is(input, select) { flex: 1; }
  .smart-plane-footer #smartPlaneAdvancedToggle { min-height: 28px; }
}
