:root {
  /* Layout tokens (dark shell — the 3D viewer sits on top of this). */
  --bg: #202932;
  --panel: rgba(20, 26, 33, 0.85);
  --text: #f3f4f6;
  --border: rgba(255, 255, 255, 0.12);
  --sans: system-ui, 'Segoe UI', Roboto, sans-serif;

  /* ---------- WPF theme palette (Acads.Core.UI.WPF/Styles/Colors.xaml) ----------
     Kept as CSS custom properties so every button / input / focus ring in
     the app can reference the exact same hex values the WPF UI uses. If
     the WPF palette changes, edit here in one place. */
  --core-green:        #6E953E;   /* CoreGreenBrush        — primary bg */
  --core-green-hover:  #8BAA65;   /* CoreGreenHoverBrush   — primary hover */
  --core-green-press:  #567530;   /* CoreGreenPressBrush   — primary pressed */
  --core-green-light:  #F0F4EB;   /* CoreGreenLightBrush   — focus fill / muted variant */

  /* Text tones — LightTextBrush / SuperLightTextBrush. */
  --text-light:        #5D5D5D;
  --text-super-light:  #8B8B8B;

  /* Error tones (used by delete affordances). */
  --error:             #d9534f;

  /* Drag-and-drop hint accent (kept as green so the overlay reads on-brand). */
  --accent-border:     rgba(110, 149, 62, 0.6);
  --accent-bg:         rgba(110, 149, 62, 0.15);

  font: 14px/1.4 var(--sans);
  color: var(--text);
  color-scheme: dark;
  -webkit-font-smoothing: antialiased;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  overflow: hidden;
}

#viewer-container {
  position: fixed;
  top: calc(var(--toolbar-h) + var(--tab-h));   /* below toolbar + tab strip */
  left: calc(var(--sidebar-w) + var(--sidebar-divider-w));   /* right of the sidebar + divider */
  right: 0;
  bottom: 0;
}

#viewer-container.drag::after {
  content: 'Drop IFC file to load';
  position: absolute;
  inset: 16px;
  border: 2px dashed var(--accent-border);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  color: var(--text);
  background: var(--accent-bg);
  pointer-events: none;
}

/* ----------------------------------------------------------------------
   Revit-style view tabs. Full-width strip that sits directly below the
   top toolbar. Each tab is a rounded chip with an icon on the left, the
   view name in the middle, and (for closable plan tabs) an × on the
   right that fades in on hover. Active tab is lifted with a bottom
   accent bar in --core-green to match the WPF SelectedPathBrush.
   ---------------------------------------------------------------------- */

#tab-bar {
  position: fixed;
  top: var(--toolbar-h);
  left: calc(var(--sidebar-w) + var(--sidebar-divider-w));   /* right of the sidebar + divider */
  right: 0;
  height: var(--tab-h);
  display: flex;
  align-items: stretch;
  gap: 2px;
  padding: 0 12px;
  background: #ececec;                     /* slightly darker than toolbar so tabs read as inset */
  border-bottom: 1px solid #c8c8c8;
  z-index: 18;                              /* under the top toolbar, over the viewer */
  overflow-x: auto;
  overflow-y: hidden;
}

.tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 12px;
  font-family: var(--sans);
  font-size: 12px;
  color: var(--text-light);
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
  background: transparent;
  border: 0;
  border-bottom: 2px solid transparent;    /* reserved for the active-tab accent below */
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}

.tab:hover {
  background: rgba(0, 0, 0, 0.04);
  color: #333;
}

/* Active tab — sits ON the border-bottom of the strip, with a green
   accent line taking over that pixel to signal selection. */
.tab.active {
  background: #f5f5f5;                     /* match the pane background below (light chrome) */
  color: var(--core-green-press);
  border-bottom-color: var(--core-green);
}
.tab.active:hover { background: #f5f5f5; }

.tab-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: currentColor;                     /* SVGs use stroke="currentColor" so they follow tab color */
}

.tab-label {
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tab-close {
  background: transparent;
  border: 0;
  color: inherit;
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  padding: 0 4px;
  margin-left: 2px;
  opacity: 0;                              /* hidden until row hover */
  border-radius: 3px;
  transition: opacity 0.12s ease, background 0.12s ease, color 0.12s ease;
}
.tab:hover .tab-close        { opacity: 0.55; }
.tab.active .tab-close       { opacity: 0.7; }
.tab-close:hover {
  opacity: 1;
  background: rgba(0, 0, 0, 0.08);
  color: var(--error);
}

/* ----------------------------------------------------------------------
   TopToolsBar — mirrors <Border Style="{StaticResource TopToolsBar}">
   from AHUAndZoneManagement.xaml. Light, full-width strip across the top
   of the window, split into left / middle-spacer / right columns via
   flexbox. The 3D viewer, tab bar, and 2D plan pane all offset from the
   TOOLBAR_HEIGHT below so they never sit underneath the toolbar.
   ---------------------------------------------------------------------- */

:root {
  /* Height of the top toolbar. Any fixed-position element that needs to
     sit BELOW the toolbar (viewer container, plan pane, tab bar) offsets
     from this. Change once; all four callers follow. */
  --toolbar-h: 48px;

  /* Height of the Revit-style tab strip that sits immediately below the
     toolbar. Similar single-source-of-truth pattern. */
  --tab-h: 34px;

  /* Width of the left sidebar (Project Browser). Driven by the
     drag-to-resize handler in viewer.js which writes new values to this
     variable in real time. All right-side elements (tab bar, viewer
     container, plan pane) offset their `left` by this value so the
     divider stays visually aligned. Persisted to localStorage. */
  --sidebar-w: 300px;

  /* Thickness of the vertical drag handle between the sidebar and the
     content pane. 6 px is comfortable to grab without stealing pixels
     from either side. */
  --sidebar-divider-w: 6px;

  /* Height of the sidebar's TOP pane (Project Browser). The bottom
     pane (Properties) fills whatever height is left. Driven by the
     horizontal drag handle inside the sidebar; persisted to
     localStorage under 'ifcViewer.sidebarTopHeight'. */
  --sidebar-top-h: 60%;

  /* Thickness of the horizontal drag handle between the sidebar's two
     panes. Same interaction pattern as the vertical divider. */
  --sidebar-hdivider-h: 6px;
}

#toolbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--toolbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;   /* left group anchors left, right group anchors right */
  gap: 12px;
  padding: 0 14px;
  background: #f5f5f5;              /* WPF TopToolsBar Background */
  border-bottom: 1px solid #d0d0d0; /* separator between toolbar and canvas */
  z-index: 20;                      /* above viewer, tab bar, plan pane */
}

