/* ======================================================================================
   DuC(k)AD - interface
   ====================
   A three-column technical workspace: request on the left, viewport in the middle, the
   active model and its adjustment controls on the right.

   The palette follows the study prototype: a light workspace, slate blue-grey panels,
   rust for committing actions (generate, save) and wheat for adjustments. Every control
   carries a dark outline, which is what gives the interface its drafting-tool character
   and keeps the wheat buttons legible against the light panels.

   Two rules hold throughout:
     - rust means "this produces or commits a design"; wheat means "this modifies one".
       Nothing else uses either colour, so the two actions stay distinguishable at a glance.
     - numeric values are always set in a monospace face, so figures line up column-wise
       and two readings can be compared without re-reading them.
   ====================================================================================== */

:root{
  --bg:        #e3e6e9;   /* page */
  --stage:     #ececec;   /* viewport backdrop, matched in viewer.js */
  --panel:     #c6d2dd;   /* side panels */
  --panel-2:   #d7e0e8;   /* nested blocks */
  --raised:    #eef2f6;
  --white:     #ffffff;

  --line:      #2c3a48;   /* the dark outline on every control */
  --line-soft: #a2b3c2;
  --line-hair: #b6c4d1;

  --ink:       #16202b;
  --ink-2:     #33434f;
  --dim:       #56687a;
  --faint:     #7b8b9a;

  --accent:    #a85c33;   /* rust - generate / save */
  --accent-h:  #bd6b3d;
  --accent-ink:#ffffff;

  --tan:       #f4d79a;   /* wheat - adjust / edit */
  --tan-h:     #fae5b6;
  --tan-ink:   #3a2c12;

  --ok:        #2f7d3e;
  --warn:      #96601b;
  --err:       #b3392f;

  --mono: ui-monospace, "Cascadia Mono", "SF Mono", Menlo, Consolas, monospace;
  --sans: ui-sans-serif, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;

  --r:   10px;
  --r-s: 8px;
  --bw:  2px;             /* the standard control outline width */

  --topbar-h: 56px;
  --panel-w:  318px;
}

*,*::before,*::after{ box-sizing:border-box }

/* The browser's own [hidden] rule is a bare attribute selector, so ANY class that sets
   `display` outranks it and the element stays on screen. That silently defeated
   `hidden` on the viewport overlay. Stated once here, with the weight to win, so that
   every `hidden` in the markup means what it says. */
[hidden]{ display:none !important }

/* The page is a single column - top bar, optional help strip, then the workspace taking
   whatever height is left. Sizing the workspace as `100vh - <the bars>` instead would mean
   restating each bar's height here, and any figure that drifted out of date showed up as a
   strip of panel scrolling past the bottom edge of the window. The browser measures it. */
html,body{ height:100% }
body{
  margin:0;
  display:flex; flex-direction:column;
  background:var(--bg);
  color:var(--ink);
  font:14px/1.5 var(--sans);
  -webkit-font-smoothing:antialiased;
  overflow:hidden;
}

.mono{ font-family:var(--mono); font-variant-numeric:tabular-nums }

