/* See It Built — the job page (a delivered deck: the model, its cuts, its boards, its hardware).
   Same tokens as the website. The model owns the screen; the panel sits on the left and the camera
   shifts the deck into the space that is left. On a phone the panel is a bottom sheet. */
:root {
  --ink: #0e1013; --ink-2: #15181d; --ink-3: #1d2128;
  --chalk: #f0eade; --muted: #a49f95; --dim: #6f6b64; --line: rgba(240, 234, 222, .12);
  --cedar: #d6884a; --cedar-2: #f0a666; --blue: #6fa3ff; --lit: #b3a9ff; --pin: #ff9b3d;
  --radius: 18px; --panel: 420px;
  --display: "Bricolage Grotesque", "Inter", system-ui, sans-serif;
  --body: "Inter", system-ui, -apple-system, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
html { scrollbar-color: rgba(240, 234, 222, .25) transparent; }
.body::-webkit-scrollbar, #stairGuide::-webkit-scrollbar { width: 8px; }
.body::-webkit-scrollbar-thumb, #stairGuide::-webkit-scrollbar-thumb { background: rgba(240, 234, 222, .22); border-radius: 999px; }
body { font: 15px/1.55 var(--body); color: var(--chalk); background: var(--ink); overflow: hidden; -webkit-font-smoothing: antialiased; }
::selection { background: var(--cedar); color: var(--ink); }
a { color: var(--blue); }
h1, h2, h3 { font-family: var(--display); line-height: 1; letter-spacing: -.025em; font-weight: 800; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
button:focus-visible, a:focus-visible, summary:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
[hidden] { display: none !important; }
.mono { font-family: var(--mono); font-size: .78rem; letter-spacing: .06em; color: var(--muted); }
.kicker { display: flex; align-items: center; gap: 12px; font-family: var(--mono); font-size: .7rem; letter-spacing: .22em; text-transform: uppercase; color: var(--cedar); }
.kicker::before { content: ""; width: 28px; height: 1px; background: var(--cedar); }

/* ---------- stage ---------- */
#view { position: fixed; inset: 0; }
#view canvas { display: block; width: 100%; height: 100%; touch-action: none; }
#labels { position: fixed; inset: 0; overflow: hidden; pointer-events: none; z-index: 3; }
.label { position: absolute; transform: translate(-50%, -100%); margin-top: -10px; padding: 8px 11px; border-radius: 10px;
  background: rgba(21, 24, 29, .96); border: 1px solid var(--lit); font-size: .78rem; line-height: 1.45; white-space: nowrap;
  box-shadow: 0 2px 12px rgba(0, 0, 0, .45); }
.label b { font-family: var(--mono); font-weight: 500; color: var(--chalk); }
.label i { font-style: normal; color: var(--cedar-2); }
.label small { display: block; color: var(--muted); font-size: .72rem; }
.pin { position: absolute; transform: translate(-50%, -50%); pointer-events: auto; width: 24px; height: 24px; border-radius: 999px;
  background: var(--pin); border: 2px solid #fff0d4; box-shadow: 0 0 0 3px rgba(14, 16, 19, .6); font: 700 11px/20px var(--mono); color: #17120c; text-align: center; cursor: pointer; z-index: 2; }
.pin:hover { background: #fff0d4; transform: translate(-50%, -50%) scale(1.15); }
.stem { position: absolute; height: 2px; background: rgba(255, 173, 97, .8); transform-origin: 0 50%; pointer-events: none; }

/* ---------- top bar ---------- */
.top { position: fixed; top: 0; left: 0; right: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 12px clamp(16px, 3vw, 48px); background: rgba(14, 16, 19, .72); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); }
.mark { display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--chalk); font-family: var(--display); font-weight: 800; letter-spacing: -.01em; font-size: 1.1rem; }
.mark img { width: 32px; height: 32px; }
.job { display: flex; align-items: baseline; gap: 12px; min-width: 0; }
.job b { font-family: var(--mono); font-weight: 500; font-size: .8rem; letter-spacing: .08em; color: var(--chalk); }
.job span { font-family: var(--mono); font-size: .74rem; letter-spacing: .04em; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top nav { display: flex; align-items: center; gap: 8px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 16px; border-radius: 999px; border: 1.5px solid transparent;
  background: var(--chalk); color: var(--ink); text-decoration: none; font-weight: 600; font-size: .84rem; line-height: 1; cursor: pointer; transition: transform .2s, background .2s, border-color .2s; }
.btn:hover { transform: translateY(-1px); background: var(--cedar-2); }
.btn.cedar { background: var(--cedar); color: var(--ink); }
.btn.ghost { background: transparent; color: var(--chalk); border-color: rgba(240, 234, 222, .35); }
.btn.ghost:hover { border-color: var(--chalk); background: rgba(240, 234, 222, .06); }
.btn.wide { width: 100%; padding: 14px 16px; font-size: .9rem; }
.btn:disabled { opacity: .45; cursor: default; transform: none; }
.btn[aria-pressed="true"] { background: var(--cedar-2); color: var(--ink); border-color: var(--cedar-2); }

/* ---------- foot ---------- */
.foot { position: fixed; left: 0; right: 0; bottom: 0; z-index: 4; display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 12px clamp(16px, 3vw, 48px); pointer-events: none; }
.foot > * { pointer-events: auto; }
.foot .hint { padding: 8px 14px; border-radius: 999px; background: rgba(14, 16, 19, .7); border: 1px solid var(--line); font: 500 .7rem var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }

/* ---------- panel ---------- */
#panel { position: fixed; top: 72px; left: clamp(16px, 3vw, 48px); bottom: 60px; width: var(--panel); max-width: calc(100vw - 32px); z-index: 6;
  display: flex; flex-direction: column; background: rgba(21, 24, 29, .94); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .45); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.panel-nav { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.panel-nav .where { font: 500 .7rem var(--mono); letter-spacing: .18em; text-transform: uppercase; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.back { display: inline-flex; align-items: center; gap: 8px; padding: 9px 14px; border-radius: 999px; background: var(--cedar); color: var(--ink); font-weight: 600; font-size: .84rem; white-space: nowrap; }
.back:hover { background: var(--cedar-2); }
.close { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); flex: none; }
.close:hover { color: var(--chalk); border-color: var(--chalk); }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; padding: 12px 14px 0; }
.tab { padding: 8px 13px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); font: 500 .82rem var(--body); }
.tab:hover { color: var(--chalk); border-color: rgba(240, 234, 222, .4); }
.tab[aria-selected="true"] { background: var(--chalk); color: var(--ink); border-color: var(--chalk); }
.body { flex: 1; overflow: auto; padding: 18px 18px 22px; display: flex; flex-direction: column; gap: 16px; overscroll-behavior: contain; }
.body > p, .hint-p { color: var(--muted); font-size: .86rem; line-height: 1.5; }
.body h2 { font-size: 1.05rem; margin-top: 4px; }
.terms { color: var(--dim); font-size: .72rem; line-height: 1.5; border-top: 1px solid var(--line); padding-top: 12px; margin-top: auto; }
.terms a { color: var(--muted); }
.notice { padding: 10px 12px; border-radius: 10px; background: rgba(214, 136, 74, .1); border: 1px solid rgba(214, 136, 74, .35); color: #e3c5a4; font-size: .82rem; line-height: 1.5; }
.stack { display: flex; flex-direction: column; gap: 8px; }

/* steps (Build) */
.step { display: grid; grid-template-columns: 30px 1fr auto; gap: 12px; align-items: center; width: 100%; text-align: left; padding: 13px 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--ink-3); }
.step:hover { border-color: rgba(240, 234, 222, .35); }
.step .num { font-family: var(--display); font-weight: 800; font-size: 1.25rem; color: var(--dim); line-height: 1; }
.step[aria-expanded="true"] { border-color: rgba(214, 136, 74, .5); }
.step[aria-expanded="true"] .num { color: var(--cedar); }
.step .t { font-weight: 600; font-size: .93rem; }
.step .s { color: var(--muted); font-size: .8rem; }
.step .n { font-family: var(--mono); font-size: .74rem; color: var(--muted); letter-spacing: .06em; }
.sub { display: flex; flex-direction: column; gap: 8px; padding-left: 18px; }

/* groups */
.group { border: 1px solid var(--line); border-radius: 14px; background: var(--ink-3); overflow: hidden; }
.group-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; text-align: left; padding: 12px 14px; font-weight: 600; font-size: .92rem; }
.group-head:hover { color: var(--cedar-2); }
.group-head .n { font-family: var(--mono); font-size: .74rem; color: var(--muted); letter-spacing: .06em; font-weight: 500; }
.group[aria-expanded="true"] > .group-head { border-bottom: 1px solid var(--line); color: var(--cedar-2); }
.group[aria-expanded="true"] > .group-head .n::after { content: " · LIT"; color: var(--lit); }
.rows { display: flex; flex-direction: column; }
.row { display: grid; grid-template-columns: 56px 1fr auto; align-items: center; gap: 10px; width: 100%; text-align: left; padding: 10px 14px; border-top: 1px solid var(--line); font-size: .86rem; }
.row:first-child { border-top: 0; }
.row:hover { background: rgba(240, 234, 222, .05); }
.row .id { font-family: var(--mono); font-size: .78rem; color: var(--cedar-2); letter-spacing: .04em; }
.row .size { color: var(--muted); font-size: .8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .len { font-family: var(--mono); font-size: .84rem; color: var(--chalk); white-space: nowrap; }
.row .len.tbd { color: var(--cedar-2); }

/* piece */
.big { font-family: var(--display); font-weight: 800; font-size: 2.4rem; letter-spacing: -.03em; line-height: 1; }
.big small { display: block; font: 500 .7rem var(--mono); letter-spacing: .2em; text-transform: uppercase; color: var(--cedar); margin-bottom: 8px; }
.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.fact { padding: 11px 13px; border: 1px solid var(--line); border-radius: 12px; background: var(--ink-3); min-width: 0; }
.fact b { display: block; font: 500 .66rem var(--mono); letter-spacing: .18em; text-transform: uppercase; color: var(--muted); margin-bottom: 5px; }
.fact span { font-family: var(--mono); font-size: 1rem; }
.fact.hero span { font-family: var(--display); font-weight: 800; font-size: 1.5rem; letter-spacing: -.02em; }
.fact.hero span.tbd { font-size: 1rem; color: var(--cedar-2); font-family: var(--body); font-weight: 600; letter-spacing: 0; }
.link-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; text-align: left; padding: 12px 14px; border: 1px solid rgba(214, 136, 74, .45); border-radius: 12px; background: rgba(214, 136, 74, .08); color: var(--chalk); }
.link-row:hover { background: rgba(214, 136, 74, .16); }
.link-row b { font-family: var(--mono); font-weight: 500; font-size: .88rem; color: var(--cedar-2); }
.link-row span { display: block; font-size: .8rem; color: var(--muted); }
.link-row em { font-style: normal; color: var(--cedar-2); font-size: .82rem; white-space: nowrap; }
.touch { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; align-items: center; width: 100%; text-align: left; padding: 11px 14px; border-top: 1px solid var(--line); font-size: .86rem; }
.touch:first-child { border-top: 0; }
.touch:hover { background: rgba(240, 234, 222, .05); }
.touch .k { font-family: var(--mono); font-size: .74rem; color: var(--muted); letter-spacing: .04em; }
.touch .go { color: var(--muted); font-family: var(--mono); }