.toolbar-group {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.toolbar-group-right { flex: 0 0 auto; }

.toolbar-label {
  font-family: var(--sans);
  font-size: 12px;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding-right: 2px;
}

/* The toolbar's right column used to carry three things besides the two
   nav buttons: a #status line (.toolbar-status), the signed-in user
   (.toolbar-project-sub), and the current project as a link back to
   /Projects (.toolbar-project + .toolbar-project-link). All three are
   gone from the markup — commentary that took the width the buttons
   needed.

   Only .toolbar-status is kept, and only because viewer.js still writes
   to a #status element when one exists: put that span back and it is
   styled exactly as it was, with no code change. The other three rules
   were deleted rather than left here, since nothing revives them. */
.toolbar-status {
  font-family: var(--sans);
  font-size: 12px;
  color: var(--text-light);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 40vw;
}

/* Inline <form> next to buttons in the toolbar — removes the default
   block margin so the wrapped button lines up with the sibling
   .btn / .btn-secondary controls. */
.toolbar-inline-form {
  display: inline-flex;
  align-items: center;
  margin: 0;
}

/* ----------------------------------------------------------------------
   Narrow-window trimming for the top toolbar.

   The failure these prevent: the left group's width is the sum of its
   controls and a flex item will not shrink below that, so past a certain
   window width it pushed the right group — project link, Projects, Sign
   out — clean off the edge of the screen, with no scrollbar and no way to
   reach them. Moving the section box and camera toggle down to
   #viewport-tools bought back around 340px, which is the real fix; these
   rules give up the cheap things first so the same thing cannot recur on
   a smaller display.

   Deliberately NOT solved with `overflow` on the left group. That would
   clip #export-menu, which is absolutely positioned inside it and opens
   downwards past the toolbar's bottom edge — trading a hidden button for
   a hidden menu.

   Ordered by what costs least to lose: select width first, then the
   labels, whose selects say the same thing. The buttons themselves are
   never hidden. There is less to give up than there was — the status
   line, the signed-in user and the project name were all trimmed here at
   one point and have since left the toolbar entirely, which is the
   better fix.

   Every selector is scoped to #toolbar, and not only for tidiness: the
   base `.select` rule further down this file sets min-width:160px, so an
   unscoped `.select` here would have equal specificity and lose on source
   order — silently, and to the one rule that buys back the most width.
   The #toolbar prefix wins regardless of where these sit, and confines
   them to the strip they are about; the 2D pane's own controls are
   unaffected.
   ---------------------------------------------------------------------- */

@media (max-width: 1500px) {
  #toolbar .select { min-width: 120px; }
}

@media (max-width: 1280px) {
  #toolbar .toolbar-label { display: none; }
}

@media (max-width: 1100px) {
  #toolbar .select { min-width: 104px; }
}

/* ----------------------------------------------------------------------
   Buttons — mirror WPF Acads.Core.UI.WPF/Styles/ButtonStyle.xaml.
   ---------------------------------------------------------------------- */

/* PrimaryBtnGreen — white text on CoreGreen fill.
   Corresponds to the WPF <Style x:Key="PrimaryBtnGreen"> in ButtonStyle.xaml.
   Works uniformly on <button>, <label>, and <a> — the explicit line-height /
   box-sizing / font resets below prevent user-agent defaults (which differ
   between form controls and text elements) from producing different heights
   for the same class. */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;                /* padding + border stay inside height */
  height: 30px;                          /* fixed height so buttons + labels match exactly */
  padding: 0 14px;                       /* vertical padding delegated to height + line-height */
  border-radius: 4px;                    /* WPF Border.CornerRadius="4" */
  font-size: 14px;
  font-weight: 500;
  font-family: var(--sans);
  line-height: 1;                        /* normalize — <label> inherits 1.4 from body, <button> uses ~1.15 */
  vertical-align: middle;                /* align with adjacent inline text/inputs */
  white-space: nowrap;
  color: #ffffff;
  background: var(--core-green);
  border: 1px solid var(--core-green);   /* thin border same color as bg keeps size stable when secondary variant swaps in */
  cursor: pointer;
  user-select: none;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

/* IsMouseOver="True" → CoreGreenHoverBrush */
.btn:hover {
  background: var(--core-green-hover);
  border-color: var(--core-green-hover);
}

/* IsPressed="True" → CoreGreenPressBrush */
.btn:active {
  background: var(--core-green-press);
  border-color: var(--core-green-press);
}

.btn:focus-visible {
  outline: 2px solid var(--core-green-light);
  outline-offset: 2px;
}

/* SecondaryBtnGreen — outlined variant: CoreGreen text + border, transparent
   fill. On hover fill flips to CoreGreenHover with white text. */
.btn-secondary {
  color: var(--core-green);
  background: transparent;
  border: 1.5px solid var(--core-green);
}
.btn-secondary:hover {
  background: var(--core-green-hover);
  border-color: var(--core-green-hover);
  color: #ffffff;
}
.btn-secondary:active {
  background: var(--core-green-press);
  border-color: var(--core-green-press);
  color: #ffffff;
}

/* Toggle-style secondary button held in the "on" state — used by the
   Section Box toggle. Reads as pressed without relying on :active,
   which only lasts while the mouse is down. Mirrors the .proj-btn
   .is-active treatment so the two toggles look consistent. */
.btn-secondary.is-active {
  background: var(--core-green);
  border-color: var(--core-green);
  color: #ffffff;
}
.btn-secondary.is-active:hover {
  background: var(--core-green-hover);
  border-color: var(--core-green-hover);
}

/* Reclassify panel (reclassify-panel.js). Draggable by its header. */
.rc-panel {
  position: fixed;
  top: calc(var(--toolbar-h, 48px) + 8px);
  right: 12px;
  z-index: 60;
  width: 400px;
  max-height: calc(100vh - var(--toolbar-h, 48px) - 24px);
  overflow-y: auto;
  padding: 0 12px 12px;
  background: #ffffff;
  color: #1f2328;
  border: 1px solid #cfd4d9;
  border-radius: 8px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18);
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-size: 13px;
}
.rc-panel[hidden] { display: none; }
.rc-head { display: flex; align-items: center; justify-content: space-between;
  margin: 0 -12px; padding: 8px 12px; background: #f3f5f7; border-bottom: 1px solid #e1e5e9;
  border-radius: 8px 8px 0 0; cursor: move; user-select: none; touch-action: none;
  position: sticky; top: 0; z-index: 1; }
