/*
  Foundry: onboarding wizard
  1. Tokens, ground (cyanotype blue, fine grid, grain) and browser surfaces
  2. The sheet: rail (dimension line), work area (forms), plan (schematic, legend, title block)
  3. Components: the themed kit (role picker, change-order dialog, revision notices, callout tooltip)
  4. Folded layouts: two columns under 1180px, one column under 820px
*/

/* ---------- 1. Tokens ---------- */
:root {
  /* colour */
  --blue: #0f3d91;            /* blueprint ground */
  --blue-deep: #0a2c6c;       /* text on yellow, shaded cells */
  --blue-lift: #1a4ca6;       /* raised cells */
  --ink: #ffffff;             /* confirmed linework and text */
  --ink-soft: #d3e1ff;        /* body text */
  --ink-faint: #a6bff3;       /* captions, pencil lettering (5.2:1 on ground) */
  --line: rgba(255, 255, 255, 0.7);
  --line-soft: rgba(255, 255, 255, 0.34);
  --line-ghost: rgba(255, 255, 255, 0.24);
  --fill: rgba(255, 255, 255, 0.05);
  --fill-strong: rgba(255, 255, 255, 0.1);
  --hi: #ffd84a;              /* highlighter: the active element, nothing else */
  --hi-wash: rgba(255, 216, 74, 0.1);
  --redline: #ffa391;         /* revision pencil: errors only */

  /* type */
  --f-title: "Barlow Condensed", "Arial Narrow", sans-serif;
  --f-text: "Barlow", system-ui, sans-serif;
  --f-mono: "Red Hat Mono", ui-monospace, monospace;

  /* space */
  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 24px;
  --s-6: 32px;
  --s-7: 48px;
  --s-8: 64px;
  --margin: 32px;             /* sheet margin */
  --trim: 14px;               /* gap between trim line and sheet border */

  /* shape and motion */
  --r: 0px;                   /* drafting is square */
  --stroke: 1.5;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

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

html {
  color-scheme: dark;
  scrollbar-color: var(--ink-faint) var(--blue-deep);
  scrollbar-width: thin;
  -webkit-text-size-adjust: 100%;
}

body {
  position: relative;
  margin: 0;
  min-height: 100vh;
  min-height: 100svh;
  padding: var(--margin);
  color: var(--ink-soft);
  font: 400 1rem/1.5 var(--f-text);
  accent-color: var(--hi);
  caret-color: var(--hi);
  background-color: var(--blue);
  /* uneven cyanotype wash, then major and minor grid */
  background-image:
    radial-gradient(120% 90% at 62% 38%, rgba(72, 128, 222, 0.34), transparent 62%),
    radial-gradient(90% 70% at 0% 100%, rgba(5, 22, 66, 0.4), transparent 60%),
    linear-gradient(rgba(255, 255, 255, 0.085) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.085) 1px, transparent 1px),
    linear-gradient(rgba(255, 255, 255, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.04) 1px, transparent 1px);
  background-size: auto, auto, 40px 40px, 40px 40px, 8px 8px, 8px 8px;
  background-position: 0 0, 0 0, -1px -1px, -1px -1px, -1px -1px, -1px -1px;
}

/* paper grain */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 50;
  pointer-events: none;
  opacity: 0.22;
  mix-blend-mode: soft-light;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 .9 0'/%3E%3C/filter%3E%3Crect width='220' height='220' filter='url(%23n)'/%3E%3C/svg%3E");
}

::selection { background: var(--hi); color: var(--blue-deep); }

:focus-visible {
  outline: 2px solid var(--hi);
  outline-offset: 3px;
}

h1, h2, p, ol, ul, dl, dd, figure, fieldset { margin: 0; padding: 0; }
ol, ul { list-style: none; }
fieldset { border: 0; min-width: 0; }
button, input { font: inherit; color: inherit; }
input { border-radius: 0; }
/* a browser's autofill keeps the sheet's ink and ground */
input:-webkit-autofill,
input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--ink);
  caret-color: var(--hi);
  box-shadow: 0 0 0 100px var(--blue-lift) inset;
  transition: background-color 9999s;
}
input::-webkit-search-cancel-button,
input::-webkit-contacts-auto-fill-button,
input::-webkit-credentials-auto-fill-button { display: none; }

