/* CBDTA Studio
 *
 * Read by a training captain deciding whether an exercise is fit to
 * put in front of a candidate. Not a developer's console: no ids, no
 * version strings, no rule names, and nothing that asks somebody to
 * learn what a thing is called internally before they can use it.
 *
 * Shaped after App Store Connect, which is the right reference because
 * it does the same job: a wide working surface, one row of tabs along
 * the top, and depth reached by opening a single item rather than by
 * breadth across a sidebar. Inside an item, its own row of tabs.
 *
 * Hierarchy comes from size, weight and space. Rules are used the way
 * Apple uses them, to close a header or separate two sections, never
 * to draw a box round something. Surfaces do not have strokes, and
 * never coloured ones.
 *
 * System font throughout. Light only, for now. */

:root {
  --page: #ffffff;
  --sunk: #f5f5f7;
  --ink: #1d1d1f;
  --ink-2: #4b4b50;
  --ink-3: #6e6e73;
  --ink-4: #98989d;
  --rule: #e3e3e5;
  --accent: #0071e3;
  --accent-soft: #eef5fd;
  --ready: #1a7f4b;
  --ready-soft: #e6f4ec;
  --attention: #92610f;
  --attention-soft: #fdf3e3;
  --stop: #b3261e;
  --stop-soft: #fceceb;
  --gutter: clamp(20px, 5vw, 72px);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue",
        system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  letter-spacing: -0.003em;
}

[hidden] { display: none !important; }
button { font: inherit; cursor: pointer; border: 0; background: none; color: inherit; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.021em; }
a { color: var(--accent); text-decoration: none; }

.link { color: var(--accent); font-size: 13px; }
.link:hover { text-decoration: underline; }

/* ---------------------------------------------------------------- gate */

.gate { min-height: 100dvh; display: grid; place-items: center; padding: 24px; background: var(--page); }
.gate-inner { text-align: center; max-width: 380px; width: 100%; }
.gate-word { font-size: 13px; font-weight: 600; letter-spacing: .12em; color: var(--ink-3); margin: 0 0 10px; }
.gate h1 { font-size: 28px; margin-bottom: 32px; font-weight: 500; }
.gate-foot { color: var(--ink-4); font-size: 12px; margin: 26px 0 0; }

/* Google's button, to Google's specification. The proportions, the
 * 18px mark, the Roboto label and the untouched wordmark are theirs;
 * we are allowed to place it, not to restyle it. */
.gsi {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 10px;
  height: 44px;
  padding: 0 18px;
  min-width: 240px;
  background: #fff;
  border: 1px solid #747775;
  border-radius: 22px;
  transition: background .15s, box-shadow .15s;
}
.gsi:hover { background: #f7f8f8; box-shadow: 0 1px 2px rgba(60,64,67,.25); }
.gsi:active { background: #eff0f0; }
.gsi:disabled { opacity: .45; cursor: default; }
.gsi-icon { display: grid; place-items: center; }
.gsi-text {
  font-family: Roboto, -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  font-size: 14px; font-weight: 500; letter-spacing: .25px; color: #1f1f1f;
}

.refusal {
  margin: 24px 0 0;
  color: var(--stop);
  background: var(--stop-soft);
  padding: 14px 18px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.5;
  text-align: left;
}

/* ------------------------------------------------------------- top bar */

.topbar { background: var(--sunk); border-bottom: 1px solid var(--rule); position: sticky; top: 0; z-index: 20; }
.topbar-inner {
  display: flex; align-items: center; gap: 28px;
  padding: 0 var(--gutter);
  height: 56px;
  max-width: 1680px; margin: 0 auto;
}

.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); }
.brand-name { font-size: 15px; font-weight: 600; white-space: nowrap; }

.tabs { display: flex; gap: 4px; flex: 1; }
.tab {
  color: var(--ink-2);
  font-size: 14px;
  padding: 8px 14px;
  border-radius: 8px;
  white-space: nowrap;
}
.tab:hover { background: rgba(0,0,0,.05); color: var(--ink); }
.tab.is-on { color: var(--ink); font-weight: 600; }

.account { display: flex; align-items: center; gap: 12px; font-size: 13px; color: var(--ink-3); white-space: nowrap; }

.menu-toggle { display: none; width: 34px; height: 34px; border-radius: 8px; padding: 8px 7px; }
.menu-toggle span { display: block; height: 1.5px; background: var(--ink); border-radius: 2px; margin: 3px 0; }
.menu-toggle:hover { background: rgba(0,0,0,.05); }

/* --------------------------------------------------------------- pages */

.view { padding: 0 var(--gutter) 120px; max-width: 1680px; margin: 0 auto; }
.loading, .empty { color: var(--ink-3); font-size: 16px; padding: 40px 0; }