.rc-title { font-weight: 600; color: #1f2328; }
.rc-step { display: flex; align-items: center; gap: 8px; font-weight: 600; color: #1f2328; }
.rc-num { width: 18px; height: 18px; border-radius: 50%; background: #e3f0fc; color: #0c447c;
  display: inline-flex; align-items: center; justify-content: center; font-size: 11px; }
.rc-x { border: 0; background: none; font-size: 18px; line-height: 1; cursor: pointer; color: #555; }
.rc-pickrow { display: flex; flex-wrap: nowrap; gap: 8px; align-items: center; }
.rc-pickrow .btn { white-space: nowrap; flex: 0 0 auto; }
.rc-grow { flex: 1; min-width: 0; }
.rc-block { display: flex; flex-direction: column; gap: 4px; }
.rc-label { font-size: 12px; font-weight: 600; color: #444; display: flex; justify-content: space-between; align-items: center; }
.rc-sub { font-weight: 400; color: #777; }
.rc-nowrap { flex-wrap: nowrap; }
.rc-nowrap .select { flex: 1; min-width: 0; }
.rc-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.rc-chips:empty { display: none; }
.rc-chip { background: #e3f0fc; color: #0c447c; border-radius: 6px; padding: 3px 4px 3px 8px;
  font-size: 12px; display: inline-flex; align-items: center; gap: 4px; max-width: 100%; word-break: break-all; }
.rc-chip button { border: 0; background: none; color: inherit; cursor: pointer; padding: 0 4px; font-size: 14px; line-height: 1; }
.rc-hint { font-size: 12px; color: #666; }
.rc-hint:empty { display: none; }
.rc-hint[hidden] { display: none; }
.rc-hint.is-warn { color: #a05a00; }
.rc-row { display: flex; flex-wrap: wrap; gap: 6px; }
.rc-right { justify-content: flex-end; }
.rc-seg { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.rc-seg button { padding: 7px 8px; border: 1px solid #b9c0c7; border-radius: 6px; background: #fff;
  color: #1f2328; cursor: pointer; font-size: 13px; }
.rc-seg button:hover { background: #f3f5f7; }
.rc-seg .rc-ignore { grid-column: 1 / -1; }
.rc-seg button.is-on { background: #e3f0fc; border-color: #378add; color: #0c447c; font-weight: 600; }
.rc-link { border: 0; background: none; padding: 0; font-size: 12px; font-weight: 400; color: #185fa5; cursor: pointer; text-decoration: underline; }
.rc-link:disabled { color: #999; cursor: default; text-decoration: none; }
.rc-link.is-on { font-weight: 600; }
#rc-reset { align-self: flex-start; }
.rc-foot { border-top: 1px solid #e5e8eb; padding-top: 10px; display: flex; flex-direction: column; gap: 8px; }
.rc-toast { display: flex; align-items: center; justify-content: space-between; gap: 8px;
  background: #eaf3de; color: #27500a; border-radius: 6px; padding: 6px 10px; font-size: 12px; }
.rc-toast[hidden] { display: none; }

/* PrimaryBtnRedSmall — destructive action variant (Clear, Delete). */
.btn-danger {
  color: #ffffff;
  background: var(--error);
  border-color: var(--error);
}
.btn-danger:hover {
  background: #b52c28;
  border-color: #b52c28;
}

/* Status text lives on the light toolbar strip now — dark text on light. */
#status {
  color: var(--text-light);
  font-size: 12px;
}

/* Vertical divider between logical tool groups. */
.sep {
  width: 1px;
  height: 22px;
  background: #d0d0d0;
  margin: 0 4px;
}

/* <select> on the light toolbar. Matches WPF ComboBoxStyle look:
   subtle border, CoreGreen focus ring. */
.select {
  height: 30px;
  padding: 0 8px;
  background: #ffffff;
  color: var(--text-light);
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 13px;
  font-family: var(--sans);
  cursor: pointer;
  min-width: 160px;
}
.select:hover {
  border-color: var(--core-green-hover);
}
.select:focus {
  outline: none;
  border-color: var(--core-green-hover);
  background: var(--core-green-light);
}
.select:disabled,
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.btn:disabled {
  background: #e0e0e0;
  border-color: #d0d0d0;
  color: #999;
}

/* Segmented projection toggle — Ortho | Persp buttons, now in the
   #viewport-tools pill at the bottom of the 3D view, which scales these
   down to 26px. The 30px sizing below is the original top-toolbar fit,
   kept as the default so the control stays flush with .btn / .select if
   it is ever put back in a full-height row. Active side flips to
   CoreGreen with white text,
   inactive side is transparent with the same muted text colour the
   other toolbar controls use. */
.proj-toggle {
  display: inline-flex;
  height: 30px;
  border: 1px solid #ccc;
  border-radius: 4px;
  overflow: hidden;
  background: #ffffff;
  box-sizing: border-box;
}
.proj-btn {
  height: 28px;                /* 30 - 2*1px border */
  padding: 0 12px;
  background: transparent;
  border: 0;
  color: var(--text-light);
  font-size: 13px;
  font-family: var(--sans);
  cursor: pointer;
  line-height: 1;
  transition: background 0.12s ease, color 0.12s ease;
}
.proj-btn + .proj-btn {
  border-left: 1px solid #ccc;
}
.proj-btn:hover:not(.is-active) {
  background: var(--core-green-light);
  color: var(--core-green-press);
}
.proj-btn.is-active {
  background: var(--core-green);
  color: #ffffff;
}
.btn-secondary:disabled {
  background: transparent;
  border-color: #d0d0d0;
  color: #999;
}

canvas {
  display: block;
  outline: none;
}

/* ----------------------------------------------------------------------
   Project Browser (formerly "Levels panel") — Revit-style tree
   docked to the TOP-LEFT below the top toolbar. Background matches the
   toolbar (#f5f5f5) so the light strip visually extends down into the
   sidebar, framing the dark 3D viewport on the right.
   ---------------------------------------------------------------------- */
/* The Project Browser is now the app's persistent LEFT SIDEBAR — full-
   height column below the top toolbar, divider on its right edge. Width
   is driven by --sidebar-w, which the divider drag handler in viewer.js
   updates in real time. No floating chrome (no border-radius, no shadow,
   no side margins) — the sidebar reads as part of the frame, matching
   Revit's Properties/Project-Browser column.

   The sidebar itself is a vertical flex column split into two panes by
   a horizontal drag handle:
     top    = Project Browser (height driven by --sidebar-top-h)
     handle = #sidebar-hdivider
     bottom = Properties (fills remaining space via flex: 1) */
#levels-panel {
  position: fixed;
  top: var(--toolbar-h);
  left: 0;
  width: var(--sidebar-w);
  bottom: 0;
  display: flex;
  flex-direction: column;
  background: #f5f5f5;                  /* match toolbar */
  color: var(--text-light);
  border-right: 1px solid #d0d0d0;      /* right edge, hidden under the divider */
  z-index: 20;
  font-family: var(--sans);
  overflow: hidden;
}

#levels-panel[hidden] {
  display: none;
}

/* Top pane — Project Browser. Height is driven by --sidebar-top-h so
   the horizontal divider below can resize it. `min-height: 0` is the
   classic flex-layout requirement so an inner scroll region can shrink
   below its content height. */
#sidebar-project-browser {
  flex: 0 0 var(--sidebar-top-h);
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Bottom pane — Properties. Fills whatever height is left after the
   top pane and horizontal divider are laid out. */
#sidebar-properties {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #f5f5f5;
}

/* Horizontal drag handle between the two sidebar panes. Same
   interaction as the outer vertical divider: hover / dragging tint
   flips to CoreGreen, wider invisible hitbox for comfortable aim. */
#sidebar-hdivider {
  flex: 0 0 var(--sidebar-hdivider-h);
  background: #d0d0d0;
  cursor: row-resize;
  position: relative;
  user-select: none;
  transition: background 0.12s ease;
}
#sidebar-hdivider:hover,
#sidebar-hdivider.is-dragging {
  background: var(--core-green);
}
#sidebar-hdivider::before {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: -3px;
  bottom: -3px;
}
body.sidebar-hresizing,
body.sidebar-hresizing * {
  cursor: row-resize !important;
  user-select: none !important;
}

/* Properties body & table — clean two-column look. Key column has a
   fixed width so long values wrap under the value cell, not push the
   key around. Same font stack + colour as the tree rows above so the
   two panes read as one continuous UI. */
.properties-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 4px 8px 8px 8px;
}
.properties-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  color: var(--text-light);
}
.properties-table th,
.properties-table td {
  padding: 4px 8px;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid #e5e5e5;
}
.properties-table th {
  width: 60px;
  color: #888;
  font-weight: 500;
  background: rgba(0, 0, 0, 0.02);
}
.properties-table td {
  color: #333;
  word-break: break-all;
}
/* Empty-state hint — shown when no element has been picked. Toggled by
   #sidebar-properties.is-empty on the parent, driven by viewer.js. */
.properties-empty {
  display: none;
  padding: 8px 12px;
  color: #999;
  font-size: 12px;
  font-style: italic;
}
#sidebar-properties.is-empty .properties-table { display: none; }
#sidebar-properties.is-empty .properties-empty { display: block; }

/* Vertical drag handle between the sidebar and the content pane. Fixed
   position so it stays parked at the current sidebar width regardless
   of what's scrolling in either panel. The handle itself is
   ${--sidebar-divider-w}px wide; the interactive hitbox is bigger
   (padding via ::before) so the resize edge is comfortable to grab. */
#sidebar-divider {
  position: fixed;
  top: var(--toolbar-h);
  left: var(--sidebar-w);
  bottom: 0;
  width: var(--sidebar-divider-w);
  background: #d0d0d0;
  cursor: col-resize;
  z-index: 21;                          /* above sidebar's border, under toolbar */
  user-select: none;
  transition: background 0.12s ease;
}
#sidebar-divider:hover,
#sidebar-divider.is-dragging {
  background: var(--core-green);
}
/* Wider invisible hitbox so users don't need pixel-perfect aim to grab
   the handle. Extends 3 px past each side of the visible bar. */
#sidebar-divider::before {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: -3px;
  right: -3px;
}

/* While dragging, everything else gets a col-resize cursor and iframe
   / canvas mouse events are ignored — otherwise the WebGL canvas would
   fight the drag with its own middle-mouse handler. */
body.sidebar-resizing,
body.sidebar-resizing * {
  cursor: col-resize !important;
  user-select: none !important;
}
body.sidebar-resizing #viewer-container,
body.sidebar-resizing #plan-2d-pane {
  pointer-events: none;
}

/* .dlg-header + .dlg-title are shared with #pick-dialog (dark theme).
   Scope the light-theme overrides to #levels-panel so the pick dialog
   keeps its own look. */
#levels-panel .dlg-header {
  padding: 8px 12px;
  border-bottom: 1px solid #d0d0d0;
  background: rgba(0, 0, 0, 0.03);
}
#levels-panel .dlg-title {
  color: var(--text-light);
  opacity: 1;
  font-weight: 600;
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.lvl-list {
  padding: 2px 0;
}

/* Row-level styles for the level list inside the Levels tree section.
   The .lvl-row block further down (in the Project Browser tree block)
   overrides layout specifics; these rules set the shared cosmetic look. */

.lvl-row:hover {
  background: rgba(0, 0, 0, 0.05);
}

.lvl-row input[type='checkbox'] {
  accent-color: var(--core-green);
  cursor: pointer;
}

.lvl-name {
  color: var(--text-light);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 13px;
}

.lvl-elev {
  color: var(--text-super-light);
  font-family: var(--mono, ui-monospace, Consolas, monospace);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

/* --- Pick dialog --- */
#pick-dialog {
  position: fixed;
  top: 16px;
  right: 16px;
  min-width: 260px;
  max-width: 340px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  backdrop-filter: blur(8px);
  z-index: 20;
  color: var(--text);
  font-family: var(--sans);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

#pick-dialog[hidden] {
  display: none;
}

.dlg-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}

