:root {
  color-scheme: light;
  --paper: #f7f9fb;
  --mist: #e8eef2;
  --line: #c8d4dc;
  --ink: #173042;
  --muted: #6f8290;
  --cyan: #176b87;
  --blue: #277ed8;
  --violet: #7b678d;
  --red: #b94149;
  --white: #ffffff;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--mist); color: var(--ink); }
button, a, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }

.sb-topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  min-height: 64px;
  display: grid;
  grid-template-columns: minmax(250px, 1fr) auto auto;
  align-items: stretch;
  background: rgba(247, 249, 251, 0.96);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

.sb-brand { display: grid; grid-template-columns: 38px auto; grid-template-rows: 1fr 1fr; column-gap: 12px; align-items: center; padding: 9px 18px; color: inherit; text-decoration: none; }
.sb-brand span { grid-row: 1 / 3; display: grid; place-items: center; width: 38px; height: 38px; border: 1px solid var(--cyan); border-radius: 5px; color: var(--cyan); font-weight: 800; }
.sb-brand b { align-self: end; font: 750 12px/1.2 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .12em; }
.sb-brand small { align-self: start; color: var(--muted); font-size: 10px; }
.sb-topbar nav, .sb-device { display: flex; align-items: stretch; }
.sb-topbar nav a, .sb-device button { display: grid; place-items: center; padding: 0 15px; border: 0; border-left: 1px solid var(--line); background: transparent; color: var(--muted); text-decoration: none; font-size: 12px; cursor: pointer; }
.sb-topbar nav a:hover, .sb-device button:hover { color: var(--ink); background: #fff; }
.sb-device button[aria-pressed="true"] { color: #fff; background: var(--cyan); }

.sb-page { max-width: 1880px; margin: 0 auto; padding: 28px; transition: max-width .25s ease; }
.sb-intro { display: grid; grid-template-columns: 1.1fr 1fr 260px; gap: 40px; align-items: end; margin-bottom: 22px; }
.eyebrow { margin: 0 0 8px; color: var(--cyan); font: 750 10px/1.2 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .16em; }
.sb-intro h1 { margin: 0; font: 500 clamp(28px, 3vw, 50px)/1.06 Georgia, "Songti SC", serif; }
.sb-intro > p { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.7; }
.sb-gate-status { border-left: 3px solid var(--red); padding: 8px 0 8px 15px; display: grid; gap: 4px; }
.sb-gate-status span, .sb-gate-status small { color: var(--muted); font-size: 10px; }
.sb-gate-status b { font: 800 18px/1 ui-monospace, SFMono-Regular, Menlo, monospace; }

.sb-workbench { height: min(760px, calc(100vh - 190px)); min-height: 640px; display: grid; grid-template-columns: 250px minmax(560px, 1fr) 350px; border: 1px solid #aebec8; background: var(--white); box-shadow: 0 18px 48px rgba(23, 48, 66, .12); overflow: hidden; }

.sb-filmstrip { border-right: 1px solid var(--line); background: #f6f8fa; overflow: hidden; display: grid; grid-template-rows: 48px 1fr; }
.sb-filmstrip > header { display: flex; align-items: center; justify-content: space-between; padding: 0 14px; border-bottom: 1px solid var(--line); font: 700 10px/1 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .12em; }
.sb-filmstrip ol { list-style: none; margin: 0; padding: 0; overflow: auto; }
.sb-filmstrip button { width: 100%; min-height: 64px; display: grid; grid-template-columns: 42px 1fr; grid-template-rows: auto auto; gap: 3px 8px; padding: 10px 12px; text-align: left; border: 0; border-bottom: 1px solid #d9e2e8; background: transparent; cursor: pointer; }
.sb-filmstrip button:hover { background: #fff; }
.sb-filmstrip button[aria-current="step"] { background: #e6f0f3; box-shadow: inset 4px 0 0 var(--cyan); }
.sb-filmstrip button span { grid-row: 1 / 3; display: grid; place-items: center; width: 36px; height: 36px; border: 1px solid var(--line); border-radius: 50%; color: var(--cyan); font: 800 10px/1 ui-monospace, SFMono-Regular, Menlo, monospace; }
.sb-filmstrip button b { font-size: 12px; line-height: 1.25; }
.sb-filmstrip button small { color: var(--muted); font-size: 9px; }
.sb-filmstrip button.is-approved span { color: #fff; border-color: var(--cyan); background: var(--cyan); }

.sb-stage-panel { min-width: 0; display: grid; grid-template-rows: 78px 1fr 52px; background: var(--mist); }
.sb-stage-head { display: grid; grid-template-columns: 110px 1fr auto; gap: 15px; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line); background: #fbfcfd; }
.sb-shot-id { display: grid; grid-template-columns: 42px 1fr; align-items: center; }
.sb-shot-id span { display: grid; place-items: center; width: 42px; height: 42px; color: #fff; background: var(--cyan); font: 800 11px/1 ui-monospace, SFMono-Regular, Menlo, monospace; }
.sb-shot-id b { padding-left: 8px; font-size: 11px; }
.sb-stage-head p { margin: 0 0 3px; color: var(--muted); font-size: 10px; }
.sb-stage-head h2 { margin: 0; font: 650 17px/1.2 Georgia, "Songti SC", serif; }
.sb-level { padding: 6px 8px; border: 1px solid var(--line); color: var(--cyan); font: 700 9px/1 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .08em; }

.sb-cad-shell { position: relative; min-height: 0; overflow: hidden; background: #e8eef2; }
.sb-cad-host, .cad-viewport, #cadCanvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.sb-cad-anchors { position: absolute; inset: 0; z-index: 4; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
.sb-cad-anchors line { stroke: #176b87; stroke-width: 1; vector-effect: non-scaling-stroke; }
.sb-cad-anchors circle { fill: #fff; stroke: #176b87; stroke-width: 2; vector-effect: non-scaling-stroke; }
.sb-cad-anchors rect { fill: rgba(255,255,255,.94); stroke: #aebec8; vector-effect: non-scaling-stroke; }
.sb-cad-anchors text { fill: #173042; font: 700 10px/1 ui-monospace, SFMono-Regular, Menlo, monospace; dominant-baseline: middle; }
.cad-viewport { overflow: hidden; }
#cadCanvas { display: block; touch-action: none; }
.cad-loading { position: absolute; inset: 0; z-index: 5; display: grid; place-content: center; gap: 12px; color: var(--muted); background: rgba(232, 238, 242, .9); text-align: center; font-size: 11px; }
.cad-loading[hidden] { display: none; }
.cad-loading span { justify-self: center; width: 38px; height: 3px; background: linear-gradient(90deg, transparent, var(--cyan), transparent); animation: load 1.1s linear infinite; }
@keyframes load { from { transform: translateX(-18px); } to { transform: translateX(18px); } }
.sb-view-tools { position: absolute; z-index: 7; top: 14px; right: 14px; display: flex; background: rgba(255,255,255,.92); border: 1px solid var(--line); }
.sb-view-tools button { border: 0; border-right: 1px solid var(--line); padding: 8px 9px; background: transparent; color: var(--muted); font-size: 9px; cursor: pointer; }
.sb-view-tools button:last-child { border-right: 0; }
.sb-view-tools button:hover, .sb-view-tools button[aria-pressed="true"] { color: #fff; background: var(--cyan); }
.sb-cad-note { position: absolute; z-index: 6; right: 14px; bottom: 12px; padding: 7px 10px; background: rgba(255,255,255,.88); border: 1px solid var(--line); color: var(--muted); font-size: 9px; }
.sb-model-badge { position: absolute; z-index: 6; left: 14px; top: 14px; max-width: 240px; padding: 10px 12px; display: grid; gap: 3px; background: rgba(255,255,255,.9); border-left: 3px solid var(--cyan); box-shadow: 0 5px 18px rgba(23,48,66,.08); }
.sb-model-badge span { color: var(--cyan); font: 700 8px/1 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .1em; }
.sb-model-badge b { font: 800 11px/1.2 ui-monospace, SFMono-Regular, Menlo, monospace; }
.sb-model-badge small { color: var(--muted); font-size: 9px; }

.sb-stage-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 12px; border-top: 1px solid var(--line); background: #fbfcfd; }
.sb-variants, .sb-shot-nav { display: flex; gap: 6px; }
.sb-variants[hidden] { display: none; }
.sb-stage-foot button { padding: 7px 10px; border: 1px solid var(--line); background: #fff; color: var(--muted); font-size: 9px; cursor: pointer; }
.sb-stage-foot button:hover, .sb-variants button[aria-pressed="true"] { color: #fff; border-color: var(--cyan); background: var(--cyan); }

.sb-inspector { border-left: 1px solid var(--line); background: #fbfcfd; overflow: auto; }
.sb-inspector section { padding: 17px 18px; border-bottom: 1px solid var(--line); }
.sb-inspector h3 { margin: 0 0 12px; font: 600 24px/1.1 Georgia, "Songti SC", serif; }
.sb-relations { margin: 0; padding: 0; list-style: none; counter-reset: relation; }
.sb-relations li { counter-increment: relation; position: relative; min-height: 42px; padding: 8px 0 8px 38px; border-top: 1px solid #dce4e9; font-size: 12px; line-height: 1.45; }
.sb-relations li::before { content: counter(relation, decimal-leading-zero); position: absolute; left: 0; top: 9px; color: var(--cyan); font: 800 10px/1 ui-monospace, SFMono-Regular, Menlo, monospace; }
.sb-labels, .sb-coverage-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.sb-labels span, .sb-coverage-tags span { padding: 5px 7px; border: 1px solid var(--line); background: #fff; font-size: 9px; }
.sb-pass-card { border-left: 3px solid var(--cyan); }
.sb-pass-card > b { display: block; margin-bottom: 14px; font-size: 12px; line-height: 1.55; }
.sb-pass-card label { display: flex; gap: 8px; align-items: flex-start; color: var(--muted); font-size: 10px; line-height: 1.4; cursor: pointer; }
.sb-pass-card input { margin-top: 1px; accent-color: var(--cyan); }
.sb-boundary { background: #fff7f5; border-left: 3px solid var(--red); }
.sb-boundary p:last-child { margin: 0; color: #80585b; font-size: 10px; line-height: 1.55; }

.sb-matrix { margin-top: 24px; border: 1px solid #aebec8; background: var(--white); }
.sb-matrix > header { display: flex; justify-content: space-between; gap: 30px; align-items: end; padding: 20px 24px; border-bottom: 1px solid var(--line); }
.sb-matrix h2 { margin: 0; font: 500 28px/1.15 Georgia, "Songti SC", serif; }
.sb-progress { min-width: 250px; display: grid; grid-template-columns: 1fr auto; gap: 5px 12px; align-items: center; color: var(--muted); font-size: 10px; }
.sb-progress b { color: var(--ink); font: 800 16px/1 ui-monospace, SFMono-Regular, Menlo, monospace; }
.sb-progress progress { grid-column: 1 / 3; width: 100%; height: 5px; accent-color: var(--cyan); }
.sb-table-wrap { overflow-x: auto; }
.sb-matrix table { width: 100%; border-collapse: collapse; font-size: 11px; }
.sb-matrix th, .sb-matrix td { padding: 12px 16px; border-bottom: 1px solid #dce4e9; text-align: left; vertical-align: top; }
.sb-matrix th { color: var(--muted); font: 700 9px/1 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .08em; }
.sb-matrix td:first-child { color: var(--cyan); font: 750 10px/1.3 ui-monospace, SFMono-Regular, Menlo, monospace; }
.sb-matrix td:last-child span { display: inline-block; padding: 4px 6px; background: #eef3f6; color: var(--muted); font-size: 9px; }
.sb-matrix footer { padding: 14px 20px; background: #eef3f6; color: var(--muted); font-size: 11px; }

body[data-device="mobile"] .sb-page { max-width: 390px; padding: 14px 0 30px; }
body[data-device="mobile"] .sb-intro { grid-template-columns: 1fr; padding: 0 14px; gap: 16px; }
body[data-device="mobile"] .sb-intro h1 { font-size: 30px; }
body[data-device="mobile"] .sb-workbench { height: auto; min-height: 0; grid-template-columns: 1fr; grid-template-rows: 112px 690px auto; border-left: 0; border-right: 0; }
body[data-device="mobile"] .sb-filmstrip { grid-template-rows: 34px 1fr; border-right: 0; border-bottom: 1px solid var(--line); }
body[data-device="mobile"] .sb-filmstrip ol { display: flex; overflow-x: auto; }
body[data-device="mobile"] .sb-filmstrip li { flex: 0 0 170px; }
body[data-device="mobile"] .sb-filmstrip button { min-height: 78px; border-right: 1px solid var(--line); }
body[data-device="mobile"] .sb-stage-panel { grid-template-rows: 96px 1fr 72px; }
body[data-device="mobile"] .sb-stage-head { grid-template-columns: 72px 1fr; gap: 10px; }
body[data-device="mobile"] .sb-level { grid-column: 1 / 3; justify-self: start; }
body[data-device="mobile"] .sb-shot-id { grid-template-columns: 38px 1fr; }
body[data-device="mobile"] .sb-shot-id span { width: 38px; height: 38px; }
body[data-device="mobile"] .sb-view-tools { top: 10px; right: 8px; display: grid; grid-template-columns: repeat(3, auto); }
body[data-device="mobile"] .sb-view-tools button { padding: 6px; border-bottom: 1px solid var(--line); }
body[data-device="mobile"] .sb-model-badge { left: 8px; top: 9px; max-width: 185px; }
body[data-device="mobile"] .sb-cad-note { left: 8px; right: auto; bottom: 8px; }
body[data-device="mobile"] .sb-stage-foot { align-items: flex-start; flex-direction: column; }
body[data-device="mobile"] .sb-shot-nav { align-self: stretch; }
body[data-device="mobile"] .sb-shot-nav button { flex: 1; }
body[data-device="mobile"] .sb-inspector { border-left: 0; border-top: 1px solid var(--line); }
body[data-device="mobile"] .sb-matrix { border-left: 0; border-right: 0; }
body[data-device="mobile"] .sb-matrix > header { display: grid; padding: 18px 14px; }
body[data-device="mobile"] .sb-matrix h2 { font-size: 24px; }
body[data-device="mobile"] .sb-topbar nav { display: none; }

@media (max-width: 1200px) {
  .sb-workbench { grid-template-columns: 210px minmax(500px, 1fr) 310px; }
  .sb-intro { grid-template-columns: 1fr 1fr; }
  .sb-gate-status { grid-column: 1 / 3; }
}

@media (max-width: 860px) {
  .sb-topbar { grid-template-columns: 1fr auto; }
  .sb-topbar nav { display: none; }
  .sb-page:not([data-force-desktop]) { padding: 14px; }
  body:not([data-device="mobile"]) .sb-workbench { grid-template-columns: 180px 1fr; }
  body:not([data-device="mobile"]) .sb-inspector { grid-column: 1 / 3; border-left: 0; border-top: 1px solid var(--line); display: grid; grid-template-columns: repeat(2, 1fr); }
}
