:root {
  --ink: #1c1915;
  --muted: #5c564c;
  --paper: #f4f0e6;
  --card: #fffdf8;
  --line: #e2d9c8;
  --accent: #0f5f5c;
  --accent-ink: #fff;
  --good: #1c6b38;
  --good-bg: #e5f4ea;
  --move: #1d4e89;
  --move-bg: #e7f0fa;
  --waive: #8a5a00;
  --waive-bg: #fbf3df;
  --park: #3d4650;
  --park-bg: #eceff2;
  --bad: #8d2a2a;
  --bad-bg: #fdecec;
  --shadow: 0 1px 2px rgba(40, 30, 10, 0.06);
  font-family: "Segoe UI", "Helvetica Neue", Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--paper);
}

* { box-sizing: border-box; }
html, body, main { overflow-anchor: none; }
body { margin: 0; min-height: 100vh; }
button, select, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3, p { margin: 0; }

.top {
  display: flex;
  gap: 24px;
  align-items: center;
  justify-content: space-between;
  padding: 16px 28px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  /* Above everything that scrolls under it: a drawing's docked list and zoom
     buttons carry their own stacking order and used to paint over the rail. */
  z-index: 10;
}
.brand { display: flex; gap: 12px; align-items: center; }
.mark {
  width: 48px; height: 48px;
  display: grid; place-items: center;
  background: var(--accent); color: var(--accent-ink);
  font-weight: 700; letter-spacing: 0.02em;
  border-radius: 8px;
}
.brand h1 { font-size: 1.15rem; font-weight: 650; }
.tagline { color: var(--muted); font-size: 0.85rem; margin-top: 2px; }
.session-bar { display: flex; align-items: center; gap: 10px; margin-left: auto; }
#who { color: var(--muted); font-size: 0.85rem; white-space: nowrap; }
.login-card { max-width: 420px; }
.form-head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.form-confirmed {
  background: var(--good-bg);
  color: var(--good);
  font-weight: 650;
}
.lab-row { border-top: 1px solid var(--line); padding: 12px 0 4px; }
.lab-label { margin-bottom: 8px; }
.class-option.gated { opacity: 0.8; }
.request-note { margin-top: 14px; }
.rail {
  display: flex; flex-wrap: wrap; gap: 6px;
  list-style: none; margin: 0; padding: 0;
}
.rail button {
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 0.85rem;
}
.rail button.here {
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 650;
}
.rail button.done { color: var(--ink); }

main {
  max-width: 1080px;
  margin: 0 auto;
  padding: 28px 28px 96px;
}
.nav[hidden], #logout[hidden], #who[hidden], .rail[hidden], .session-bar[hidden] {
  display: none !important;
}
.nav {
  position: sticky;
  bottom: 0;
  z-index: 10;
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
  padding: 14px 28px;
  background: var(--card);
  border-top: 1px solid var(--line);
}
.nav p { color: var(--muted); font-size: 0.9rem; text-align: center; flex: 1; }
#back, #next, .primary, .secondary {
  border-radius: 8px;
  padding: 10px 18px;
  border: 1px solid var(--line);
  background: var(--card);
}
#next, .primary {
  background: var(--card);
  color: var(--accent);
  border-color: var(--accent);
  font-weight: 650;
}
#next:disabled, #back:disabled, .primary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.secondary { background: var(--card); }