.dlg-title {
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  color: var(--text);
  opacity: 0.85;
}

.dlg-close {
  background: transparent;
  border: none;
  color: var(--text);
  opacity: 0.7;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
  border-radius: 4px;
}

.dlg-close:hover {
  opacity: 1;
  background: rgba(255, 255, 255, 0.08);
}

.dlg-body {
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.dlg-row {
  display: grid;
  grid-template-columns: 90px 1fr;
  gap: 8px;
  font-size: 13px;
  align-items: baseline;
}

.dlg-key {
  color: var(--text);
  opacity: 0.6;
}

.dlg-val {
  color: var(--text);
  font-family: var(--mono, ui-monospace, Consolas, monospace);
  word-break: break-all;
}

/* --- 2D plan pane (overlay on top of the 3D viewer) --- */
#plan-2d-pane {
  position: fixed;
  top: calc(var(--toolbar-h) + var(--tab-h));   /* below toolbar + tab strip */
  left: calc(var(--sidebar-w) + var(--sidebar-divider-w));   /* right of the sidebar + divider */
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  background: #fafafa;
  z-index: 5;
}

#plan-2d-pane[hidden] { display: none; }

.plan-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: #f0f0f0;
  border-bottom: 1px solid #d0d0d0;
  color: #333;
  font-size: 14px;
  flex-shrink: 0;
}

.plan-canvas-wrap {
  flex: 1;
  position: relative;
  overflow: hidden;
}

.plan-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  /* Default cursor; LevelVmRenderer flips to 'grabbing' during pan drag and
     'pointer' on hit-test hover, so the user gets the right affordance per
     interaction without us forcing a single cursor here. */
  cursor: default;
  background: #ffffff;
}

/* NOTE: the floating .plan-pick / .plan-pick-row rules were removed —
   picked-element info now lives in the sidebar's Properties pane
   (see #sidebar-properties + .properties-table above). */

/* ----------------------------------------------------------------------
   Plan pane bottom toolbar. Mirrors the WPF <Border Grid.Row="2"
   Style="{StaticResource BottomToolsBar}"> block in AHUAndZoneManagement.xaml:
   grey strip background + a white pill on the left containing scale +
   [+] / [−] / Reset controls. Right-hand column left open for future
   toggles (e.g. Show Room Zone Colours).
   ---------------------------------------------------------------------- */

.plan-bottom-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: #f5f5f5;
  border-top: 1px solid #ddd;
  flex-shrink: 0;
}

.plan-zoom-pill {
  display: inline-flex;
  align-items: center;
  height: 28px;
  padding: 0 4px;
  background: #ffffff;
  border: 1px solid #d0d0d0;
  border-radius: 4px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.plan-scale {
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-light);
  min-width: 44px;
  padding: 0 8px;
  text-align: center;
  font-variant-numeric: tabular-nums;   /* stable width as digits change */
}

.plan-divider {
  display: inline-block;
  width: 1px;
  height: 18px;
  background: #d0d0d0;
  margin: 0 2px;
}

/* Individual pill button — icon-sized for + / −, wider for the Reset label. */
.plan-icon-btn {
  height: 24px;
  min-width: 28px;
  padding: 0 8px;
  margin: 0 1px;
  border: 0;
  background: transparent;
  color: var(--text-light);
  font-family: var(--sans);
  font-size: 15px;
  font-weight: 600;
  line-height: 1;
  border-radius: 3px;
  cursor: pointer;
  transition: background-color 0.12s ease, color 0.12s ease;
}
.plan-icon-btn:hover {
  background: var(--core-green-light);
  color: var(--core-green-press);
}
.plan-icon-btn:active {
  background: var(--core-green-hover);
  color: #ffffff;
}

/* Reset — text label instead of icon, slightly smaller font-weight. */
.plan-icon-btn-text {
  font-size: 12px;
  font-weight: 600;
  color: var(--core-green-press);
}