.page-title { display: flex; align-items: center; gap: 16px; padding: 34px 0 18px; }
.page-title h1 { font-size: 30px; }
.page-title .grow { flex: 1; }

/* The round add, sitting with the title the way App Store Connect
 * sets it: part of the heading rather than an action parked beside it. */
.add {
  width: 26px; height: 26px; flex: none;
  border-radius: 50%;
  background: var(--accent);
  display: grid; place-items: center;
  transition: filter .15s ease, transform .15s ease;
}
.add:hover { filter: brightness(1.08); transform: scale(1.06); }
.add:active { transform: scale(.96); }
.add svg { width: 20px; height: 20px; stroke: #fff; stroke-width: 1.8; stroke-linecap: round; fill: none; }
.page-title .aside { color: var(--ink-3); font-size: 14px; }

.rule { height: 1px; background: var(--rule); margin: 0 0 28px; }

.note {
  background: var(--accent-soft);
  border-radius: 12px;
  padding: 14px 18px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink-2);
  margin: 0 0 26px;
}

/* Scenario list: a wide table of rows, separated by rules the way ASC
 * separates its lists, not by boxes. */

.list { display: grid; }
.list-head {
  display: grid;
  grid-template-columns: minmax(280px, 2.4fr) minmax(200px, 1.6fr) 150px 130px;
  gap: 24px;
  padding: 0 12px 10px;
  font-size: 12px;
  color: var(--ink-4);
  border-bottom: 1px solid var(--rule);
}
.list-row {
  display: grid;
  grid-template-columns: minmax(280px, 2.4fr) minmax(200px, 1.6fr) 150px 130px;
  gap: 24px;
  align-items: center;
  padding: 18px 12px;
  border-bottom: 1px solid var(--rule);
  text-align: left;
  width: 100%;
  transition: background .12s;
}
.list-row { color: inherit; }
.list-row:hover { background: var(--sunk); }
.list-row.is-flat { cursor: default; }
.list-row.is-flat:hover { background: none; }
.list-row .name { font-size: 16px; font-weight: 500; }
.list-row .sub { font-size: 13px; color: var(--ink-3); margin-top: 3px; }
.list-row .watches { font-size: 13.5px; color: var(--ink-2); }
.list-row .when { font-size: 13px; color: var(--ink-4); }

/* Status. Filled and soft, a word as well as a tone. */

.status { display: inline-block; font-size: 12px; font-weight: 600; padding: 4px 11px; border-radius: 20px; white-space: nowrap; }
.status.ready { background: var(--ready-soft); color: var(--ready); }
.status.attention { background: var(--attention-soft); color: var(--attention); }
.status.stop { background: var(--stop-soft); color: var(--stop); }
.status.quiet { background: rgba(0,0,0,.06); color: var(--ink-3); }
.status.live { background: var(--accent-soft); color: var(--accent); }

/* ------------------------------------------------------- scenario page */

.crumb { display: inline-flex; align-items: center; gap: 5px; font-size: 13px; color: var(--accent); padding: 26px 0 0; }
.crumb:hover { text-decoration: underline; }

.scenario-head { display: flex; align-items: flex-end; gap: 26px; padding: 14px 0 0; flex-wrap: wrap; }
.scenario-head h1 { font-size: 30px; line-height: 1.15; }
.scenario-head .meta { font-size: 14px; color: var(--ink-3); margin: 6px 0 0; }

/* The item's own tabs, underlined, exactly the ASC pattern. */
.subtabs { display: flex; gap: 26px; margin: 22px 0 0; border-bottom: 1px solid var(--rule); }
.subtab {
  font-size: 15px;
  color: var(--accent);
  padding: 0 0 12px;
  position: relative;
  top: 1px;
  border-bottom: 2px solid transparent;
}
.subtab.is-on { color: var(--ink); font-weight: 500; border-bottom-color: var(--accent); }
.subtab:hover:not(.is-on) { color: #0058b0; }

.panel { padding: 34px 0 0; }

.section { margin: 0 0 42px; max-width: 78ch; }
.section > h2 { font-size: 20px; margin: 0 0 14px; }
.section p { font-size: 16px; line-height: 1.6; color: var(--ink-2); margin: 0 0 14px; }

.label { font-size: 12px; color: var(--ink-4); margin: 0 0 8px; }

.facts { list-style: none; margin: 0; padding: 0; display: grid; gap: 9px; }
.facts li { font-size: 15px; line-height: 1.5; color: var(--ink-2); }

/* Checks */
.checks { display: grid; gap: 14px; margin: 0; }
.check { display: grid; grid-template-columns: 12px 1fr; gap: 12px; align-items: start; }
.check .dot { width: 8px; height: 8px; border-radius: 50%; margin: 8px 0 0 2px; }
.check.error .dot { background: var(--stop); }
.check.warning .dot { background: var(--attention); }
.check p { margin: 0; font-size: 15px; line-height: 1.5; }
.check .where { color: var(--ink-3); font-size: 13.5px; margin-top: 2px; }

/* The timeline. The rail is wide enough to read as a shape, and the
 * stages are hung off it in the order they are flown. */

.timeline { position: relative; padding-left: 38px; max-width: 88ch; }
.timeline::before {
  content: ""; position: absolute; left: 4px; top: 10px; bottom: 10px;
  width: 4px; border-radius: 4px; background: #e8e8ea;
}
.stage { position: relative; padding: 0 0 44px; }
.stage::before {
  content: ""; position: absolute; left: -38px; top: 4px;
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--ink-4); box-shadow: 0 0 0 4px var(--page);
}
.stage:last-child { padding-bottom: 8px; }
.stage-no { font-size: 12px; font-weight: 600; color: var(--ink-4); margin: 0 0 8px; }
.scene { font-size: 17px; line-height: 1.55; margin: 0 0 16px; }