/* scroll areas inside the sheet: a thin ruled track */
.scroller, .step { scrollbar-color: var(--ink-faint) transparent; scrollbar-width: thin; }
@supports not (scrollbar-color: auto) {
  .scroller::-webkit-scrollbar, .step::-webkit-scrollbar { width: 6px; }
  .scroller::-webkit-scrollbar-track, .step::-webkit-scrollbar-track { background: transparent; border-left: 1px solid var(--line-ghost); }
  .scroller::-webkit-scrollbar-thumb, .step::-webkit-scrollbar-thumb { background: var(--ink-faint); }
}
button { cursor: pointer; }
svg { display: block; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.mono { font-family: var(--f-mono); font-size: 0.875rem; }

kbd {
  display: inline-block;
  padding: 1px 6px 2px;
  border: 1px solid var(--line-soft);
  font: 500 0.75rem/1.4 var(--f-mono);
  color: var(--ink);
}

.link {
  padding: 0;
  border: 0;
  background: none;
  color: var(--ink);
  font: 600 0.9375rem/1 var(--f-title);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 4px;
  transition: color 0.2s;
}
.link:hover { color: var(--hi); }
.link:disabled { color: var(--ink-faint); cursor: progress; text-decoration: none; }
/* 44px touch target without changing the visual size */
.link { position: relative; }
.link::after { content: ""; position: absolute; inset: -14px -10px; }

/* ---------- Zone marks in the margin ---------- */
.zones {
  position: absolute;
  display: flex;
  font: 500 0.75rem/1 var(--f-mono);
  color: var(--ink-faint);
  pointer-events: none;
}
.zones span {
  flex: 1;
  display: grid;
  place-items: center;
}
.zones--top {
  top: calc(var(--margin) - var(--trim));
  left: var(--margin);
  right: var(--margin);
  height: var(--trim);
}
.zones--top span + span { border-left: 1px solid var(--line-soft); }
.zones--side {
  flex-direction: column;
  left: calc(var(--margin) - var(--trim));
  top: var(--margin);
  bottom: var(--margin);
  width: var(--trim);
}
.zones--side span + span { border-top: 1px solid var(--line-soft); }

/* ---------- 2. The sheet ---------- */
.sheet {
  position: relative;
  display: grid;
  grid-template-columns: 224px minmax(400px, 492px) minmax(0, 1fr);
  min-height: calc(100vh - 2 * var(--margin));
  min-height: calc(100svh - 2 * var(--margin));
  border: 2px solid var(--ink);
}
/* trim line outside the border */
.sheet::before {
  content: "";
  position: absolute;
  inset: calc(-1 * var(--trim) - 2px);
  border: 1px solid var(--line-soft);
  pointer-events: none;
}

/* ----- Rail ----- */
.rail {
  display: flex;
  flex-direction: column;
  padding: var(--s-6) var(--s-5) var(--s-5) var(--s-6);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: var(--s-3);
  align-self: flex-start;
  color: var(--ink);
  text-decoration: none;
}
.brand__name {
  font: 700 1.625rem/1 var(--f-title);
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.dim { margin-top: var(--s-8); }

.dim__step {
  position: relative;
  min-height: 92px;
  padding-left: 38px;
}
/* dimension line from this tick to the next: dashed until the step is passed */
.dim__step::before {
  content: "";
  position: absolute;
  left: 9px;
  top: 13px;
  bottom: -13px;
  border-left: 1px dashed var(--line-soft);
}
.dim__step.is-done::before { border-left: 1px solid var(--ink); }
.dim__step:last-child { min-height: 0; }
.dim__step:last-child::before { display: none; }
/* architectural tick: a 45 degree slash on the line */
.dim__step::after {
  content: "";
  position: absolute;
  left: 1px;
  top: 12px;
  width: 17px;
  border-top: 1.5px solid var(--ink-faint);
  transform: rotate(-45deg);
  transition: border-color 0.3s;
}
.dim__step.is-done::after { border-color: var(--ink); }
.dim__step.is-current::after { border-top: 3px solid var(--hi); top: 11px; }

.dim__btn {
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: var(--s-2);
  align-items: baseline;
  width: 100%;
  padding: 0 0 var(--s-2);
  border: 0;
  background: none;
  text-align: left;
  color: var(--ink);
}
/* witness line from the tick to the lettering */
.dim__btn::before {
  content: "";
  position: absolute;
  left: -22px;
  top: 12.5px;
  width: 14px;
  border-top: 1px solid var(--line-soft);
}
.dim__no {
  font: 500 0.75rem/1 var(--f-mono);
  color: var(--ink-faint);
}
.dim__name {
  font: 600 1.4375rem/1.1 var(--f-title);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.dim__val {
  grid-column: 1 / -1;
  margin-top: 5px;
  overflow: hidden;
  font: 400 0.75rem/1.4 var(--f-mono);
  color: var(--ink-faint);
  text-overflow: ellipsis;
  white-space: nowrap;
}
.dim__btn:disabled { cursor: default; color: var(--ink-faint); }
.dim__btn:not(:disabled):hover .dim__name {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 4px;
}
.dim__step.is-done .dim__val { color: var(--ink-soft); }
.dim__step.is-done .dim__btn:disabled { color: var(--ink); }
.dim__step.is-current .dim__name,
.dim__step.is-current .dim__no { color: var(--hi); }

.notes {
  margin-top: auto;
  padding-top: var(--s-6);
  max-width: 180px;
}
.notes__title {
  font: 600 0.8125rem/1 var(--f-title);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink);
}
.notes__list {
  margin-top: var(--s-3);
  counter-reset: note;
  font-size: 0.8125rem;
  line-height: 1.45;
  color: var(--ink-faint);
}
.notes__list li {
  position: relative;
  padding-left: 20px;
  counter-increment: note;
}
.notes__list li + li { margin-top: 6px; }
.notes__list li::before {
  content: counter(note) ".";
  position: absolute;
  left: 0;
  font-family: var(--f-mono);
  font-size: 0.75rem;
  line-height: 1.6;
}
.notes kbd { padding: 0 4px 1px; }

/* ----- Work area ----- */
.work {
  --work-top: 60px;
  --work-bottom: 52px;
  position: relative;
  padding: var(--work-top) 40px var(--work-bottom) var(--s-5);
}

/* The sheet stays one composed page: the work column never sets the sheet's height.
   A step is a column whose schedule (seats, variables) scrolls inside it, so the
   title, the actions and the title block stay in view however long the lists get. */
@media (min-width: 820px) {
  .js .work {
    contain: size;
    min-height: calc(var(--work-top) + var(--work-bottom) + 660px);
  }
  .js .step.is-current {
    display: flex;
    flex-direction: column;
    max-height: calc(100% + 12px);
    margin: -6px;
    padding: 6px;          /* room for focus rings inside the scroll box */
    overflow: hidden auto;
  }
  .js .step > * { flex: none; }
  .js .step > .is-elastic {
    display: flex;
    flex-direction: column;
    flex: 0 1 auto;
    min-height: 168px;
  }
  .js .is-elastic > * { flex: none; }
  .js .is-elastic > .scroller {
    flex: 0 1 auto;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
  }
}

/* a schedule that continues below the fold fades out until its end is reached */
@property --fade-t { syntax: "<length>"; inherits: false; initial-value: 0px; }
@property --fade-b { syntax: "<length>"; inherits: false; initial-value: 0px; }
@supports (animation-timeline: scroll()) {
  .scroller {
    --mask: linear-gradient(transparent, #000 var(--fade-t), #000 calc(100% - var(--fade-b)), transparent);
    -webkit-mask-image: var(--mask);
    mask-image: var(--mask);
    animation: fade-ends linear both;
    animation-timeline: scroll(self);
  }
  @keyframes fade-ends {
    0% { --fade-t: 0px; --fade-b: 36px; }
    6%, 94% { --fade-t: 24px; --fade-b: 36px; }
    100% { --fade-t: 24px; --fade-b: 0px; }
  }
}

html:not(.js) .step--done { display: none; }
html:not(.js) .step + .step { margin-top: var(--s-8); }
.js .step:not(.is-current) { display: none; }

/* the sheet title is lettered at poster size and breaks over two lines */
.step__title {
  font: 700 clamp(3rem, 1.1rem + 3.7vw, 4.375rem)/0.9 var(--f-title);
  letter-spacing: 0;
  text-transform: uppercase;
  text-wrap: balance;
  color: var(--ink);
  outline: none;
}
.step__lead {
  margin-top: 20px;
  max-width: 44ch;
  text-wrap: pretty;
}
.step__lead + * { margin-top: var(--s-6); }

/* fields */
.field + .field { margin-top: var(--s-5); }
.field__label {
  display: block;
  margin-bottom: var(--s-2);
  font: 600 0.875rem/1.2 var(--f-title);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink);
}
.field__hint {
  margin-top: var(--s-2);
  font-size: 0.875rem;
  color: var(--ink-faint);
}
.field__msg {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--redline);
}
.field__msg:not(:empty) {
  margin-top: var(--s-2);
  padding-left: 22px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23ffa391' stroke-width='2'%3E%3Cpath d='M12 3 2 21h20ZM12 10v5M12 17.500v1'/%3E%3C/svg%3E") 0 2px / 16px 16px no-repeat;
}
.field__msg--block:not(:empty) {
  margin-top: var(--s-4);
  padding: var(--s-3) var(--s-3) var(--s-3) 38px;
  border: 1px solid var(--redline);
  background-position: 12px 13px;
}

.input {
  display: block;
  width: 100%;
  height: 52px;
  padding: 0 var(--s-4);
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--fill);
  color: var(--ink);
  font: 500 1rem/1 var(--f-mono);
  transition: border-color 0.2s, background-color 0.2s, box-shadow 0.2s;
}
.input::placeholder,
.input input::placeholder { color: var(--ink-faint); opacity: 1; }
.input:hover { background: var(--fill-strong); }
.input:focus-visible,
.input--affix:focus-within {
  outline: none;
  border-color: var(--hi);
  box-shadow: 0 0 0 1px var(--hi);
  background: var(--hi-wash);
}
.input--sm { height: 44px; font-size: 0.875rem; padding: 0 var(--s-3); }
.is-invalid .input,
.input[aria-invalid="true"] { border-color: var(--redline); }

.input--affix {
  display: flex;
  align-items: center;
  padding: 0;
}
.input--affix input {
  flex: 1;
  min-width: 0;
  height: 100%;
  padding: 0 0 0 var(--s-4);
  border: 0;
  outline: none;
  background: none;
  font: inherit;
  text-align: right;
}
.input__suffix {
  padding-right: var(--s-4);
  color: var(--ink-faint);
  white-space: nowrap;
}