/* board strip */
.strip { position: relative; height: 54px; border: 1px solid rgba(214, 136, 74, .55); border-radius: 8px; background: #2a2118; overflow: hidden; }
.strip .ft { position: absolute; top: 0; bottom: 0; width: 1px; background: rgba(240, 234, 222, .1); }
.seg { position: absolute; top: 0; height: 100%; display: flex; align-items: center; justify-content: center; overflow: hidden; border-right: 2px solid var(--ink); font: 500 .74rem var(--mono); color: var(--ink); background: var(--cedar); white-space: nowrap; }
.seg:nth-child(even) { background: var(--cedar-2); }
.seg:hover { filter: brightness(1.15); }
.offcut { position: absolute; top: 0; height: 100%; background: repeating-linear-gradient(45deg, transparent 0 5px, rgba(240, 234, 222, .18) 5px 7px); }
.ticks { display: flex; justify-content: space-between; font: 500 .64rem var(--mono); color: var(--dim); letter-spacing: .06em; margin-top: 5px; }

/* shopping */
table { width: 100%; border-collapse: collapse; font-size: .88rem; }
th, td { text-align: left; padding: 9px 6px; border-bottom: 1px solid var(--line); }
th { font: 500 .66rem var(--mono); letter-spacing: .18em; text-transform: uppercase; color: var(--muted); }
td:last-child, th:last-child { text-align: right; }
td:last-child { font-family: var(--mono); color: var(--cedar-2); font-size: 1rem; }
td:nth-child(2) { font-family: var(--mono); }
.count { font-family: var(--display); font-weight: 800; font-size: 2rem; letter-spacing: -.03em; color: var(--cedar); }

/* legend for pins */
.legend { position: fixed; right: clamp(16px, 3vw, 48px); top: 84px; z-index: 4; display: flex; flex-direction: column; gap: 6px; padding: 10px 12px; background: rgba(21, 24, 29, .94); border: 1px solid var(--line); border-radius: 12px; font-size: .78rem; max-width: 260px; }
.legend button { display: flex; align-items: center; gap: 8px; text-align: left; }
.legend .pin { position: static; transform: none; flex: none; pointer-events: none; }

/* loader */
#loading { position: fixed; inset: 0; z-index: 20; background: var(--ink); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px; }
#loading svg { width: min(320px, 70vw); height: auto; }
#loading path { fill: none; stroke: var(--blue); stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }
#loading .word { font-family: var(--display); font-weight: 800; letter-spacing: .32em; text-indent: .32em; font-size: .9rem; }
#loading .pct { font-family: var(--mono); font-size: .76rem; letter-spacing: .24em; color: var(--muted); }
#loading .bar { width: min(320px, 70vw); height: 2px; background: var(--line); overflow: hidden; }
#loading .bar i { display: block; height: 100%; width: 0; background: var(--cedar); transition: width .2s; }
#loading.error .pct { color: #f0a08f; letter-spacing: .04em; text-transform: none; max-width: 32em; text-align: center; line-height: 1.5; }

/* ---------- Codex's stair guide (its markup; our colours) ---------- */
#stairGuide { position: fixed; inset: 3vh 3vw; width: 94vw; max-width: 1400px; height: 94vh; max-height: 94vh; margin: 0; padding: 24px; overflow: auto; z-index: 30;
  background: var(--ink-2); color: var(--chalk); border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 20px 80px rgba(0, 0, 0, .6); font: 15px/1.55 var(--body); }