.lead { font-size: 1.35rem; font-weight: 650; margin-bottom: 6px; }
.sub { color: var(--muted); margin-bottom: 18px; max-width: 62ch; line-height: 1.45; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  box-shadow: var(--shadow);
}
.card h2 { font-size: 1rem; margin-bottom: 8px; }
.card.wide { grid-column: 1 / -1; }
.path {
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 0.82rem;
  word-break: break-all;
  background: var(--paper);
  border-radius: 6px;
  padding: 8px;
  min-height: 2.4em;
}
.chosen { outline: 2px solid var(--accent); }
.row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.crumbs { display: flex; justify-content: space-between; gap: 8px; align-items: center; margin-bottom: 8px; }
.dirlist { display: flex; flex-direction: column; gap: 4px; max-height: 280px; overflow: auto; }
.dirlist button, .linkish {
  text-align: left;
  background: transparent;
  border: 0;
  padding: 6px 8px;
  border-radius: 6px;
}
.dirlist button.selected { background: var(--move-bg); font-weight: 650; }
.modal-back {
  position: fixed;
  inset: 0;
  background: rgba(28, 25, 21, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
  padding: 16px;
}
.modal {
  background: var(--card);
  width: min(680px, 100%);
  max-height: 80vh;
  overflow: auto;
  border-radius: 12px;
  padding: 16px 18px;
  box-shadow: var(--shadow);
}
label.field { display: flex; flex-direction: column; gap: 4px; font-size: 0.9rem; margin-bottom: 10px; }
select, input[type="text"], input[type="number"], textarea {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: white;
  width: 100%;
}
input.missing {
  border-color: var(--bad);
  background: var(--bad-bg);
}
textarea { min-height: 72px; resize: vertical; }
.callout {
  border-left: 4px solid var(--accent);
  background: #eef6f5;
  padding: 10px 12px;
  border-radius: 8px;
  margin: 12px 0;
  line-height: 1.45;
}
.callout.warn { border-color: var(--waive); background: var(--waive-bg); }
.callout.wall { border-color: var(--bad); background: var(--bad-bg); }
.counts { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 12px; }
.count {
  background: var(--paper);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.85rem;
}
table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 0.78rem; letter-spacing: 0.04em; text-transform: uppercase; }
.item.host { background: #f3faf8; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.yn { position: relative; z-index: 3; }
.chip {
  border-radius: 999px;
  border: 1px solid var(--line);
  background: white;
  padding: 4px 10px;
}
.yn .chip {
  min-width: 56px;
  min-height: 34px;
  padding: 6px 14px;
}
.yn .chip.on {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
  font-weight: 650;
}
.sheet-list { max-height: 240px; overflow: auto; }
.chip.accept.on, .badge.accept { background: var(--good-bg); color: var(--good); border-color: transparent; }
.chip.move.on, .badge.move { background: var(--move-bg); color: var(--move); border-color: transparent; }
.chip.waive.on, .badge.waive { background: var(--waive-bg); color: var(--waive); border-color: transparent; }
.chip.park.on, .badge.park { background: var(--park-bg); color: var(--park); border-color: transparent; }
.chip.reject.on { background: var(--bad-bg); color: var(--bad); border-color: transparent; }
.class-list { display: flex; flex-direction: column; gap: 8px; margin: 12px 0; }
.class-option {
  text-align: left;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
}
.class-option.on { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(15, 95, 92, 0.18); }
.class-option strong { display: block; margin-bottom: 2px; }
a.inline { color: var(--accent); font-weight: 650; }
.lead-copy { font-size: 1.05rem; margin: 8px 0; }
.badge { border-radius: 999px; padding: 2px 8px; font-size: 0.8rem; }
.log {
  white-space: pre-wrap;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 0.78rem;
  background: #1c1915;
  color: #f4f0e6;
  border-radius: 8px;
  padding: 12px;
  max-height: 240px;
  overflow: auto;
}
.sheet {
  width: 100%;
  min-height: 420px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: white;
}
.error {
  background: var(--bad-bg);
  color: var(--bad);
  padding: 10px 12px;
  border-radius: 8px;
  margin-bottom: 12px;
}
.ok { color: var(--good); font-weight: 650; }
.samples { color: var(--muted); font-size: 0.82rem; margin: 0 0 8px; }
@media (max-width: 800px) {
  .top, main, .nav { padding-left: 16px; padding-right: 16px; }
  .grid { grid-template-columns: 1fr; }
  .top { flex-direction: column; align-items: flex-start; }
}

/* Equipment already in the seated unit (Graph step). */
.plant-box { margin-top: 20px; }
.plant-box h3 { font-size: 1rem; margin-bottom: 8px; }
.plant-list { display: grid; gap: 8px; }
.plant-row {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
}
.plant-row .chip { margin-top: 6px; }
.review-pane { margin-top: 8px; }
.review-pane .lab-row { margin-bottom: 8px; }
.review-reason { width: 100%; min-height: 60px; margin: 8px 0; font: inherit; }
.consequence { color: var(--muted); }

/* Door B rows and checklist prefill: one finding, its stamps, its outcome. */
.prefill-row { border-top: 1px solid var(--line, #ddd); padding: 8px 0; }
.prefill-row .chips { margin-top: 4px; }

/* Door B: the compiler's drawing with the loop decisions docked on it, and the
   sample sheet under test below it for comparison (owner rulings 2026-10-04). */
.drawing-title { margin: 18px 0 6px; }
.marked-sheet { min-width: 0; }
.dock {
  position: absolute; top: 48px; right: 10px; bottom: 34px; width: min(360px, 46%);
  overflow: auto; z-index: 2; padding: 10px 12px;
  background: rgba(255, 253, 248, 0.96); border: 1px solid var(--line);
  border-left: 4px solid #ef6c00; border-radius: 10px;
  box-shadow: 0 4px 18px rgba(40, 30, 10, 0.18); cursor: auto; user-select: text;
}
.dock.folded { display: none; }
.dock > h3 { margin-bottom: 4px; }
.group, .sample-group { border: 1px solid var(--line); border-radius: 10px; background: var(--card);
  padding: 8px 10px; margin: 8px 0; transition: box-shadow 0.3s, background 0.3s; }
.group.lit, .sample-group.lit { background: #fffde7; box-shadow: 0 0 0 3px #fbc02d; }
.group-head { display: flex; flex-direction: column; gap: 4px; }
.tally { display: flex; flex-wrap: wrap; gap: 4px; }
.group-q { margin: 6px 0 4px; font-size: 0.92em; }
.tags summary { cursor: pointer; margin-top: 4px; }
.kit-row { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.kit { border: 2px solid; border-radius: 6px; padding: 1px 6px; font-size: 0.82em;
  font-weight: 650; background: white; }
.kit.missed { background: #fff3e0; }
.kit.extra { background: #ffebee; border-style: dashed; }
.kit.decided { background: #e8f5e9; }
.kit.both { background: #e3f2fd; }
.kit.left-out { text-decoration: line-through; }
.kit.logic { border-style: dotted; }
.legend { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 4px 14px; margin: 8px 0 12px; font-size: 0.88em; }
.legend-item { display: flex; align-items: baseline; gap: 6px; }
.swatch { flex: 0 0 auto; width: 16px; height: 12px; border: 3px solid; border-radius: 3px; }
.swatch.extra, .swatch.logic { border-style: dashed; }
.items-fold, .backlog { margin-top: 12px; }
.backlog > summary { cursor: pointer; }
.busy { font-weight: 650; }
.warn { color: #b45309; }
.sample-stage { position: relative; }
.sample-stage img.sheet { display: block; }
.sample-marks { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }

/* What the click just did: the decided loop pulses on the drawing. */
.lab-marks .lit rect, .lab-marks text.lit { animation: lit 0.6s ease-in-out 8 alternate; }
.lab-marks .lit rect { stroke-width: 7; fill-opacity: 0.35; }
@keyframes lit { from { opacity: 1; } to { opacity: 0.25; } }

/* Zoom and pan on every drawing: wheel or pinch zooms, drag pans. */
.zoom-frame { position: relative; height: 80vh; min-height: 460px; overflow: hidden;
  border: 1px solid var(--line); border-radius: 12px; background: white;
  cursor: grab; touch-action: none; user-select: none; }
.zoom-frame.dragging { cursor: grabbing; }
.zoom-inner { transform-origin: 0 0; width: 100%; }
.zoom-inner.glide { transition: transform 0.6s ease; }
.zoom-frame .sheet { border: 0; border-radius: 0; min-height: 0; display: block; }
.zoom-frame svg.sheet, .zoom-frame img.sheet { width: 100%; height: auto; }
.zoom-tools { position: absolute; top: 8px; right: 10px; display: flex; gap: 4px; z-index: 3; }
.zoom-btn { min-width: 34px; height: 30px; border: 1px solid var(--line); border-radius: 6px;
  background: var(--card); }
.zoom-hint { position: absolute; left: 10px; bottom: 6px; font-size: 0.75rem;
  color: var(--muted); background: rgba(255, 255, 255, 0.85); padding: 1px 6px; border-radius: 4px; }
@media (max-width: 700px) { .dock { width: auto; left: 10px; top: auto; height: 45%; } }

/* Three button states (owner rulings 2026-10-04 and 2026-10-05). The one
   control the step is waiting on is filled and ringed (.next-up); one that
   cannot be pressed yet is faded, with its reason written beside it; one
   already pressed is grey with a check and a past-tense label (.done). */
button:disabled { cursor: not-allowed; }
.chip:disabled, .secondary:disabled { opacity: 0.45; }
.primary.done, .primary.done:disabled, .secondary.done, .secondary.done:disabled {
  opacity: 1; background: var(--park-bg); color: var(--park); border-color: var(--line);
  box-shadow: none; cursor: default;
}
.class-option.on > strong::before, .path.chosen::before, .chip.on::before {
  content: "✓ "; color: var(--good); font-weight: 700;
}
.form-block .form-lead, .form-block .form-detail { margin: 6px 0; }
.form-detail { display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  padding-left: 14px; border-left: 3px solid var(--line); }
.detail-label { min-width: 210px; font-size: 0.92em; }
.form-block.answered .lab-label strong::before { content: "✓ "; color: var(--good); }
.loop-summary { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 6px; }

.next-up, #next.next-up, .primary.next-up, .secondary.next-up {
  background: var(--accent); color: var(--accent-ink); border-color: var(--accent);
  font-weight: 650;
  box-shadow: 0 0 0 4px rgba(15, 95, 92, 0.22);
  animation: invite 1.8s ease-in-out 3;
}
@keyframes invite { 50% { box-shadow: 0 0 0 9px rgba(15, 95, 92, 0.08); } }
@media (prefers-reduced-motion: reduce) { .next-up { animation: none; } }
.badge.drawn, .badge.optional {
  display: inline-block; border-radius: 999px; padding: 3px 10px; font-size: 0.82rem;
  background: var(--park-bg); color: var(--park); font-weight: 600;
}
.badge.drawn { align-self: center; }
.badge.optional { margin-left: 10px; vertical-align: middle; }

/* Every step opens with its name, what it is for, and its tasks in order.
   The cards below carry the same numbers. */
.step-head { margin-bottom: 14px; }
.step-head .sub { margin-bottom: 8px; }
.role-line { color: var(--muted); margin-bottom: 10px; max-width: 80ch; }
.tasks {
  list-style: none; counter-reset: task; display: flex; flex-wrap: wrap; gap: 6px 8px;
  margin: 0; padding: 0;
}
.tasks[hidden] { display: none; }
.tasks li { counter-increment: task; }
.tasks li button {
  border: 1px solid var(--line); background: var(--card); color: var(--muted);
  border-radius: 999px; padding: 5px 12px; font-size: 0.88rem;
}
.tasks li button::before { content: counter(task) "  "; font-weight: 700; }
.tasks li.done button { background: var(--park-bg); color: var(--park); }
.tasks li.now button {
  border-color: var(--accent); color: var(--ink); font-weight: 650;
  box-shadow: 0 0 0 2px rgba(15, 95, 92, 0.18);
}
.task { margin-bottom: 16px; scroll-margin-top: 110px; }
.task-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; flex-wrap: wrap; }
.task-head h2, .task-head h2.lead { font-size: 1.05rem; margin: 0; }
.task-head .form-head { flex: 1; }
.task-n {
  flex: none; width: 26px; height: 26px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--paper); border: 1px solid var(--line); font-weight: 700; font-size: 0.85rem;
}
.task.task-now { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(15, 95, 92, 0.18); }
.task.task-now .task-n { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.task.task-wait { opacity: 0.7; }
.fold { margin-top: 12px; }
.fold > summary { cursor: pointer; color: var(--muted); }
.fold[open] > summary { margin-bottom: 8px; }
details.card.fold { margin-bottom: 16px; }
.fold .class-option { margin-bottom: 8px; }

.rail button { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.15; }
.rail-title { white-space: nowrap; }
.rail-cap { font-size: 0.68rem; font-weight: 400; opacity: 0.85; white-space: nowrap; }
.rail button:disabled { opacity: 0.45; cursor: not-allowed; }

.choice-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.decision-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 10px; }
.class-option:disabled { opacity: 0.5; }
.class-option.decision.on { background: var(--park-bg); }
.seat-fields { display: grid; grid-template-columns: 220px 1fr; gap: 12px; align-items: start; }
.seat-extra { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.seat-extra[hidden] { display: none; }
@media (max-width: 700px) {
  .choice-row, .seat-fields, .seat-extra { grid-template-columns: 1fr; }
  .decision-row { grid-template-columns: 1fr 1fr; }
}

/* A task answered by choosing one of several: every open choice in the
   current task carries the accent, so the place to click is not in doubt. */
.task.task-now .class-option:not(.gated):not(.on):not(:disabled),
.task.task-now .form-block:not(.answered) .yn .chip:not(.on) { border-color: var(--accent); }
.task.task-now .class-option:not(.gated):not(:disabled):hover,
.task.task-now .yn .chip:hover { background: #eef6f5; }
.task.task-now .group .chips .chip.decide:not(.on):not(:disabled) { border-color: var(--accent); }

/* JL-179: the plant's essential documents */
.readiness-row { border-top: 1px solid var(--line, #ddd); padding: 8px 0; }
.readiness-picks { display: grid; gap: 2px; max-height: 220px; overflow: auto; margin: 4px 0; }
.readiness-picks label { font-size: 0.85em; overflow-wrap: anywhere; }

/* JL-181: the plant's rule settings */
.rule-setting { border-top: 1px solid var(--line, #ddd); padding: 8px 0; }
.rule-setting .row select, .rule-setting .row input[type=text] { max-width: 100%; }
.rule-setting .row input[type=text] { flex: 1 1 220px; }

/* JL-185: a pattern card shown in place, as cards.py drew it */
.pattern-row iframe { display: block; width: 100%; height: 820px; margin-top: 8px; border: 1px solid var(--line, #ddd); background: #fff; }

/* JL-187 T9: the plant screen and the header chip */
.plant-chip { display: inline-flex; align-items: center; gap: 8px; font-size: 0.85rem; white-space: nowrap; }
.plant-chip .plant-name { font-weight: 600; }
button.small { padding: 3px 9px; font-size: 0.8rem; }
.plant-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; margin-bottom: 20px; }
.plant-card { display: grid; gap: 8px; align-content: start; }
.plant-card.current { border-color: var(--accent, var(--line)); }
.plant-card.new { max-width: 560px; }
.plant-facts { margin: 0; padding-left: 18px; color: var(--muted); font-size: 0.9rem; line-height: 1.5; }

/* JL-187 T10: where a value comes from (vocabulary and conventions forms) */
.source-fields { display: grid; gap: 6px; margin: 8px 0; }
.source-fields input[type="number"] { max-width: 8em; }

/* JL-196 T11: the link to the equipment studio */
.studio-link {
  font-size: 0.85rem; color: var(--accent); text-decoration: none; white-space: nowrap;
  border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px;
}
.studio-link:hover { border-color: var(--accent); }