/* availability status */
.status {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  min-height: 22px;
  margin-top: var(--s-2);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--ink-soft);
}
.status[data-state="idle"] { display: none; }
.status__icon {
  flex: none;
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  display: none;
}
.status[data-state="checking"] .status__icon--busy,
.status[data-state="free"] .status__icon--ok,
.status[data-state="taken"] .status__icon--bad,
.status[data-state="invalid"] .status__icon--bad { display: block; }
.status[data-state="free"] { color: var(--ink); }
.status[data-state="taken"],
.status[data-state="invalid"] { color: var(--redline); }
.status__text { overflow-wrap: anywhere; }
/* the busy mark is a dimension line being measured */
.status__icon--busy,
.btn__busy { animation: measure 0.9s var(--ease) infinite alternate; }
@keyframes measure {
  from { transform: scaleX(0.35); }
  to { transform: scaleX(1); }
}

.suggest {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-2) var(--s-3);
  margin-top: var(--s-3);
}
.suggest[hidden] { display: none; }
.suggest__label { font-size: 0.875rem; color: var(--ink-faint); }
.suggest__list { display: flex; flex-wrap: wrap; gap: var(--s-2); }
.chip {
  min-height: 44px;
  padding: 0 var(--s-3);
  border: 1px dashed var(--line);
  background: none;
  font: 500 0.875rem/1 var(--f-mono);
  color: var(--ink);
  transition: border-color 0.2s, background-color 0.2s;
}
.chip:hover { border-style: solid; border-color: var(--hi); background: var(--hi-wash); }

/* buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-3);
  min-height: 52px;
  padding: 0 20px;
  border: 1px solid transparent;
  border-radius: var(--r);
  font: 600 1.125rem/1 var(--f-title);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color 0.2s, border-color 0.2s, color 0.2s, transform 0.2s var(--ease);
}
.btn__icon,
.btn__busy {
  flex: none;
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  transition: transform 0.3s var(--ease);
}
.btn__busy { display: none; }
.btn--primary {
  background: var(--hi);
  color: var(--blue-deep);
}
.btn--primary:hover { background: #ffe37a; }
.btn--primary:hover .btn__icon { transform: translateX(4px); }
.btn--primary:active { transform: translateY(1px); }
.btn--primary:focus-visible { outline-color: var(--ink); }
.btn--ghost {
  border-color: var(--line);
  background: none;
  color: var(--ink);
}
.btn--ghost:hover { border-color: var(--ink); background: var(--fill-strong); }
.btn--ghost:hover .btn__icon { transform: translateX(-4px); }
.btn--line {
  gap: var(--s-2);
  padding: 0 var(--s-4);
  border-color: var(--line);
  background: var(--fill);
  color: var(--ink);
}
.btn--line:hover { border-color: var(--hi); background: var(--hi-wash); }
.btn--line .btn__icon { width: 16px; height: 16px; }
.btn--sm { min-height: 44px; font-size: 1rem; }
.btn.is-busy { cursor: progress; }
.btn.is-busy .btn__icon { display: none; }
.btn.is-busy .btn__busy { display: block; }
.btn[disabled] { opacity: 0.55; cursor: not-allowed; }
.btn.is-busy[disabled] { opacity: 1; cursor: progress; }

.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-3);
  margin-top: var(--s-7);
}
.actions__hint {
  margin-left: var(--s-2);
  font-size: 0.875rem;
  color: var(--ink-faint);
}

/* leaving the wizard: a quiet link at the foot of the work column, guarded by the change order */
.scrap {
  position: absolute;
  left: var(--s-5);
  bottom: 18px;
  color: var(--ink-faint);
  font-size: 0.875rem;
}
.scrap:hover { color: var(--redline); }
.sheet[data-step="done"] .scrap { display: none; }
html:not(.js) .scrap { display: none; }

/* step 2: framework choices */
.choices {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--s-3);
}
.choice { position: relative; display: block; cursor: pointer; }
.choice input,
.region input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}
.choice__box {
  display: grid;
  grid-template-columns: 32px 1fr;
  column-gap: var(--s-3);
  align-items: center;
  height: 100%;
  min-height: 76px;
  padding: var(--s-3) var(--s-4);
  border: 1px solid var(--line-soft);
  background: var(--fill);
  transition: border-color 0.2s, background-color 0.2s, box-shadow 0.2s;
}
.choice__glyph {
  grid-row: 1 / 3;
  width: 32px;
  height: 32px;
  fill: none;
  stroke: var(--ink-soft);
  stroke-width: 1.25;
  transition: stroke 0.2s;
}
.choice__name {
  align-self: end;
  font: 600 1.375rem/1.05 var(--f-title);
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--ink);
}
.choice__meta {
  align-self: start;
  margin-top: 3px;
  font: 400 0.75rem/1.3 var(--f-mono);
  color: var(--ink-faint);
}
.choice:hover .choice__box { border-color: var(--ink); background: var(--fill-strong); }
.choice input:checked + .choice__box {
  border-color: var(--hi);
  box-shadow: 0 0 0 1px var(--hi);
  background: var(--hi-wash);
}
.choice input:checked + .choice__box .choice__glyph { stroke: var(--hi); }
.choice input:checked + .choice__box .choice__name { color: var(--hi); }
.choice input:focus-visible + .choice__box,
.region input:focus-visible + .region__box {
  outline: 2px solid var(--hi);
  outline-offset: 3px;
}

.preset {
  display: grid;
  grid-template-columns: 1.5fr 1fr 1fr;
  margin-top: var(--s-5);
  border-top: 1px solid var(--line-soft);
  border-bottom: 1px solid var(--line-soft);
}
.preset div { padding: var(--s-3) var(--s-3) var(--s-3) 0; min-width: 0; }
.preset div + div { padding-left: var(--s-3); border-left: 1px solid var(--line-soft); }
.preset dt,
.schedule th,
.seat__role {
  font: 500 0.75rem/1.2 var(--f-title);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.preset dd {
  margin-top: 4px;
  font: 500 0.8125rem/1.35 var(--f-mono);
  color: var(--ink);
  overflow-wrap: anywhere;
}
.preset:not(.is-set) dd { color: var(--ink-faint); font-weight: 400; }

/* step 3: regions */
.region { position: relative; display: block; cursor: pointer; }
.region + .region { margin-top: -1px; }
.region__box {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) 80px 62px;
  column-gap: var(--s-3);
  align-items: center;
  min-height: 56px;
  padding: 0 var(--s-4);
  border: 1px solid var(--line-soft);
  background: var(--fill);
  transition: border-color 0.2s, background-color 0.2s;
}
.region__code { font: 500 0.875rem/1 var(--f-mono); color: var(--ink); }
.region__city {
  font: 600 1.25rem/1.1 var(--f-title);
  letter-spacing: 0.03em;
  text-transform: uppercase;
  white-space: nowrap;
  color: var(--ink);
}
.region__tag {
  display: inline-block;
  margin-left: 6px;
  padding: 2px 5px;
  border: 1px solid var(--line-soft);
  font: 500 0.75rem/1.2 var(--f-mono);
  letter-spacing: 0.02em;
  color: var(--ink-soft);
  vertical-align: 3px;
}
/* latency drawn as a dimension line: longer is slower */
.region__dim { display: block; height: 11px; }
.region__dim i {
  display: block;
  width: var(--w, 40%);
  min-width: 6px;
  height: 100%;
  border-left: 1px solid var(--ink-soft);
  border-right: 1px solid var(--ink-soft);
  background: linear-gradient(var(--ink-soft), var(--ink-soft)) 0 50% / 100% 1px no-repeat;
  transition: width 0.6s var(--ease);
}
.region__ms {
  font: 400 0.8125rem/1 var(--f-mono);
  font-variant-numeric: tabular-nums;
  text-align: right;
  color: var(--ink-soft);
}
.region__ms b { font-weight: 500; color: var(--ink); }
.region:hover .region__box { border-color: var(--ink); background: var(--fill-strong); }
.region:hover { z-index: 1; }
.region:has(input:checked) { z-index: 2; }
.region input:checked + .region__box {
  border-color: var(--hi);
  box-shadow: 0 0 0 1px var(--hi);
  background: var(--hi-wash);
}
.region input:checked + .region__box .region__code,
.region input:checked + .region__box .region__city { color: var(--hi); }
.region input:checked + .region__box .region__tag { color: var(--hi); border-color: var(--hi); }
.region input:checked + .region__box .region__dim i {
  border-color: var(--hi);
  background-image: linear-gradient(var(--hi), var(--hi));
}

