/* The 3D stage and everything floating over it: first-run drop zone, messages, the tool
   bar (section box first), the view widget, selection/filter chips, the build progress,
   legend, toasts, tooltip. Dark chrome in both themes: it sits on the canvas. */
.stage { color: var(--stage-text); }

/* First run: a welcoming drop zone */
.shell[data-loaded="false"] .stage-ui { display: grid; place-items: start center; }

.stage-message { position: absolute; top: 50%; left: 50%; display: grid; gap: 6px; width: min(440px, calc(100% - 32px)); padding: var(--s-4) var(--s-5); border: 1px solid var(--stage-chrome-line); border-radius: var(--r-3); background: var(--stage-chrome); transform: translate(-50%, -50%); }
.stage-message[data-tone="error"] { box-shadow: inset 3px 0 0 var(--sev-blocking); }
.stage-message strong { font-size: var(--t-lg); }
.stage-message p { color: var(--stage-text-2); font-size: var(--t-sm); line-height: var(--lh); }

/* Floating chrome */
.toolbar, .chip, .legend, .toast {
  border: 1px solid var(--stage-chrome-line);
  background: var(--stage-chrome);
  box-shadow: var(--shadow-1);
  backdrop-filter: blur(8px) saturate(1.2);
}
/* Floating chrome never steals a click: only real controls are hit-testable. A stray
   decorative icon must never block a control underneath (W4 session contract). */
