:root {
  color-scheme: light dark;
  --ink: light-dark(#1a1a1a, #f5f3ec);
  --muted: light-dark(#706d65, #aaa59a);
  --quiet: light-dark(#918b7d, #777269);
  --line: light-dark(#dcd6c8, #3b3d43);
  --panel: light-dark(rgba(255,253,248,.93), rgba(29,31,37,.93));
  --panel-solid: light-dark(#fffdf8, #1d1f25);
  --bg: light-dark(#f6f3ec, #111318);
  --link: light-dark(#1552a1, #83b0e8);
  --soft: light-dark(rgba(26,26,26,.04), rgba(255,255,255,.045));
  --active: light-dark(#e5ebf3, #2a303b);
  --stage: light-dark(radial-gradient(circle at 50% 47%, #fffdf8, #eee9df 52%, #ddd6c9), radial-gradient(circle at 50% 47%, #282d38, #191c23 52%, #101217));
  --grid: light-dark(rgba(65,63,57,.085), rgba(210,216,228,.06));
  --guide: light-dark(rgba(45,53,67,.24), rgba(211,221,237,.18));
  --outline: light-dark(rgba(255,253,248,.92), rgba(15,17,21,.9));
  --edge: light-dark(#3b4657, #b8c5d8);
  --halo: light-dark(#9a6300, #f0b96e);
  --shadow: light-dark(rgba(58,43,14,.15), rgba(0,0,0,.32));
}
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { width: 100%; min-height: 100%; margin: 0; background: var(--bg); }
body { min-height: 100vh; min-height: 100svh; overflow: hidden; color: var(--ink); font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
button, input { font: inherit; }
button { color: inherit; }
a { color: var(--link); text-underline-offset: .2em; }
.topbar { position: relative; z-index: 30; height: 72px; display: grid; grid-template-columns: 270px 1fr 270px; align-items: center; padding: 0 18px; border-bottom: 1px solid var(--line); background: var(--panel); backdrop-filter: blur(16px); }
.back { font-family: Georgia, serif; font-size: .9rem; }
.title-block { text-align: center; }
.title-block h1 { margin: 0; font-family: Georgia, serif; font-size: 1.45rem; font-weight: 500; }
.title-block p { margin: 4px 0 0; color: var(--muted); font-size: .69rem; letter-spacing: .1em; text-transform: uppercase; }
.top-actions { justify-self: end; display: flex; align-items: center; gap: 9px; }
.icon-button, .theme-toggle { display: grid; place-items: center; width: 38px; height: 38px; padding: 0; border: 1px solid var(--line); border-radius: 10px; background: var(--soft); cursor: pointer; }
.theme-toggle { width: 34px; height: 34px; border-radius: 50%; background: none; }
.icon-button:hover, .theme-toggle:hover { border-color: var(--link); }
.icon-button svg, .theme-toggle svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
:root[data-theme="dark"] .theme-toggle .moon, :root[data-theme="light"] .theme-toggle .sun { display: none; }
.workspace { --details-width: 330px; height: calc(100svh - 72px); display: grid; grid-template-columns: minmax(0,1fr) var(--details-width); }
.workspace.details-collapsed { grid-template-columns: minmax(0,1fr) 28px; }
#stage { position: relative; min-width: 0; min-height: 0; overflow: hidden; background: var(--stage); container-type: size; }
#stage::before { content: ""; position: absolute; inset: 0; background-image: linear-gradient(var(--grid) 1px,transparent 1px),linear-gradient(90deg,var(--grid) 1px,transparent 1px); background-size: 44px 44px; mask-image: radial-gradient(circle,black,transparent 75%); }
#cloud, #overlay { position: absolute; inset: 0; display: block; width: 100%; height: 100%; }
#cloud { pointer-events: none; }
#overlay { touch-action: none; cursor: grab; outline: none; }
#overlay.grabbing { cursor: grabbing; }
#overlay.pull { cursor: move; }
.unsupported { position: absolute; inset: 50% auto auto 50%; z-index: 9; transform: translate(-50%,-50%); padding: 10px 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); color: var(--muted); }
.card, .zoom-card { position: absolute; z-index: 6; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); box-shadow: 0 8px 26px -18px var(--shadow); backdrop-filter: blur(14px); }
.show-card { top: 14px; left: 14px; width: 252px; height: calc(62% - 20px); overflow: hidden; }
.options-card { top: 14px; right: 14px; width: 238px; max-height: calc(72% - 20px); }
.look-card { bottom: 14px; left: 14px; width: 252px; max-height: calc(38% - 20px); }
.card { overflow: auto; scrollbar-width: thin; }
.card-head { position: sticky; top: 0; z-index: 2; width: 100%; display: flex; justify-content: space-between; padding: 9px 11px 7px; border: 0; background: var(--panel-solid); color: var(--link); font-size: .66rem; font-weight: 750; letter-spacing: .13em; text-transform: uppercase; cursor: pointer; }
.card-head i { display: none; font-style: normal; }
.card-body { padding: 2px 10px 11px; }
.show-card .card-body { height: calc(100% - 34px); overflow-y: auto; scrollbar-width: thin; }
.segmented { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; padding: 3px; border-radius: 9px; background: var(--soft); }
.segment { min-height: 30px; padding: 0 7px; border: 0; border-radius: 7px; color: var(--muted); background: transparent; cursor: pointer; font-size: .7rem; }
.segment:hover { color: var(--ink); }
.segment.active { color: var(--ink); background: var(--active); box-shadow: 0 1px 6px var(--shadow); }
.dimensions { margin-bottom: 8px; }
.scene-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; }
.scene-group-heading { grid-column: 1/-1; display: flex; align-items: center; gap: 5px; margin: 5px 0 0; padding: 4px 1px; border: 0; background: none; color: var(--muted); text-align: left; cursor: pointer; font-size: .57rem; font-weight: 750; letter-spacing: .08em; text-transform: uppercase; }
.scene-group-heading:hover { color: var(--ink); }
.scene-group-heading i { width: 10px; color: var(--link); font-style: normal; font-size: .72rem; letter-spacing: 0; }
.scene-group-heading:first-child { margin-top: 1px; }
.scene-button { min-width: 0; min-height: 39px; display: flex; flex-direction: column; align-items: flex-start; justify-content: center; padding: 6px 7px; border: 1px solid var(--line); border-radius: 8px; background: var(--soft); text-align: left; cursor: pointer; }
.scene-button strong { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: Georgia,serif; font-size: .75rem; font-weight: 600; }
.scene-button strong small { color: var(--link); font: 700 .58rem/1 system-ui,sans-serif; }
.scene-button span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--quiet); font-size: .57rem; }
.scene-button.featured { min-height: 47px; }
.scene-button .sub { display: flex; width: 100%; gap: 5px; }
.scene-button .sub span { flex: 1 1 auto; min-width: 0; }
.scene-button .sub em { flex: none; margin-left: auto; color: var(--muted); font-style: normal; font-variant-numeric: tabular-nums; }
.scene-note { margin: 2px 1px 7px; }
.scene-button.active { border-color: var(--link); background: color-mix(in srgb,var(--link) 11%,transparent); }
.scene-button.left { border-color: var(--link); border-style: dashed; }
.motion-row { display: flex; gap: 5px; margin-top: 6px; }
.motion-row .segmented { flex: 1; }
.step-button { flex: none; padding: 0 9px; border: 1px solid var(--line); border-radius: 9px; background: var(--soft); color: var(--ink); cursor: pointer; font-size: .7rem; }
.step-button:hover { border-color: var(--link); }
.show-controls { position: absolute; top: 12px; right: 12px; z-index: 12; padding: 7px 11px; border: 1px solid var(--line); border-radius: 9px; background: var(--panel); color: var(--ink); cursor: pointer; font-size: .7rem; opacity: 0; pointer-events: none; transition: opacity .3s; }
.show-controls.visible { opacity: 1; pointer-events: auto; }
body:not(.ui-hidden) .show-controls { display: none; }
.details-mobile { display: none; }
body.ui-hidden .topbar, body.ui-hidden .card, body.ui-hidden .zoom-card, body.ui-hidden .stage-status, body.ui-hidden .results, body.ui-hidden .hover-card, body.ui-hidden .details-mobile { display: none !important; }
body.ui-hidden .workspace { height: 100svh; display: grid; grid-template-columns: minmax(0,1fr); }
body.ui-hidden #stage { height: 100svh; min-height: 0; }
body.ui-hidden { overflow: hidden; }
.scene-button:disabled, .segment:disabled { opacity: .36; cursor: not-allowed; }
.options-card .segmented + .segmented { margin-top: 6px; }
.control-note { margin: 5px 1px 8px; color: var(--quiet); font-size: .58rem; line-height: 1.35; }
.range-row { display: grid; grid-template-columns: 1fr auto; gap: 4px 7px; margin-top: 10px; color: var(--muted); font-size: .68rem; }
.range-row output { color: var(--ink); font-family: ui-monospace,SFMono-Regular,Menlo,monospace; }
.range-row input { grid-column: 1/-1; width: 100%; margin: 0; accent-color: var(--link); }
.range-ends { display: flex; justify-content: space-between; color: var(--quiet); font-size: .58rem; }
.wide-button { width: 100%; margin: 7px 0; padding: 7px; border: 1px solid var(--line); border-radius: 8px; background: var(--soft); cursor: pointer; font-size: .7rem; }
.mini-label { display: block; margin: 7px 0 5px; color: var(--muted); font-size: .62rem; text-transform: uppercase; letter-spacing: .1em; }
.colour-options { display: grid; grid-template-columns: repeat(5,1fr); gap: 3px; }
.look-card .colour-options { margin-top: 8px; }
.choice { min-width: 0; min-height: 27px; padding: 0 3px; border: 1px solid var(--line); border-radius: 7px; background: var(--soft); color: var(--muted); cursor: pointer; font-size: .62rem; }
.choice.active { border-color: var(--link); color: var(--ink); background: color-mix(in srgb,var(--link) 10%,transparent); }
.choice:disabled { opacity: .35; }
.legend { margin-top: 7px; display: grid; gap: 2px; }
.legend.two-columns { grid-template-columns: 1fr 1fr; column-gap: 10px; }
.legend-row { display: grid; grid-template-columns: 9px 1fr auto; align-items: center; gap: 6px; min-height: 18px; padding: 1px 2px; border: 0; background: none; color: var(--muted); text-align: left; cursor: pointer; font-size: .59rem; }
.legend-row i { width: 8px; height: 8px; border-radius: 50%; background: var(--swatch); }
.legend-row span:last-child { font-variant-numeric: tabular-nums; }
.legend-row.off { opacity: .33; text-decoration: line-through; }
.zoom-card { right: 14px; bottom: 14px; display: flex; flex-direction: column; overflow: hidden; }
.zoom-card button { width: 38px; height: 36px; display: grid; place-items: center; border: 0; background: transparent; cursor: pointer; font-size: 1.2rem; }
.zoom-card button + button { border-top: 1px solid var(--line); }
.zoom-card svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.hover-card { position: absolute; z-index: 8; max-width: 220px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel-solid); color: var(--muted); pointer-events: none; font-size: .66rem; line-height: 1.45; box-shadow: 0 8px 24px var(--shadow); }
.stage-status { position: absolute; right: 66px; bottom: 15px; left: 282px; z-index: 5; display: flex; justify-content: space-between; gap: 12px; color: var(--quiet); font-size: .61rem; pointer-events: none; }
.results { position: relative; min-width: 0; min-height: 0; overflow: hidden; border-left: 1px solid var(--line); background: var(--panel); }
.results-content { height: 100%; overflow-y: auto; padding: 22px 20px 40px 38px; }
.details-collapsed .results-content { display: none; }
.details-rail { position: absolute; inset: 0 auto 0 0; z-index: 3; width: 18px; padding: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 9px; border: 0; border-right: 1px solid var(--line); background: var(--soft); color: var(--link); cursor: col-resize; touch-action: none; }
.details-rail span { display: none; writing-mode: vertical-rl; transform: rotate(180deg); color: var(--muted); font-size: .59rem; font-weight: 750; letter-spacing: .11em; text-transform: uppercase; }
.details-rail i { font: normal 1rem/1 system-ui,sans-serif; }
.details-collapsed .details-rail { width: 28px; }
.details-collapsed .details-rail span { display: block; }
.details-rail:focus-visible { outline: 2px solid var(--link); outline-offset: -3px; }
.eyebrow { color: var(--link); font-size: .64rem; font-weight: 750; letter-spacing: .12em; text-transform: uppercase; }
.result-title h2 { margin: 7px 0 8px; font: 500 1.55rem/1.1 Georgia,serif; }
.result-title p { margin: 0; color: var(--muted); font: .86rem/1.5 Georgia,serif; }
.result-section { padding: 17px 0; border-top: 1px solid var(--line); }
.result-title + .result-section { margin-top: 18px; }
.result-section h3 { margin: 7px 0; font: 500 1rem Georgia,serif; }
.coordinates { margin: 7px 0; font: .69rem/1.55 ui-monospace,SFMono-Regular,Menlo,monospace; overflow-wrap: anywhere; }
.secondary { margin: 6px 0; color: var(--muted); font-size: .68rem; line-height: 1.45; }
.pile-stepper { display: flex; align-items: center; justify-content: space-between; margin: 10px 0 3px; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; color: var(--muted); font-size: .69rem; }
.pile-stepper button { width: 32px; height: 28px; border: 0; background: var(--soft); cursor: pointer; font-size: 1.1rem; }
.layer-section { font-size: .68rem; }
.layer-row { display: grid; grid-template-columns: 9px 1fr auto; align-items: center; gap: 7px; padding: 4px 0; color: var(--muted); }
.layer-row i { width: 8px; height: 8px; border-radius: 50%; background: var(--swatch); }
.layer-row strong { color: var(--ink); font-family: ui-monospace,SFMono-Regular,Menlo,monospace; font-weight: 500; }
.prose p { margin: 8px 0; color: var(--muted); font: .8rem/1.55 Georgia,serif; }
.sources { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; padding-top: 17px; border-top: 1px solid var(--line); font-size: .7rem; }
.info-page { overflow: auto; }
.info-page main { width: min(720px,calc(100% - 36px)); margin: 0 auto; padding: 50px 0 80px; }
.info-page h1,.info-page h2 { font-family: Georgia,serif; font-weight: 500; }
.info-page h1 { font-size: clamp(2rem,6vw,3.7rem); }
.info-page p { max-width: 68ch; line-height: 1.65; }

@media (max-width: 1080px) {
  .topbar { grid-template-columns: 1fr auto 1fr; }
  .back { font-size: 0; text-decoration: none; }
  .back::before { content: "←"; font-size: 1.2rem; }
  .workspace { --details-width: 270px; }
  .results-content { padding: 18px 15px 34px 33px; }
  .show-card,.look-card { width: 220px; }
  .options-card { width: 215px; }
  .stage-status { left: 250px; }
}

@media (max-width: 760px) {
  body { overflow: auto; }
  .topbar { position: sticky; top: 0; height: 58px; padding: 0 10px; }
  .title-block h1 { font-size: 1.08rem; }
  .title-block p { display: none; }
  .workspace { height: auto; display: block; }
  #stage { height: calc(100svh - 58px); min-height: 500px; }
  .results { min-height: 100svh; border-top: 1px solid var(--line); border-left: 0; }
  .workspace.details-collapsed .results { min-height: 42px; }
  .results-content { height: auto; min-height: 100svh; overflow: visible; padding: 24px 18px 60px; }
  .details-rail { position: static; width: 100%; height: 42px; flex-direction: row; border-right: 0; border-bottom: 1px solid var(--line); cursor: pointer; }
  .details-rail span, .details-collapsed .details-rail span { display: block; writing-mode: horizontal-tb; transform: none; }
  .details-collapsed .details-rail { width: 100%; }
  .details-mobile { position: absolute; right: 56px; bottom: 9px; z-index: 6; display: block; min-height: 36px; padding: 0 11px; border: 1px solid var(--line); border-radius: 9px; background: var(--panel); color: var(--link); cursor: pointer; font-size: .68rem; }
  .card { width: auto; max-height: none; overflow: visible; }
  .show-card { height: auto; }
  .show-card .card-body { height: auto; }
  .show-card { top: 9px; left: 9px; }
  .options-card { top: 9px; right: 9px; }
  .look-card { bottom: 9px; left: 9px; }
  .card-head { position: static; width: auto; min-width: 86px; display: flex; gap: 10px; padding: 9px 10px; border-radius: 10px; }
  .card-head i { display: block; }
  .card-body { position: absolute; width: 232px; max-height: min(66svh,480px); overflow-y: auto; padding: 8px 9px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel-solid); box-shadow: 0 8px 24px var(--shadow); }
  .show-card .card-body { top: 42px; left: 0; }
  .options-card .card-body { top: 42px; right: 0; }
  .look-card .card-body { bottom: 42px; left: 0; }
  .card.folded .card-body { display: none; }
  .card.folded .card-head i { transform: rotate(0); }
  .zoom-card { right: 9px; bottom: 9px; }
  .stage-status { right: 140px; bottom: 10px; left: 106px; }
  #motion-status { display: none; }
  .hover-card { display: none; }
}

@media (max-height: 430px) and (pointer: coarse) {
  .topbar { height: 44px; }
  .topbar { grid-template-columns: 44px 1fr 88px; }
  .topbar .back { visibility: hidden; }
  .title-block p { display: none; }
  .workspace { height: auto; }
  #stage { height: calc(100svh - 44px); min-height: 0; }
  .results { min-height: 0; }
  .show-card,.options-card { top: 6px; }
  .show-card,.look-card { left: 6px; }
  .options-card,.zoom-card { right: 6px; }
  .look-card,.zoom-card { bottom: 6px; }
  .card { width: auto; height: auto; max-height: none; overflow: visible; }
  .card-head { position: static; width: auto; min-width: 72px; display: flex; gap: 10px; padding: 7px 8px; border-radius: 10px; }
  .card-head i { display: block; }
  .card-body, .show-card .card-body { position: absolute; width: 232px; height: auto; overflow-y: auto; padding: 8px 9px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel-solid); box-shadow: 0 8px 24px var(--shadow); }
  .show-card .card-body, .look-card .card-body { left: 0; }
  .options-card .card-body { right: 0; }
  .show-card .card-body { width: min(340px, calc(100vw - 300px)); }
  .scene-buttons { grid-template-columns: repeat(3, 1fr); }
  .card.folded .card-body { display: none; }
  .show-card .card-body,.options-card .card-body { top: 36px; }
  .look-card .card-body { bottom: 36px; }
  .card-body { max-height: calc(100svh - 96px); }
  .stage-status { display: none; }
}

@media (max-height: 800px) {
  .scene-note { display: none; }
  .scene-buttons { gap: 4px; }
  .scene-button, .scene-button.featured { min-height: 31px; padding: 3px 7px; }
  .scene-group-heading { margin-top: 2px; padding: 3px 1px; }
}

@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; } }

.selected-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.text-button { padding: 2px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--soft); color: var(--link); cursor: pointer; font-size: .68rem; }
.text-button[hidden] { display: none; }