.measure {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-2) var(--s-4);
  margin-top: var(--s-4);
  font-size: 0.875rem;
  color: var(--ink-faint);
}

/* step 4: invites */
.invite {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 128px auto;
  gap: var(--s-2);
}
.seats,
.env { margin-top: var(--s-6); }
.env { margin-top: var(--s-5); }
.env .icon-btn { height: 40px; }
.step[data-step="5"] .step__lead + * { margin-top: var(--s-5); }
.step[data-step="5"] .actions { margin-top: var(--s-5); }
.seats__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s-4);
  padding-bottom: var(--s-2);
  border-bottom: 1px solid var(--ink);
}
.seats__title {
  font: 600 0.875rem/1.2 var(--f-title);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink);
}
.seats__count {
  font: 400 0.75rem/1.2 var(--f-mono);
  font-variant-numeric: tabular-nums;
  color: var(--ink-faint);
}
.seat {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) auto 44px;
  column-gap: var(--s-3);
  align-items: center;
  min-height: 52px;
  border-bottom: 1px solid var(--line-soft);
}
.seat--owner { grid-template-columns: 30px minmax(0, 1fr) auto; padding-right: var(--s-3); }
.js .seat.is-new { animation: row-in 0.5s var(--ease) both; }
@keyframes row-in {
  from { opacity: 0; clip-path: inset(0 100% 0 0); }
  to { opacity: 1; clip-path: inset(0 0 0 0); }
}
/* seat symbols match the schematic: filled owner, double ring admin, ring developer, dotted viewer */
.seat__mark {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 1.5px solid var(--ink);
  border-radius: 50%;
  font: 600 0.75rem/1 var(--f-title);
  letter-spacing: 0.04em;
  color: var(--ink);
}
.seat__mark[data-role="Owner"] { background: var(--ink); color: var(--blue); }
.seat__mark[data-role="Admin"] { box-shadow: inset 0 0 0 2px var(--blue), inset 0 0 0 3.5px var(--ink); }
.seat__mark[data-role="Viewer"] { border-style: dotted; }
.seat__who {
  min-width: 0;
  overflow: hidden;
  font: 400 0.8125rem/1.3 var(--f-mono);
  color: var(--ink);
  text-overflow: ellipsis;
  white-space: nowrap;
}
.seat__who b {
  display: block;
  font: 600 1.0625rem/1.15 var(--f-title);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.seat__who span { color: var(--ink-faint); }
.icon-btn {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--ink-faint);
  transition: color 0.2s;
}
.icon-btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; }
.icon-btn:hover { color: var(--redline); }
.icon-btn:focus-visible { outline-offset: -5px; color: var(--ink); }

/* step 5: schedule, environment, launch log */
.schedule {
  width: 100%;
  border-collapse: collapse;
  border-top: 1px solid var(--ink);
}
.schedule tr { border-bottom: 1px solid var(--line-soft); }
.schedule th,
.schedule td { height: 46px; padding: 4px 0; text-align: left; vertical-align: middle; }
.schedule th { width: 96px; font-weight: 500; overflow-wrap: anywhere; }
.schedule td {
  font: 600 1.125rem/1.2 var(--f-title);
  letter-spacing: 0.03em;
  color: var(--ink);
  overflow-wrap: anywhere;
}
.schedule td.mono { font: 500 0.875rem/1.3 var(--f-mono); letter-spacing: 0; }
.schedule td small {
  display: block;
  margin-top: 1px;
  font: 400 0.75rem/1.3 var(--f-mono);
  letter-spacing: 0;
  color: var(--ink-faint);
}
.schedule td:last-child { width: 44px; text-align: right; }

