/* Interactive build-up and section views */
.stage-tone { --stage: #e9ebe6; --stage-line: rgba(21, 24, 27, 0.08); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .stage-tone { --stage: #1d2124; --stage-line: rgba(232, 234, 229, 0.06); } }
:root[data-theme="dark"] .stage-tone { --stage: #1d2124; --stage-line: rgba(232, 234, 229, 0.06); }

.bu { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); border: 1.5px solid var(--ink); border-radius: 2px; background: var(--ground); }
.bu-plan { border-right: 1.5px solid var(--ink); display: grid; grid-template-rows: auto 1fr auto; min-width: 0; }
.pane-head { display: flex; justify-content: space-between; align-items: center; gap: var(--s3); padding: 10px 14px; border-bottom: 1px solid var(--rule); flex-wrap: wrap; }
.pane-head .hint { font-family: var(--f-mono); font-size: 12px; color: var(--chalk); }
.plan-box { padding: var(--s3); display: grid; place-items: start center; min-width: 0; }
#plan { width: 100%; height: auto; max-height: 560px; display: block; touch-action: manipulation; }
#plan .room { font-family: var(--f-mono); font-size: 0.62px; fill: var(--ink-2); pointer-events: none; }
#plan .room.apt { font-size: 0.85px; font-weight: 600; fill: var(--ink); }
#plan .wall { cursor: pointer; }
#plan .wall .vis { transition: opacity 150ms; }
#plan .wall .halo { stroke: var(--chalk); opacity: 0; transition: opacity 150ms; }
#plan .wall .hit { stroke: transparent; }
#plan.has-sel .wall:not(.sel) .vis { opacity: 0.38; }
#plan .wall:hover .vis { opacity: 1; }
#plan .wall:hover .halo { opacity: 0.35; }
#plan .wall.sel .halo { opacity: 1; }
#plan .win { stroke-width: 0.12; opacity: 0.8; }
#plan .slabline { stroke: var(--rule); stroke-width: 0.06; fill: none; }
.legend { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px 12px 12px; border-top: 1px solid var(--rule); }
.legend button { display: inline-flex; align-items: center; gap: 6px; font: 500 12px/1 var(--f-mono); color: var(--ink); background: var(--sheet); border: 1px solid var(--rule); border-radius: 2px; padding: 6px 8px; cursor: pointer; }
.legend button i { width: 12px; height: 4px; border-radius: 1px; display: block; }
.legend button[aria-pressed="true"] { border-color: var(--chalk); box-shadow: inset 0 0 0 1px var(--chalk); }

.bu-detail { display: grid; grid-template-rows: auto auto auto 1fr; min-width: 0; }
.bu-title { display: flex; gap: var(--s3); align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--rule); }
.code-chip { flex: none; min-width: 44px; height: 30px; padding: 0 8px; display: grid; place-items: center; border-radius: 2px; color: #fff; font: 700 13px/1 var(--f-mono); }
.bu-title b { display: block; font: 800 22px/1.05 var(--f-display); font-stretch: 78%; text-transform: uppercase; }
.bu-title span { display: block; font-family: var(--f-mono); font-size: 12px; color: var(--ink-2); margin-top: 3px; }
.bu-title .code-chip { display: grid; color: #fff; font: 700 13px/1 var(--f-mono); margin-top: 0; }
.view3d { position: relative; background: var(--stage); background-image: linear-gradient(var(--stage-line) 1px, transparent 1px), linear-gradient(90deg, var(--stage-line) 1px, transparent 1px); background-size: 20px 20px; height: 340px; border-bottom: 1px solid var(--rule); overflow: hidden; }
.view3d canvas { width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; }
.view3d canvas:active { cursor: grabbing; }
.view3d .tools { position: absolute; top: 10px; right: 10px; display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.seg { display: inline-flex; border: 1.5px solid var(--ink); border-radius: 2px; overflow: hidden; background: var(--sheet); }
.seg button { font: 600 12px/1 var(--f-mono); letter-spacing: 0.04em; text-transform: uppercase; padding: 8px 10px; border: 0; background: transparent; color: var(--ink); cursor: pointer; }
.seg button + button { border-left: 1.5px solid var(--ink); }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--sheet); }
.tool-btn { font: 600 12px/1 var(--f-mono); letter-spacing: 0.04em; text-transform: uppercase; padding: 8px 10px; border: 1.5px solid var(--ink); border-radius: 2px; background: var(--sheet); color: var(--ink); cursor: pointer; }
.view3d .gesture { position: absolute; left: 10px; bottom: 10px; font-family: var(--f-mono); font-size: 11px; color: var(--ink-2); background: color-mix(in srgb, var(--sheet) 85%, transparent); padding: 4px 6px; border-radius: 2px; pointer-events: none; }
.view3d .nogl { position: absolute; inset: 0; display: grid; place-items: center; padding: var(--s5); text-align: center; color: var(--ink-2); font-size: 15px; }

.bu-layers { list-style: none; margin: 0; padding: 4px 0; border-bottom: 1px solid var(--rule); }
.bu-layers li { display: grid; grid-template-columns: 22px 14px minmax(0, 1fr); gap: 10px; align-items: center; padding: 7px 14px; font-size: 15px; line-height: 1.3; cursor: default; }
.bu-layers li .n { font: 600 12px/1 var(--f-mono); color: var(--ink-2); }
.bu-layers li .sw { width: 14px; height: 14px; border-radius: 2px; border: 1px solid rgba(0,0,0,0.25); }
.bu-layers li small { display: block; font-family: var(--f-mono); font-size: 12px; color: var(--ink-2); }
.bu-layers li.off { opacity: 0.35; }
.bu-layers li:hover { background: var(--chalk-tint); }

.bu-steps { padding: 12px 14px 14px; display: grid; gap: 10px; align-content: start; }
.bu-steps-head { display: flex; justify-content: space-between; align-items: center; gap: var(--s3); flex-wrap: wrap; }
.bu-steps ol { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.bu-steps li button { width: 100%; text-align: left; display: grid; grid-template-columns: 30px minmax(0, 1fr); gap: 10px; padding: 9px 10px; background: var(--sheet); border: 1px solid var(--rule); border-radius: 2px; color: var(--ink); cursor: pointer; font: inherit; }
.bu-steps li button .k { width: 26px; height: 26px; border-radius: 50%; border: 1.5px solid var(--ink); display: grid; place-items: center; font: 600 12px/1 var(--f-mono); }
.bu-steps li button b { font-size: 15px; }
.bu-steps li button .trade { font: 600 11px/1 var(--f-mono); letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-2); margin-left: 6px; }
.bu-steps li button p { font-size: 14px; color: var(--ink-2); margin-top: 2px; }
.bu-steps li button[aria-current="step"] { border-color: var(--chalk); background: var(--chalk-tint); }
.bu-steps li button[aria-current="step"] .k { background: var(--chalk); border-color: var(--chalk); color: var(--on-chalk); }
.bu-steps li.later button { opacity: 0.55; }
@media (max-width: 960px) { .bu { grid-template-columns: minmax(0, 1fr); } .bu-plan { border-right: 0; border-bottom: 1.5px solid var(--ink); } }
@media (max-width: 520px) { .view3d { height: 300px; } }

.sec { border: 1.5px solid var(--ink); border-radius: 2px; background: var(--ground); }
.sec .view3d { height: 520px; border-bottom: 0; }
.sec-bar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s3) var(--s5); padding: 12px 14px; border-top: 1.5px solid var(--ink); }
.sec-bar label { font-family: var(--f-mono); font-size: 12px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-2); display: flex; align-items: center; gap: 10px; }
.sec-bar input[type="range"] { width: 180px; max-width: 100%; accent-color: var(--chalk); }
.sec-bar output { font: 600 13px/1 var(--f-mono); color: var(--ink); min-width: 52px; }
.sec-legend { display: flex; flex-wrap: wrap; gap: 6px 12px; margin-left: auto; }
.sec-legend span { display: inline-flex; align-items: center; gap: 6px; font: 500 12px/1 var(--f-mono); color: var(--ink-2); }
.sec-legend i { width: 12px; height: 12px; border-radius: 2px; display: block; }
.sec-card { position: absolute; left: 10px; top: 10px; width: 300px; max-width: calc(100% - 20px); background: var(--sheet); border: 1.5px solid var(--ink); border-radius: 2px; padding: 12px; display: grid; gap: 8px; }
.sec-card .row { display: flex; gap: 10px; align-items: center; }
.sec-card b { font: 800 19px/1.05 var(--f-display); font-stretch: 78%; text-transform: uppercase; }
.sec-card small { display: block; font-family: var(--f-mono); font-size: 12px; color: var(--ink-2); }
.sec-card ul { margin: 0; padding-left: 18px; font-size: 14px; color: var(--ink-2); }
.sec-card .tool-btn { justify-self: start; background: var(--chalk); color: var(--on-chalk); border-color: var(--chalk); }
.sec-label { position: absolute; transform: translate(-50%, -50%); font: 600 11px/1 var(--f-mono); color: #15181b; background: rgba(247, 248, 245, 0.85); padding: 3px 5px; border-radius: 2px; pointer-events: none; white-space: nowrap; }
.sec-label.apt { background: #15181b; color: #f3f4f0; }
@media (max-width: 640px) { .sec .view3d { height: 420px; } .sec-card { top: auto; bottom: 10px; } .sec-legend { margin-left: 0; } }

.sec-x { margin-left: auto; align-self: flex-start; width: 30px; height: 30px; border: 1.5px solid var(--ink); background: var(--sheet); color: var(--ink); border-radius: 2px; font: 600 18px/1 var(--f-mono); cursor: pointer; flex: none; }

.floor-tabs button { padding: 7px 9px; }
.extract-note { display: grid; grid-template-columns: 22px minmax(0, 1fr); gap: 10px; margin-top: var(--s4); padding: 12px 14px; border: 1.5px dashed var(--chalk); background: var(--chalk-tint); border-radius: 2px; max-width: 62ch; }
.extract-note svg { width: 18px; height: 18px; color: var(--chalk); margin-top: 3px; }
.extract-note p { margin: 0 !important; font-size: 15px !important; color: var(--ink) !important; }
#plan .beam .halo { stroke: var(--chalk); }
.sec-bar .tool-btn[aria-pressed="true"] { background: var(--ink); color: var(--sheet); }

/* The live demo: the app's own 3D, with the picked item's sheet beside it */
.demo { border: 1.5px solid var(--ink); border-radius: 2px; background: var(--ground); overflow: hidden; }
.demo-body { position: relative; height: 720px; }
.demo-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 12px; border-bottom: 1.5px solid var(--ink); font-size: 14px; color: var(--ink-2); }
.demo-top b { color: var(--ink); }
.demo:fullscreen, .demo.demo-fs { border: 0; border-radius: 0; width: 100vw; height: 100vh; height: 100dvh; display: flex; flex-direction: column; background: var(--ground); }
.demo.demo-fs { position: fixed; inset: 0; z-index: 1000; padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px); }
.demo:fullscreen .demo-body, .demo.demo-fs .demo-body { flex: 1; height: auto; min-height: 0; }
html.demo-locked, html.demo-locked body { overflow: hidden; }
.demo-3d { position: absolute; inset: 0; background: var(--stage, #eef0ec); transition: right 260ms cubic-bezier(0.16, 1, 0.3, 1); }
.demo.has-sheet .demo-3d { right: 460px; }
.demo-3d iframe { width: 100%; height: 100%; border: 0; display: block; }
.demo-status { position: absolute; inset: 0; display: grid; place-items: center; font-family: var(--f-mono); font-size: 13px; color: var(--ink-2); background: var(--ground); padding: var(--s5); text-align: center; }
.demo-menu { position: absolute; left: 12px; bottom: 84px; width: 250px; max-width: calc(100% - 24px); background: var(--sheet); border: 1.5px solid var(--ink); border-radius: 2px; box-shadow: 0 12px 30px -12px rgba(0,0,0,0.35); padding: 4px 0; z-index: 3; max-height: calc(100% - 100px); overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.dm-head { display: flex; justify-content: space-between; align-items: center; padding: 6px 12px; font: 600 12px/1 var(--f-mono); letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-2); position: sticky; top: -4px; background: var(--sheet); z-index: 1; }
.dm-x { width: 30px; height: 30px; border: 1.5px solid var(--ink); background: var(--sheet); color: var(--ink); border-radius: 2px; font: 600 16px/1 var(--f-mono); cursor: pointer; flex: none; }
.demo-menu button[role] { display: grid; width: 100%; text-align: left; padding: 9px 12px 9px 34px; background: none; border: 0; color: var(--ink); font: 500 15px/1.3 var(--f-body); cursor: pointer; position: relative; }
.demo-menu button[role]:hover { background: var(--chalk-tint); }
.demo-menu button[aria-checked="true"]::before { content: ""; position: absolute; left: 12px; top: 50%; width: 12px; height: 7px; border-left: 2.5px solid var(--chalk); border-bottom: 2.5px solid var(--chalk); transform: translateY(-70%) rotate(-45deg); }
.demo-menu small { font-size: 12px; color: var(--ink-2); }

.demo-sheet { position: absolute; top: 0; right: 0; bottom: 0; width: 460px; max-width: 100%; overflow-y: auto; overscroll-behavior: contain; background: var(--ground); border-left: 1.5px solid var(--ink); z-index: 2; animation: ds-in 260ms cubic-bezier(0.16, 1, 0.3, 1); }
@keyframes ds-in { from { transform: translateX(24px); } to { transform: none; } }
.ds-head { position: sticky; top: 0; z-index: 1; display: flex; gap: 10px; align-items: flex-start; justify-content: space-between; padding: 14px 16px 12px; background: var(--ground); border-bottom: 1px solid var(--rule); }
.ds-head b { display: block; font: 800 24px/1.05 var(--f-display); font-stretch: 76%; text-transform: uppercase; }
.ds-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip { font: 600 11px/1 var(--f-mono); letter-spacing: 0.05em; text-transform: uppercase; padding: 5px 7px; border: 1px solid var(--rule); border-radius: 2px; color: var(--ink-2); background: var(--sheet); }
.chip.type { color: var(--chalk); border-color: var(--chalk); }
.chip.prop { color: var(--hold); border-color: color-mix(in srgb, var(--hold) 50%, transparent); }
.chip.ok { color: #2f8f6b; border-color: #2f8f6b; }
.ds-room-note { padding: 16px; color: var(--ink-2); }
.ds-sample-note { margin: 0; padding: 12px 16px; font-size: 14px; color: var(--ink-2); background: var(--chalk-tint); border-bottom: 1px solid var(--rule); }
.ds-sample-note a { color: var(--chalk); font-weight: 600; }
.ds-sec { padding: 14px 16px; display: grid; gap: 10px; border-bottom: 1px solid var(--rule); }
.ds-label { display: flex; align-items: center; gap: 8px; font: 600 12px/1 var(--f-mono); letter-spacing: 0.07em; text-transform: uppercase; color: var(--ink); }
.step-dot { width: 20px; height: 20px; border-radius: 50%; background: var(--chalk); color: var(--on-chalk); display: grid; place-items: center; font-size: 11px; }
.ds-plan { position: relative; height: 300px; overflow: hidden; background: #fff; border: 1.5px solid var(--ink); border-radius: 2px; }
.ds-plan-stage { position: absolute; left: 0; top: 0; transform-origin: 0 0; transition: transform 420ms cubic-bezier(0.16, 1, 0.3, 1), width 420ms cubic-bezier(0.16, 1, 0.3, 1), height 420ms cubic-bezier(0.16, 1, 0.3, 1); }
.ds-plan-stage img { display: block; width: 100%; height: 100%; user-select: none; }
#ds-plan-svg { position: absolute; inset: 0; width: 100%; height: 100%; }
#ds-plan-svg .pi { cursor: pointer; }
#ds-plan-svg .mark, #ds-plan-svg circle:not(.hit) { fill: none; stroke: var(--c); stroke-width: 2.2px; vector-effect: non-scaling-stroke; opacity: 0.38; stroke-linecap: round; stroke-linejoin: round; }
#ds-plan-svg .pi.area .mark, #ds-plan-svg .pi.slab .mark { fill: var(--c); fill-opacity: 0.04; stroke-width: 1px; }
#ds-plan-svg circle:not(.hit) { fill: var(--c); fill-opacity: 0.3; }
#ds-plan-svg .hit { fill: none; stroke: transparent; stroke-width: 14px; vector-effect: non-scaling-stroke; pointer-events: stroke; }
#ds-plan-svg circle.hit { fill: transparent; pointer-events: all; }
#ds-plan-svg .pi.area .hit, #ds-plan-svg .pi.slab .hit { pointer-events: none; }
#ds-plan-svg .pi:hover .mark { opacity: 0.85; }
#ds-plan-svg .pi.on .mark, #ds-plan-svg .pi.on circle:not(.hit) { stroke: #1f50c2; stroke-width: 7px; opacity: 1; filter: drop-shadow(0 0 4px rgba(31, 80, 194, 0.65)); }
#ds-plan-svg .pi.on circle:not(.hit) { fill: #1f50c2; fill-opacity: 0.6; }
.ds-plan.pulse #ds-plan-svg .pi.on .mark { animation: ds-pulse 1.4s ease-out 2; }
@keyframes ds-pulse { 0% { stroke-width: 7px; } 40% { stroke-width: 14px; } 100% { stroke-width: 7px; } }
.ds-sheet-tag { position: absolute; right: 8px; bottom: 8px; background: #15181b; color: #f3f4f0; font-size: 12px; font-weight: 600; padding: 4px 7px; border-radius: 2px; }
.ds-plan-foot { display: flex; flex-wrap: wrap; gap: 6px 12px; justify-content: space-between; align-items: center; font-family: var(--f-mono); font-size: 12px; color: var(--ink-2); }
.link-btn { background: none; border: 0; padding: 0; color: var(--chalk); font: 600 12px/1.4 var(--f-mono); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.ds-tip { font-size: 13px; color: var(--ink-2); margin: 0; }
.ds-dims { display: flex; flex-wrap: wrap; border-bottom: 1px solid var(--rule); }
.ds-dims:empty { display: none; }
.ds-dims div { padding: 10px 16px; flex: 1 1 90px; }
.ds-dims div + div { border-left: 1px solid var(--rule); }
.ds-dims b { display: block; font: 600 18px/1.2 var(--f-mono); }
.ds-dims span { font-family: var(--f-mono); font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-2); }
.ds-lines { list-style: none; margin: 0; padding: 0; border: 1px solid var(--rule); background: var(--sheet); }
.ds-lines li { display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 6px 12px 6px 6px; font-size: 14px; line-height: 1.35; }
.ds-lines li.big { grid-template-columns: 140px minmax(0, 1fr) auto; }
.mp { width: 44px; height: 44px; border-radius: 2px; background: #fff; border: 1px solid var(--rule); display: grid; place-items: center; overflow: hidden; cursor: zoom-in; }
.ds-lines li.big .mp { width: 140px; height: 140px; cursor: zoom-out; }
.mp img { width: 100%; height: 100%; object-fit: contain; display: block; }
.mp.none { background: repeating-linear-gradient(45deg, var(--sheet), var(--sheet) 4px, var(--ground) 4px, var(--ground) 8px); cursor: default; }
.mp.sm { width: 34px; height: 34px; cursor: default; }
.ds-lines li + li { border-top: 1px dashed var(--rule); }
.ds-lines .q { font-family: var(--f-mono); font-weight: 600; white-space: nowrap; }
.ds-lines .q.held { color: var(--hold); }
.ds-bu-head { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; justify-content: space-between; }
.ds-bu-head b { font: 700 15px/1.3 var(--f-body); min-width: 0; }
.ds-bu-head .seg button { padding: 7px 9px; }
.ds-bu-view { height: 280px; border: 1.5px solid var(--ink); border-radius: 2px; overflow: hidden; background: var(--stage, #eef0ec); }
.ds-bu-view iframe { width: 100%; height: 100%; border: 0; display: block; }
.ds-layers { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.ds-layers li { display: grid; grid-template-columns: 18px 34px minmax(0, 1fr); align-items: center; gap: 8px; padding: 6px 8px; font-size: 14px; cursor: pointer; border-radius: 2px; }
.ds-layers li .n { font: 600 12px/1.6 var(--f-mono); color: var(--ink-2); }
.ds-layers li small { display: block; font-family: var(--f-mono); font-size: 12px; color: var(--ink-2); }
.ds-layers li:hover, .ds-layers li.on { background: var(--chalk-tint); }
.ds-steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.ds-steps li button { width: 100%; text-align: left; display: grid; grid-template-columns: 30px minmax(0, 1fr); gap: 10px; padding: 9px 10px; background: var(--sheet); border: 1px solid var(--rule); border-radius: 2px; color: var(--ink); cursor: pointer; font: inherit; }
.ds-steps li button .k { width: 26px; height: 26px; border-radius: 50%; border: 1.5px solid var(--ink); display: grid; place-items: center; font: 600 12px/1 var(--f-mono); }
.ds-steps li button b { font-size: 15px; }
.ds-steps li button .trade { font: 600 11px/1 var(--f-mono); letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-2); margin-left: 6px; }
.ds-steps li button p { font-size: 14px; color: var(--ink-2); margin-top: 2px; }
.ds-steps li button[aria-current="step"] { border-color: var(--chalk); background: var(--chalk-tint); }
.ds-steps li button[aria-current="step"] .k { background: var(--chalk); border-color: var(--chalk); color: var(--on-chalk); }
.ds-steps li.later button { opacity: 0.55; }
.ds-trace { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.ds-trace li { font-size: 14px; color: var(--ink-2); padding-left: 14px; border-left: 2px solid var(--chalk); }
.ds-trace li b { font-family: var(--f-mono); color: var(--ink); }
@media (max-width: 900px) {
  .demo-body { height: auto; }
  .demo:fullscreen, .demo.demo-fs { overflow-y: auto; }
  .demo-3d, .demo.has-sheet .demo-3d { position: relative; inset: auto; right: auto; height: 560px; }
  /* Full screen: the model fills what the browser shows; with a pick, it keeps the top 60% and the sheet scrolls below. */
  .demo:fullscreen .demo-body, .demo.demo-fs .demo-body { display: flex; flex-direction: column; }
  .demo:fullscreen .demo-3d, .demo.demo-fs .demo-3d { flex: 1 0 auto; height: auto; min-height: 0; }
  .demo:fullscreen.has-sheet .demo-3d, .demo.demo-fs.has-sheet .demo-3d { flex: 0 0 auto; height: 60dvh; }
  .demo-sheet { position: static; width: auto; border-left: 0; border-top: 1.5px solid var(--ink); overflow: visible; animation: none; }
  .ds-head { position: static; }
  }

/* The real project, 2D */
.trace-plan { position: relative; height: 200px; overflow: hidden; background: #fff; border-bottom: 1px solid var(--rule); cursor: zoom-in; container-type: inline-size; }
.trace-stage { position: absolute; }
.rl-ref .trace-stage img { display: block; width: 100%; height: auto; max-height: none; object-fit: fill; border: 0; cursor: zoom-in; }
.trace-stage svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.trace-stage polyline, .trace-stage circle { fill: none; stroke: #1f50c2; stroke-width: 7px; vector-effect: non-scaling-stroke; stroke-linecap: round; filter: drop-shadow(0 0 4px rgba(31,80,194,0.6)); }
.rl-ref.trace.whole img { max-height: 200px; object-fit: contain; object-position: center; }

.rl-refs { display: grid; gap: 10px; }
.rl-ref { margin: 0; border: 1.5px solid var(--ink); border-radius: 2px; background: var(--sheet); overflow: hidden; }
.rl-ref img { display: block; width: 100%; height: auto; max-height: 220px; object-fit: contain; object-position: left top; background: #fff; cursor: zoom-in; border-bottom: 1px solid var(--rule); }
.rl-ref figcaption { padding: 8px 10px; display: grid; gap: 3px; }
.rl-ref-head { display: flex; gap: 8px; align-items: baseline; }
.rl-ref-head b { font-size: 13px; color: var(--chalk); }
.rl-ref-head span { font: 600 11px/1 var(--f-mono); letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-2); }
.rl-ref p { margin: 0; font-size: 14px; color: var(--ink); }
.rl-ref small { font-size: 12px; color: var(--ink-2); }
.rl-ref.flash { animation: rl-flash 1.6s ease-out; }
@keyframes rl-flash { 0%, 40% { box-shadow: 0 0 0 4px var(--chalk); } 100% { box-shadow: 0 0 0 0 transparent; } }
.spec-link { display: block; margin-top: 3px; padding: 0; border: 0; background: none; color: var(--chalk); font: 600 11px/1.3 var(--f-mono); cursor: pointer; text-align: left; text-decoration: underline; text-underline-offset: 2px; }
.ds-lines .lab { min-width: 0; }
.rl-lightbox { position: fixed; inset: 0; z-index: 2000; background: rgba(10, 12, 14, 0.82); display: grid; place-items: center; padding: 24px; cursor: zoom-out; }
.rl-lightbox figure { margin: 0; max-width: min(1200px, 100%); display: grid; gap: 8px; }
.rl-lightbox img { max-width: 100%; max-height: 80vh; background: #fff; border-radius: 2px; }
.rl-lightbox figcaption { color: #f3f4f0; font: 500 13px/1.4 var(--f-mono); }
.rl-lightbox .dm-x { position: absolute; top: 16px; right: 16px; }

.rl { display: grid; grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); border: 1.5px solid var(--ink); border-radius: 2px; background: var(--ground); height: 720px; overflow: hidden; }
.rl-plan { display: grid; grid-template-rows: auto 1fr auto auto; min-height: 0; border-right: 1.5px solid var(--ink); background: #fff; }
.rl-bar { display: flex; flex-wrap: wrap; gap: 8px; padding: 10px 12px; background: var(--ground); border-bottom: 1.5px solid var(--ink); }
.rl-bar .seg button { padding: 8px 10px; }
.rl-box { position: relative; overflow: hidden; min-height: 0; display: grid; place-items: center; touch-action: none; }
.rl-stage { position: relative; width: 100%; transform-origin: 0 0; }
.rl-stage img { display: block; width: 100%; height: auto; user-select: none; }
#rl-svg { position: absolute; inset: 0; width: 100%; height: 100%; }
#rl-svg .pi { cursor: pointer; }
#rl-svg .mark, #rl-svg circle:not(.hit) { fill: none; stroke: var(--c); stroke-width: 5px; vector-effect: non-scaling-stroke; opacity: 0.85; stroke-linecap: round; stroke-linejoin: round; }
#rl-svg .pi.dim .mark, #rl-svg .pi.dim circle:not(.hit) { opacity: 0.12; }
#rl-svg .pi.line .mark, #rl-svg .pi.count circle:not(.hit) { opacity: 0.55; stroke-width: 2px; }
.rl-legend { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 12px; background: var(--ground); border-top: 1px solid var(--rule); max-height: 96px; overflow-y: auto; }
.rl-legend button { display: inline-flex; align-items: center; gap: 6px; font: 500 12px/1 var(--f-mono); color: var(--ink); background: var(--sheet); border: 1px solid var(--rule); border-radius: 2px; padding: 6px 8px; cursor: pointer; }
.rl-legend button i { width: 16px; height: 5px; border-radius: 1px; }
.rl-legend button span { color: var(--ink-2); font-family: var(--f-body); }
.rl-legend button[aria-pressed="true"] { border-color: var(--chalk); box-shadow: inset 0 0 0 1px var(--chalk); }
#rl-svg .pi.area .mark, #rl-svg .pi.slab .mark { fill: var(--c); fill-opacity: 0.05; stroke-width: 1px; }
#rl-svg circle:not(.hit) { fill: var(--c); fill-opacity: 0.35; }
#rl-svg .hit { fill: none; stroke: transparent; stroke-width: 14px; vector-effect: non-scaling-stroke; pointer-events: stroke; }
#rl-svg circle.hit { fill: transparent; pointer-events: all; }
#rl-svg .pi.area .hit, #rl-svg .pi.slab .hit { pointer-events: none; }
#rl-svg .pi:hover .mark { opacity: 1; stroke-width: 4px; }
#rl-svg.has-pick .pi:not(.on) .mark { opacity: 0.3; }
#rl-svg .pi.on .mark, #rl-svg .pi.on circle:not(.hit) { stroke: #1f50c2; stroke-width: 7px; opacity: 1; stroke-dasharray: none; filter: drop-shadow(0 0 4px rgba(31, 80, 194, 0.65)); }
.rl-foot { display: flex; gap: 10px; align-items: center; padding: 8px 12px; border-top: 1px solid #d7d9d3; font-family: var(--f-mono); font-size: 12px; color: #545a60; background: #f6f7f4; }
.rl-foot .mono { font-weight: 600; color: #15181b; }
.rl-zoom { margin-left: auto; display: inline-flex; gap: 4px; }
.rl-zoom button { width: 30px; height: 30px; border: 1.5px solid #15181b; background: #fff; color: #15181b; border-radius: 2px; font: 600 16px/1 var(--f-mono); cursor: pointer; }
.rl-panel { overflow-y: auto; overscroll-behavior: contain; min-height: 0; }
.rl-panel .ds-head { position: sticky; top: 0; z-index: 1; }
@media (max-width: 900px) {
  .rl { grid-template-columns: minmax(0, 1fr); height: auto; }
  .rl-plan { border-right: 0; border-bottom: 1.5px solid var(--ink); height: 520px; }
  .rl-panel { overflow: visible; }
  .rl-panel .ds-head { position: static; }
}