::-webkit-scrollbar{ width:11px; height:11px }
::-webkit-scrollbar-track{ background:transparent }
::-webkit-scrollbar-thumb{ background:#9fb0be; border-radius:6px; border:3px solid var(--panel) }
::-webkit-scrollbar-thumb:hover{ background:#879aaa }

:focus-visible{ outline:2px solid var(--accent); outline-offset:2px; border-radius:4px }

/* ====================================================================================== *
   Top bar
   ====================================================================================== */

.topbar{
  height:var(--topbar-h);
  flex:0 0 auto;                 /* a column flex item shrinks by default; this one must not */
  display:flex; align-items:center; gap:18px;
  padding:0 16px;
  background:var(--panel);
  border-bottom:var(--bw) solid var(--line);
  position:relative; z-index:20;
}

.brand{ display:flex; align-items:center; gap:10px; flex:0 0 auto }
.brand__mark{ width:34px; height:34px; object-fit:contain; display:block }
.brand__name{ font-weight:750; font-size:16px; letter-spacing:-.015em; color:var(--ink) }
.brand__name span{ color:var(--accent) }
.topbar__stats{ display:flex; gap:8px; margin-right:auto }
.topbar__right{ display:flex; align-items:center; gap:8px }
.menu{ display:flex; gap:5px }

.chip{
  display:inline-flex; align-items:center; gap:6px;
  padding:4px 10px; border-radius:99px;
  background:var(--panel-2); border:1px solid var(--line-soft);
  font-size:11.5px; color:var(--dim); white-space:nowrap;
}
.chip--mono{ font-family:var(--mono); font-variant-numeric:tabular-nums }
.chip--id{ color:var(--ink-2) }
.chip__k{ color:var(--faint); font-size:10px; letter-spacing:.08em }
.chip--ok  { color:var(--ok);   border-color:#7fae88; background:#dff0e2 }
.chip--warn{ color:var(--warn); border-color:#d3b077; background:#faeed5 }

/* Segmented chip: the survey-version switch. Marked with a dashed border when it is
   forcing a version, so a session running under an override is obvious on screen and not
   only in the event log. */
.chip--seg{ gap:3px; padding:3px 4px 3px 9px; cursor:default }
.chip--seg button{
  font:700 11px/1 var(--mono); width:20px; height:19px; padding:0;
  border:1px solid var(--line-soft); border-radius:4px;
  background:var(--white); color:var(--dim); cursor:pointer; transition:.12s;
}
.chip--seg button:hover{ border-color:var(--line); color:var(--ink) }
.chip--seg button.is-on{
  background:var(--accent); border-color:var(--line); color:var(--accent-ink);
}
.chip--seg.is-overridden{ border-style:dashed; border-color:var(--warn) }
.chip--seg.is-overridden .chip__k{ color:var(--warn) }

/* ====================================================================================== *
   Help strip
   ====================================================================================== */

.help{
  background:var(--panel-2); border-bottom:var(--bw) solid var(--line);
  padding:18px 20px; position:relative; z-index:19;
  flex:0 0 auto;
}
.help__grid{ display:grid; grid-template-columns:repeat(4,1fr); gap:22px; max-width:1500px;
             padding-right:36px }   /* clears the close button */
.help__close{
  position:absolute; top:10px; right:12px;
  width:28px; height:28px; padding:0; display:grid; place-items:center;
  font:400 20px/1 var(--sans); color:var(--dim); cursor:pointer;
  background:var(--white); border:1px solid var(--line-soft); border-radius:var(--r-s);
  transition:.12s;
}
.help__close:hover{ border-color:var(--line); color:var(--ink) }
.help h4{ margin:0 0 5px; font-size:12px; color:var(--accent); letter-spacing:.03em }
.help p{ margin:0; font-size:12.5px; color:var(--dim); line-height:1.6 }
.help strong{ color:var(--ink-2); font-weight:650 }

@media (max-width:1100px){ .help__grid{ grid-template-columns:repeat(2,1fr) } }

/* ====================================================================================== *
   Layout
   ====================================================================================== */

.layout{
  display:grid;
  grid-template-columns:var(--panel-w) minmax(0,1fr) 344px;
  flex:1; min-height:0;          /* fills the window below the bars, whatever they measure */
}

.panel{ background:var(--panel); display:flex; flex-direction:column; min-height:0 }
.panel--left { border-right:var(--bw) solid var(--line) }
.panel--right{ border-left:var(--bw) solid var(--line) }
.panel__scroll{ overflow-y:auto; overflow-x:hidden; flex:1; padding:4px 0 28px }

/* The left panel ends in a sticky Generate block, which has to meet the bottom edge of the
   window exactly. A sticky box is held inside its containing block, so bottom padding on
   the scroller parks it that far up and leaves a sliver of scrolling content on show
   underneath it. Nothing follows the button in this panel, so it gets none. */
.panel--left .panel__scroll{ padding-bottom:0 }

.block{ padding:16px 16px 18px; border-bottom:1px solid var(--line-hair) }
.block:last-child{ border-bottom:0 }
.block__title{
  margin:0 0 3px; font-size:11px; font-weight:750;
  letter-spacing:.09em; text-transform:uppercase; color:var(--dim);
}
.block__hint{ margin:0 0 11px; font-size:11.5px; color:var(--faint); line-height:1.5 }
.block__hint strong{ color:var(--dim) }

/* Expandable sections in the request panel. */
.block--fold > summary{
  display:flex; align-items:center; justify-content:space-between;
  margin:0; cursor:pointer; list-style:none; user-select:none;
}
.block--fold > summary::-webkit-details-marker{ display:none }
.block--fold > summary::after{
  content:"▸"; font-size:12px; color:var(--faint); transition:transform .15s;
}
.block--fold[open] > summary::after{ transform:rotate(90deg) }
.block--fold > summary:hover{ color:var(--text, inherit) }
.block--fold > summary:focus-visible{ outline:2px solid var(--accent); outline-offset:3px }
.block--fold[open] > summary{ margin-bottom:6px }

.block--sticky{
  position:sticky; bottom:0; background:var(--panel);
  border-top:var(--bw) solid var(--line); border-bottom:0;
  box-shadow:0 -10px 20px -14px rgba(20,32,44,.5);
}

.row{ display:flex; gap:8px; align-items:stretch }
.row--stack{ flex-direction:column }

/* ====================================================================================== *
   Controls
   ====================================================================================== */

.btn{
  font:700 12.5px/1.25 var(--sans);
  padding:10px 14px; border-radius:var(--r-s); cursor:pointer;
  border:var(--bw) solid var(--line);
  background:var(--raised); color:var(--ink);
  transition:background .13s, color .13s, box-shadow .13s, transform .08s;
  white-space:nowrap;
}
.btn:hover:not(:disabled){ background:var(--white) }
.btn:active:not(:disabled){ transform:translateY(1px) }
.btn:disabled{ opacity:.42; cursor:not-allowed }

/* Rust: produces or commits a design. */
.btn--primary{ background:var(--accent); border-color:var(--line); color:var(--accent-ink) }
.btn--primary:hover:not(:disabled){ background:var(--accent-h) }

/* Wheat: modifies the design in front of you. */
.btn--tan{ background:var(--tan); color:var(--tan-ink) }
.btn--tan:hover:not(:disabled){ background:var(--tan-h) }

.btn--ghost{ background:transparent; border-color:var(--line-soft); font-weight:600 }
.btn--ghost:hover:not(:disabled){ background:var(--panel-2); border-color:var(--line) }

.btn--sm{ padding:6px 11px; font-size:11.5px; border-width:1px }
.btn--lg{ padding:14px 16px; font-size:14px; white-space:normal }
.btn--block{ flex:1; text-align:center; justify-content:center }

.input{
  width:100%;
  font:13px/1.3 var(--sans);
  padding:8px 10px; border-radius:var(--r-s);
  background:var(--white); color:var(--ink);
  border:1px solid var(--line-soft);
}
.input:focus{ border-color:var(--accent); outline:none; box-shadow:0 0 0 2px rgba(168,92,51,.18) }
.input::placeholder{ color:var(--faint) }
.input--sm{ padding:6px 8px; font-size:12px }
.input--area{ resize:vertical; font-family:var(--sans); line-height:1.55 }

input[type=number]{ font-family:var(--mono); font-variant-numeric:tabular-nums }

/* -- chair type pills ------------------------------------------------------------------ */

.pills{ display:flex; flex-wrap:wrap; gap:6px }
.pill{ cursor:pointer }
.pill input{ position:absolute; opacity:0; pointer-events:none }
.pill span{
  display:inline-block; padding:6px 12px; border-radius:99px;
  background:var(--raised); border:1px solid var(--line-soft);
  font-size:12px; font-weight:600; color:var(--ink-2); transition:.13s;
}
.pill:hover span{ border-color:var(--line) }
.pill input:checked + span{
  background:var(--accent); border-color:var(--line); color:var(--accent-ink);
}
.pill input:focus-visible + span{ outline:2px solid var(--accent); outline-offset:2px }

/* -- numeric bounds -------------------------------------------------------------------- */

.bounds{ display:grid; gap:9px; margin-bottom:12px }
.bound label{ display:block; font-size:11.5px; color:var(--dim); margin-bottom:4px }
.bound label em{ font-style:normal; color:var(--faint); font-family:var(--mono); font-size:10.5px }
.bound__row{ display:grid; grid-template-columns:1fr auto 1fr; gap:6px; align-items:center }
.bound__sep{ color:var(--faint); font-size:12px }

.flags{ display:grid; gap:6px }
.tri{ display:grid; grid-template-columns:1fr 96px; gap:8px; align-items:center;
      font-size:12px; color:var(--ink-2) }

/* -- objectives ------------------------------------------------------------------------ */

.objs{ display:grid; gap:5px }
.obj{
  display:grid; grid-template-columns:auto 1fr; gap:9px; align-items:center;
  padding:7px 8px; border-radius:var(--r-s); cursor:pointer;
  border:1px solid transparent; transition:.13s;
}
.obj:hover{ background:var(--panel-2); border-color:var(--line-soft) }
.obj__label{ font-size:12.5px; color:var(--ink-2) }
.obj:has(input:checked){ background:var(--raised); border-color:var(--accent) }
.obj:has(input:checked) .obj__label{ color:var(--accent); font-weight:650 }
.obj.is-disabled{ cursor:not-allowed; opacity:.45 }
.obj.is-disabled:hover{ background:none; border-color:transparent }
.obj.is-disabled input{ cursor:not-allowed }

input[type=checkbox],input[type=radio]{ accent-color:var(--accent); width:14px; height:14px; cursor:pointer }


/* ====================================================================================== *
   Stage / viewport
   ====================================================================================== */

.stage{ position:relative; background:var(--stage); min-width:0; overflow:hidden }
#viewport{ display:block; width:100%; height:100%; cursor:grab }
#viewport:active{ cursor:grabbing }
.stage.is-loading #viewport{ opacity:.55; transition:opacity .12s }

/* -- generate loader: the duck logo bobbing on water ------------------------------------ */
.loader{
  position:absolute; inset:0; z-index:9;
  display:grid; place-content:center; justify-items:center; gap:14px;
  background:rgba(236,236,236,.72);
}
.loader__scene{ position:relative; width:170px; height:120px; overflow:hidden }
.loader__duck{
  position:absolute; left:50%; bottom:14px; width:78px; height:auto;
  margin-left:-39px; z-index:2;
  animation:duck-bob 1.6s ease-in-out infinite;
}
.loader__water{
  position:absolute; left:0; right:0; bottom:0; height:40px;
  border-radius:0 0 50% 50% / 0 0 30% 30%;
}
.loader__wave{ position:absolute; left:0; bottom:0; width:200%; height:100% }
.loader__wave--back { fill:#9cc4e0; animation:wave-drift 3.2s linear infinite; opacity:.8 }
.loader__wave--front{ fill:#5b9cc9; animation:wave-drift 2.2s linear infinite reverse; z-index:3 }
.loader__text{ font:600 12.5px/1 var(--sans); color:var(--dim); letter-spacing:.02em }

@keyframes duck-bob{
  0%,100%{ transform:translateY(0)    rotate(-4deg) }
  50%    { transform:translateY(-7px) rotate(4deg) }
}
@keyframes wave-drift{
  from{ transform:translateX(0) }
  to  { transform:translateX(-50%) }
}
@media (prefers-reduced-motion:reduce){
  .loader__duck,.loader__wave{ animation:none }
}

/* Corner mark, mirroring the study prototype. */
.stage__mark{
  position:absolute; top:10px; right:12px; z-index:6;
  display:grid; justify-items:center; gap:1px; pointer-events:none;
}
.stage__mark img{ width:58px; height:auto; display:block }
.stage__mark span{
  font:700 9px/1 var(--sans); letter-spacing:.14em; text-transform:uppercase;
  color:var(--dim);
}

.stage__overlay{
  position:absolute; inset:0; display:grid; place-items:center;
  background:rgba(236,236,236,.94); z-index:10; padding:32px;
}
.overlay__box{
  max-width:560px; text-align:center;
  background:var(--white); border:var(--bw) solid var(--line); border-radius:var(--r);
  padding:26px 28px; box-shadow:0 16px 40px -18px rgba(20,32,44,.5);
}
.overlay__box h3{ margin:0 0 8px; font-size:16px; color:var(--ink) }
.overlay__box p{ margin:0 0 14px; color:var(--dim); font-size:13px; line-height:1.65 }
.overlay__box--setup{ text-align:left }
.overlay__box--setup h3{ color:var(--accent) }
.setup{ margin:0 0 18px; padding-left:20px; color:var(--ink-2); font-size:13px; line-height:1.85 }
.setup strong{ font-weight:700 }
.setup a{ color:var(--accent); font-weight:650 }
/* Boot guard. Sits above everything, including the top bar, because when it fires nothing
   behind it is functional and letting the shell show through only invites more clicking. */
.bootguard{
  position:fixed; inset:0; z-index:999;
  display:grid; place-items:center; padding:32px;
  background:var(--bg);
}
.bootguard .overlay__box{ max-width:600px }

.overlay__box code{
  font:12px var(--mono); background:var(--panel-2);
  padding:1px 5px; border-radius:4px; color:var(--ink);
}
.overlay__detail{
  margin:16px 0 0 !important; padding-top:12px; border-top:1px solid var(--line-hair);
  font:11px/1.6 var(--mono) !important; color:var(--faint) !important;
}

.toolbar{
  position:absolute; top:12px; left:12px; right:88px;
  display:flex; gap:8px; flex-wrap:wrap; pointer-events:none;
}
.toolbar__group{
  display:flex; gap:2px; pointer-events:auto;
  background:var(--white);
  border:1px solid var(--line); border-radius:var(--r-s); padding:3px;
  box-shadow:0 2px 6px -3px rgba(20,32,44,.4);
}
.tool{
  font:650 11.5px/1 var(--sans);
  padding:6px 10px; border-radius:5px; cursor:pointer;
  background:transparent; border:0; color:var(--dim); transition:.12s;
}
.tool:hover{ background:var(--panel-2); color:var(--ink) }
.tool.is-on{ background:var(--accent); color:var(--accent-ink) }

.stage__foot{
  position:absolute; left:12px; right:12px; bottom:12px;
  display:flex; gap:12px; align-items:flex-end; justify-content:space-between;
  pointer-events:none;
}
.status{
  pointer-events:auto; max-width:min(700px,72%);
  background:var(--white);
  border:1px solid var(--line); border-left:4px solid var(--accent);
  border-radius:var(--r-s); padding:9px 13px;
  font-size:12.5px; line-height:1.5; color:var(--ink-2);
  box-shadow:0 2px 8px -4px rgba(20,32,44,.45);
}
.status--warn { border-left-color:var(--warn); background:#fdf6e7 }
.status--error{ border-left-color:var(--err);  background:#fbeae8; color:#7d2a23 }

.measured{
  pointer-events:auto; margin-left:auto;   /* stays right even when .status is hidden */
  background:var(--white); border:1px solid var(--line-soft); border-radius:var(--r-s);
  padding:8px 11px; font-size:11.5px; color:var(--dim); white-space:nowrap;
}

.stage__hint{
  position:absolute; top:60px; left:15px;
  font-size:11px; color:var(--faint); letter-spacing:.02em;
  pointer-events:none;
}

/* ====================================================================================== *
   Right panel - model
   ====================================================================================== */

.empty{ padding:60px 26px; text-align:center; color:var(--faint) }
.empty__mark{ font-size:36px; color:var(--line-soft); margin-bottom:10px }
.empty h3{ margin:0 0 7px; font-size:14px; color:var(--dim); font-weight:700 }
.empty p{ margin:0; font-size:12.5px; line-height:1.6 }
.empty strong{ color:var(--ink-2) }

.model__name{ margin:0 0 8px; font-size:17px; font-weight:700; letter-spacing:-.01em }
.model__meta{ display:flex; flex-wrap:wrap; gap:6px; margin-bottom:7px }
.model__meta span{
  font-size:10.5px; padding:3px 8px; border-radius:5px;
  background:var(--panel-2); border:1px solid var(--line-soft); color:var(--dim);
}
.model__meta .mono{ font-family:var(--mono) }
.model__mats{ font-size:11.5px; color:var(--faint) }

/* -- design outcomes --------------------------------------------------------------------
   Given a rust border and larger figures than the dimension table, because these are the
   results a design is judged on rather than the inputs that produced it. */
.block--outcomes{ background:var(--panel-2) }

.stats{ display:grid; grid-template-columns:1fr 1fr; gap:7px }
.stat{
  background:var(--white); border:1px solid var(--line-soft);
  border-left:3px solid var(--accent);
  border-radius:var(--r-s); padding:9px 11px; cursor:help;
}
.stat__k{
  display:block; font-size:9.5px; letter-spacing:.06em; text-transform:uppercase;
  color:var(--dim); margin-bottom:3px; line-height:1.3;
}
/* Set in the sans face, not mono: the monospace stack lacks glyphs such as the subscript
   in "kg CO₂e", so the browser fell back to a different font mid-value and the four
   outcomes did not match. One face, one size, one weight for every outcome. */
.stat__v{
  font:700 16px/1.15 var(--sans); font-variant-numeric:tabular-nums;
  color:var(--ink); display:block;
}

.disclaimer{
  margin:11px 0 0; padding:8px 10px;
  background:var(--raised); border:1px dashed var(--line-soft); border-radius:var(--r-s);
  font-size:10.5px; line-height:1.55; color:var(--dim);
}
.disclaimer strong{ color:var(--ink-2) }

.ftable{ width:100%; border-collapse:collapse }
.ftable th,.ftable td{
  padding:6px 0; border-bottom:1px solid var(--line-hair);
  font-size:12px; font-weight:400; text-align:left;
}
.ftable th{ color:var(--dim) }
.ftable td{ text-align:right; color:var(--ink-2);
            font-family:var(--mono); font-variant-numeric:tabular-nums }
.ftable tr:last-child th,.ftable tr:last-child td{ border-bottom:0 }

/* -- adjusters -------------------------------------------------------------------------- */

.adjs{ display:grid; gap:7px }
.adj{
  display:grid; grid-template-columns:1fr 136px; gap:9px; align-items:center;
  padding:3px 5px; margin:0 -5px; border-radius:var(--r-s);
}
.adj__label{ font-size:12.5px; font-weight:600; color:var(--ink-2) }
.adj__label em{
  font-style:normal; color:var(--faint);
  font-family:var(--mono); font-size:10px; margin-left:5px; font-weight:400;
}
.adj__ctrl{ display:grid; grid-template-columns:30px 1fr 30px; gap:4px }

.step{
  border:var(--bw) solid var(--line); background:var(--tan); color:var(--tan-ink);
  border-radius:var(--r-s); cursor:pointer;
  font:700 16px/1 var(--sans); padding:0; height:31px;
  transition:.12s;
}
.step:hover:not(:disabled){ background:var(--tan-h) }
.step:active:not(:disabled){ transform:translateY(1px) }
.step:disabled{ opacity:.3; cursor:not-allowed; background:var(--raised) }
/* Clickable, but only by leaving the current chair type. Dimmed to set expectations
   without hiding the affordance - the refusal message is what teaches the toggle. */
.step.is-cross{ background:var(--raised); border-style:dashed; color:var(--dim) }
.step.is-cross:hover:not(:disabled){ background:var(--tan); color:var(--tan-ink) }

.adj__val{
  height:31px; text-align:center;
  background:var(--white); color:var(--ink);
  border:1px solid var(--line-soft); border-radius:var(--r-s);
  font:12.5px/1 var(--mono); font-variant-numeric:tabular-nums;
  padding:0 2px; width:100%;
}
.adj__val:focus{ border-color:var(--accent); outline:none;
                 box-shadow:0 0 0 2px rgba(168,92,51,.18) }

/* This chair has no armrests, so the feature does not exist here. Distinct from a
   disabled control, which means "exists, but the catalog has nothing further". */
.adj--na .adj__label{ color:var(--faint); font-weight:500 }
.adj__na{
  height:31px; display:grid; place-items:center;
  border:1px dashed var(--line-soft); border-radius:var(--r-s);
  font:11px/1 var(--sans); color:var(--faint); font-style:italic;
}

@keyframes blocked{
  0%,100%{ background:transparent }
  20%,60%{ background:rgba(179,57,47,.14) }
}
.adj.is-blocked{ animation:blocked .5s ease }

.opts{ display:grid; gap:8px; margin-top:14px; padding-top:13px;
       border-top:1px solid var(--line-hair) }
.opt{ display:flex; align-items:center; gap:8px; font-size:12px; color:var(--dim); cursor:pointer }
.opt:hover{ color:var(--ink-2) }

/* -- saved designs ------------------------------------------------------------------------
   Each row is a button, not a label: the list exists to be clicked back into. The row on
   screen keeps the rust marker and loses its hover, so it reads as a position in the list
   rather than as somewhere still to go. */

.history{ list-style:none; margin:0; padding:0; display:grid; gap:3px }
.history__go{
  width:100%; font:inherit; text-align:left; cursor:pointer;
  display:grid; grid-template-columns:auto 1fr auto; gap:9px; align-items:baseline;
  padding:5px 8px; border-radius:5px; font-size:11.5px; color:var(--dim);
  background:transparent; border:0; border-left:3px solid transparent;
  transition:background .12s, color .12s;
}
.history__go:hover{ background:var(--panel-2); color:var(--ink-2) }
.history li.is-current .history__go{
  background:var(--raised); border-left-color:var(--accent); color:var(--ink-2);
  cursor:default;
}
.history .mono{ font-size:10.5px; color:var(--faint) }
.history em{ font-style:normal; font-size:10px; color:var(--faint); text-align:right }

/* ====================================================================================== *
   Survey
   ====================================================================================== */

.survey{ position:fixed; inset:0; z-index:60 }
.survey__scrim{
  position:absolute; inset:0; background:rgba(30,42,54,.42);
  opacity:0; transition:opacity .18s;
}
.survey.is-open .survey__scrim{ opacity:1 }

.survey__panel{
  position:absolute; top:50%; left:50%;
  transform:translate(-50%,-48%) scale(.985);
  width:min(680px,calc(100vw - 40px)); max-height:min(94vh,860px);
  display:flex; flex-direction:column;
  background:var(--white); border:var(--bw) solid var(--line);
  border-radius:12px; box-shadow:0 28px 70px -20px rgba(20,32,44,.55);
  opacity:0; transition:opacity .18s, transform .18s;
}
.survey.is-open .survey__panel{ opacity:1; transform:translate(-50%,-50%) scale(1) }

.survey__head{ padding:14px 22px 10px; border-bottom:1px solid var(--line-hair);
               background:var(--panel-2); border-radius:9px 9px 0 0 }
.survey__head h2{ margin:0 0 2px; font-size:15px; font-weight:700 }
.survey__head p{ margin:0; font-size:12px; color:var(--dim) }
.survey__head strong{ color:var(--accent); font-weight:700 }

.survey__body{ overflow-y:auto; padding:2px 22px 0 }

/* Compact spacing: the five stakeholder questions must fit on a typical laptop screen
   without the participant having to scroll. */
.q{ padding:9px 0; border-bottom:1px solid var(--line-hair) }
.q__head{ display:grid; grid-template-columns:auto 1fr; gap:10px; margin-bottom:6px }
.q .input--area{ padding-block:6px; line-height:1.4; min-height:0 }

/* Yes/No questions put the answer on the same line as the statement. */
.q:has(.choices--inline){ display:grid; grid-template-columns:1fr auto; align-items:center; gap:14px }
.q:has(.choices--inline) .q__head{ margin-bottom:0 }
.q:has(.choices--inline) .q__body{ padding-left:0 }
.q:has(.choices--inline) .choice{ padding:6px 12px }
.q__n{ font:700 10.5px/1.7 var(--mono); color:var(--faint) }
.q__t{ font-size:13px; line-height:1.5; color:var(--ink) }
.q__req{
  font-style:normal; font-size:9.5px; letter-spacing:.07em; text-transform:uppercase;
  color:var(--faint); margin-left:8px; vertical-align:1px;
}
.q--missing .q__t{ color:var(--err) }
.q--missing{ background:#fbeae8; border-radius:6px; padding-inline:9px; margin-inline:-9px }
.q__body{ padding-left:26px }

/* likert */
.likert{ display:grid; grid-template-columns:auto 1fr auto; gap:11px; align-items:center }
.likert__anchor{ font-size:10.5px; color:var(--faint); max-width:88px; line-height:1.35 }
.likert__anchor--r{ text-align:right }
.likert__scale{ display:flex; gap:5px; justify-content:space-between }
.likert__pt{ flex:1; cursor:pointer }
.likert__pt input{ position:absolute; opacity:0; pointer-events:none }
.likert__pt span{
  display:grid; place-items:center; height:36px; border-radius:var(--r-s);
  background:var(--raised); border:1px solid var(--line-soft);
  font:650 12px/1 var(--mono); color:var(--dim); transition:.12s;
}
.likert__pt:hover span{ border-color:var(--line); color:var(--ink) }
.likert__pt input:checked + span{
  background:var(--accent); border-color:var(--line); border-width:var(--bw);
  color:var(--accent-ink); font-weight:700;
}
.likert__pt input:focus-visible + span{ outline:2px solid var(--accent); outline-offset:2px }

/* choices */
.choices{ display:grid; gap:5px }
/* Yes/No and other short option sets sit in a row. With five stakeholders stacked down the
   modal, keeping each answer on one line is what makes the set scannable as a group. */
.choices--inline{ display:flex; gap:6px }
.choices--inline .choice{ flex:0 0 auto; min-width:78px; justify-content:center }
.choice{
  display:flex; align-items:center; gap:9px; cursor:pointer;
  padding:9px 12px; border-radius:var(--r-s);
  background:var(--raised); border:1px solid var(--line-soft);
  font-size:12.5px; color:var(--ink-2); transition:.12s;
}
.choice:hover{ border-color:var(--line) }
.choice:has(input:checked){
  background:var(--tan); border-color:var(--line); border-width:var(--bw);
  color:var(--tan-ink); font-weight:600;
}

/* slider */
.slider{ display:grid; grid-template-columns:auto 1fr auto auto; gap:11px; align-items:center }
.slider__anchor{ font-size:10.5px; color:var(--faint) }
.slider input[type=range]{ width:100%; accent-color:var(--accent); cursor:pointer }
.slider__out{ font:700 12px/1 var(--mono); color:var(--accent); min-width:48px; text-align:right }

.survey__error{
  margin:14px 0 0; padding:10px 12px; border-radius:var(--r-s);
  background:#fbeae8; border:1px solid #d79b95;
  color:#7d2a23; font-size:12.5px;
}

.survey__foot{
  position:sticky; bottom:0;
  display:flex; gap:9px; justify-content:flex-end; align-items:center;
  padding:10px 0 14px; margin-top:2px;
  background:linear-gradient(to top,var(--white) 68%,transparent);
}
/* Stands in for the dismiss button on a mandatory instrument, so the absence of a way out
   reads as deliberate rather than as a missing control. */
.survey__required{ margin-right:auto; font-size:11.5px; color:var(--dim) }

.survey__note{
  margin:8px 0 0; padding:6px 10px; border-radius:var(--r-s);
  background:var(--panel-2); border:1px solid var(--line-soft);
  font-size:12px; line-height:1.5; color:var(--dim);
}

/* A mandatory survey cannot be dismissed, so the scrim is opaque enough to make clear that
   the page behind it is not available until the form is done. */
.survey__panel--mandatory{ border-color:var(--accent) }

/* -- closing notice ---------------------------------------------------------------------
   The hand-off to the external questionnaire. Narrower than a form panel, because it is
   three short lines, and the link is sized as the one thing on screen left to act on. */
.survey__panel--notice{ width:min(520px,calc(100vw - 40px)); border-color:var(--accent) }
.notice{ padding:20px 24px 24px }
.notice__text{ margin:0 0 14px; font-size:13.5px; line-height:1.6; color:var(--ink-2) }

/* The full address is the link text, so it stays usable to someone reading this screen
   from a second device, or copying it by hand. It must therefore be able to wrap. */
.notice__link{
  display:block; padding:12px 14px; border-radius:var(--r-s);
  background:var(--panel-2); border:var(--bw) solid var(--line);
  font:600 13px/1.45 var(--mono); color:var(--accent);
  overflow-wrap:anywhere; text-decoration:none;
}
.notice__link:hover{ background:var(--white); text-decoration:underline }
.notice__aside{ margin:11px 0 0; font-size:11.5px; line-height:1.5; color:var(--faint) }

/* The way out sits apart from the link and is styled down to a ghost button: it is the
   recovery path for a mistaken Finish, not an alternative to taking the survey. */
.notice__foot{
  display:flex; justify-content:flex-end;
  margin-top:18px; padding-top:14px; border-top:1px solid var(--line-hair);
}

/* ====================================================================================== *
   Narrow screens. The tool is built for a desktop workspace; below this the side panels
   stack under the viewport rather than crushing it into uselessness.
   ====================================================================================== */

@media (max-width:1080px){
  body{ overflow:auto; display:block }
  .layout{ grid-template-columns:1fr; flex:none; min-height:0 }
  .panel--left .panel__scroll{ padding-bottom:28px }   /* .block--sticky is static here */
  .stage{ height:62vh; min-height:420px; order:-1 }
  .panel--left,.panel--right{ border:0; border-top:var(--bw) solid var(--line) }
  .panel__scroll{ overflow:visible }
  .block--sticky{ position:static; box-shadow:none }
  .topbar{ flex-wrap:wrap; height:auto; padding:9px 12px; gap:10px }
  .topbar__stats{ order:3; width:100% }
}

/* Design Problem pop-up */
.problem{ z-index:70 }
.problem__panel{ width:min(560px,calc(100vw - 40px)) }
.problem__head{ display:flex; align-items:center; justify-content:space-between }
.problem__head h2{ margin:0 }
.problem__close{ border:0; background:none; font-size:26px; line-height:1; cursor:pointer;
                 color:var(--dim); padding:0 4px }
.problem__close:hover{ color:var(--ink) }
.problem__body{ padding:14px 22px 20px; font-size:14px; line-height:1.5 }
.problem__body p{ margin:0 0 10px }
.problem__body ul{ margin:0; padding-left:20px }
.problem__body li{ margin:6px 0 }