.env__row {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1fr) 44px;
  column-gap: var(--s-3);
  align-items: center;
  min-height: 40px;
  border-bottom: 1px solid var(--line-soft);
  font: 400 0.8125rem/1.3 var(--f-mono);
}
.env__row.is-new { animation: row-in 0.5s var(--ease) both; }
.env__key { color: var(--ink); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.env__val { color: var(--ink-faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.env__auto {
  justify-self: end;
  font: 500 0.75rem/1 var(--f-title);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.env__add {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1fr) auto;
  gap: var(--s-2);
  margin-top: var(--s-3);
}

.log {
  margin-top: var(--s-5);
  padding: var(--s-3) var(--s-4);
  border: 1px solid var(--line-soft);
  background: var(--fill);
  font: 400 0.8125rem/1.6 var(--f-mono);
  color: var(--ink-soft);
}
.log[hidden] { display: none; }
.log li {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) auto;
  column-gap: var(--s-2);
}
.js .log:not(.log--record) li { animation: row-in 0.45s var(--ease) both; }
.log__t { color: var(--ink-faint); font-variant-numeric: tabular-nums; }
.log__ok { color: var(--ink); }
.log li:last-child .log__msg { color: var(--ink); }
.log--record { margin-top: var(--s-5); }

/* while launching, the form is read only */
.step.is-launching .schedule .link { visibility: hidden; }
.step.is-launching .env { display: none; }

/* success */
.copy {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  min-height: 52px;
  padding: 3px 3px 3px var(--s-4);
  border: 1px solid var(--line);
  background: var(--fill);
}
.copy__value {
  flex: 1;
  min-width: 0;
  padding: var(--s-2) 0;
  font: 500 0.875rem/1.4 var(--f-mono);
  color: var(--ink);
  overflow-wrap: anywhere;
}
a.copy__value {
  color: var(--hi);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 4px;
}

/* step change: the new sheet slides in from the direction of travel */
@media (prefers-reduced-motion: no-preference) {
  .js .step.is-current { animation: sheet-in 0.55s var(--ease) both; }
  .js .sheet[data-dir="back"] .step.is-current { animation-name: sheet-back; }
}
@keyframes sheet-in {
  from { opacity: 0; transform: translateX(18px); }
  to { opacity: 1; transform: none; }
}
@keyframes sheet-back {
  from { opacity: 0; transform: translateX(-18px); }
  to { opacity: 1; transform: none; }
}

/* ----- Plan: schematic ----- */
.plan {
  display: flex;
  flex-direction: column;
  min-width: 0;
  border-left: 1px solid var(--line-soft);
}
.drawing {
  position: relative;
  flex: 1;
  min-height: 440px;
}
.schematic {
  position: absolute;
  inset: var(--s-4) var(--s-5) var(--s-2);
  width: calc(100% - 2 * var(--s-5));
  height: calc(100% - var(--s-4) - var(--s-2));
}
/* --t and --tt are set by script.js from the drawing's rendered scale, so lettering
   never falls under 12px on screen however small the schematic is drawn */
.schematic text {
  font-family: var(--f-title);
  font-size: calc(var(--t, 12) * 1px);
  font-weight: 500;
  letter-spacing: 0.1em;
  fill: var(--ink-faint);
}

/* pencil: still to be decided */
.ghost rect,
.ghost path,
.ghost circle {
  fill: none;
  stroke: var(--line-ghost);
  stroke-width: 1;
  stroke-dasharray: 5 4;
}
.ghost .ghost__grat { stroke-dasharray: 1 5; stroke: var(--line-soft); }
.ghost .ghost__map path { stroke: var(--line-soft); stroke-dasharray: none; stroke-width: 0.8; }
.ghost [data-for] { transition: opacity 0.4s; }
/* the part the current sheet will draw waits in highlighter, its dashes on the move */
.ghost .is-next > :is(rect, path, circle) { stroke: var(--hi); stroke-width: 1.4; stroke-dasharray: 6 5; }
.schematic .ghost .is-next > text { fill: var(--hi); }
@media (prefers-reduced-motion: no-preference) {
  .ghost .is-next > :is(rect, path, circle) { animation: march 2.6s linear infinite; }
}
@keyframes march { to { stroke-dashoffset: -22; } }
.ghost [data-for].is-inked { opacity: 0; }

/* ink: each path is normalised to length 1 so one rule draws them all */
.ink {
  fill: none;
  stroke: var(--ink);
  stroke-width: 1.3;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
}
.lbl { opacity: 0; }
.part.is-drawn .ink,
.part.is-drawn .node.is-in .ink {
  stroke-dashoffset: 0;
  transition: stroke-dashoffset var(--draw, 0.8s) var(--ease) calc(var(--base, 0s) + var(--d, 0s)), stroke 0.4s;
}
.part.is-drawn .lbl,
.part.is-drawn .node.is-in .lbl {
  opacity: 1;
  transition: opacity 0.4s ease calc(var(--base, 0s) + var(--d, 0.3s)), fill 0.4s, stroke 0.4s;
}
.part .node .ink { stroke-dashoffset: 1; transition: none; }
.part .node .lbl { opacity: 0; transition: none; }
.part.is-drawn .node.is-set .ink,
.part.is-drawn .node.is-set .lbl { transition: stroke 0.4s, fill 0.4s; }
.schematic.is-instant .ink,
.schematic.is-instant .lbl { transition: none !important; }

.schematic .lbl--cap { fill: var(--ink); }
.schematic .lbl--mono {
  font-family: var(--f-mono);
  font-weight: 400;
  letter-spacing: 0;
  fill: var(--ink-soft);
}
.schematic .lbl--value { font-weight: 500; fill: var(--ink); }
.schematic .lbl--title {
  font-size: calc(var(--tt, 21) * 1px);
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  fill: var(--ink);
}
.schematic .lbl--knock {
  paint-order: stroke;
  stroke: var(--blue);
  stroke-width: 5px;
  stroke-linejoin: round;
}
.sch-glyph * { fill: none; stroke: var(--ink); stroke-width: 0.9; }
.map .ink { stroke: var(--ink-soft); stroke-width: 0.85; }
.sites circle { fill: var(--blue); stroke: var(--ink); stroke-width: 1; }
.node__fill { fill: var(--ink); stroke: none; }
.node__ring { fill: none; stroke: var(--ink); stroke-width: 1; }
.node__ring--dot { stroke-dasharray: 1.5 2.5; }
.schematic .node__txt { font-weight: 600; letter-spacing: 0; fill: var(--ink); }
.schematic .node[data-role="Owner"] .node__txt { fill: var(--blue); }

/* the highlighter follows the step being answered */
.part.is-active .ink:not(.map .ink),
.part.is-active .node__ring { stroke: var(--hi); }
.part.is-active .lbl--value,
.part.is-active .lbl--title,
.part.is-active .node:not([data-role="Owner"]) .node__txt { fill: var(--hi); }
.part.is-active .node__fill { fill: var(--hi); }
.part.is-active .sch-glyph * { stroke: var(--hi); }

/* launch */
.part--final .ink--flow { stroke: var(--hi); stroke-width: 2.4; }
.part--final .ink--arc { stroke: var(--hi); stroke-width: 0.9; }

/* the stamp lands on the open water west of the map once every line is in */
.sch-stamp {
  transform-box: fill-box;
  transform-origin: center;
  transform: scale(1.6);
}
.sch-stamp rect { fill: color-mix(in srgb, var(--blue) 70%, transparent); stroke: var(--hi); stroke-width: 2; }
.schematic .sch-stamp text { font-size: 17px; font-weight: 700; letter-spacing: 0.16em; fill: var(--hi); }
.schematic .sch-stamp .sch-stamp__sub { font-size: calc(var(--t, 12) * 1px); letter-spacing: 0.12em; }
.part.is-drawn .sch-stamp {
  transform: none;
  transition: opacity 0.25s ease var(--d), transform 0.5s var(--ease) var(--d);
}

.key path { fill: none; stroke: var(--ink); stroke-width: 1.2; }
.key .key__dash { stroke: var(--line-soft); stroke-dasharray: 5 4; }

/* Without script the drawing cannot measure itself: narrow sheets get large pencil labels */
@media (max-width: 1399px) {
  html:not(.js) .schematic { --t: 19; }
  html:not(.js) .key { display: none; }
}

/* Compact drawing (narrow columns, the phone overview): fewer, larger labels */
.schematic[data-lod="compact"] .lod-full,
.schematic[data-lod="compact"] .node__txt { display: none; }
.schematic[data-lod="compact"] .sch-repo { transform: translateY(9px); }
.schematic[data-lod="compact"] .sch-edge { transform: translateY(-31px); }
.schematic[data-lod="compact"] #sch-fw-glyph { transform: translate(233px, 107px) scale(1.5); }
.schematic[data-lod="compact"] #sch-fw-name { text-anchor: middle; transform: translate(15px, 45px); }
.schematic[data-lod="compact"] .part.is-drawn .sch-stamp { transform: translateY(-14px) scale(1.3); }
.schematic[data-lod="compact"] .sch-stamp .sch-stamp__sub { font-size: calc(var(--t, 12) * 0.78px); }

/* ----- Legend and title block ----- */
.strip {
  display: flex;
  align-items: stretch;
  border-top: 2px solid var(--ink);
}
.legend {
  flex: 1;
  min-width: 0;
  padding: var(--s-3);
}
.legend__title,
.tb dt {
  font: 500 0.75rem/1.2 var(--f-title);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.legend__empty {
  margin-top: var(--s-2);
  font: 400 0.75rem/1.4 var(--f-mono);
  color: var(--ink-faint);
}
.legend__list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(150px, 100%), 1fr));
  gap: 0 var(--s-4);
  margin-top: 6px;
}
.legend__list li {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  min-width: 0;
  font: 400 0.75rem/1.5 var(--f-mono);
  color: var(--ink);
}
.legend__list li span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.legend__list li::before {
  content: "";
  flex: none;
  width: 9px;
  height: 9px;
  border: 1.5px solid var(--ink);
  transform: rotate(45deg) scale(0.8);
}
.legend__list li[data-kind="auto"]::before { background: var(--ink); }
@media (prefers-reduced-motion: no-preference) {
  .legend__list li { animation: row-in 0.6s var(--ease) both; animation-delay: calc(var(--i, 0) * 70ms); }
}
.sheet[data-step="5"] .legend__title { color: var(--hi); }