/* ----------------------------------------------------------------------
   Viewport tools — floating pill at the bottom of the 3D view carrying
   the camera projection toggle and the section box.

   Floating rather than docked: a docked strip would take height off the
   viewport permanently, and this is a handful of controls that are only
   occasionally touched. Same white-pill treatment as .plan-zoom-pill in
   the 2D pane, so the two bottom bars read as the same thing in two
   contexts.
   ---------------------------------------------------------------------- */

.viewport-tools {
  position: fixed;
  bottom: 14px;
  /* Spans the viewer, not the window, so the pill centres over the 3D
     canvas rather than under the sidebar. --sidebar-w is rewritten live by
     the divider drag handler, so this follows a resized sidebar. */
  left: calc(var(--sidebar-w) + var(--sidebar-divider-w));
  right: 0;
  display: flex;
  justify-content: center;
  /* The strip is full-width and invisible, so it must not intercept
     anything. Without this it would swallow orbit and pan drags across the
     whole bottom of the viewport — the pill re-enables pointer events for
     itself below. */
  pointer-events: none;
  /* Above the 3D canvas and the plan pane (5), below #toolbar (20) and
     #tab-bar (18) — though neither of those can reach the bottom of the
     window, so the only ordering that matters here is against the two
     rules below. */
  z-index: 15;
}

/* Hidden while a plan tab is open.

   The 2D pane has its own bottom toolbar, which this would otherwise sit
   directly on top of. Hiding rather than repositioning because the
   controls have nothing to act on there: plan tabs force orthographic
   regardless of the toggle, and the plan is drawn server-side from level
   geometry, so the section box does not affect it either.

   The one consequence worth knowing: a section box left switched on stays
   on while you are in a plan tab, with no visible control. It is still
   clipping the 3D view, and the button — still showing as active — comes
   back when you return to it. That is a change from when these lived in
   the top toolbar and were always on screen.

   The sibling combinator works because #viewport-tools is written after
   #plan-2d-pane in Index.cshtml; keep that order. */
#plan-2d-pane:not([hidden]) ~ .viewport-tools {
  display: none;
}

/* Hidden during a model load, for the same reason #ifc-loading exists.
   That overlay covers exactly the 3D pane to blank it while web-ifc
   parses on the main thread — and this pill sits inside that rectangle at
   a higher z-index, so without this rule it would float over the loading
   card, still looking clickable. The section box button is disabled by
   then, but the projection toggle is not: a click would queue a camera
   change that fires whenever the parse finally releases the thread. */
#ifc-loading:not([hidden]) ~ .viewport-tools {
  display: none;
}

.viewport-tools-pill {
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 8px;
  background: #ffffff;
  border: 1px solid #d0d0d0;
  border-radius: 6px;
  /* Slightly deeper than .plan-zoom-pill's shadow because this one floats
     over a dark 3D canvas rather than sitting on a light strip. */
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
}

/* The projection toggle is shared with nothing else now, but it was sized
   for the 30px top-toolbar row. Scoped down here rather than changed at
   source, so .proj-toggle keeps its original proportions if it is ever
   reused in a full-height strip again. */
.viewport-tools .proj-toggle { height: 26px; }
.viewport-tools .proj-btn {
  height: 24px;
  padding: 0 11px;
  font-size: 12px;
}

/* ----------------------------------------------------------------------
   Progress overlay for GetIFCLevelGeometry (NDJSON-streamed). Centered
   card over the 2D pane. The fill is driven from JS off the server's
   progress events — bands match the labels in
   IFCViewerController.ResolveProgressLabel.
   ---------------------------------------------------------------------- */

.plan-progress {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(360px, 80%);
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid #d0d0d0;
  border-radius: 8px;
  padding: 14px 16px;
  box-shadow: 0 6px 22px rgba(0, 0, 0, 0.16);
  font-family: var(--sans);
  color: #222;
  z-index: 7;
}

.plan-progress[hidden] { display: none; }

.plan-progress-label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 13px;
  margin-bottom: 8px;
  gap: 12px;
}

.plan-progress-label #plan-progress-text {
  color: #333;
}

.plan-progress-label #plan-progress-pct {
  color: #666;
  font-variant-numeric: tabular-nums;
  font-size: 12px;
}

.plan-progress-track {
  width: 100%;
  height: 6px;
  background: #ececec;
  border-radius: 3px;
  overflow: hidden;
}

.plan-progress-fill {
  height: 100%;
  width: 0%;
  background: #009FFF;   /* SelectedPathBrush — same accent as curtain walls */
  border-radius: 3px;
  transition: width 0.15s ease-out;
}

/* ----------------------------------------------------------------------
   Export status toast — visible feedback while the .cnect file is being
   built and streamed to the browser. Sits fixed at the top-right of the
   viewport, tucked under the toolbar so it doesn't obscure it. Fades in
   on show, fades out on hide.

   Three visual states, keyed by class on the outer element:
     .export-status.is-busy     → indeterminate animated fill (CoreGreen)
     .export-status.is-success  → filled bar (CoreGreen), auto-hides
     .export-status.is-error    → filled bar (error red), stays a bit longer
   ---------------------------------------------------------------------- */
.export-status {
  position: fixed;
  top: calc(var(--toolbar-h) + 8px);
  right: 16px;
  min-width: 260px;
  max-width: 380px;
  padding: 8px 12px 10px 12px;
  background: #ffffff;
  border: 1px solid #d0d0d0;
  border-radius: 6px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
  font-family: var(--sans);
  font-size: 12px;
  color: var(--text-light);
  z-index: 30;                          /* above toolbar */
  transition: opacity 0.18s ease, transform 0.18s ease;
  opacity: 1;
  transform: translateY(0);
}
.export-status[hidden] {
  display: none;
}
.export-status.is-hiding {
  opacity: 0;
  transform: translateY(-4px);
}

.export-status-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 6px;
}
.export-status-text {
  font-weight: 500;
  color: #333;
}
.export-status-pct {
  color: #666;
  font-variant-numeric: tabular-nums;
}
.export-status-track {
  height: 6px;
  background: #ececec;
  border-radius: 3px;
  overflow: hidden;
  position: relative;
}
.export-status-fill {
  height: 100%;
  width: 0%;
  background: var(--core-green);
  border-radius: 3px;
  transition: width 0.15s ease-out, background 0.18s ease;
}

/* Busy state — the fill becomes an indeterminate shimmer that slides
   left→right continuously. No width transition on the fill; we drive
   width via keyframes on ::after. */
.export-status.is-busy .export-status-fill {
  width: 100%;
  background: linear-gradient(
      90deg,
      transparent 0%,
      var(--core-green) 30%,
      var(--core-green) 70%,
      transparent 100%);
  background-size: 40% 100%;
  background-repeat: no-repeat;
  background-position: -40% 0;
  animation: export-status-slide 1.2s linear infinite;
}
@keyframes export-status-slide {
  0%   { background-position: -40% 0; }
  100% { background-position: 140% 0; }
}

/* Success — solid CoreGreen fill at 100%. */
.export-status.is-success .export-status-fill {
  width: 100%;
  background: var(--core-green);
  animation: none;
}