.speech { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0 0 18px; align-items: start; }
.speech .role { font-size: 13px; font-weight: 600; color: var(--ink-3); padding-top: 3px; white-space: nowrap; }
.speech .line { font-size: 16px; line-height: 1.55; margin: 0; }

.options { display: grid; gap: 0; margin: 0; padding: 0; list-style: none; }
.option { padding: 18px 0; border-top: 1px solid var(--rule); }
.option:last-child { border-bottom: 1px solid var(--rule); }
.option .what { font-size: 16px; font-weight: 500; margin: 0; line-height: 1.45; }
.option .carries { font-size: 14px; color: var(--ink-3); margin: 7px 0 0; line-height: 1.45; }
.option .reply { font-size: 15px; color: var(--ink-2); margin: 11px 0 0; line-height: 1.5; }
.option .reply b { color: var(--ink-3); font-weight: 600; margin-right: 8px; }

.marks { display: flex; flex-wrap: wrap; gap: 7px; margin: 11px 0 0; }
.mark { font-size: 12.5px; font-weight: 500; padding: 4px 10px; border-radius: 20px; }
.mark.effective { background: var(--ready-soft); color: var(--ready); }
.mark.not-yet { background: var(--attention-soft); color: var(--attention); }
.mark-note { font-size: 14px; color: var(--ink-3); margin: 9px 0 0; line-height: 1.5; }

.endings { display: grid; gap: 26px; }
.ending .after { font-size: 13px; font-weight: 600; color: var(--ink-3); margin: 0 0 11px; }

/* --------------------------------------------------------------- edit */

.editnote { font-size: 14px; color: var(--ink-3); line-height: 1.55; margin: 0 0 30px; max-width: 72ch; }