.chip, .toolbar, .legend, .tooltip, .stage-progress { pointer-events: none; }
.chip button, .chip a, .toolbar button, .legend button, .toolbar .tool { pointer-events: auto; }
.toolbar { position: absolute; z-index: 70; display: flex; align-items: center; gap: 2px; padding: 3px; border-radius: 10px; }
.toolbar > * { flex: none; } /* phone: the bar scrolls, a tool never shrinks under its label (« Coupe ») */
.toolbar-tools { bottom: var(--s-4); left: 50%; transform: translateX(-50%); width: max-content; max-width: calc(100% - 16px); flex-wrap: wrap; justify-content: center; } /* narrow stage (clash layout): wraps, never clipped */
.toolbar-views { top: var(--s-3); right: var(--s-3); display: grid; grid-template-columns: repeat(2, 30px); gap: 2px; padding: 3px; }
.toolbar-views .tool { width: 30px; height: 30px; padding: 0; }
.toolbar-views .icon { width: 18px; height: 18px; }
.tool {
  position: relative;
  height: 30px;
  min-width: 32px;
  padding: 0 7px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--stage-text-2);
  font-size: var(--t-sm);
  font-weight: var(--w-medium);
}
.tool:hover:not([aria-disabled="true"]) { background: var(--stage-hover); color: var(--stage-text); }
.tool[aria-pressed="true"] { background: #e3e7ec; color: #0c0e11; }
.tool[aria-pressed="true"]:hover { background: #ffffff; color: #0c0e11; }
.tool[aria-disabled="true"] { opacity: .36; cursor: default; }
.tool:focus-visible { outline: 2px solid #d7e3f6; outline-offset: -2px; }
.tool-text { gap: 6px; padding: 0 10px 0 8px; }
.tool-label { font-size: var(--t-sm); }
.tool-prominent { padding: 0 12px 0 9px; border: 1px solid var(--stage-chrome-line); }
.tool-prominent[aria-pressed="true"] { border-color: transparent; }
.tool-sep { width: 1px; height: 20px; margin: 0 4px; background: var(--stage-chrome-line); }

/* Chips: selection, filter, isolation — each with its way out */
.chips { position: absolute; top: var(--s-3); left: var(--s-3); z-index: 3; display: grid; justify-items: start; gap: 6px; max-width: calc(100% - 120px); pointer-events: none; }
.chip { display: flex; align-items: center; gap: var(--s-2); max-width: 100%; overflow: hidden; height: 30px; padding: 0 3px 0 10px; border-radius: 15px; color: var(--stage-text); font-size: var(--t-sm); pointer-events: auto; }
.chip-measure .chip-value { color: var(--stage-text); font-size: var(--t-md); font-weight: var(--w-semibold); }
.chip-warn { box-shadow: inset 3px 0 0 var(--sev-review), var(--shadow-1); }
.stage-action { justify-self: start; margin-top: var(--s-2); border-color: var(--stage-chrome-line); color: var(--stage-text); }
.stage-action:hover { background: var(--stage-hover); }
.chip-dot { width: 8px; height: 8px; flex: none; border-radius: 50%; background: var(--brand-a); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-a) 25%, transparent); }
.chip-icon { color: var(--stage-text-2); }
.chip-icon .icon { width: 14px; height: 14px; }
.chip-title { min-width: 0; max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: var(--w-semibold); }
.chip-meta { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; color: var(--stage-text-2); font-size: var(--t-xs); white-space: nowrap; }
.chip-action { height: 24px; padding: 0 9px; border: 0; border-radius: 12px; background: var(--stage-hover); color: var(--stage-text); font-size: var(--t-xs); font-weight: var(--w-semibold); }
.chip-action:hover { background: #333c47; }
.chip .chip-clear { width: 24px; height: 24px; border-radius: 12px; color: var(--stage-text-2); }
.chip .chip-clear:hover { background: var(--stage-hover); color: var(--stage-text); }
.chip .chip-clear .icon { width: 12px; height: 12px; }

/* Build progress: a hairline across the top of the stage, and a quiet label */
.stage-progress { position: absolute; top: 0; left: 0; right: 0; z-index: 3; pointer-events: none; }
.stage-progress:empty { display: none; }
.stage-progress .progress { position: absolute; top: 0; left: 0; right: 0; display: block; width: auto; height: 2px; border-radius: 0; background: #ffffff14; }
.stage-progress .progress-bar { background: #cfd8e3; transition: transform 320ms var(--ease); }
.stage-progress .progress-label { position: absolute; top: var(--s-3); left: 50%; display: flex; align-items: center; gap: var(--s-2); height: 28px; padding: 0 var(--s-3); border: 1px solid var(--stage-chrome-line); border-radius: 14px; background: var(--stage-chrome); color: var(--stage-text); font-size: var(--t-sm); transform: translateX(-50%); white-space: nowrap; }
.stage-progress .progress-label .num { color: var(--stage-text-2); }

/* Legend (colour mode) */
.legend { position: absolute; top: 96px; right: var(--s-3); display: flex; align-items: center; gap: var(--s-3); height: 30px; padding: 0 var(--s-3); border-radius: 15px; color: var(--stage-text-2); font-size: var(--t-xs); }
.legend-title { color: var(--stage-text); font-weight: var(--w-semibold); }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.legend-item[data-severity="blocking"] .sev-dot { background: #e5484d; }
.legend-item[data-severity="review"] .sev-dot { background: #f0a830; }
.legend-item[data-severity="info"] .sev-dot { background: #7d8da3; }

/* Toasts */
.toasts { bottom: 64px; }
.toast { display: flex; align-items: center; gap: var(--s-2); max-width: 100%; padding: 6px 6px 6px var(--s-3); border-radius: var(--r-2); color: var(--stage-text); font-size: var(--t-sm); }
.toast[data-tone="error"] { box-shadow: inset 3px 0 0 var(--sev-blocking), var(--shadow-1); }
.toast .icon-button { width: 22px; height: 22px; color: var(--stage-text-2); }
.toast .icon-button:hover { background: var(--stage-hover); color: var(--stage-text); }

/* Tooltip (one for the page, positioned by dom/tooltip.js) */
.tooltip { position: fixed; top: var(--tip-y, 0); left: var(--tip-x, 0); z-index: 90; display: grid; gap: 2px; max-width: 260px; padding: 5px 8px; border: 1px solid #39424d; border-radius: var(--r-2); background: #0b0d10; box-shadow: var(--shadow-1); color: #e8ebef; font-size: var(--t-xs); pointer-events: none; }
.tooltip[hidden] { display: none; }
.tip-main { display: flex; align-items: center; gap: var(--s-2); }
.tooltip .kbd { border-color: #39424d; color: #a6afba; }
.tip-note { color: #a6afba; }

@media (max-width: 760px) {
  .shell[data-loaded="false"] .stage-ui { margin: var(--s-3); }
  .welcome { padding: var(--s-4); }
  .toolbar-tools { bottom: var(--s-2); flex-wrap: nowrap; justify-content: flex-start; overflow-x: auto; }
  .toolbar-views { grid-template-columns: repeat(4, 30px); }
  .legend { display: none; }
  .chips { max-width: calc(100% - 24px); top: 52px; }
  .shell[data-model="false"] .stage-message { position: static; margin: var(--s-4) auto; transform: none; }
}

/* D-S1-04 : panneau « Filtre » (entités IFC), posé au-dessus de la barre d'outils du bas. */
.efilter-layer:empty { display: none; }
.efilter { position: absolute; z-index: 75; bottom: 56px; left: 50%; transform: translateX(-50%); display: grid; grid-template-rows: auto auto auto minmax(0, 1fr); gap: var(--s-2); width: min(380px, calc(100% - 16px)); max-height: min(520px, calc(100% - 120px)); padding: var(--s-3); border: 1px solid var(--stage-chrome-line); border-radius: var(--r-3); background: var(--stage-chrome); box-shadow: var(--shadow-1); backdrop-filter: blur(8px) saturate(1.2); color: var(--stage-text); }
.efilter-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s-2); }
.efilter-title { display: flex; align-items: center; gap: 6px; margin: 0; font-size: var(--t-md); font-weight: var(--w-semibold); }
.efilter .field { height: 30px; border-color: var(--stage-chrome-line); background: transparent; color: var(--stage-text); }
.efilter-tools { display: flex; align-items: center; gap: var(--s-2); }
.efilter-storey { flex: 1 1 auto; min-width: 0; }
.efilter .secondary-action { border-color: var(--stage-chrome-line); background: transparent; color: var(--stage-text); }
.efilter .secondary-action:hover:not(:disabled) { background: var(--stage-hover); }
.efilter .secondary-action[aria-pressed="true"] { background: var(--stage-on); }
.efilter-body { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; gap: var(--s-2); min-height: 0; }
.efilter-bulk { display: flex; align-items: center; gap: var(--s-2); font-size: var(--t-sm); color: var(--stage-text-2); }
.efilter-summary { flex: 1 1 auto; min-width: 0; }
.efilter-bulk .link-row { width: auto; padding: 2px 6px; color: var(--stage-text); }
.efilter-scroll { min-height: 0; max-height: 300px; overflow-y: auto; overscroll-behavior: contain; }
.efilter-list { display: grid; gap: 1px; margin: 0; padding: 0; list-style: none; }
.efilter-row { display: grid; grid-template-columns: 18px minmax(0, 1fr) auto auto; align-items: center; gap: var(--s-2); min-height: 32px; padding: 2px 6px; border-radius: 6px; font-size: var(--t-sm); cursor: pointer; }
.efilter-row:hover { background: var(--stage-hover); }
.efilter-row input { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); }
.efilter-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.efilter-class { max-width: 9.5em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--stage-text-2); font-size: var(--t-xs); }
.efilter-count { color: var(--stage-text-2); font-variant-numeric: tabular-nums; }
.efilter-group-title { display: flex; justify-content: space-between; margin: var(--s-2) 6px 2px; color: var(--stage-text-2); font-size: var(--t-xs); font-weight: var(--w-semibold); text-transform: uppercase; letter-spacing: .04em; }
.efilter-empty { margin: var(--s-2); color: var(--stage-text-2); font-size: var(--t-sm); }
.efilter-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.efilter-actions .primary-action { height: 30px; padding: 0 12px; }
.efilter-actions :disabled { opacity: .45; cursor: default; }
@media (max-width: 760px) {
  .efilter { bottom: 48px; max-height: calc(100% - 64px); }
  .efilter-row { grid-template-columns: 18px minmax(0, 1fr) auto; row-gap: 0; padding: 4px 6px; }
  .efilter-class { grid-column: 2; grid-row: 2; max-width: 100%; }
  .efilter-count { grid-column: 3; grid-row: 1 / span 2; }
}