.tb {
  position: relative;
  flex: none;
  display: grid;
  grid-template-columns: 124px 1fr 1fr 104px;
  grid-template-rows: repeat(3, minmax(56px, auto));
  width: 476px;
  border-left: 2px solid var(--ink);
  color: var(--ink);
}
.tb__brand,
.tb__cell {
  margin: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 6px var(--s-3) 7px;
  border-left: 1px solid var(--line);
  border-top: 1px solid var(--line);
  min-width: 0;
}
.tb__brand {
  grid-area: 1 / 1 / 3 / 2;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: var(--s-2);
  border-left: 0;
  border-top: 0;
  font: 700 1.125rem/1 var(--f-title);
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.tb__brand small {
  display: block;
  margin-top: 4px;
  font: 500 0.75rem/1.2 var(--f-title);
  letter-spacing: 0.06em;
  color: var(--ink-faint);
}
.tb__cell dd {
  margin-top: 2px;
  overflow: hidden;
  font: 600 1.0625rem/1.15 var(--f-title);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.tb__cell--project { grid-area: 1 / 2 / 2 / 4; border-top: 0; }
.tb__cell--sheet { grid-area: 1 / 4 / 3 / 5; border-top: 0; display: flex; flex-direction: column; justify-content: center; }
.tb__cell--sheet dd { font-size: 1.75rem; line-height: 1; margin-top: 6px; overflow: visible; }
.tb__cell--sheet b { font-weight: 700; color: var(--hi); }
.tb__cell--by { grid-area: 2 / 2 / 3 / 3; }
.tb__cell--date { grid-area: 2 / 3 / 3 / 4; }
.tb__cell--dwg { grid-area: 3 / 1 / 4 / 3; border-left: 0; }
.tb__cell--status { grid-area: 3 / 3 / 4 / 4; }
.tb__cell--rev { grid-area: 3 / 4 / 4 / 5; }
.sheet[data-step="done"] #tb-status { color: var(--hi); }


/* ---------- 3. Components ----------
   The themed kit. Everything here is drawn from the tokens at the top of this file, so it
   can be lifted into another page of the same product:
     .pick + .pick-list   select replacement (a button and a listbox)
     .order               confirmation dialog, a change order pinned over the sheet
     .notices + .notice   toasts, lettered as revision notes
     .tip                 tooltip, a callout on a leader line
   Behaviour for all four is in script.js under "Components". */

/* role symbols, the same ones the schematic uses for seats */
.sym {
  display: block;
  width: 20px;
  height: 20px;
  border: 1.5px solid var(--ink);
  border-radius: 50%;
}
.sym[data-role="Admin"] { box-shadow: inset 0 0 0 2px var(--blue-deep), inset 0 0 0 3.5px var(--ink); }
.sym[data-role="Viewer"] { border-style: dotted; }

/* ----- Picker: the button ----- */
.pick {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  width: 100%;
  height: 52px;
  padding: 0 var(--s-3);
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--fill);
  color: var(--ink);
  font: 600 1.0625rem/1 var(--f-title);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-align: left;
  white-space: nowrap;
  transition: border-color 0.2s, background-color 0.2s, box-shadow 0.2s;
}
.pick:hover { background: var(--fill-strong); }
.pick:focus-visible,
.pick[aria-expanded="true"] {
  outline: none;
  border-color: var(--hi);
  box-shadow: 0 0 0 1px var(--hi);
  background: var(--hi-wash);
}
.pick__value { flex: 1; min-width: 0; }
.pick__chev {
  flex: none;
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  transition: transform 0.3s var(--ease);
}
.pick[aria-expanded="true"] .pick__chev { transform: rotate(180deg); }
.pick--sm {
  height: 36px;
  padding: 0 var(--s-2);
  border-color: transparent;
  background: none;
  font-size: 0.9375rem;
}
.pick--sm:hover { border-color: var(--line-soft); }
.pick--sm .pick__chev { width: 14px; height: 14px; }

/* ----- Picker: the list. Fixed to the viewport by script.js, so no scroll box can clip it ----- */
.pick-list {
  position: fixed;
  z-index: 60;
  top: 0;
  left: 0;
  width: 300px;
  max-width: calc(100vw - 16px);
  margin: 0;
  padding: 5px;
  border: 1px solid var(--ink);
  background-color: var(--blue-deep);
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.05) 1px, transparent 1px);
  background-size: 8px 8px;
  box-shadow: 0 18px 32px -10px rgba(3, 12, 40, 0.75);
}
.pick-list[hidden] { display: none; }
/* witness ticks at the corners, as on a dimensioned box */
.pick-list::before,
.pick-list::after {
  content: "";
  position: absolute;
  top: -7px;
  width: 1px;
  height: 6px;
  background: var(--ink);
}
.pick-list::before { left: -1px; }
.pick-list::after { right: -1px; }
.pick-list.is-up::before,
.pick-list.is-up::after { top: auto; bottom: -7px; }
.pick-opt {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr) 16px;
  column-gap: var(--s-3);
  align-items: center;
  min-height: 52px;
  padding: 7px var(--s-3);
  border: 1px solid transparent;
  cursor: pointer;
}
.pick-opt .sym { grid-row: 1 / 3; }
.pick-opt__name {
  align-self: end;
  font: 600 1.0625rem/1.1 var(--f-title);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink);
}
.pick-opt__desc {
  grid-column: 2;
  align-self: start;
  margin-top: 2px;
  font: 400 0.75rem/1.3 var(--f-mono);
  color: var(--ink-faint);
}
.pick-opt__tick {
  grid-area: 1 / 3 / 3 / 4;
  width: 16px;
  height: 16px;
  fill: none;
  stroke: var(--ink);
  stroke-width: 2;
  visibility: hidden;
}
.pick-opt[aria-selected="true"] .pick-opt__tick { visibility: visible; }
.pick-opt.is-active {
  border-color: var(--hi);
  background: var(--hi-wash);
}
.pick-opt.is-active .pick-opt__name { color: var(--hi); }
.pick-opt.is-active .sym { border-color: var(--hi); }
.pick-opt.is-active .sym[data-role="Admin"] { box-shadow: inset 0 0 0 2px var(--blue-deep), inset 0 0 0 3.5px var(--hi); }
.pick-opt.is-active .pick-opt__tick { stroke: var(--hi); }
@media (prefers-reduced-motion: no-preference) {
  .pick-list.is-open { animation: unroll 0.3s var(--ease) both; }
  .pick-list.is-open.is-up { animation-name: unroll-up; }
}
@keyframes unroll {
  from { clip-path: inset(-8px -8px 100% -8px); opacity: 0.5; }
  to { clip-path: inset(-8px -8px -40px -8px); opacity: 1; }
}
@keyframes unroll-up {
  from { clip-path: inset(100% -8px -8px -8px); opacity: 0.5; }
  to { clip-path: inset(-8px -8px -40px -8px); opacity: 1; }
}