#stairGuide::backdrop { background: rgba(14, 16, 19, .7); }
#stairGuide h1 { font-size: 2rem; margin: 6px 0; }
#stairGuide h2 { font-size: 1.15rem; margin: 22px 0 8px; }
#stairGuide small { color: var(--muted); font-family: var(--mono); letter-spacing: .16em; font-size: .68rem; }
#stairGuide p { margin: 8px 0; }
#stairGuide .sg-note { color: var(--muted); font-size: .86rem; max-width: 900px; }
#stairGuide .sg-heading, #stairGuide .sg-inputs, #stairGuide .sg-actions, #stairGuide .sg-stats { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
#stairGuide .sg-heading { justify-content: space-between; }
#stairGuide .sg-inputs label { flex: 1; min-width: 200px; display: block; margin: 8px 0; }
#stairGuide input[type="number"] { display: block; width: 100%; padding: 12px; margin-top: 6px; border: 1px solid var(--line); border-radius: 8px; background: var(--ink-3); color: var(--chalk); font: inherit; }
#stairGuide input[type="checkbox"] { width: 20px; height: 20px; accent-color: var(--cedar); }
#stairGuide .sg-stats > span { padding: 12px 14px; background: var(--ink-3); border: 1px solid var(--line); border-radius: 10px; }
#stairGuide .sg-stats b { display: block; color: var(--blue); font-family: var(--display); font-size: 1.4rem; }
#stairGuide button { padding: 10px 16px; border: 1px solid var(--line); border-radius: 999px; background: var(--ink-3); color: var(--chalk); font-weight: 600; font-size: .86rem; }
#stairGuide button:hover { background: #2a2f38; }
#stairGuide button[aria-pressed="true"] { background: var(--cedar) !important; color: var(--ink) !important; border-color: var(--cedar) !important; }
#stairGuide [data-choice] { border-radius: 14px !important; background: var(--ink-3) !important; border: 2px solid var(--line) !important; color: var(--chalk) !important; padding: 14px 16px; }
#stairGuide [data-choice][aria-pressed="true"] { border-color: var(--cedar) !important; background: rgba(214, 136, 74, .12) !important; color: var(--chalk) !important; }
#stairGuide #sgBack { background: var(--cedar); color: var(--ink); border: 0; }
#stairGuide svg { width: 100%; height: auto; max-height: 48vh; min-height: 260px; background: #efeee5; border-radius: 12px; color: #263a3e; }
#stairGuide #sgSquare { transition: transform .5s ease; }
#stairGuide table { margin-top: 10px; }
#stairGuide td, #stairGuide th { padding: 8px; }
#stairGuide .sg-active { background: rgba(214, 136, 74, .14); }
#stairGuide details { margin-top: 16px; border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; background: var(--ink-3); }
#stairGuide summary { cursor: pointer; font-weight: 600; }
#sgLevelError { color: #f0a08f; }
@media (prefers-reduced-motion: reduce) { #stairGuide #sgSquare { transition: none; } }

/* ---------- phone: the panel is a bottom sheet ---------- */
@media (max-width: 760px) {
  .top { padding: 10px 14px; }
  .mark { font-size: 1rem; }
  .mark img { width: 26px; height: 26px; }
  .job span { display: none; }
  .top nav .btn.dl { display: none; }
  .foot { bottom: auto; top: 52px; padding: 6px 10px; }
  .foot .hint { display: none; }
  .foot nav { display: flex; gap: 6px; overflow-x: auto; width: 100%; scrollbar-width: none; }
  .foot nav::-webkit-scrollbar { display: none; }
  .foot nav .btn { padding: 8px 12px; font-size: .74rem; white-space: nowrap; flex: none; }
  #panel { top: auto; left: 0; right: 0; bottom: 0; width: auto; max-width: none; height: 52vh; border-radius: 22px 22px 0 0; border-bottom: 0; box-shadow: 0 -20px 60px rgba(0, 0, 0, .55); }
  #panel.tall { height: 86vh; }
  #panel.short { height: 30vh; }
  .grip { display: flex; justify-content: center; padding: 8px 0 0; }
  .grip i { width: 44px; height: 5px; border-radius: 999px; background: rgba(240, 234, 222, .25); }
  .panel-nav { padding: 6px 14px 10px; }
  .body { padding: 14px 14px 20px; gap: 12px; }
  .big { font-size: 2rem; }
  .legend { top: 92px; right: 10px; left: 10px; max-width: none; flex-direction: row; flex-wrap: wrap; font-size: .68rem; padding: 6px 8px; gap: 4px 10px; }
  .legend button span:last-child { max-width: 130px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  #stairGuide { inset: 1vh 2vw; width: 96vw; height: 98vh; max-height: 98vh; padding: 16px; }
  #stairGuide .sg-heading button { width: 100%; }
  #stairGuide .sg-inputs label { min-width: 100%; }
  #stairGuide #sgDrawing { overflow: auto; }
  #stairGuide #sgDrawing svg { min-width: 740px; min-height: 365px; max-height: none; }
}
@media (min-width: 761px) { .grip { display: none; } }