/* Error — solid error red at 100%; message text turns red too. */
.export-status.is-error .export-status-fill {
  width: 100%;
  background: var(--error, #d93025);
  animation: none;
}
.export-status.is-error .export-status-text {
  color: var(--error, #d93025);
}

/* ----------------------------------------------------------------------
   Add-Room controls in the plan toolbar. Match the WPF pattern:
     - Add Room = toggle. Active state uses the SelectedPathBrush accent.
     - Add All  = one-shot button next to it.
     - Confirm / Cancel appear only while add-room is active.
   ---------------------------------------------------------------------- */

.plan-room-tools {
  display: inline-flex;
  gap: 4px;
}

/* Plan-toolbar compact button. Same "utility outlined" resting state as
   .dlg-mini, same CoreGreen hover/active. Extra visual affordances
   (is-active toggle state + plan-mini-btn-primary) map to the WPF
   PrimaryBtnGreen palette. */
.plan-mini-btn {
  height: 26px;
  padding: 0 10px;
  font-family: var(--sans);
  font-size: 12px;
  color: var(--text-light);
  background: #f7f7f7;
  border: 1px solid #d0d0d0;
  border-radius: 4px;
  cursor: pointer;
  user-select: none;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.plan-mini-btn:hover {
  background: var(--core-green-light);
  border-color: var(--core-green-hover);
  color: var(--core-green-press);
}
.plan-mini-btn:active {
  background: var(--core-green-hover);
  border-color: var(--core-green-press);
  color: #ffffff;
}
.plan-mini-btn[hidden] { display: none; }

/* Disabled — the Section Box button ships disabled and view-clipper.js
   re-enables it once a model is loaded. Without this it looked identical
   to an enabled button and simply did nothing when clicked. Matches
   .btn-secondary:disabled so the two read the same. */
.plan-mini-btn:disabled {
  background: #f7f7f7;
  border-color: #e0e0e0;
  color: #aaa;
  cursor: default;
}
.plan-mini-btn:disabled:hover {
  background: #f7f7f7;
  border-color: #e0e0e0;
  color: #aaa;
}

/* Toggle-button "on" state — Add Room while user is placing rooms. */
.plan-mini-btn.is-active {
  background: var(--core-green);
  border-color: var(--core-green);
  color: #ffffff;
}
.plan-mini-btn.is-active:hover {
  background: var(--core-green-hover);
  border-color: var(--core-green-hover);
  color: #ffffff;
}

/* Primary variant — Confirm room, Save, etc. */
.plan-mini-btn.plan-mini-btn-primary {
  background: var(--core-green);
  border-color: var(--core-green);
  color: #ffffff;
}
.plan-mini-btn.plan-mini-btn-primary:hover {
  background: var(--core-green-hover);
  border-color: var(--core-green-hover);
  color: #ffffff;
}
.plan-mini-btn.plan-mini-btn-primary:active {
  background: var(--core-green-press);
  border-color: var(--core-green-press);
}

.plan-add-room-icon {
  font-weight: bold;
  margin-right: 2px;
}

/* ----------------------------------------------------------------------
   Level rows in the storeys panel. The Delete × sits on the right and
   fades in on row hover — matches the OnlineCAD 'level-del' pattern the
   design references.
   ---------------------------------------------------------------------- */

/* ----------------------------------------------------------------------
   Project Browser tree. Sections collapse via max-height on
   .tree-section-body; the chevron rotates -90° when the section root
   picks up the .collapsed class.
   ---------------------------------------------------------------------- */

.project-tree {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 4px 0;
}

.tree-section {
  border-bottom: 1px solid #e0e0e0;
}
.tree-section:last-child { border-bottom: 0; }

.tree-section-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  cursor: pointer;
  user-select: none;
  outline: none;
}
.tree-section-header:hover,
.tree-section-header:focus-visible {
  background: rgba(0, 0, 0, 0.05);   /* dark tint on light bg */
}

/* Chevron — deliberately 3× the prior size so it reads clearly as a
   collapse affordance. Uses a fixed width so the section titles line up
   horizontally across all sections regardless of chevron rotation. */
.tree-toggle {
  display: inline-block;
  width: 26px;
  text-align: center;
  color: var(--text-light);
  font-size: 30px;
  font-weight: 300;
  line-height: 1;
  transition: transform 0.15s ease;
  transform-origin: 50% 50%;
}
.tree-section.collapsed .tree-toggle {
  transform: rotate(-90deg);
}

.tree-section-title {
  flex: 1;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.tree-section-count {
  font-size: 10px;
  color: var(--text-super-light);
  font-variant-numeric: tabular-nums;
  padding: 0 4px;
}

.tree-section-actions {
  display: inline-flex;
  gap: 3px;
  opacity: 0.55;
  transition: opacity 0.15s ease;
}
.tree-section-header:hover .tree-section-actions,
.tree-section-header:focus-within .tree-section-actions {
  opacity: 1;
}

/* Collapse animation. max-height must be a fixed value for a smooth
   transition — 50vh is generous enough that no realistic level count
   would truncate mid-animation. */
.tree-section-body {
  max-height: 50vh;
  overflow-y: auto;
  transition: max-height 0.2s ease, opacity 0.15s ease;
}
.tree-section.collapsed .tree-section-body {
  max-height: 0;
  opacity: 0;
  overflow: hidden;
}

/* Generic tree row (3D Views, Elevations). Level rows still use .lvl-row. */
.tree-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px 4px 44px;   /* left inset aligns with the chevron column below */
  font-size: 13px;
  color: var(--text-light);
  cursor: pointer;
}
.tree-item:hover {
  background: rgba(0, 0, 0, 0.05);
}
.tree-item-muted {
  color: var(--text-super-light);
  font-style: italic;
  cursor: default;
}
.tree-item-muted:hover { background: transparent; }

/* Nested level rows sit inside the Levels tree section — indent them so
   the checkbox column aligns with the tree items below. */
.tree-section-body .lvl-row {
  padding-left: 44px;   /* aligns with .tree-item indent (chevron column) */
  grid-template-columns: 20px 1fr auto 22px;
  border-bottom: 0;
}

.lvl-row {
  display: grid;
  grid-template-columns: 24px 1fr auto 22px;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  cursor: pointer;
}

.lvl-row:hover {
  background: rgba(255, 255, 255, 0.05);
}

/* Selected level row — mirrors the 2D plan's SelectedPathBrush blue so
   the panel and the 3D plane paint the same colour when a level is
   picked. Left-side accent bar echoes the WPF selection indicator. The
   row's grid columns already account for 8px padding, so the 3px inset
   accent lands cleanly without shifting content around. */
.lvl-row.is-selected {
  background: rgba(0, 159, 255, 0.10);
  box-shadow: inset 3px 0 0 0 #009FFF;
}
.lvl-row.is-selected:hover {
  background: rgba(0, 159, 255, 0.16);
}
.lvl-row.is-selected .lvl-name {
  color: #009FFF;
  font-weight: 600;
}

/* Custom levels used to render in italic-grey to signal "user-created".
   That extra styling made the list feel inconsistent — custom rows now
   look identical to IFC-imported rows. The .lvl-row-custom class is
   preserved (no style rules) so future differentiations can hang off it
   without another DOM change. */

.lvl-row .lvl-del {
  opacity: 0;
  background: transparent;
  border: 0;
  color: var(--text-super-light);
  font-size: 16px;
  line-height: 1;
  padding: 0;
  cursor: pointer;
  transition: opacity 0.12s ease, color 0.12s ease;
}

.lvl-row:hover .lvl-del  { opacity: 0.8; }
.lvl-row .lvl-del:hover  { color: var(--error); opacity: 1; }

/* Compact utility button used inside dialog headers and the level panel
   header (+ / All / None). Base is neutral grey; hover flips to the
   CoreGreen accent so it aligns with the WPF button palette without
   overwhelming panel chrome. */
.dlg-mini {
  height: 22px;
  padding: 0 8px;
  font-family: var(--sans);
  font-size: 12px;
  color: var(--text-light);
  background: #f0f0f0;
  border: 1px solid #ccc;
  border-radius: 4px;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.dlg-mini:hover {
  background: var(--core-green-light);
  border-color: var(--core-green-hover);
  color: var(--core-green-press);
}
.dlg-mini:active {
  background: var(--core-green-hover);
  border-color: var(--core-green-press);
  color: #ffffff;
}

/* Primary compact button — matches WPF PrimaryBtnGreen at reduced size. */
.dlg-mini-primary {
  background: var(--core-green);
  border-color: var(--core-green);
  color: #ffffff;
}
.dlg-mini-primary:hover {
  background: var(--core-green-hover);
  border-color: var(--core-green-hover);
  color: #ffffff;
}
.dlg-mini-primary:active {
  background: var(--core-green-press);
  border-color: var(--core-green-press);
}

/* ----------------------------------------------------------------------
   Create-Level modal. Centered overlay dialog with the same accent
   colors as the rest of the plan UI.
   ---------------------------------------------------------------------- */

.cam-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 26, 33, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}
.cam-modal-overlay[hidden] { display: none; }

.cam-modal-box {
  min-width: 320px;
  background: #ffffff;
  color: #222;
  border: 1px solid #d0d0d0;
  border-radius: 8px;
  padding: 18px 20px 14px 20px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
}

.cam-modal-title {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 12px;
  color: #1f2937;
}

.cam-modal-label {
  display: block;
  font-size: 11px;
  color: #666;
  margin: 8px 0 4px 0;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.cam-modal-input {
  width: 100%;
  height: 30px;
  padding: 0 8px;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-family: var(--sans);
  font-size: 13px;
  color: #222;
  background: #fafafa;
  box-sizing: border-box;
}
.cam-modal-input:focus {
  outline: none;
  /* Match WPF TextBox focus — CoreGreenLight fill + CoreGreenHover border. */
  border-color: var(--core-green-hover);
  background: var(--core-green-light);
}

.cam-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
}

.cam-modal-error {
  color: #d9534f;
  font-size: 12px;
  margin-top: 8px;
}
.cam-modal-error[hidden] { display: none; }

/* Message variant (the refused-RVT dialog): a sentence and a few facts
   rather than inputs. */
.cam-modal-box-message {
  max-width: 460px;
}

.cam-modal-message {
  margin: 0 0 12px 0;
  font-size: 13px;
  line-height: 1.45;
  color: #333;
}

.cam-modal-facts {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 4px 12px;
  margin: 0;
  padding: 10px 12px;
  background: #f6f7f8;
  border: 1px solid #e3e5e8;
  border-radius: 6px;
  font-size: 12px;
}
.cam-modal-facts dt {
  color: #666;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  font-size: 11px;
  align-self: center;
}
.cam-modal-facts dd {
  margin: 0;
  color: #1f2937;
  font-weight: 600;
  overflow-wrap: anywhere;
}


/* ----------------------------------------------------------------------
   Right-click context menu on the 3D canvas.
   viewer.js's contextmenu handler positions this at the mouse and
   toggles [hidden] to show/hide. Uses fixed positioning so it doesn't
   scroll with the viewer container; z-index sits above the viewer but
   below the top toolbar so keyboard focus doesn't fight the toolbar.
   ---------------------------------------------------------------------- */
.pick-menu {
  position: fixed;
  min-width: 180px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 0;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
  z-index: 8000;
  color: var(--text);
  font: 13px var(--sans);
  user-select: none;
}
.pick-menu[hidden] { display: none; }

/* The "Classify as" block: its items lay out as direct children of the
   menu; [hidden] removes the block for an RVT element (viewer.js). */
.pick-menu-classify { display: contents; }
.pick-menu-classify[hidden] { display: none; }

.pick-menu-item {
  display: block;
  width: 100%;
  padding: 8px 14px;
  background: none;
  border: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.pick-menu-item:hover,
.pick-menu-item:focus {
  background: var(--core-green);
  color: #fff;
  outline: none;
}

.pick-menu-item[disabled] {
  color: var(--text-super-light);
  cursor: default;
}
.pick-menu-item[disabled]:hover { background: transparent; color: var(--text-super-light); }

.pick-menu-sep {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 4px 0;
}
/* ----------------------------------------------------------------------
   Orbit cursor — Shift + middle-drag rotates the 3D camera.

   Two states, both driven by wwwroot/js/viewer.js → setupOrbitModifier:
     .orbit-armed   Shift is held, orbit is available but not yet engaged
     .orbit-active  Shift + middle button is down, camera is orbiting

   The glyph is a pair of opposing curved arrows around a centre dot —
   the conventional "rotate about a point" symbol. Drawn twice in the
   SVG: a thick dark stroke underneath and a thin white stroke on top,
   so it stays legible against both the dark 3D background and light
   model surfaces. Hotspot is the centre (16 16) because that's the
   point the camera pivots around.
   ---------------------------------------------------------------------- */
#viewer-container.orbit-armed,
#viewer-container.orbit-active {
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='32' height='32' viewBox='0 0 32 32'%3E%3Cg fill='none' stroke='%23000' stroke-opacity='.55' stroke-width='4.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M16 6.5 A 9.5 9.5 0 0 1 25.5 16'/%3E%3Cpath d='M21.6 12.6 L25.6 16.6 L29.4 12.5'/%3E%3Cpath d='M16 25.5 A 9.5 9.5 0 0 1 6.5 16'/%3E%3Cpath d='M10.4 19.4 L6.4 15.4 L2.6 19.5'/%3E%3C/g%3E%3Cg fill='none' stroke='%23fff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M16 6.5 A 9.5 9.5 0 0 1 25.5 16'/%3E%3Cpath d='M21.6 12.6 L25.6 16.6 L29.4 12.5'/%3E%3Cpath d='M16 25.5 A 9.5 9.5 0 0 1 6.5 16'/%3E%3Cpath d='M10.4 19.4 L6.4 15.4 L2.6 19.5'/%3E%3C/g%3E%3Ccircle cx='16' cy='16' r='3' fill='%23000' fill-opacity='.55'/%3E%3Ccircle cx='16' cy='16' r='1.9' fill='%23fff'/%3E%3C/svg%3E") 16 16, move;
}

/* Non-interactive group heading inside the pick context menu — labels
   the "Classify as" block so its four category items don't read as
   siblings of Hide / Isolate. */
.pick-menu-label {
  padding: 6px 14px 2px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.7px;
  text-transform: uppercase;
  color: var(--text-super-light);
  user-select: none;
  pointer-events: none;
}

/* ── Export format split button ──────────────────────────────────────
   A caret sits flush against the Export button and opens a menu of
   output formats. Rendered as a separate <button> rather than a <select>
   because the two formats need explanatory sub-text — CamelModel and
   ProjectDto are different structures in different units, and a bare
   dropdown label doesn't carry enough to prevent the wrong pick. */
.export-split {
  position: relative;                    /* anchors the absolutely-positioned menu */
  display: inline-flex;
  vertical-align: middle;
}

.export-caret {
  padding: 0 8px;                        /* narrower than a normal .btn — it's a caret, not a label */
  margin-left: -1px;                     /* collapse the doubled border against Export */
  border-top-left-radius: 0;             /* fuse visually with the button on its left */
  border-bottom-left-radius: 0;
  font-size: 11px;
}

.export-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 40;                           /* above the canvas and the toolbar's own stacking */
  min-width: 260px;
  padding: 4px;
  background: #ffffff;
  border: 1px solid var(--border, #d7dce1);
  border-radius: 4px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.16);
}

.export-menu-item {
  display: block;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: 3px;
  background: transparent;
  font-family: var(--sans);
  text-align: left;                      /* override the button centring inherited from .btn siblings */
  cursor: pointer;
}

.export-menu-item:hover,
.export-menu-item:focus-visible {
  background: rgba(0, 159, 255, 0.10);
}

.export-menu-item strong {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: #1c2530;
}

/* Sub-label carries the distinction that matters: units and consumer.
   Muted so it reads as supporting detail, not a second option. */
.export-menu-item small {
  display: block;
  margin-top: 2px;
  font-size: 11px;
  color: #6b7784;
}

/* CAMEL+Cnect export dialog — supporting text inside the shared
   .cam-modal-box shell. Two states: a neutral note, and an error tint used
   when the Accelerator is unreachable or the user isn't signed in, since
   that message is the difference between "wait" and "go do something". */
.cc-modal-note {
  max-width: 360px;
  margin: 8px 0 4px 0;
  font-size: 12px;
  line-height: 1.45;
  color: #6b7784;
}

.cc-modal-note.is-error {
  color: #b03a2e;
}

/* ----------------------------------------------------------------------
   IFC load indicator.

   Covers the 3D pane only — geometry mirrors #viewer-container so the
   toolbar, tab strip and sidebar stay usable and visible.

   ── Why the animation is a bare transform ──
   web-ifc parses on the MAIN THREAD (initIfcLoader sets a wasm path but no
   worker), so during a large model load the main thread is blocked and any
   JS-driven animation, or any animation of a property that needs layout or
   paint, stops dead. A `transform: rotate` keyframe is promoted to the
   compositor, which runs on its own thread and keeps the ring turning
   while the parse blocks everything else. `will-change: transform` forces
   that layer up front rather than on first frame.

   This is also why there is no percentage: ifcLoader.load() is a single
   opaque await with no progress events. An indeterminate ring is honest;
   a progress bar would have to invent numbers.
   ---------------------------------------------------------------------- */

#ifc-loading {
  position: fixed;
  top: calc(var(--toolbar-h) + var(--tab-h));
  left: calc(var(--sidebar-w) + var(--sidebar-divider-w));
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  /* Slightly milky rather than opaque: the model fades in behind the card
     as it loads, which reads as progress on its own. */
  background: rgba(240, 243, 245, 0.72);
  backdrop-filter: blur(1.5px);
  z-index: 8;                /* above the 2D pane's progress card (7) */
  cursor: progress;
}