/* ----- Change order: the confirmation dialog ----- */
.order {
  width: min(500px, calc(100vw - 2 * var(--s-5)));
  max-width: none;
  max-height: calc(100dvh - 2 * var(--s-5));
  margin: auto;
  padding: 0;
  border: 0;
  background: none;
  color: var(--ink-soft);
  overflow: visible;
}
/* the sheet underneath is hatched out, as a section that is not in this drawing */
.order::backdrop {
  background-color: rgba(4, 16, 48, 0.78);
  background-image: repeating-linear-gradient(-45deg, rgba(255, 255, 255, 0.09) 0 1px, transparent 1px 10px);
}
.order__sheet {
  position: relative;
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  column-gap: var(--s-4);
  padding: 28px 28px var(--s-5);
  border: 2px solid var(--ink);
  background-color: var(--blue);
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.07) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.07) 1px, transparent 1px);
  background-size: 8px 8px;
  background-position: -1px -1px;
  box-shadow: 0 34px 60px -24px rgba(2, 9, 32, 0.9);
}
/* trim line, like the main sheet */
.order__sheet::before {
  content: "";
  position: absolute;
  inset: -10px;
  border: 1px solid var(--line-soft);
  pointer-events: none;
}
.order__delta {
  width: 48px;
  height: 48px;
  margin-top: 2px;
  fill: none;
  stroke: var(--redline);
  stroke-width: 2;
}
.order__title {
  align-self: center;
  font: 700 2.5rem/0.94 var(--f-title);
  text-transform: uppercase;
  text-wrap: balance;
  color: var(--ink);
}
.order__text,
.order__struck,
.order__actions { grid-column: 1 / -1; }
.order__text { margin-top: var(--s-4); text-wrap: pretty; }
.order__struck {
  margin-top: var(--s-4);
  border-top: 1px solid var(--line-soft);
  font: 500 0.8125rem/1.3 var(--f-mono);
  color: var(--ink);
}
.order__struck:empty { display: none; }
.order__struck li {
  padding: 9px 0 8px;
  border-bottom: 1px solid var(--line-soft);
  overflow-wrap: anywhere;
}
/* red pencil through what will be erased */
.order__struck span {
  background: linear-gradient(var(--redline), var(--redline)) 0 54% / 100% 1.5px no-repeat;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}
.order__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: var(--s-3);
  margin-top: var(--s-5);
}
.btn--redline { background: var(--redline); color: var(--blue-deep); }
.btn--redline:hover { background: #ffb8aa; }
.btn--redline:active { transform: translateY(1px); }
.btn--redline:focus-visible { outline-color: var(--ink); }
@media (prefers-reduced-motion: no-preference) {
  .order[open] .order__sheet { animation: pin 0.45s var(--ease) both; }
  .order[open]::backdrop { animation: hatch 0.3s ease both; }
  .order[open] .order__struck span { animation: strike 0.5s var(--ease) 0.25s both; }
  .order.is-closing .order__sheet { animation: unpin 0.18s ease-in both; }
  .order.is-closing::backdrop { animation: hatch 0.18s ease-in reverse both; }
}
@keyframes pin {
  from { opacity: 0; transform: translateY(18px) rotate(-1.2deg); clip-path: inset(0 0 100% 0); }
  to { opacity: 1; transform: none; clip-path: inset(-12px); }
}
@keyframes unpin {
  to { opacity: 0; transform: translateY(10px); }
}
@keyframes hatch { from { opacity: 0; } }
@keyframes strike { from { background-size: 0 1.5px; } }
@media (max-width: 480px) {
  .order__sheet { grid-template-columns: 36px minmax(0, 1fr); column-gap: var(--s-3); padding: var(--s-5) 20px 20px; }
  .order__delta { width: 36px; height: 36px; }
  .order__title { font-size: 2.125rem; }
  .order__actions .btn { flex: 1 1 auto; }
}

/* ----- Notices: revision notes ----- */
.notices {
  position: fixed;
  z-index: 70;
  /* pinned to the head of the work column, clear of the drawing they report on */
  top: calc(var(--margin) + 5px);
  left: calc(var(--margin) + 224px + var(--s-5));
  display: grid;
  gap: var(--s-2);
  width: min(428px, calc(100vw - 2 * var(--s-4)));
  pointer-events: none;
}
.notice {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--s-3);
  min-height: 52px;
  padding: 6px 4px 6px var(--s-3);
  border: 1px solid var(--ink);
  background: var(--blue-deep);
  color: var(--ink);
  font: 500 0.9375rem/1.35 var(--f-text);
  box-shadow: 0 16px 30px -12px rgba(3, 12, 40, 0.8);
  pointer-events: auto;
}
/* revision triangle */
.notice__mark {
  flex: none;
  width: 22px;
  height: 22px;
  fill: none;
  stroke: var(--hi);
  stroke-width: 1.75;
}
.notice__text { flex: 1; min-width: 0; padding: 4px 0; overflow-wrap: anywhere; }
.notice .link { flex: none; margin: 0 var(--s-2); color: var(--hi); }
.notice .link::after { inset: -14px -8px; }
.notice .icon-btn { flex: none; color: var(--ink-soft); }
.notice .icon-btn:hover { color: var(--ink); }
.notice--warn { border-color: var(--redline); }
.notice--warn .notice__mark { stroke: var(--redline); }
/* time left, measured off along a dimension line */
.notice::after {
  content: "";
  position: absolute;
  left: -1px;
  right: -1px;
  bottom: -1px;
  height: 2px;
  background: var(--hi);
  transform-origin: left;
  animation: run-out var(--life, 5s) linear both;
}
.notice--warn::after { background: var(--redline); }
.notice:hover::after,
.notice:focus-within::after { animation-play-state: paused; }
@keyframes run-out { to { transform: scaleX(0); } }
@media (prefers-reduced-motion: no-preference) {
  .notice { animation: note-in 0.45s var(--ease) both; }
  .notice.is-leaving { animation: note-out 0.2s ease-in both; }
}
@keyframes note-in {
  from { opacity: 0; clip-path: inset(0 0 0 100%); transform: translateX(12px); }
  to { opacity: 1; clip-path: inset(-2px -2px -40px -2px); transform: none; }
}
@keyframes note-out { to { opacity: 0; transform: translateX(12px); } }
@media (prefers-reduced-motion: reduce) {
  .notice::after { display: none; }
}

/* ----- Tooltip: a callout box with a leader line down to what it names ----- */
.tip {
  position: fixed;
  z-index: 80;
  top: 0;
  left: 0;
  max-width: min(340px, calc(100vw - 16px));
  padding: 5px 9px 6px;
  border: 1px solid var(--ink);
  background: var(--blue-deep);
  color: var(--ink);
  font: 500 0.75rem/1.4 var(--f-mono);
  overflow-wrap: anywhere;
  pointer-events: none;
}
.tip[hidden] { display: none; }
.tip::before,
.tip::after {
  content: "";
  position: absolute;
  left: var(--ax, 50%);
}
.tip::before {
  top: 100%;
  width: 1px;
  height: 8px;
  background: var(--ink);
}
.tip::after {
  top: calc(100% + 6px);
  width: 5px;
  height: 5px;
  margin-left: -2px;
  border-radius: 50%;
  background: var(--ink);
}
.tip.is-under::before { top: auto; bottom: 100%; }
.tip.is-under::after { top: auto; bottom: calc(100% + 6px); }
@media (prefers-reduced-motion: no-preference) {
  .tip:not([hidden]) { animation: tip-in 0.18s var(--ease) both; }
}
@keyframes tip-in { from { opacity: 0; transform: translateY(3px); } }

/* ---------- 4. Folded layouts ---------- */

/* Wide but short of three full columns: legend sits above the title block */
@media (max-width: 1399px) {
  .strip { flex-direction: column; }
  .legend { border-bottom: 1px solid var(--line); }
  .legend__list { grid-template-columns: repeat(auto-fill, minmax(min(170px, 100%), 1fr)); }
  .legend { padding: var(--s-3) var(--s-4); }
  .tb { width: 100%; border-left: 0; grid-template-columns: 108px 1fr 1fr 100px; grid-template-rows: repeat(3, minmax(44px, auto)); }
  .tb__cell dd { font-size: 1rem; }
  .tb__cell--sheet dd { font-size: 1.625rem; }
}

