  /* Layout: full-bleed model stage; HUD pinned to the edges, name plate top-left, view rail and switches along the bottom */
  :root {
    --bg: #ffffff;
    --scene: #ffffff;
    --panel: #f7f5f1;
    --fg: #1d1b18;
    --muted: #6a645a;
    --line: #cdc6bb;
    --accent: #95540f;
    --accent-ink: #fffaf2;
    --font-ui: "Archivo", "Helvetica Neue", Arial, sans-serif;
    --font-mono: "IBM Plex Mono", ui-monospace, Menlo, Consolas, monospace;
    color-scheme: light;
  }
  /* the background is always white (the model sits on the white 3DNA pages); a dark look only on request */
  :root[data-theme="dark"] {
    --bg: #121110; --scene: #141312; --panel: #1c1b19; --fg: #efebe4; --muted: #a59e93;
    --line: #38342f; --accent: #e2a15a; --accent-ink: #1b1206; color-scheme: dark;
  }

  html, body { height: 100%; }
  body {
    background: var(--bg);
    color: var(--fg);
    font-family: var(--font-ui);
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
  }

  #stage { position: fixed; inset: 0; background: var(--scene); }
  #stage canvas { display: block; width: 100%; height: 100%; touch-action: none; outline: none; }

  #tags { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
  .tag {
    position: absolute; left: 0; top: 0;
    display: flex; flex-direction: column; align-items: center; gap: 3px;
    padding-bottom: 16px; white-space: nowrap; will-change: transform;
  }
  .tag::after {
    content: ""; position: absolute; bottom: 0; left: 50%;
    width: 1px; height: 14px; background: var(--fg); opacity: .45;
  }
  .tag::before {
    content: ""; position: absolute; bottom: -3px; left: calc(50% - 3px);
    width: 7px; height: 7px; border-radius: 50%; background: var(--accent);
  }
  .tag-name {
    font: 650 11.5px/1.2 var(--font-ui); font-stretch: 115%;
    letter-spacing: .08em; text-transform: uppercase;
    padding: 4px 8px; border-radius: 4px;
    background: color-mix(in srgb, var(--panel) 90%, transparent);
    border: 1px solid var(--line);
  }
  .tag-dim {
    font: 500 11px/1.2 var(--font-mono); color: var(--muted);
    padding: 1px 6px; border-radius: 3px;
    background: color-mix(in srgb, var(--panel) 78%, transparent);
    font-variant-numeric: tabular-nums;
  }
  .tag--dim .tag-name { font: 600 12px/1.2 var(--font-mono); letter-spacing: 0; text-transform: none; }
  .tag--dim::before { background: var(--fg); }

  .hud {
    position: fixed; inset: 0; pointer-events: none;
    display: flex; flex-direction: column; justify-content: space-between; gap: 12px;
    padding-block: calc(env(safe-area-inset-top, 0px) + 16px) calc(env(safe-area-inset-bottom, 0px) + 16px);
    padding-left: max(16px, env(safe-area-inset-left, 0px));
    padding-right: max(16px, env(safe-area-inset-right, 0px));
  }
  .glass {
    background: color-mix(in srgb, var(--panel) 88%, transparent);
    border: 1px solid var(--line);
    border-radius: 8px;
    backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  }

  .plate { pointer-events: auto; align-self: flex-start; width: min(360px, 100%); padding: 14px 16px; }
  .eyebrow {
    margin: 0 0 6px; font: 600 11px/1 var(--font-mono);
    letter-spacing: .14em; text-transform: uppercase; color: var(--accent);
  }
  h1 {
    margin: 0; font: 700 26px/1.02 var(--font-ui); font-stretch: 120%;
    letter-spacing: -.005em; text-wrap: balance;
  }
  .note { margin: 8px 0 0; font-size: 13px; line-height: 1.45; color: var(--muted); }
  details { margin-top: 10px; border-top: 1px solid var(--line); padding-top: 8px; }
  summary {
    cursor: pointer; list-style: none; display: flex; justify-content: space-between; align-items: center;
    font: 650 11.5px/1.3 var(--font-ui); font-stretch: 112%; letter-spacing: .08em; text-transform: uppercase;
  }
  summary::-webkit-details-marker { display: none; }
  summary::after { content: "+"; font: 500 15px/1 var(--font-mono); color: var(--muted); }
  details[open] summary::after { content: "\2212"; }
  summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 2px; }
  details ul { margin: 8px 0 0; padding-left: 16px; font-size: 13px; line-height: 1.5; color: var(--muted); display: grid; gap: 3px; }
  details li::marker { color: var(--accent); }

  .dock { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 10px; pointer-events: none; }
  .dock-left { display: flex; flex-direction: column; gap: 8px; min-width: 0; max-width: 100%; pointer-events: none; }
  .rail, .switches { pointer-events: auto; display: flex; gap: 2px; padding: 4px; max-width: 100%; }
  .rail { overflow-x: auto; scrollbar-width: none; }
  .rail::-webkit-scrollbar { display: none; }
  .switches { flex-wrap: wrap; }
  .rail button, .switches button {
    flex: none; appearance: none; border: 0; cursor: pointer;
    font: 600 13px/1 var(--font-ui); font-stretch: 106%;
    padding: 9px 12px; border-radius: 5px;
    background: transparent; color: var(--fg);
  }
  .rail button:hover, .switches button:hover { background: color-mix(in srgb, var(--fg) 8%, transparent); }
  .rail button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
  .switches button { display: flex; align-items: center; gap: 8px; color: var(--muted); }
  .switches button[aria-pressed="true"] { color: var(--fg); }
  .pip { width: 9px; height: 9px; border-radius: 50%; border: 1.5px solid currentColor; }
  .switches button[aria-pressed="true"] .pip { background: var(--accent); border-color: var(--accent); }
  button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

  .dock-right { display: flex; flex-direction: column; gap: 8px; width: min(480px, 100%); pointer-events: none; }
  .finishes { pointer-events: auto; display: grid; gap: 12px; padding: 12px 12px 14px; }
  .finish-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 8px; }
  .finish-label {
    font: 650 11px/1.2 var(--font-ui); font-stretch: 112%;
    letter-spacing: .08em; text-transform: uppercase; color: var(--muted);
  }
  .finish-value { font: 600 13px/1.2 var(--font-ui); text-align: right; min-width: 0; }
  .swatches { display: grid; grid-template-columns: repeat(10, minmax(0, 1fr)); gap: 6px; }
  .swatches--led { grid-template-columns: repeat(6, 30px); gap: 10px; }
  .swatch {
    appearance: none; padding: 0; width: 100%; aspect-ratio: 1; cursor: pointer;
    border: 1px solid color-mix(in srgb, var(--fg) 18%, transparent); border-radius: 5px;
    background-color: var(--line); background-size: 230%; background-position: 20% 20%;
    transition: transform .12s ease;
  }
  .swatch:hover { transform: translateY(-1px); }
  .swatch[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--panel), 0 0 0 4px var(--accent); }
  .swatches--led .swatch { border-radius: 50%; }
  .swatches--led .swatch[aria-pressed="true"] {
    box-shadow: 0 0 0 2px var(--panel), 0 0 0 4px var(--accent), 0 0 14px 3px var(--glow, transparent);
  }
  @media (prefers-reduced-motion: reduce) { .swatch { transition: none; } }

  .hint { margin: 0; font: 500 11px/1.4 var(--font-mono); color: var(--muted); pointer-events: none; }
  .hint .touch { display: none; }
  @media (pointer: coarse) { .hint .mouse { display: none; } .hint .touch { display: inline; } }

  .status {
    position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%);
    width: min(360px, calc(100% - 32px)); padding: 16px 18px; text-align: center;
  }
  .status p { margin: 0; font-size: 14px; line-height: 1.5; }
  .status strong { display: block; margin-bottom: 4px; font: 650 12px/1.3 var(--font-ui); letter-spacing: .08em; text-transform: uppercase; }

  /* Specification panel: top right, scrolls inside itself, clear of the finishes panel */
  .spec {
    position: fixed; z-index: 4;
    top: calc(env(safe-area-inset-top, 0px) + 16px); right: max(16px, env(safe-area-inset-right, 0px));
    width: min(420px, calc(100% - 32px)); max-height: calc(100dvh - var(--dock-h, 300px) - 48px); min-height: 200px;
    display: flex; flex-direction: column; outline: none;
  }
  .spec[hidden] { display: none; }
  .spec-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 14px 16px 10px; border-bottom: 1px solid var(--line); }
  .spec h2 { margin: 0; font: 700 20px/1.05 var(--font-ui); font-stretch: 120%; }
  .spec-close {
    appearance: none; border: 0; cursor: pointer; width: 32px; height: 32px; border-radius: 5px;
    background: transparent; color: var(--fg); font: 400 22px/1 var(--font-ui);
  }
  .spec-close:hover { background: color-mix(in srgb, var(--fg) 8%, transparent); }
  #spec-body { overflow-y: auto; padding: 4px 16px 0; overscroll-behavior: contain; }
  .spec-sec { padding: 12px 0; border-bottom: 1px solid var(--line); }
  .spec-sec h3 {
    display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin: 0 0 8px;
    font: 650 11px/1.2 var(--font-ui); font-stretch: 112%; letter-spacing: .08em; text-transform: uppercase; color: var(--muted);
  }
  .spec-sec h3 span { font: 600 12px/1.2 var(--font-ui); letter-spacing: 0; text-transform: none; color: var(--fg); text-align: right; }
  .spec table { width: 100%; border-collapse: collapse; font-size: 13px; }
  .spec th, .spec td { padding: 4px 0; vertical-align: top; }
  .spec th { font-weight: 500; text-align: left; color: var(--fg); }
  .spec td { text-align: right; font: 500 12.5px/1.4 var(--font-mono); font-variant-numeric: tabular-nums; white-space: nowrap; padding-left: 12px; }
  .spec tr.tot th, .spec tr.tot td { font-weight: 650; }
  .spec tr.tot td { color: var(--accent); }
  .spec-fix { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
  .spec-fix li { display: grid; grid-template-columns: 1fr auto; gap: 1px 12px; font-size: 12.5px; line-height: 1.4; color: var(--muted); }
  .spec-fix b { font-weight: 600; color: var(--fg); }
  .spec-fix .spec-room { text-align: right; font: 500 11px/1.4 var(--font-mono); }
  .spec-fix span:nth-of-type(n+2) { grid-column: 1 / -1; }
  .spec-note { margin: 0; padding: 10px 16px 14px; font-size: 11.5px; line-height: 1.45; color: var(--muted); }

  @media (max-width: 640px) {
    .spec { top: calc(env(safe-area-inset-top, 0px) + 8px); right: 8px; width: calc(100% - 16px); max-height: calc(100dvh - 120px); }
    h1 { font-size: 22px; }
    .plate { padding: 12px 14px; }
    .note { font-size: 12.5px; }
    .dock { flex-direction: column; align-items: stretch; }
    .switches { align-self: flex-start; }
    .dock-right { width: 100%; }
    .finishes { padding: 10px; gap: 10px; }
    .hint { display: none; }
    .tag-dim { display: none; }
  }

  /* public embed (?public=1, the 3DNA project page): no name plate; the page around it carries the title
     and the "concept model" note. The controls stay at the bottom. */
  html[data-public] .plate { display: none; }
  html[data-public] .hud { justify-content: flex-end; }

  /* ---------- phones (mobile first): the model gets the screen above the controls ---------- */
  .phone-only, .switches button.phone-only { display: none; }
  @media (max-width: 640px) {
    /* the 3D view ends where the controls begin (--stage-bottom, set by the script), so the model is framed
       in the free space instead of behind the panels */
    #stage { bottom: var(--stage-bottom, 0px); }
    .phone-only, .switches button.phone-only { display: flex; }
    .dock { gap: 8px; }
    .dock-left { width: 100%; }
    .rail { width: 100%; box-sizing: border-box; }
    .rail button, .switches button { padding: 11px 12px; }     /* 40 px+ touch targets */
    .switches { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; align-self: stretch; overscroll-behavior-x: contain; }
    .switches::-webkit-scrollbar { display: none; }
    /* finishes fold into a sheet opened by the "Finishes" switch */
    .finishes { display: none; max-height: 46vh; overflow-y: auto; overscroll-behavior: contain; }
    html.finishes-open .finishes { display: grid; }
    #t-finishes[aria-expanded="true"] { color: var(--fg); }
    #t-finishes[aria-expanded="true"] .pip { background: var(--accent); border-color: var(--accent); }
    .swatches { gap: 5px; }
    .swatches--led { grid-template-columns: repeat(6, 34px); gap: 12px; }
  }

  /* direct-link pages (/<lang>/…/<project>/<model>/): a way back to the project page */
  .ws-back {
    position: fixed; z-index: 3; top: calc(env(safe-area-inset-top, 0px) + 12px); left: max(12px, env(safe-area-inset-left, 0px));
    display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 14px;
    font: 650 12px/1 var(--font-ui); font-stretch: 112%; letter-spacing: .08em; text-transform: uppercase;
    color: var(--fg); text-decoration: none;
  }
  .ws-back:hover { color: var(--accent); }
  .ws-back:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

  /* ---------- services layers: switch pips and labels in the layer colours ---------- */
  .switches button[aria-pressed="true"] .pip--elec { background: #f2a900; border-color: #f2a900; }
  .switches button[aria-pressed="true"] .pip--water { background: #2f7de1; border-color: #2f7de1; }
  .switches button[aria-pressed="true"] .pip--drain { background: #7a6552; border-color: #7a6552; }
  .tag--svc .tag-name { font: 600 10.5px/1.2 var(--font-ui); letter-spacing: .02em; text-transform: none; padding: 3px 7px; }
  .tag--svc .tag-dim { font-size: 10px; }
  .tag--elec::before { background: #f2a900; }
  .tag--water::before { background: #2f7de1; }
  .tag--drain::before { background: #7a6552; }
  .spec-layer { margin: 12px 0 6px; font: 650 11px/1.2 var(--font-ui); letter-spacing: .08em; text-transform: uppercase; display: flex; align-items: center; gap: 8px; }
  .spec-layer::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
  .spec-layer--elec { color: #b07a00; } .spec-layer--water { color: #2f7de1; } .spec-layer--drain { color: #7a6552; }

  /* ---------- print the selected configuration ---------- */
  .spec-actions { display: flex; align-items: center; gap: 6px; }
  .spec-print {
    appearance: none; cursor: pointer; border: 1px solid var(--line); border-radius: 5px; background: var(--panel);
    padding: 8px 10px; font: 600 11.5px/1.2 var(--font-ui); color: var(--fg); text-align: left; max-width: 170px;
  }
  .spec-print:hover { border-color: var(--accent); color: var(--accent); }
  #print-sheet { display: none; }
  @media print {
    @page { size: A4; margin: 14mm; }
    html, body { height: auto !important; overflow: visible !important; background: #fff !important; }
    body > *:not(#print-sheet) { display: none !important; }
    #print-sheet { display: block; color: #1d1b18; font: 10.5pt/1.45 var(--font-ui); }
    .ps-head { border-bottom: 1px solid #cdc6bb; padding-bottom: 8px; margin-bottom: 12px; }
    .ps-brand { margin: 0; font: 600 9pt/1 var(--font-mono); letter-spacing: .14em; color: #95540f; }
    .ps-head h1 { margin: 4px 0 2px; font-size: 18pt; }
    .ps-meta { margin: 0; color: #6a645a; font-size: 9pt; }
    #print-sheet h2 { margin: 14px 0 6px; font-size: 12pt; }
    .ps-config dl { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 0; }
    .ps-config dt { font-size: 8pt; text-transform: uppercase; letter-spacing: .08em; color: #6a645a; }
    .ps-config dd { margin: 2px 0 0; font-weight: 600; }
    .ps-shot { margin: 12px 0; border: 1px solid #e6e2dc; }
    .ps-shot img { display: block; width: 100%; max-height: 120mm; object-fit: contain; }
    .ps-spec .spec-sec { break-inside: avoid; padding: 8px 0; border-bottom: 1px solid #e6e2dc; }
    .ps-spec h3 { display: flex; justify-content: space-between; margin: 0 0 4px; font-size: 9pt; text-transform: uppercase; letter-spacing: .08em; color: #6a645a; }
    .ps-spec h3 span { text-transform: none; letter-spacing: 0; color: #1d1b18; }
    .ps-spec table { width: 100%; border-collapse: collapse; font-size: 9.5pt; }
    .ps-spec th { text-align: left; font-weight: 500; } .ps-spec td { text-align: right; font-family: var(--font-mono); }
    .ps-spec tr.tot th, .ps-spec tr.tot td { font-weight: 700; }
    .ps-spec .spec-fix { list-style: none; margin: 0; padding: 0; columns: 2; column-gap: 10mm; font-size: 9pt; }
    .ps-spec .spec-fix li { break-inside: avoid; margin-bottom: 5px; display: grid; grid-template-columns: 1fr auto; }
    .ps-spec .spec-fix span:nth-of-type(n+2) { grid-column: 1 / -1; color: #6a645a; }
    .ps-note { margin-top: 10px; font-size: 8pt; color: #6a645a; }
  }