#ifc-loading[hidden] { display: none; }

/* Same card treatment as .plan-progress and .cam-modal-box. */
.ifc-loading-card {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 260px;
  max-width: 420px;
  padding: 16px 20px;
  background: rgba(255, 255, 255, 0.97);
  border: 1px solid #d0d0d0;
  border-radius: 8px;
  box-shadow: 0 6px 22px rgba(0, 0, 0, 0.16);
  font-family: var(--sans);
}

.ifc-loading-spinner {
  flex: 0 0 auto;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  /* Three-quarter ring: a full ring with one segment tinted reads as
     rotation; a uniform ring would look static however fast it spins. */
  border: 3px solid #e2e7e3;
  border-top-color: var(--core-green);
  will-change: transform;
  animation: ifc-spin 0.9s linear infinite;
}

@keyframes ifc-spin {
  to { transform: rotate(360deg); }
}

/* Respect the OS setting — a perpetual spin is a common migraine trigger.
   Pulse the opacity instead so there is still a sign of life. */
@media (prefers-reduced-motion: reduce) {
  .ifc-loading-spinner {
    animation: ifc-pulse 1.6s ease-in-out infinite;
    border-top-color: var(--core-green);
  }
  @keyframes ifc-pulse {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0.35; }
  }
}

.ifc-loading-title {
  font-size: 14px;
  font-weight: 600;
  color: #1f2937;
}