/* Short screens (a 13 inch laptop): tighter rail and work margins so the sheet still fits */
@media (min-width: 1180px) and (max-height: 840px) {
  .work { --work-top: 36px; --work-bottom: 44px; }
  .step__title { font-size: 3.25rem; }
  .scrap { bottom: 14px; }
  .dim { margin-top: var(--s-7); }
  .dim__step { min-height: 78px; }
  .notes { padding-top: var(--s-5); }
}

/* Two columns: the dimension line turns horizontal across the top */
@media (max-width: 1179px) {
  :root { --margin: 24px; --trim: 10px; }
  .zones { display: none; }
  .sheet {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-rows: auto 1fr;
  }
  .rail {
    grid-column: 1 / -1;
    flex-direction: row;
    align-items: flex-start;
    gap: var(--s-7);
    padding: var(--s-5) var(--s-6);
    border-bottom: 1px solid var(--line-soft);
  }
  .notes { display: none; }
  .notices { top: auto; bottom: var(--s-5); left: 50%; transform: translateX(-50%); }
  .dim { flex: 1; margin-top: 2px; }
  .dim__list { display: flex; }
  .dim__step { flex: 1; min-height: 0; padding: 26px 0 0; }
  .dim__step:last-child { flex: 0 0 auto; }
  .dim__step::before {
    left: 9px;
    right: -9px;
    top: 9px;
    bottom: auto;
    border-left: 0;
    border-top: 1px dashed var(--line-soft);
  }
  .dim__step.is-done::before { border-left: 0; border-top: 1px solid var(--ink); }
  .dim__step::after { top: 8px; }
  .dim__step.is-current::after { top: 7px; }
  .dim__btn { padding: 0 var(--s-3) 0 0; min-height: 44px; align-content: start; }
  .dim__btn::before { display: none; }
  .dim__name { font-size: 1.1875rem; }
  .work { --work-top: var(--s-7); padding: var(--work-top) var(--s-6) var(--work-bottom); }
  .scrap { left: var(--s-6); }
  .drawing { min-height: 380px; }
  .schematic { inset: var(--s-4) var(--s-4) var(--s-2); width: calc(100% - 2 * var(--s-4)); height: calc(100% - var(--s-4) - var(--s-2)); }

  .tb { grid-template-columns: 96px 1fr 1fr 84px; }
  .tb__brand { font-size: 1rem; letter-spacing: 0.1em; padding-left: var(--s-2); padding-right: var(--s-2); }
  .tb__brand small { letter-spacing: 0.02em; }
  .tb__cell { padding: 6px var(--s-2) 7px; }
  .tb__cell dd { font-size: 0.9375rem; }
  .tb__cell--sheet dd { font-size: 1.5rem; }
}

/* One column: the schematic folds above the form, the title block closes the sheet */
@media (max-width: 819px) {
  :root { --margin: 8px; }
  .sheet { display: flex; flex-direction: column; border-width: 1.5px; }
  .sheet::before { display: none; }
  .rail { display: contents; }
  .plan { display: contents; }
  .brand { order: 0; margin: var(--s-4) var(--s-4) 0; }
  .brand__mark { width: 26px; height: 26px; }
  .brand__name { font-size: 1.375rem; }
  .dim { order: 1; flex: none; margin: var(--s-4) var(--s-4) 0; }
  .drawing {
    order: 2;
    flex: none;
    min-height: 0;
    margin-top: var(--s-2);
    border-top: 1px solid var(--line-soft);
    border-bottom: 1px solid var(--line-soft);
    background: rgba(5, 22, 66, 0.16);
  }
  .schematic { position: static; width: 100%; height: auto; }
  .work { order: 3; --work-top: var(--s-6); padding: var(--work-top) var(--s-4) var(--work-bottom); }
  .step { max-width: 560px; }
  .scrap { position: relative; left: auto; bottom: auto; display: inline-block; margin-top: var(--s-6); }
  .strip { order: 4; }

  /* steps: numbers on the line, only the current one is lettered */
  .dim__step { flex: 1 1 0; }
  /* the whole tick and its number is the tap target, 44px at least */
  .dim__btn { display: flex; flex-direction: column; gap: 3px; min-width: 44px; margin-top: -26px; padding: 26px var(--s-2) 0 0; min-height: 70px; }
  .dim__val { display: none; }
  .dim__name { font-size: 1.0625rem; white-space: nowrap; }
  .dim__step:not(.is-current) .dim__name {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
  }
  .dim__no { font-size: 0.8125rem; }
  .dim__step.is-done .dim__no { color: var(--ink); }

  .step__title { font-size: clamp(2.75rem, 13.4vw, 3.5rem); }
  .work { --work-bottom: var(--s-6); }
  .actions { margin-top: var(--s-6); }
  .actions__hint { display: none; }
  .actions .btn--primary { flex: 1; }

  .invite { grid-template-columns: minmax(0, 1fr) auto; }
  .invite > .input { grid-column: 1 / -1; }
  .seat:not(.seat--owner) {
    grid-template-columns: 30px minmax(0, 1fr) 44px;
    grid-template-rows: auto auto;
    padding: var(--s-2) 0 2px;
  }
  .seat:not(.seat--owner) .seat__mark { grid-row: 1 / 3; align-self: start; margin-top: 4px; }
  .seat:not(.seat--owner) .seat__who { white-space: normal; overflow-wrap: anywhere; }
  .seat:not(.seat--owner) .pick { grid-column: 2; justify-self: start; width: auto; margin-left: calc(-1 * var(--s-2)); }
  .seat:not(.seat--owner) .icon-btn { grid-area: 1 / 3 / 3 / 4; align-self: center; }
  .region__box { grid-template-columns: 44px minmax(0, 1fr) 56px 58px; column-gap: var(--s-2); padding: 0 var(--s-3); }
  .region__city { font-size: 1.125rem; }
  .region__tag { margin-left: 2px; }
  .choice__box { grid-template-columns: 26px 1fr; column-gap: var(--s-2); padding: var(--s-3); }
  .choice__glyph { width: 26px; height: 26px; }
  .choice__name { font-size: 1.1875rem; }
  .preset { grid-template-columns: 1fr 1fr; }
  .preset div:first-child { grid-column: 1 / -1; border-bottom: 1px solid var(--line-soft); }
  .preset div:nth-child(2) { padding-left: 0; border-left: 0; }
  .schedule th { width: 88px; }
  .env__row { min-height: 48px; }
  .env .icon-btn { height: 44px; }
}

/* The smallest phones: the title block letters a size down so nothing is cut */
@media (max-width: 400px) {
  .tb { grid-template-columns: 86px 1fr 1fr 74px; }
  .tb__cell dd { font-size: 0.875rem; letter-spacing: 0.02em; }
  .tb__cell--sheet dd { font-size: 1.3125rem; }
}

/* A narrow work column (the phone, the two-column fold): Back is the arrow alone so it
   always shares a row with the primary action, and the variable form stacks */
.work { container-type: inline-size; }
@container (max-width: 400px) {
  .actions [data-back] { width: 52px; padding: 0; }
  .actions [data-back] .btn__label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
  }
  .actions__hint { display: none; }
  .env__row { grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr) 44px; column-gap: var(--s-2); }
  .env__add { grid-template-columns: 1fr 1fr; }
  .env__add .btn { grid-column: 1 / -1; }
  /* the nearest region keeps its tag; its dimension line (the shortest) gives way */
  .region:has(.region__tag) .region__dim { visibility: hidden; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    transition-delay: 0s !important;
  }
}