.editrow { display: grid; gap: 7px; margin: 0 0 22px; max-width: 72ch; }
.editrow > label { font-size: 12px; color: var(--ink-4); }
.editrow textarea, .editrow input {
  font: inherit; font-size: 15px; line-height: 1.55;
  padding: 11px 13px;
  border-radius: 10px;
  border: 1px solid var(--rule);
  background: var(--page);
  color: var(--ink);
  width: 100%;
  resize: vertical;
}
.editrow textarea:focus, .editrow input:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
.editrow.changed textarea, .editrow.changed input { background: #fffdf3; }

.gradepick { display: flex; gap: 8px; align-items: center; margin: 8px 0 0; }
.gradepick .seg { display: inline-flex; background: var(--sunk); border-radius: 8px; padding: 2px; }
.gradepick .seg button { font-size: 12.5px; padding: 5px 12px; border-radius: 6px; color: var(--ink-3); }
.gradepick .seg button.on { background: var(--page); color: var(--ink); font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.gradepick .who { font-size: 12.5px; color: var(--ink-4); }

.editgroup { margin: 0 0 44px; }
.editgroup > h3 { font-size: 15px; margin: 0 0 4px; }
.editgroup > .sub { font-size: 13px; color: var(--ink-4); margin: 0 0 18px; }

.savebar {
  position: sticky; bottom: 0;
  background: rgba(255,255,255,.92);
  backdrop-filter: saturate(180%) blur(12px);
  border-top: 1px solid var(--rule);
  padding: 14px 0;
  display: flex; align-items: center; gap: 14px;
  margin: 34px 0 0;
}
.savebar .count { font-size: 14px; color: var(--ink-3); flex: 1; }

/* ---------------------------------------------------------- analytics */

.figures { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 1px; background: var(--rule); border-radius: 12px; overflow: hidden; margin: 0 0 34px; }
.figure { background: var(--page); padding: 22px 24px; }
.figure .n { font-size: 30px; font-weight: 600; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.figure .n.none { color: var(--ink-4); font-weight: 400; font-size: 22px; }
.figure .k { font-size: 13px; color: var(--ink-3); margin-top: 4px; }
.figure .note { font-size: 12px; color: var(--ink-4); margin-top: 6px; line-height: 1.4; }

/* --------------------------------------------------------------- decide */

.decide { margin: 8px 0 0; padding: 26px 0 0; border-top: 1px solid var(--rule); max-width: 72ch; }
.decide h2 { font-size: 19px; margin-bottom: 6px; }
.decide .hint { color: var(--ink-3); font-size: 14.5px; margin: 0 0 20px; line-height: 1.55; }
.actions { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }

.btn-primary { background: var(--accent); color: #fff; font-size: 15px; font-weight: 500; padding: 10px 22px; border-radius: 980px; transition: filter .15s; }
.btn-primary:hover:not(:disabled) { filter: brightness(1.07); }
.btn-primary:disabled { opacity: .4; cursor: default; }
.btn-soft { background: rgba(0,0,0,.06); color: var(--ink); font-size: 15px; font-weight: 500; padding: 10px 20px; border-radius: 980px; }
.btn-soft:hover { background: rgba(0,0,0,.09); }
.btn-plain { color: var(--accent); font-size: 15px; padding: 8px 2px; }
.btn-plain:hover { text-decoration: underline; }
.btn-stop { color: var(--stop); }

.field { display: grid; gap: 8px; margin: 0 0 18px; }
.field label { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.field select, .field textarea {
  font: inherit; font-size: 15px; padding: 11px 13px;
  border-radius: 10px; border: 1px solid var(--rule);
  background: var(--page); color: var(--ink); width: 100%;
}
.field textarea { min-height: 88px; resize: vertical; line-height: 1.55; }
.field select:focus, .field textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
.field .why { font-size: 13px; color: var(--ink-3); margin: 0; line-height: 1.45; }

.problem { color: var(--stop); font-size: 14.5px; margin: 14px 0 0; line-height: 1.5; }
.saved { color: var(--ready); font-size: 14.5px; margin: 0; }

.decided { display: grid; gap: 6px; }
.decided .verdict { font-size: 17px; font-weight: 600; }
.decided .verdict.approved { color: var(--ready); }
.decided .verdict.rejected { color: var(--stop); }
.decided .by { font-size: 14px; color: var(--ink-3); }
.decided .said { font-size: 15px; color: var(--ink-2); line-height: 1.55; margin: 6px 0 0; }

.disagreement { margin: 16px 0 0; padding: 14px 18px; border-radius: 12px; background: var(--accent-soft); color: #08498f; font-size: 14px; line-height: 1.55; }

/* -------------------------------------------------------------- narrow */

@media (max-width: 900px) {
  .list-head { display: none; }
  .list-row { grid-template-columns: 1fr max-content; gap: 14px; padding: 16px 4px; }
  .list-row .watches, .list-row .when { display: none; }
}

@media (max-width: 720px) {
  .menu-toggle { display: block; order: 3; }
  .topbar-inner { height: 52px; gap: 12px; }
  .brand-name { display: none; }
  .account { order: 2; flex: 1; justify-content: flex-end; }
  .account span { display: none; }
  .tabs {
    order: 4; flex: none;
    position: absolute; left: 0; right: 0; top: 52px;
    background: var(--sunk);
    border-bottom: 1px solid var(--rule);
    flex-direction: column; gap: 0;
    padding: 6px 12px 10px;
    display: none;
  }
  .tabs.open { display: flex; }
  .tab { padding: 11px 12px; border-radius: 8px; font-size: 15px; }
  .page-title { padding: 24px 0 14px; }
  .page-title h1 { font-size: 24px; }
  .scenario-head h1 { font-size: 24px; }
  .subtabs { gap: 18px; overflow-x: auto; }
  .timeline { padding-left: 26px; }
  .stage::before { left: -26px; }
  .figures { grid-template-columns: 1fr 1fr; }
}


/* ------------------------------------------------- the work area rail
 *
 * A four stage exercise is four scenes, fifteen options, sixty
 * authored answers and five endings. In one column that is a wall you
 * scroll through hoping to recognise where you are. So the sections
 * are listed down the side, nested one level, with the one you are
 * looking at marked as you scroll. The same rail serves reading and
 * editing, because they are the same document. */

.work { display: grid; grid-template-columns: 232px minmax(0, 1fr); gap: 52px; align-items: start; }

.rail {
  position: sticky;
  top: 76px;
  max-height: calc(100dvh - 100px);
  overflow-y: auto;
  padding: 34px 0 20px;
}

.outline { display: grid; gap: 1px; }

.out-row {
  display: block;
  color: var(--ink-2);
  font-size: 13.5px;
  line-height: 1.35;
  padding: 7px 12px;
  border-radius: 7px;
  transition: background .12s, color .12s;
}
.out-row:hover { background: rgba(0,0,0,.045); color: var(--ink); }
.out-row.is-sub { padding-left: 26px; font-size: 13px; color: var(--ink-3); }
.out-row.is-here { background: rgba(0,0,0,.07); color: var(--ink); font-weight: 600; }
.out-row.is-sub.is-here { font-weight: 500; }

.panel { padding: 34px 0 0; min-width: 0; }

/* Sections get their own breathing room and a scroll offset, so a jump
 * does not land the heading under the sticky bar. */
.section, .editgroup { scroll-margin-top: 82px; }
.section { margin: 0 0 52px; max-width: 74ch; }
.section.wide { max-width: none; }

.editgroup { margin: 0 0 52px; max-width: 74ch; }
.editgroup > h3 { font-size: 19px; margin: 0 0 4px; }
.editgroup > .sub { font-size: 14px; color: var(--ink-3); margin: 0 0 22px; }

.option-edit { margin: 26px 0; padding: 20px 0 4px; border-top: 1px solid var(--rule); scroll-margin-top: 82px; }
.option-lbl { font-size: 12px; font-weight: 600; color: var(--ink-4); margin: 0 0 14px; }

@media (max-width: 1000px) {
  .work { grid-template-columns: 1fr; gap: 0; }
  .rail {
    position: static; max-height: none; overflow: visible;
    padding: 22px 0 0;
    border-bottom: 1px solid var(--rule);
    margin-bottom: 8px;
  }
  .outline { display: flex; flex-wrap: wrap; gap: 2px; padding-bottom: 14px; }
  .out-row { padding: 6px 11px; }
  .out-row.is-sub { display: none; }
}

/* ---------------------------------------------------- the first paint
 *
 * Both faces start hidden, and the boot hint decides which one appears
 * before a single module has loaded. Treating "not yet known" as
 * signed out is what flashed the sign-in page at somebody who was
 * already signed in on every reload: the session lives in IndexedDB
 * and restoring it happens well after the first paint.
 *
 * With no hint at all, neither face shows. That is a blank page for a
 * few hundred milliseconds, which is the honest answer to a question
 * we have not answered yet, and much less jarring than showing the
 * wrong one and snatching it back. */

html[data-boot="in"] #shell { display: grid !important; }
html[data-boot="out"] #gate { display: grid !important; }

/* The skeleton the shell opens on. Four quiet bars where the rows will
 * be, so the page has its shape before it has its contents. No pulse:
 * an animation that plays for 150 milliseconds is a flicker with
 * ambitions. */
.skeleton { display: grid; gap: 2px; }
.skeleton span {
  display: block;
  height: 58px;
  border-bottom: 1px solid var(--rule);
  background: linear-gradient(90deg, rgba(0,0,0,.035) 0 34%, transparent 34%);
  background-size: 100% 15px;
  background-position: 12px 18px;
  background-repeat: no-repeat;
}

/* ==================================================================
 * The drop
 *
 * The one surface in this product that has to feel like something.
 * Same language as everywhere else, given more room: white ground,
 * one accent, hierarchy from size and space, and motion used once per
 * event rather than continuously. Nothing pulses for its own sake.
 * ================================================================== */

.drop-stage { display: grid; place-items: center; padding: 8vh 0 12vh; }

.dropzone {
  view-transition-name: source-doc;
  display: grid;
  justify-items: center;
  gap: 6px;
  width: min(560px, 100%);
  padding: 64px 40px;
  border-radius: 22px;
  background: var(--sunk);
  cursor: pointer;
  text-align: center;
  transition: background .18s ease, transform .18s ease;
}
.dropzone:hover { background: #eeeef0; }
.dropzone.over { background: var(--accent-soft); transform: scale(1.008); }

.dz-mark { color: var(--ink-4); margin-bottom: 12px; transition: color .18s ease; }
.dropzone.over .dz-mark { color: var(--accent); }
.dz-title { font-size: 19px; font-weight: 600; letter-spacing: -0.02em; }
.dz-sub { font-size: 15px; color: var(--ink-3); }
.dz-sub u { color: var(--accent); text-decoration: none; }
.dropzone:hover .dz-sub u { text-decoration: underline; }
.dz-fine {
  font-size: 13px; color: var(--ink-4); line-height: 1.5;
  max-width: 34ch; margin-top: 14px;
}

.drop-problem {
  margin: 22px auto 0; max-width: 52ch;
  color: var(--stop); background: var(--stop-soft);
  padding: 13px 17px; border-radius: 12px;
  font-size: 14.5px; line-height: 1.5;
}

/* Three columns: what came in, where the work is, what is coming out.
 * The eye belongs on the right hand one. The other two are context and
 * are pinned so they stay put while it scrolls. */

/* THE BUILD. Three equal columns, the whole screen, each scrolling on
/* THE BUILD. Three equal columns, the whole screen, each scrolling on
 * its own, standing on a workspace rather than on a page: the faint
 * grid says scratchpad, bench, something being made, which is what is
 * happening. */

.view.is-build { padding: 0; max-width: none; }

.build {
  display: grid;
  grid-template-columns: minmax(240px, 22%) minmax(0, 1fr);
  height: calc(100dvh - var(--topbar-h, 56px));
  min-height: 0;
  background-color: #fbfbfc;
  background-image:
    radial-gradient(circle at 1px 1px, rgba(0,0,0,.055) 1px, transparent 0);
  background-size: 22px 22px;
}
.col { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.col + .col { border-left: 1px solid var(--rule); }

.col-head {
  flex: 0 0 auto;
  display: flex; align-items: baseline; gap: 14px;
  font-size: 13px; font-weight: 600; color: var(--ink-3);
  padding: 16px 28px 15px;
  border-bottom: 1px solid var(--rule);
  background: var(--page);
}
.meter {
  margin-left: auto; display: flex; gap: 14px;
  font-variant-numeric: tabular-nums; font-weight: 600;
  color: var(--ink-4);
}
.meter span:last-child { color: var(--accent); }

.col-scroll {
  flex: 1 1 auto; min-height: 0;
  overflow-y: auto; overscroll-behavior: contain;
  scrollbar-width: thin;
  padding: 26px 28px 60px;
}

/* What went in. */

.source { max-width: 340px; }
.paper {
  aspect-ratio: 1 / 1.414;
  border-radius: 12px; overflow: hidden;
  background: var(--page);
  box-shadow: 0 1px 3px rgba(0,0,0,.10), 0 14px 38px rgba(0,0,0,.11);
}
.paper embed { width: 100%; height: 100%; border: 0; pointer-events: none; }
.paper.is-absent {
  display: grid; place-items: center;
  background: var(--sunk); box-shadow: none;
  color: var(--ink-4); font-size: 13px; text-align: center; padding: 20px;
}
.src-name { font-size: 16px; font-weight: 600; margin: 20px 0 0; overflow-wrap: anywhere; }
.src-meta { font-size: 13.5px; color: var(--ink-3); margin: 4px 0 0; }

.src-facts { display: grid; gap: 11px; margin: 24px 0 0; }
.src-facts div { display: flex; justify-content: space-between; gap: 14px; align-items: baseline; }
.src-facts dt { font-size: 13.5px; color: var(--ink-3); }
.src-facts dd { font-size: 13.5px; font-weight: 600; font-variant-numeric: tabular-nums; }

/* BEING WRITTEN. One thing at a time. */

.canvas { display: flex; flex-direction: column; gap: 18px; max-width: 96ch; }

.trail {
  display: flex; gap: 6px; flex-wrap: nowrap;
  overflow-x: auto; scrollbar-width: none;
  padding-bottom: 2px;
}
.trail::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto;
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12.5px; font-weight: 600; white-space: nowrap;
  padding: 5px 11px 5px 8px; border-radius: 8px; border: 0; cursor: pointer;
  background: rgba(0,0,0,.045); color: var(--ink-3);
  transition: background .16s ease, color .16s ease;
}

/* The working mark, in the chip of the thing being written. One place
 * to look, and it is the place where the words are appearing. */
.chip-ring {
  width: 11px; height: 11px; flex: 0 0 auto; border-radius: 50%;
  border: 2px solid currentColor; opacity: .3;
}
.chip.is-live .chip-ring {
  opacity: 1;
  border-color: currentColor;
  border-top-color: transparent;
  animation: spin .85s linear infinite;
}
.chip-tick { width: 11px; height: 11px; flex: 0 0 auto; position: relative; }
.chip-tick::after {
  content: ""; position: absolute; inset: 1px 0 2px 1px;
  border-left: 2px solid currentColor; border-bottom: 2px solid currentColor;
  transform: rotate(-45deg); opacity: .55;
}
.chip:hover { background: rgba(0,0,0,.08); color: var(--ink); }
.chip.is-on { background: var(--ink); color: #fff; }
.chip.is-live { background: var(--accent-soft); color: var(--accent); }
.chip.is-on.is-live { background: var(--accent); color: #fff; }
.chip.is-back { background: var(--accent); color: #fff; margin-left: auto; }

.live {
  background: var(--page);
  border-radius: 16px;
  padding: 24px 26px 26px;
  box-shadow: 0 1px 2px rgba(0,0,0,.05), 0 10px 30px rgba(0,0,0,.055);
  opacity: 0; transform: translateY(10px);
}
.live.here {
  opacity: 1; transform: none;
  transition: opacity .34s ease, transform .42s cubic-bezier(.2,.8,.2,1);
}
.live-what {
  font-size: 12.5px; font-weight: 600; color: var(--accent);
  margin-bottom: 16px;
}
.live-quiet { font-size: 14.5px; color: var(--ink-3); line-height: 1.5; }

/* Text still being written carries the cursor. */
.typing::after {
  content: ""; display: inline-block;
  width: 2px; height: 1em; margin-left: 2px;
  background: var(--accent); vertical-align: -0.15em;
  animation: blink .9s steps(1) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

/* The exercise's own shapes, the same ones the finished View tab uses,
 * so there is no reveal moment at the end. */

.f-title { font-size: 25px; letter-spacing: -0.022em; line-height: 1.15; }
.f-context { font-size: 14.5px; color: var(--ink-3); margin: 8px 0 0; }
.f-brief { font-size: 16px; line-height: 1.6; color: var(--ink-2); margin: 16px 0 0; }
.f-goal { font-size: 14.5px; color: var(--ink-3); margin: 14px 0 0; font-style: italic; }

.f-label { font-size: 12.5px; font-weight: 600; color: var(--ink-4); margin: 20px 0 10px; }
.live-body > .f-label:first-child { margin-top: 0; }
.f-fact { font-size: 15px; line-height: 1.5; color: var(--ink-2); margin: 0 0 9px; }
.f-summary { font-size: 16.5px; line-height: 1.55; }

.f-scene { font-size: 16.5px; line-height: 1.55; margin: 0 0 14px; }
.f-said { font-size: 15px; line-height: 1.55; margin: 0 0 9px; }
.f-said b { color: var(--ink-3); font-weight: 600; margin-right: 9px; }

.f-opt { padding: 14px 0; border-bottom: 1px solid var(--rule); }
.f-opt:last-child { border-bottom: 0; padding-bottom: 0; }
.f-what { font-size: 15.5px; font-weight: 500; line-height: 1.45; }
.f-opt.is-long .f-what { color: var(--attention); }
.f-long { font-size: 12.5px; color: var(--attention); margin: 6px 0 0; }
.f-mark {
  display: inline-block; font-size: 12px; font-weight: 500;
  padding: 3px 9px; border-radius: 20px; margin: 9px 7px 0 0;
}
.f-mark.green { background: var(--ready-soft); color: var(--ready); }
.f-mark.amber { background: var(--attention-soft); color: var(--attention); }
.f-reply { font-size: 14.5px; color: var(--ink-2); line-height: 1.5; margin: 10px 0 0; }
.f-reply b { color: var(--ink-3); font-weight: 600; margin-right: 8px; }

.f-ans { padding: 11px 0; border-bottom: 1px solid var(--rule); }
.f-ans:last-child { border-bottom: 0; }
.f-when { font-size: 12.5px; color: var(--ink-4); margin: 0 0 5px; }
.f-ans .f-said { margin: 0; }

.f-ev { display: grid; grid-template-columns: 62px minmax(0, 1fr); gap: 12px; padding: 10px 0; }
.f-at { font-size: 12.5px; color: var(--ink-4); font-variant-numeric: tabular-nums; padding-top: 2px; }
.f-ev .f-said:last-child { margin: 0; }
.f-take { font-size: 12.5px; color: var(--attention); margin: 4px 0 0; }

.f-end { padding: 12px 0; border-bottom: 1px solid var(--rule); }
.f-end:last-child { border-bottom: 0; }
.f-after { font-size: 13px; font-weight: 600; color: var(--ink-3); margin: 0 0 9px; }

.f-chips { display: flex; flex-wrap: wrap; gap: 7px; }
.f-chip {
  font-size: 12.5px; font-weight: 500; padding: 4px 11px;
  border-radius: 20px; background: var(--sunk); color: var(--ink-2);
}
.f-chip.is-added { background: var(--accent-soft); color: var(--accent); }

.f-also {
  font-size: 14px; line-height: 1.5; color: var(--ink-2);
  background: var(--sunk); border-radius: 12px; padding: 14px 16px; margin: 18px 0 0;
}
.f-gap { margin: 20px 0 0; padding: 17px 19px; border-radius: 14px; background: var(--attention-soft); }
.f-gap-h { font-size: 13px; font-weight: 600; color: var(--attention); margin: 0 0 10px; }
.f-gap-l { font-size: 14.5px; line-height: 1.5; color: var(--ink-2); margin: 0 0 6px; }
.f-gap-l b { font-weight: 600; }
.f-gap-f { font-size: 13.5px; color: var(--ink-3); margin: 12px 0 0; }

.f-clean { font-size: 15px; color: var(--ready); }
.f-check { padding: 11px 0; border-bottom: 1px solid var(--rule); }
.f-check:last-child { border-bottom: 0; }
.f-check-w { font-size: 14.5px; line-height: 1.5; color: var(--attention); }
.f-check.is-stop .f-check-w { color: var(--stop); }

.f-tally { display: grid; gap: 10px; margin: 22px 0; }
.f-tally div { display: flex; align-items: baseline; gap: 12px; }
.f-tally dt {
  font-size: 21px; font-weight: 600; min-width: 42px;
  font-variant-numeric: tabular-nums; letter-spacing: -0.02em;
}
.f-tally dd { font-size: 14.5px; color: var(--ink-3); }

/* Finished. The door, pinned, rather than a jump nobody asked for. */

.build-foot {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 15;
  background: rgba(255,255,255,.88);
  backdrop-filter: saturate(180%) blur(20px);
  border-top: 1px solid var(--rule);
  animation: rise .5s cubic-bezier(.2,.8,.2,1) both;
}
.foot-in {
  display: flex; align-items: center; gap: 20px;
  padding: 14px var(--gutter);
  max-width: 1680px; margin: 0 auto;
}
.foot-w { font-size: 15px; color: var(--ink-2); flex: 1; }
.build-foot.is-failed .foot-w { color: var(--stop); }
.foot-go {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--accent); color: #fff;
  font-size: 15px; font-weight: 600;
  padding: 11px 20px; border-radius: 10px;
  transition: filter .16s ease, transform .16s ease;
}
.foot-go:hover { filter: brightness(1.08); }
.foot-go:active { transform: scale(.98); }
.foot-go.is-quiet { background: var(--sunk); color: var(--ink); }
.foot-go svg {
  width: 17px; height: 17px; fill: none; stroke: currentColor;
  stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round;
}

.arrive { opacity: 0; transform: translateY(6px); }
.arrive.here {
  opacity: 1; transform: none;
  transition: opacity .38s ease, transform .38s cubic-bezier(.2,.8,.2,1);
}

@keyframes rise { from { transform: translateY(100%); } to { transform: none; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes draw { to { stroke-dashoffset: 0; } }

.drop-problem { color: var(--stop); font-size: 14.5px; padding: 16px 28px; }
.drop-problem[hidden] { display: none; }

@media (max-width: 1180px) {
  .col-scroll, .col-head { padding-left: 20px; padding-right: 20px; }
  .live { padding: 20px; }
}

@media (max-width: 900px) {
  .build { grid-template-columns: 1fr; height: auto; }
  .col + .col { border-left: 0; border-top: 1px solid var(--rule); }
  .col-scroll { overflow: visible; padding-bottom: 32px; }
  .col-canvas .col-scroll { padding-bottom: 40vh; }
  .paper { max-width: 200px; }
  .col-head { position: sticky; top: var(--topbar-h, 56px); z-index: 5; }
  .canvas { max-width: none; }
  .dropzone { padding: 48px 26px; }
  .foot-in { padding: 13px 20px; gap: 14px; }
  .foot-w { font-size: 13.5px; }
}

@media (prefers-reduced-motion: reduce) {
  .arrive, .arrive.here, .live, .live.here { transition: none; opacity: 1; transform: none; }
  .ph::before { animation: none; }
  .spin .arc { animation-duration: 2.4s; }
  .tick path { animation: none; stroke-dashoffset: 0; }
  .typing::after { animation: none; }
  .build-foot { animation: none; }
}


/* Being written right now.
 *
 * Above the library, because two people commissioning the same thing
 * twenty minutes apart is exactly what a shared corpus prevents, and
 * it can only prevent it if the first one is visible. The pip breathes
 * because this is the one thing on the page that is genuinely still
 * moving; everything else is at rest. */

.working { display: grid; gap: 2px; margin: 0 0 26px; }

.inflight {
  display: grid;
  color: inherit;
  transition: background .14s ease;
  grid-template-columns: 10px minmax(0, 1fr) max-content;
  gap: 16px;
  align-items: center;
  padding: 16px 18px;
  border-radius: 12px;
  background: var(--accent-soft);
}
.inflight-name { font-size: 16px; font-weight: 500; }
.inflight-sub { font-size: 13.5px; color: var(--ink-3); margin-top: 3px; overflow-wrap: anywhere; }

.pip {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent);
  animation: breathe 1.9s ease-in-out infinite;
}
.inflight:hover { background: #e0edfb; }

@keyframes breathe { 0%, 100% { opacity: 1; } 50% { opacity: .32; } }
@media (prefers-reduced-motion: reduce) { .pip { animation: none; } }