.ifc-loading-sub {
  margin-top: 3px;
  font-size: 12px;
  color: #6b7784;
  /* Long IFC filenames shouldn't stretch the card off-centre. */
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 320px;
}
.ifc-loading-sub:empty { display: none; }

/* ----------------------------------------------------------------------
   Levels list — busy state.

   The level list is built from the BROWSER's parse of the IFC, so it fills
   in seconds. The server needs longer: it has to receive the upload and
   build its own Xbim geometry context before it can answer a plan request.
   During that window the rows exist and look clickable but nothing can be
   opened yet, so they're visibly disabled rather than silently unresponsive.

   pointer-events only stops the mouse — LevelsManager.openPlanTab carries
   the same check so keyboard and programmatic callers are blocked too.
   ---------------------------------------------------------------------- */

.lvl-list.is-busy {
  /* Not display:none — the user should still see WHICH levels are coming,
     just not be able to open them yet. */
  opacity: 0.45;
  pointer-events: none;
  user-select: none;
}

/* Progress hint above the list, so the reason is visible next to the thing
   that's disabled rather than only in the toolbar toast.

   The text comes from data-busy-reason, written by LevelsManager.setBusy
   from the ServerModelGate state, rather than being hard-coded here. It used
   to always read "Preparing model on the server…", which is a lie in the two
   states that are not preparation: nothing loaded yet, and a load that
   failed. Those need to say so — a user staring at "preparing…" over a load
   that died has no reason to stop waiting. */
#levels-panel.is-busy .lvl-list::before {
  content: attr(data-busy-reason);
  display: block;
  padding: 6px 8px;
  font-size: 11px;
  font-style: italic;
  color: var(--core-green-press, #2f6b3c);
}

/* A failed load is not progress. Same slot, error colour, so the difference
   is legible at a glance rather than only on a careful read. */
#levels-panel.is-busy[data-busy-state="failed"] .lvl-list::before {
  color: var(--error, #d9534f);
  font-style: normal;
}

/* Suppress the row hover affordance while disabled — a highlight on
   something that can't be clicked is a lie. */
.lvl-list.is-busy .lvl-row:hover {
  background: transparent;
  cursor: not-allowed;
}

/* ── CAMEL+Cnect 3D Builder export dialog ─────────────────────────── */
.cb-open-link {
  display: flex;
  gap: 6px;
  align-items: center;
  margin: 6px 0 2px 0;
}

.cb-open-link[hidden] {
  display: none;
}

.cb-open-link .cam-modal-input {
  flex: 1;
  font-size: 12px;
}
