/* Ruleset flowchart view — layers on common.css, adds nothing to the palette.
 *
 * The three condition tags map onto the app's existing semantic colours rather
 * than new ones: a fact is muted because nothing can be done about it, something
 * fixable is green because it is actionable, and timing is amber because it only
 * needs waiting.
 *
 * One idea of its own: each question's authority hangs in the left margin, the
 * way an annotation sits beside a printed statute, off a single spine so a route
 * reads as one column of law.
 */

.ruleset-page {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 24px 80px;
}

/* ---------------------------------------------------------------- header --- */

.doc-head {
  padding: 32px 0 20px;
  animation: fadeInDown 0.5s ease-out;
}

.doc-head h1 {
  font-family: 'DM Serif Display', Georgia, serif;
  font-size: 30px;
  font-weight: 400;
  color: var(--crimson);
  letter-spacing: -0.5px;
  line-height: 1.2;
}

.doc-meta {
  margin-top: 6px;
  font-size: 14px;
  color: var(--text-secondary);
}

.doc-meta .sep { color: var(--text-muted); margin: 0 7px; }

/* .warn-toggle is a small button, shaped in common.css with the rest of them. */

.warnings {
  margin-top: 14px;
  background: var(--warning-bg);
  border-left: 3px solid var(--warning);
  border-radius: var(--radius-sm);
  padding: 16px 20px;
  max-width: 78ch;
  animation: fadeIn 0.3s ease-out;
}

.warnings p {
  color: var(--warning);
  font-size: 13.5px;
  font-weight: 500;
  margin-bottom: 10px;
}

.warnings p:last-child { margin-bottom: 0; }
.warnings[hidden] { display: none; }

/* The derived fork, as the diagram itself: the fact once at the top, then one
 * collapsible group per arm — see `web/ts/rules.ts`'s own docstring for why the
 * grouping is read off the engine rather than recomputed here. */
.fork-question {
  font-family: 'DM Serif Display', Georgia, serif;
  font-size: 20px;
  margin: 4px 0 16px;
  color: var(--text);
}

/* The conditions inside an open question, and the fact that another can be added under
   them. */
.cond-head {
  margin-top: 18px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.fork-arm-group {
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  margin-bottom: 10px;
  padding: 2px 14px;
}

.fork-arm-group summary {
  cursor: pointer;
  padding: 10px 0;
  font-weight: 600;
  font-size: 14.5px;
  color: var(--text);
}

.fork-arm-group summary:hover { color: var(--crimson-dark); }

.fork-arm-routes { padding: 4px 0 14px; }

/* "What the record works out" sits below the diagram, set apart the same way the
 * diagram itself is set apart from the summary above it. */
.derivations-group { margin-top: 32px; }
.derivations-group .calc-card:first-child { margin-top: 4px; }

.fork-overlap-note {
  font-size: 12.5px;
  color: var(--warning);
  background: var(--warning-bg);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  margin: 0 0 10px;
}

.tree-route-box + .tree-route-box { margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--border-light); }

.route-head-mini { display: flex; align-items: baseline; gap: 8px; margin-bottom: 4px; }
.route-subtitle-mini { font-size: 12px; color: var(--text-muted); }

/* ------------------------------------------------------------------ body --- */

.layout {
  display: flex;
  align-items: flex-start;
  gap: 28px;
}

/* rail ------------------------------------------------------------------- */

.rail {
  width: 292px;
  flex: none;
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 18px 0 10px;
  position: sticky;
  top: 24px;
  max-height: calc(100vh - 48px);
  overflow-y: auto;
}

.rail-title {
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  padding: 0 22px 12px;
}

.route-btn {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  border-left: 3px solid transparent;
  background: none;
  font-family: inherit;
  color: var(--text);
  padding: 9px 20px 9px 19px;
  cursor: pointer;
  transition: background var(--transition);
}

.route-btn:hover { background: var(--crimson-subtle); }

.route-btn[aria-current="true"] {
  border-left-color: var(--crimson);
  background: var(--crimson-subtle);
}

.route-btn .rname {
  display: block;
  font-family: 'DM Serif Display', Georgia, serif;
  font-size: 15px;
  line-height: 1.3;
  letter-spacing: -0.2px;
}

.route-btn[aria-current="true"] .rname { color: var(--crimson-dark); }

.route-btn .rmeta {
  display: block;
  margin-top: 3px;
  font-size: 11.5px;
  color: var(--text-muted);
}

/* stage ------------------------------------------------------------------ */

.stage { flex: 1; min-width: 0; }

.route-head {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 26px 30px;
  position: relative;
  overflow: hidden;
  animation: fadeInUp 0.4s ease-out;
}

.route-head::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 3px;
  height: 100%;
  background: var(--crimson);
}

.route-head h2 {
  font-family: 'DM Serif Display', Georgia, serif;
  font-size: 24px;
  font-weight: 400;
  color: var(--crimson-dark);
  letter-spacing: -0.3px;
  line-height: 1.25;
}

.route-head .authority {
  margin-top: 7px;
  font-size: 13.5px;
  color: var(--text-secondary);
}

/* the spine -------------------------------------------------------------- */

.chain {
  margin: 22px 0 0;
  padding: 0 0 0 160px;
  position: relative;
  list-style: none;
}

.chain::before {
  content: '';
  position: absolute;
  left: 160px;
  top: 10px;
  bottom: 46px;
  width: 1px;
  background: var(--border);
}

.step {
  position: relative;
  padding: 0 0 24px 28px;
  animation: fadeInUp 0.4s ease-out both;
}

.step:nth-child(1) { animation-delay: 0.04s; }
.step:nth-child(2) { animation-delay: 0.08s; }
.step:nth-child(3) { animation-delay: 0.12s; }
.step:nth-child(4) { animation-delay: 0.16s; }
.step:nth-child(5) { animation-delay: 0.2s; }
.step:nth-child(6) { animation-delay: 0.24s; }

/* the marginal citation, hanging outside the spine like a statute annotation */
.step .margin-cite {
  position: absolute;
  left: -160px;
  top: 2px;
  width: 142px;
  text-align: right;
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--text-muted);
}

.step::before {
  content: '';
  position: absolute;
  left: 0;
  top: 12px;
  width: 20px;
  height: 1px;
  background: var(--border);
}

.step::after {
  content: '';
  position: absolute;
  left: -4px;
  top: 9px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--crimson-light);
}

.q {
  font-family: 'DM Serif Display', Georgia, serif;
  font-size: 18px;
  font-weight: 400;
  line-height: 1.4;
  letter-spacing: -0.2px;
  max-width: 54ch;
}

.tags { margin-top: 9px; }

.tag {
  display: inline-block;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  border-radius: 4px;
  padding: 2px 7px;
  margin-right: 7px;
}

.t-fact { color: var(--text-muted); background: var(--border-light); }
.t-fixable { color: var(--success); background: var(--success-bg); }
.t-timing { color: var(--warning); background: var(--warning-bg); }

.cond { font-size: 13.5px; color: var(--text-secondary); }

.cure {
  margin-top: 5px;
  font-size: 13px;
  color: var(--success);
  max-width: 54ch;
}

.joinnote {
  margin-top: 7px;
  font-size: 12px;
  color: var(--text-muted);
  font-style: italic;
}

/* the "if no" branch off each question */
.branch {
  margin-top: 12px;
  border-left: 2px solid var(--border-light);
  padding: 2px 0 2px 14px;
  max-width: 60ch;
}

.branch .lead {
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.branch .note {
  margin-top: 3px;
  font-size: 13.5px;
  color: var(--text-secondary);
  line-height: 1.6;
}

.branch .advice {
  margin-top: 6px;
  font-size: 13px;
  color: var(--text-secondary);
}

.branch .advice .src {
  font-size: 9.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-left: 6px;
}

/* endings ---------------------------------------------------------------- */

.ending {
  display: inline-block;
  font-weight: 600;
  font-size: 14px;
  padding: 4px 14px;
  border-radius: 4px;
}

.e-eligible { color: var(--success); background: var(--success-bg); }
.e-notYet { color: var(--warning); background: var(--warning-bg); }
.e-ruledOut { color: var(--danger); background: var(--danger-bg); }

.ending .scope {
  font-weight: 400;
  font-size: 11.5px;
  margin-left: 8px;
  opacity: 0.85;
}

.outcome {
  position: relative;
  padding-left: 28px;
}

.outcome::before {
  content: '';
  position: absolute;
  left: 0;
  top: 14px;
  width: 20px;
  height: 1px;
  background: var(--border);
}

.outcome::after {
  content: '';
  position: absolute;
  left: -4px;
  top: 11px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success);
}

.outcome .note {
  margin-top: 9px;
  font-size: 13.5px;
  color: var(--text-secondary);
  max-width: 60ch;
  line-height: 1.65;
}

/* ------------------------------------------------------------ responsive --- */

@media (max-width: 940px) {
  .layout { flex-direction: column; }
  .rail {
    width: 100%;
    position: static;
    max-height: none;
  }
  .chain { padding-left: 0; }
  .chain::before { left: 0; }
  .step .margin-cite {
    position: static;
    width: auto;
    text-align: left;
    margin-bottom: 4px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .step, .route-head, .doc-head, .warnings { animation: none; }
}

/* ---------------------------------------------------------------- editing --- */

/* Every control below borrows the app's field language: --radius-sm corners,
 * a 1.5px border, and the same crimson focus ring the intake questions use.
 * Only the padding is scaled down, because these sit inline in a flowchart. */

.ask-field,
.note-field,
.authority-field,
.route-name-inline,
.objection,
.newq-ask {
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  transition: all var(--transition);
}

.ask-field:focus,
.note-field:focus,
.authority-field:focus,
.route-name-inline:focus,
.objection:focus,
.newq-ask:focus {
  outline: none;
  border-color: var(--crimson);
  box-shadow: 0 0 0 3px rgba(132, 22, 23, 0.08);
}

/* Fields that sit in running text stay invisible until touched, so the page
 * reads as a document rather than a form. */
.ask-field,
.authority-field {
  border-color: transparent;
  background: transparent;
}

.ask-field:hover,
.authority-field:hover { border-color: var(--border-light); }

.ask-field {
  font-family: 'DM Serif Display', Georgia, serif;
  font-size: 18px;
  line-height: 1.4;
  letter-spacing: -0.2px;
  width: 100%;
  max-width: 54ch;
  padding: 7px 10px;
  margin-left: -10px;
  resize: vertical;
  min-height: 2.7em;
}

/* The route's name, edited in the group's own title. The title's size and weight, so pressing
   the pencil does not restyle the row it opens in — with a visible border, because a field that
   appears where a heading was has to look like a field. */
.route-name-inline {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
  max-width: 46ch;
  padding: 2px 6px;
  margin: -2px 0;
}

.authority-field {
  position: absolute;
  left: -160px;
  top: 0;
  width: 152px;
  font-size: 11.5px;
  color: var(--text-muted);
  text-align: right;
  padding: 3px 7px;
}

.authority-field:focus { text-align: left; }

/* ---- the rules, behind a disclosure ---- */

.rules-box {
  margin-top: 10px;
  max-width: 58ch;
}

.rules-box > summary {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 5px 11px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  display: inline-block;
  transition: all var(--transition);
  list-style: none;
}

.rules-box > summary::-webkit-details-marker { display: none; }
.rules-box > summary::before { content: '▸ '; color: var(--crimson-light); }
.rules-box[open] > summary::before { content: '▾ '; }
.rules-box > summary:hover { border-color: var(--crimson-light); color: var(--crimson); background: var(--crimson-subtle); }

.rules-body {
  margin-top: 10px;
  padding: 14px 16px;
  background: var(--bg);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
}

/* A condition, shown for inspection. */
.cond-shown + .cond-shown { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border-light); }
.cond-formal { margin-top: 5px; font-size: 12.5px; color: var(--text-muted); font-style: italic; }

/* Removing a condition, and adding one — see `renderRemoveConditionButton` and
 * `renderAddConditionPanel` in rules.ts. A refusal (the node's only condition) is
 * written on the page beside the disabled control, not left for a click to do
 * nothing about. */

.add-cond-box { margin-top: 14px; }

/* Drawn as an empty slot at the foot of the condition list rather than as one more
   secondary button among the several an open question already holds. "I don't have a
   button to add new conditions" was said about a button that was there and looked like
   its neighbours; a dashed slot the width of the list reads as the next item in it. */
.add-cond-btn {
  display: flex;
  width: 100%;
  max-width: 58ch;
  border-style: dashed;
  padding: 10px 18px;
  font-size: 14px;
}
.add-cond-panel {
  margin-top: 8px; padding: 12px 14px;
  background: var(--bg); border: 1px solid var(--border-light); border-radius: var(--radius);
}
.add-cond-lead { font-size: 12.5px; color: var(--text-secondary); margin-bottom: 8px; }
.add-cond-manual > * + * { margin-top: 8px; }
.add-cond-manual .btn-row,
.add-cond-manual .primary-btn { margin-top: 10px; }

.note-field {
  width: 100%; max-width: 68ch; margin-top: 4px;
  font-size: 13px; line-height: 1.55; padding: 8px 10px; min-height: 7.5em; resize: vertical;
}

/* ---- the confirm strip ---- */

.confirm {
  border: 1px solid rgba(146, 64, 14, 0.25);
  border-left: 3px solid var(--warning);
  background: var(--warning-bg);
  border-radius: var(--radius-sm);
  padding: 15px 18px;
  margin-bottom: 14px;
  max-width: 58ch;
  animation: fadeIn 0.3s ease-out;
}

.confirm .lead {
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--warning);
}

.confirm .yours {
  font-family: 'DM Serif Display', Georgia, serif;
  font-size: 17px;
  margin-top: 8px;
  line-height: 1.35;
}

.confirm .ours { margin-top: 9px; font-size: 13px; color: var(--text-secondary); }
.confirm .ours b { color: var(--text); font-weight: 600; }
.confirm .btn-row { margin-top: 13px; gap: 9px; }
.confirm .primary-btn, .confirm .secondary-btn { padding: 8px 18px; font-size: 13.5px; }
.confirm .working { font-size: 12.5px; color: var(--text-muted); font-style: italic; margin-top: 9px; }

/* ---------------------------------------------------------------- toolbar --- */

.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 12px 16px;
  margin-bottom: 20px;
}

.toolbar .spacer { flex: 1; }
.toolbar .saved { font-size: 12px; color: var(--text-muted); }
.toolbar .secondary-btn { padding: 8px 18px; font-size: 13.5px; }

/* Buttons that belong together, kept together.
 *
 * A row of seven identical small buttons is a pile, and reading a pile means reading all
 * of it every time. Three of them show you something about these rules, two are the file
 * on disk, two go somewhere else — so they sit in threes with a hairline between, and you
 * can find the one you want by where it is rather than by reading every label. */
.btn-group {
  display: flex;
  gap: 6px;
  align-items: center;
}

.btn-group + .btn-group::before {
  content: '';
  align-self: stretch;
  width: 1px;
  background: var(--border);
  margin: 3px 4px 3px 0;
}

.offer {
  background: var(--crimson-subtle);
  border: 1px solid rgba(132, 22, 23, 0.14);
  border-left: 3px solid var(--crimson);
  border-radius: var(--radius-sm);
  padding: 15px 18px;
  margin-bottom: 20px;
  font-size: 13.5px;
  color: var(--text-secondary);
  max-width: 70ch;
  animation: fadeIn 0.3s ease-out;
}

.offer[hidden] { display: none; }
.offer .btn-row { margin-top: 11px; gap: 9px; }
.offer .primary-btn, .offer .secondary-btn { padding: 8px 18px; font-size: 13.5px; }

@media (max-width: 940px) {
  .authority-field {
    position: static; left: auto; top: auto;
    width: 100%; text-align: left; margin-bottom: 5px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .confirm, .offer { animation: none; }
}

/* ---- a proposal that needs a new client question ---- */

.newq {
  margin-top: 12px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
}

.newq .lead { color: var(--text-secondary); }
.newq-row + .newq-row { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border-light); }

.newq-ask {
  width: 100%;
  margin-top: 7px;
  font-size: 13.5px;
  padding: 7px 10px;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  transition: all var(--transition);
}

.newq-ask:focus {
  outline: none;
  border-color: var(--crimson);
  box-shadow: 0 0 0 3px rgba(132, 22, 23, 0.08);
}

.newq-meta { margin-top: 5px; font-size: 11.5px; color: var(--text-muted); }

/* A proposed fact that is really the statute talking: approving it is fine, and leaves a
   derivation to write. Warning colours rather than error colours, because nothing here is
   refused — the fact is created either way. */
.newq-awaiting {
  margin-top: 9px;
  padding: 10px 12px;
  border-left: 3px solid var(--warning);
  background: var(--warning-bg);
  border-radius: var(--radius-sm);
}
.newq-awaiting-lead { font-size: 12px; font-weight: 600; color: var(--text-secondary); }
.newq-awaiting-why { margin-top: 6px; font-size: 12.5px; line-height: 1.55; color: var(--text-secondary); }
.newq-awaiting-where { margin-top: 7px; font-size: 12px; font-weight: 600; color: var(--text-secondary); }
.newq-similar { margin-top: 8px; font-size: 12px; color: var(--text-secondary); display: flex; flex-wrap: wrap; gap: 7px; align-items: center; }

/* ---- working out the rule from a reworded question (engine.propose) ---- */

.propose-box { margin-top: 10px; }
.propose-btn { padding: 7px 14px; font-size: 13px; }

.propose {
  border: 1px solid rgba(132, 22, 23, 0.14);
  border-left: 3px solid var(--crimson);
  background: var(--crimson-subtle);
  border-radius: var(--radius-sm);
  padding: 15px 18px;
  max-width: 58ch;
  animation: fadeIn 0.3s ease-out;
}

.propose-lead {
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--crimson-dark);
  margin: 0;
}

.propose-readback { margin: 8px 0 0; font-size: 13.5px; color: var(--text-secondary); line-height: 1.5; }
.propose-status { margin: 0; font-size: 13px; color: var(--text-muted); font-style: italic; }
.propose-error { margin: 4px 0 0; font-size: 13.5px; color: var(--danger); }
.propose .btn-row { margin-top: 13px; gap: 9px; }
.propose .primary-btn, .propose .secondary-btn { padding: 8px 18px; font-size: 13.5px; }
.propose .objection { margin-top: 10px; width: 100%; padding: 7px 10px; font-size: 13px; }

.new-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: #fff;
  background: var(--crimson);
  border-radius: 3px;
  padding: 1px 6px;
  margin-right: 4px;
  vertical-align: middle;
}

@media (prefers-reduced-motion: reduce) {
  .propose { animation: none; }
}

/* ---------------------------------------------------------------- the key --- */

.keybar {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-left: 3px solid var(--crimson);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 15px 18px;
  margin-bottom: 20px;
  max-width: 70ch;
}

.keybar[hidden] { display: none; }

.keybar label {
  display: block;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text);
}

.keybar-row { display: flex; gap: 10px; margin-top: 10px; flex-wrap: wrap; }

.keybar input {
  flex: 1;
  min-width: 22ch;
  font-family: inherit;
  font-size: 14px;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  transition: all var(--transition);
}

.keybar input::placeholder { color: var(--text-muted); }

.keybar input:focus {
  outline: none;
  border-color: var(--crimson);
  box-shadow: 0 0 0 3px rgba(132, 22, 23, 0.08);
}

.keybar .primary-btn { padding: 10px 20px; font-size: 14px; }
.keybar-note { margin-top: 9px; font-size: 12px; color: var(--text-muted); }

.keybar-set {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: space-between;
  border-left-color: var(--success);
  font-size: 13px;
  color: var(--text-secondary);
  padding: 11px 16px;
}

/* ---- correcting a reading by saying what is wrong with it ---- */

.confirm .said {
  border-left: 2px solid rgba(146, 64, 14, 0.3);
  padding: 2px 0 2px 11px;
  margin-top: 11px;
  font-size: 12.5px;
}

.confirm .said-read { color: var(--text-muted); font-style: italic; }
.confirm .said-you { color: var(--text-secondary); margin-top: 3px; }

.confirm .fixbox {
  margin-top: 14px;
  padding-top: 13px;
  border-top: 1px solid rgba(146, 64, 14, 0.2);
}

.confirm .objection {
  width: 100%;
  margin-top: 7px;
  min-height: 4.2em;
  resize: vertical;
  font-family: inherit;
  font-size: 13.5px;
  padding: 9px 11px;
  color: var(--text);
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  transition: all var(--transition);
}

.confirm .objection::placeholder { color: var(--text-muted); }

.confirm .objection:focus {
  outline: none;
  border-color: var(--crimson);
  box-shadow: 0 0 0 3px rgba(132, 22, 23, 0.08);
}

/* ---- adding a route or a question ---- */

.route-add,
.question-add {
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--crimson);
  background: none;
  border: 1.5px dashed var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
}

.route-add {
  display: block;
  width: calc(100% - 32px);
  margin: 12px 16px 4px;
  padding: 9px 12px;
  text-align: left;
}

.question-add {
  display: block;
  margin: 4px 0 26px;
  padding: 8px 14px;
}

.route-add:hover,
.question-add:hover { border-color: var(--crimson-light); background: var(--crimson-subtle); }

.route-add:focus-visible,
.question-add:focus-visible { outline: 2px solid var(--crimson-light); outline-offset: 2px; }

.unwritten {
  font-size: 12.5px;
  color: var(--crimson);
  font-style: italic;
  margin-bottom: 5px;
}

/* ---- waiting on Gemini ---- */

.confirm .waiting {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 11px;
  font-size: 13px;
  color: var(--text-secondary);
}

.confirm .spin {
  width: 15px;
  height: 15px;
  flex: none;
  border: 2px solid rgba(146, 64, 14, 0.25);
  border-top-color: var(--warning);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  .confirm .spin { animation-duration: 2.4s; }
}

.keybar-actions { display: flex; gap: 8px; flex: none; }

/* ---- structural tools ---- */

.q-tools { display: flex; flex-wrap: wrap; gap: 7px; align-items: center; margin-top: 11px; }

/* .tool-btn is a small button — shape, hover, focus and the danger variant all come from
 * common.css, where every small button in the app is shaped. Only its place is here. */
.route-head .tool-btn.danger { margin-top: 12px; }

.also-asked { font-size: 11.5px; color: var(--text-muted); font-style: italic; }

/* The slot the "ask something different here" button lands in, in the row of three at the foot
   of an open question. Empty — and so invisible — where the question is this route's own. */
.sharing { display: contents; }

.split-panel {
  align-self: stretch;
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-left: 3px solid var(--crimson-light);
  border-radius: var(--radius-sm);
  background: var(--crimson-subtle);
}

/* Adding a question to a route: the button at the foot of the chain, and the panel it
   opens. Indented to the chain it adds to, so it reads as the next step of the route
   rather than as a control belonging to the whole page. */
.add-question-row { margin: 6px 0 2px 0.35rem; }

.add-question-panel {
  margin: 8px 0 2px 0.35rem;
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-left: 3px solid var(--crimson-light);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.add-question-panel .fact-stage { margin-top: 8px; }
.add-question-panel .deduction-ask,
.add-question-panel .ask-field { width: 100%; }
.add-question-wording { margin: 4px 0 2px; }
.split-panel .ask-field { width: 100%; }

/* Its own row across the outcome box rather than a column beside the pill: as a flex item next
   to `eligible` it shrank to about a quarter of the width, which is a paragraph edited four words
   to a line. `flex-wrap` on `.tree-end` is what lets it take the whole line. */
.ending-edit { flex: 1 0 100%; margin-top: 6px; }
.ending-edit-label { display: block; }
.ending-row { display: flex; gap: 8px; margin-top: 7px; flex-wrap: wrap; }

.kind-select,
.scope-select {
  font-family: inherit;
  font-size: 12px;
  padding: 4px 9px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
}

/* Wide enough for the longest question it offers and no wider. Unconstrained, the builder's
   "choose a question…" ran to 646px — a bar most of the way across the card with nothing in
   it, because a `<select>` sizes to its widest option and the options are whole questions. */
.kind-select,
.scope-select {
  max-width: 34ch;
  text-overflow: ellipsis;
}

.kind-select:focus,
.scope-select:focus {
  outline: none;
  border-color: var(--crimson);
  box-shadow: 0 0 0 3px rgba(132, 22, 23, 0.08);
}



/* ------------------------------------------------------- drafting a statute --- */

.back-link { display: inline-block; margin-top: 14px; text-decoration: none; }

.draft-card { max-width: 78ch; }
.draft-card h2 { margin-bottom: 18px; }

.field { display: block; margin-bottom: 16px; }

.field > span {
  display: block;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.field select,
.field input,
.field textarea {
  width: 100%;
  font-family: inherit;
  font-size: 14px;
  padding: 11px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  transition: all var(--transition);
}

.field textarea {
  resize: vertical;
  line-height: 1.65;
  font-size: 13.5px;
}

.field select { cursor: pointer; appearance: auto; }

.field input::placeholder,
.field textarea::placeholder { color: var(--text-muted); }

.field select:focus,
.field input:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--crimson);
  box-shadow: 0 0 0 3px rgba(132, 22, 23, 0.08);
}

.field-row { display: flex; gap: 14px; flex-wrap: wrap; }
.field-row .field { flex: 1; min-width: 16ch; }
.field-row .field.narrow { flex: 0 0 12ch; }

.draft-hint { font-size: 12.5px; color: var(--text-muted); }

/* ---- progress ---- */

.progress-list { list-style: none; margin: 0; padding: 0; }

.progress-item {
  position: relative;
  padding: 8px 0 8px 30px;
  font-size: 14px;
  color: var(--text);
  animation: fadeInUp 0.3s ease-out;
}

.progress-item::before {
  position: absolute;
  left: 0;
  top: 8px;
  width: 18px;
  text-align: center;
}

.progress-item.doing { color: var(--text-secondary); }

.progress-item.doing::before {
  content: '';
  top: 12px;
  left: 2px;
  width: 13px;
  height: 13px;
  border: 2px solid rgba(132, 22, 23, 0.25);
  border-top-color: var(--crimson);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.progress-item.done::before { content: '✓'; color: var(--success); font-weight: 700; }
.progress-item.failed { color: var(--danger); }
.progress-item.failed::before { content: '✕'; color: var(--danger); font-weight: 700; }

.progress-item.sub {
  padding: 3px 0 3px 48px;
  font-size: 13px;
  color: var(--text-secondary);
}

.progress-item.sub::before { content: '·'; left: 32px; color: var(--text-muted); }

/* ---- the draft ---- */

.draft-summary { margin: 16px 0 20px; }

.summary-counts {
  font-size: 13px;
  color: var(--text-secondary);
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-light);
}

.draft-routes { margin-top: 4px; }

.drafted-route {
  border-left: 3px solid var(--crimson);
  padding: 2px 0 2px 15px;
  margin-bottom: 22px;
}

.dr-name {
  font-family: 'DM Serif Display', Georgia, serif;
  font-size: 18px;
  color: var(--crimson-dark);
  letter-spacing: -0.2px;
}

.dr-authority { font-size: 12px; color: var(--text-muted); margin-top: 3px; }

.dr-questions {
  margin: 11px 0 0;
  padding-left: 20px;
  font-size: 13.5px;
  color: var(--text);
}

.dr-questions li { margin-bottom: 10px; line-height: 1.55; }
.dr-ask { display: block; }

.dr-questions .tag {
  display: inline-block;
  margin: 4px 7px 0 0;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  border-radius: 4px;
  padding: 2px 7px;
}

.dr-formal { font-size: 12.5px; color: var(--text-muted); font-style: italic; }

.drafted-uncertainty {
  background: var(--warning-bg);
  border-left: 3px solid var(--warning);
  border-radius: var(--radius-sm);
  padding: 12px 15px;
  margin-bottom: 12px;
  max-width: 72ch;
}

.du-issue { font-size: 13px; color: var(--warning); font-weight: 500; }
.du-settle { font-size: 12.5px; color: var(--text-secondary); margin-top: 5px; }

/* ---- several sources ---- */

.sources { display: flex; flex-direction: column; gap: 14px; }

.source-row {
  border: 1px solid var(--border-light);
  border-left: 3px solid var(--crimson-light);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  background: var(--bg);
}

.source-head { display: flex; gap: 9px; align-items: center; flex-wrap: wrap; margin-bottom: 9px; }

.source-name {
  flex: 1;
  min-width: 18ch;
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  padding: 7px 11px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  transition: all var(--transition);
}

.source-kind {
  font-family: inherit;
  font-size: 12.5px;
  padding: 7px 10px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
}

.source-text {
  width: 100%;
  font-family: inherit;
  font-size: 13px;
  line-height: 1.6;
  padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  resize: vertical;
  transition: all var(--transition);
}

.source-name::placeholder,
.source-text::placeholder { color: var(--text-muted); }

.source-name:focus,
.source-kind:focus,
.source-text:focus {
  outline: none;
  border-color: var(--crimson);
  box-shadow: 0 0 0 3px rgba(132, 22, 23, 0.08);
}

.source-tools { display: flex; gap: 9px; align-items: center; margin-top: 12px; flex-wrap: wrap; }

.kept-note { display: block; margin-top: 9px; color: var(--success); }

/* ---- the rules as one tree ---- */

.tree-branch { border-left: 2px solid var(--line, #d8d8d2); margin-left: 0.35rem; padding-left: 0.9rem; }
.tree-branch.d-0 { border-left: none; margin-left: 0; padding-left: 0; }

.tree-ask {
  font-weight: 600;
  margin: 0.7rem 0 0.2rem;
}

.tree-arm { margin: 0.15rem 0 0.15rem 0.2rem; }

.tree-answer {
  font-size: 0.9rem;
  color: var(--ink-soft, #5a5a52);
  margin: 0.35rem 0 0.1rem;
}
.tree-answer::before { content: "→ "; opacity: 0.5; }

.tree-note {
  font-size: 0.85rem;
  color: var(--ink-soft, #5a5a52);
  font-style: italic;
  margin: 0.3rem 0;
}

.tree-run { margin: 0.2rem 0; }

.tree-cond {
  font-size: 0.9rem;
  padding: 0.15rem 0;
  display: flex;
  gap: 0.4rem;
  align-items: baseline;
  flex-wrap: wrap;
}

.tree-authority {
  font-size: 0.78rem;
  color: var(--ink-soft, #5a5a52);
  margin-left: auto;
}

.tree-end {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: baseline;
  padding: 0.25rem 0.5rem;
  margin: 0.2rem 0;
  border-radius: 3px;
  background: var(--tint, #f3f3ee);
  font-size: 0.9rem;
}
.tree-end.k-eligible { background: #e8f2e8; }
.tree-end.k-notYet { background: #f6f1e2; }
.tree-end.k-ruledOut { background: #f2f2f2; color: var(--ink-soft, #5a5a52); }

.tree-kind { font-size: 0.8rem; color: var(--ink-soft, #5a5a52); margin-left: auto; }

/* ---- the flowchart is the editor: a box grows in place, it is not replaced by one ---- */

.tree-question {
  padding: 0.35rem 0.5rem;
  margin: 0.15rem 0;
  border-radius: 4px;
  cursor: pointer;
}

.tree-question:hover { background: var(--crimson-subtle); }

/* On the read-only rules page a box opens onto nothing, so it does not look like it would. */
body:not([data-mode="edit"]) .tree-question { cursor: default; }
body:not([data-mode="edit"]) .tree-question:hover { background: none; }

.tree-question-open {
  cursor: default;
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  margin: 8px 0;
  box-shadow: var(--shadow-sm);
}

.tree-question-open:hover { background: var(--surface); }

/* Moving a question up or down its route. Top-right of the box, out of the way of the
   question itself, and quiet until the pointer is over the box it belongs to. */
.tree-question { position: relative; }

/* The header's own controls, beside the picker. One button, and it deletes the ruleset —
   so it is coloured as what it is rather than looking like every other small button. */
/* The header's own controls, beside the picker: draft another ruleset, or delete this one. */
.ruleset-tools {
  margin-top: 10px;
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}

.danger-btn {
  border-color: var(--danger);
  color: var(--danger);
}

.danger-btn:hover {
  background: var(--danger-bg);
  border-color: var(--danger);
}

.step-move {
  position: absolute;
  top: 0.3rem;
  right: 0.4rem;
  display: flex;
  gap: 2px;
  opacity: 0;
  transition: opacity var(--transition);
}

.tree-question:hover .step-move,
.tree-question-open .step-move { opacity: 1; }

.move-btn {
  font-family: inherit;
  font-size: 13px;
  line-height: 1;
  padding: 3px 7px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-secondary);
  cursor: pointer;
}

.move-btn:hover:not(:disabled) { border-color: var(--crimson-light); color: var(--crimson); }
.move-btn:disabled { opacity: 0.3; cursor: default; }

/* The one condition tested first on a route — marked on the box itself, so "where
 * does this start" is answered by looking rather than by counting indentation. */
.tree-question-first { position: relative; }

.tree-question-first::before {
  content: "tested first";
  display: block;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 2px;
}


.ending { cursor: pointer; }

/* What refused an edit, said where the attorney is looking rather than only in the error
   line at the top of the page. Used by the split panel, the add-a-question panel and the
   deduction builder. */
.edit-problem {
  margin-top: 8px;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--danger);
}


.route-group {
  margin-bottom: 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  background: var(--surface);
}

.route-group > summary {
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 600;
}

/* The pencil in that summary. Quiet until it is wanted, and crimson while the fields it opens
   are showing, so the row says whether they are open without a second word in the title. */
.route-rename {
  margin-left: 8px;
  padding: 0 4px;
  font-family: inherit;
  font-size: 13px;
  line-height: 1;
  color: var(--text-muted);
  background: none;
  border: none;
  cursor: pointer;
}

.route-rename:hover,
.route-rename.on { color: var(--crimson); }

/* The stages: what has to be known before what. */

.facts-hint {
  margin: 10px 0 4px;
  font-size: 12.5px;
  color: var(--text-muted);
  max-width: 62ch;
}

/* Every card in the questions panel: one question, one statutory list, one proposal. They had
   no rule at all — the class was written, styled nothing, and every card ran into the next as
   one undifferentiated column of text on the page background. White, because that is what a
   route group on the diagram above is, and the two are the same kind of object: one thing you
   can open, read and edit. */
.fact-box {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  box-shadow: var(--shadow-sm);
}

.facts-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Edit and Delete at the foot of a card. It used to carry `.classify-answer`, which is styled
   in `screen.css` — a stylesheet this page does not load — so the row had no rule at all and
   the two buttons touched, Delete flush against Edit. Kept a wide gap deliberately: one of
   them cannot be undone. */
.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 10px;
}

/* Inside a card. Eight classes on this page were written, used, and styled nothing: every one
   of these rendered at the browser's default size, so a note about how to answer a question
   came out as large as the question, and a card's title no larger than its body.
   `.fact-ask` is the thing the card is about, `.fact-meta` the quiet line under it. */
.fact-ask {
  font-size: 14.5px;
  font-weight: 600;
  line-height: 1.45;
  color: var(--text);
}

.fact-meta {
  margin-top: 5px;
  font-size: 12px;
  color: var(--text-muted);
}

.fact-note {
  margin-top: 7px;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--text-secondary);
  font-style: italic;
}

.fact-values {
  margin-top: 6px;
  font-size: 12.5px;
  color: var(--text-secondary);
}

/* What to do about a curable failure, under the condition it belongs to. */
.cond-cure {
  margin-top: 4px;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--text-secondary);
}

/* One collapsible panel under the diagram. Its summary is the handle, and it is a heading:
   the arrow alone was doing all the work of saying it could be opened. */
.facts-group { margin-top: 22px; }

.facts-group > summary {
  cursor: pointer;
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  padding: 4px 0;
}

.facts-group > summary:hover { color: var(--crimson); }


/* The panel holds three lists of questions, and each one is a heading that opens and shuts it:
   forty-odd cards between the panel's heading and the tools under it is a panel nobody can see
   the foot of. Bigger than `.stage-head`, which titles one card. */
/* Indented under the panel's own summary, with a rule down the left, so the three lists read
   as parts of "Questions" rather than as three more sections that happen to sit below it. The
   same idiom as `.tree-branch` on the diagram above, which is the other place this app nests
   one collapsible inside another. */
.questions-part {
  margin: 20px 0 0 0.9rem;
  padding-left: 0.9rem;
  border-left: 2px solid var(--border-light);
}

.questions-head {
  margin: 0;
  padding: 3px 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
}

.questions-head:hover { color: var(--crimson); }

.questions-head:focus-visible {
  outline: 2px solid var(--crimson-light);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* The hint under a heading, and the first list in the panel, both sat too far from what they
   belong to when every block was carrying `.questions-head`'s old 22px top margin. */
.questions-part > .facts-hint { margin: 6px 0 10px; }

#questions > details > div:first-of-type > .questions-part { margin-top: 8px; }

/* Adding a question and working one out are the same act, so they are one row of cards rather
   than one block stacked under the other — two columns while there is room for both, one when
   there is not. */
.question-tools {
  /* Lined up with the three lists above it, and one shorthand: a `margin-left` followed later
     in the same rule by `margin-top` is a `margin-left` silently reset to zero. */
  margin: 20px 0 0 0.9rem;
  padding-left: 0.9rem;
  border-left: 2px solid var(--border-light);
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 12px;
  /* `stretch`, as in `.add-route-cols`: two columns of different heights read as the short one
     being unfinished. The right column holds two cards to the left column's one, so they share
     the height between them rather than leaving a gap under the shorter pair. */
  align-items: stretch;
}

.question-tools > div {
  display: flex;
  flex-direction: column;
  gap: 10px;
}


/* One card per block, the two columns the same height, and each card's own control at its foot
   so the buttons across the row line up instead of floating at three different heights. */
.question-tools .stage-group {
  display: flex;
  flex-direction: column;
  flex: 1;
  margin: 0;
  /* Roomier than a question card, because there are two of these to a column and they were
     coming out squat — a heading and one control apiece, with the leftover height showing as
     a gap between them rather than as air inside either. */
  padding: 18px 18px;
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
}

.question-tools .stage-group > :last-child { margin-top: auto; }

/* A card's title is the thing the card is about, so it reads as a heading rather than as the
   small ruled caption `.stage-head` draws where it subdivides a form. */
.question-tools .stage-head {
  margin: 0 0 4px;
  padding-bottom: 0;
  border-bottom: none;
  font-size: 14.5px;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
  color: var(--text);
}

/* Prose and fields both run the width of the card they are in: a 62ch cap inside a column
   half that wide only made the spacing under it uneven. */
.question-tools .facts-hint { margin: 6px 0 8px; max-width: none; }
.question-tools .add-question { max-width: none; }

/* The card just added, for as long as it takes to look at it. Scrolling to a card in a list of
   fifteen says where it is; this says which one it is. */
.fact-box.just-added {
  border-color: var(--crimson-light);
  box-shadow: 0 0 0 3px var(--crimson-subtle);
  animation: fadeIn 0.4s ease-out;
}

/* Cards that are not in a `.facts-list` still need to be told apart from each other. */
#questions .fact-box + .fact-box { margin-top: 8px; }

.stage-group { margin-top: 16px; }

/* Inside a popout there is no card to be a part of: the blocks stack down the dialog. */
#suggested-body > * + *,
#builder-body > * + * { margin-top: 12px; }
#suggested-body .stage-group,
#builder-body .stage-group { margin-top: 0; }

.stage-head {
  margin: 0 0 8px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-secondary);
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border-light);
}

.fact-stage[hidden] { display: none; }

.fact-stage {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 8px 0;
  padding: 7px 9px;
  border-radius: 5px;
  background: var(--border-light);
}

.fact-stage-note {
  font-size: 11.5px;
  color: var(--text-muted);
}

/* The stage on a closed box, so the order of the form reads straight off the flowchart. */
.tree-stage {
  display: inline-block;
  margin-bottom: 4px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-secondary);
  background: var(--border-light);
  border-radius: 4px;
  padding: 2px 6px;
}

.fact-stage-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.stage-field {
  width: 56px;
  padding: 3px 6px;
  font: inherit;
  font-size: 12.5px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  color: var(--text);
}

/* What each answer to a box does. Not italic and not muted, unlike `.joinnote` which it
 * replaces: this is the line that says whether "yes" carries a case on or turns it away, and
 * a reader skipping it is how two questions worded the opposite way round from their own
 * conditions went unnoticed. */
.answers {
  margin-top: 7px;
  font-size: 12.5px;
  color: var(--text);
  max-width: 60ch;
}

.answers-go {
  font-weight: 600;
}

/* The panel of questions worked out rather than asked. */
.deduction-formula {
  margin-top: 6px;
  font-size: 12.5px;
  color: var(--text);
  max-width: 60ch;
}

/* The sentence the attorney typed, kept beside what it compiled to. Quieter than the formula
 * on purpose: the formula is what the rule now checks, and this is what somebody meant. */
.deduction-said {
  margin-top: 4px;
  font-size: 12px;
  color: var(--text-muted);
  font-style: italic;
  max-width: 60ch;
}

.deduction-rows {
  margin-top: 10px;
  border-left: 2px solid var(--border-light);
  padding: 2px 0 2px 14px;
}

.deduction-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
  font-size: 12.5px;
}

.deduction-n {
  width: 5em;
  font: inherit;
  padding: 2px 4px;
}

.deduction-ask {
  flex: 1 1 24em;
  font: inherit;
  padding: 3px 5px;
}

.deduction-add {
  color: var(--text-muted);
}

/* Asking for something new. */
.add-question {
  margin-top: 8px;
  max-width: 62ch;
}

/* `[hidden]` is a UA rule of one attribute, and a class rule setting `display` beats it: the
   choices row was told to hide itself for every answer kind but "one of a list of choices" and
   stayed on the page anyway, so people were typing choices into a free-text question. */
.add-row[hidden] { display: none; }

/* The form's own answer to its own button. Quiet, and green rather than crimson: a refusal is
   already `.edit-problem`, and the two must not look alike. */
.add-said {
  margin: 8px 0 0;
  font-size: 12.5px;
  color: var(--success, #2f6f4f);
}

.add-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 6px;
}

.add-label {
  flex: 0 0 8em;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

/* How the phrase will read back, and what a formula can do with the answer. Both are things
 * that go wrong silently, so they sit under the field rather than in a tooltip. */
.add-reads {
  margin: 2px 0 8px 8.4em;
  font-size: 12px;
  color: var(--text-muted);
  font-style: italic;
}

/* A condition already added to the formula being built. */
.deduction-built {
  background: var(--bg-sunk, rgba(0, 0, 0, 0.03));
  border-radius: 3px;
  padding: 3px 6px;
}

/* What the whole formula says, from the server's own describer — the sentence to read before
 * saving, because reading it afterwards is reading it too late. */
.deduction-reads {
  margin-top: 6px;
  font-size: 12.5px;
  color: var(--text);
  max-width: 62ch;
}

.deduction-reads-bad {
  color: var(--danger, #a4243b);
}

.small-btn-quiet {
  opacity: 0.65;
  font-size: 11px;
}

/* Say it in words and the model writes the conditions. Set apart from the rows below it, since
   the two are alternatives — describe it, or build it by hand — and either way the read-back
   underneath is what gets checked. */
/* Adding a route: describe one in a sentence, or add an empty one and fill it in by hand.
   Always on the page — it was a `<details>` shut by default, which is the shape that had an
   attorney reporting there was no way to add a route — and the two ways side by side, since
   they are alternatives rather than steps. */
.add-route-panel { margin-top: 22px; }

/* A panel that does not open and shut still needs a heading the size the ones that do have. */
.panel-head {
  padding: 4px 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

.add-route-cols {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 12px;
  /* `stretch`, not `start`: the two are alternatives to each other, and one card two thirds
     the height of the other reads as the short one being unfinished rather than as a choice
     between two ways of doing the same thing. Their buttons then sit on the same line, because
     each card pushes its own to the bottom. */
  align-items: stretch;
  margin-top: 8px;
}

/* One card twice, so the two columns read as a pair. The describe box brought its own styling
   — a crimson rule and a tinted background — which made it the loud one of the two; both are
   the same white card now, and the button in each is pushed to the foot. */
.add-route-cols > .deduction-sentence,
.add-route-cols > .stage-group {
  display: flex;
  flex-direction: column;
  margin: 0;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-left: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
}

.add-route-cols > .deduction-sentence > button,
.add-route-cols > .stage-group > button { align-self: start; margin-top: auto; }

/* Its heading titles the card, and its field runs the card's width with the button under it —
   the input was leaving the button stranded halfway across the row. */
.add-route-cols .stage-head {
  margin-top: 0;
  padding-bottom: 0;
  border-bottom: none;
}

.add-route-cols .ask-field { width: 100%; margin-bottom: 8px; }

.deduction-sentence {
  margin: 10px 0 14px;
  padding: 12px 14px;
  border-left: 3px solid var(--crimson);
  background: var(--border-light);
  border-radius: 6px;
}

.deduction-sentence .facts-hint {
  margin-top: 0;
}

.deduction-sentence .ask-field {
  width: 100%;
  margin-bottom: 8px;
}

/* A stage heading inside the "Still asked" list. Quieter than a section head — it is a divider
   in a list, not a section of its own. */
.asked-stage {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin: 12px 0 4px;
}

.asked-stage:first-child {
  margin-top: 0;
}

/* The chips above a question in a list, and what depends on it underneath.
 *
 * The same `.tree-stage` pill the diagram uses on a box: this list and the diagram describe the
 * same questions, and describing them two different ways was most of why the list was hard to
 * read. What replaced a run-together line of four middot-separated facts, followed by a
 * paragraph naming four more questions — prose is the wrong shape for a set of one-word facts,
 * and for a list of four questions each of which is a sentence. */
.q-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin: 6px 0 2px;
}

.q-pills .tree-stage { margin-bottom: 0; }

.q-feeds-head {
  margin-top: 10px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--text-secondary);
}

.q-feeds {
  margin: 4px 0 0;
  padding: 0 0 0 16px;
  list-style: none;
}

.q-feeds li {
  position: relative;
  padding-left: 14px;
  margin-bottom: 3px;
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-secondary);
}

.q-feeds li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 9px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--crimson-light);
}

.q-feeds li:last-child { margin-bottom: 0; }

/* The answers a choice question offers. Ten of them on this ruleset's disposition question,
   several a clause long — run together with middots they were a paragraph nobody could find an
   answer in. */
.q-values {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 5px;
}

.q-value {
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-secondary);
  background: var(--bg);
  border: 1px solid var(--border-light);
  border-radius: 4px;
  padding: 3px 8px;
}

/* Embedding the lists — a once-off with a cost, so it says what it is before it is pressed. */
/* The foot of the statutory lists: add one, embed them all. One row of two buttons, clear of
   the last card — the paragraph that used to hold them apart is gone, and they were stacked
   either side of a hairline that made the embed button look like a section of its own. */
.lists-foot {
  display: flex;
  flex-wrap: wrap;
  /* Stretch, not centre: `.primary-btn` is a 15px label in 12px of padding and `.small-btn` a
     12px label in 6px, so side by side they were two different heights. Stretching takes the
     shorter one up to the taller rather than fixing a height here that either button's own
     rule could then drift away from. */
  align-items: stretch;
  gap: 12px;
  margin-top: 16px;
}

/* What the embedding did. A sentence, so it goes under the row and reads at the size of the
   quiet lines on the cards above rather than at a control's size. */
.lists-said {
  margin-top: 10px;
  font-size: 12.5px;
  color: var(--text-secondary);
}

/* ---- the read-only rules page: the routes drawn as the home page draws them ---- */

.rules-map {
  display: grid;
  grid-template-columns: minmax(0, 400px) minmax(0, 1fr);
  gap: 40px;
  align-items: start;
  margin-top: 8px;
}

.map-pane { position: sticky; top: 20px; max-height: calc(100vh - 40px); overflow-y: auto; padding: 2px; }

.map-head {
  font-family: 'DM Serif Display', Georgia, serif;
  font-weight: 400;
  font-size: clamp(28px, 3vw, 36px);
  line-height: 1.1;
  letter-spacing: -0.5px;
  color: var(--text);
}


.map-index { list-style: none; margin-top: 20px; display: grid; gap: 2px; }

.map-index-btn {
  display: flex;
  gap: 12px;
  align-items: baseline;
  width: 100%;
  text-align: left;
  font: inherit;
  font-size: 14px;
  color: var(--text);
  background: none;
  border: 0;
  border-radius: 6px;
  padding: 6px 8px;
  cursor: pointer;
}

.map-index-btn:hover, .map-index-btn:focus-visible { background: var(--crimson-subtle); }

.map-index-lab { flex: none; width: 4.2em; font-size: 12.5px; color: var(--text-muted); font-weight: 500; }

.map-nav { display: flex; gap: 8px; margin-bottom: 12px; }

.map-card {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: 12px;
  box-shadow: 0 30px 60px -36px rgba(44, 24, 16, 0.35);
  padding: 22px 24px;
  font-size: 14px;
}

.map-card-title { font-family: 'DM Serif Display', Georgia, serif; font-size: 22px; line-height: 1.25; }

.map-card-sub { margin-top: 2px; font-size: 12.5px; color: var(--text-muted); }

/* The route as a spine of dots, the home page's specimen card at reading length. */
.map-steps { list-style: none; position: relative; margin-top: 18px; }
.map-steps li { position: relative; padding: 0 0 14px 24px; }
.map-steps li:not(.end)::after {
  content: '';
  position: absolute;
  left: 4px;
  top: 14px;
  bottom: -8px;
  width: 1px;
  background: var(--border);
}
.map-steps li::before {
  content: '';
  position: absolute;
  left: 1px;
  top: 9px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--crimson);
}
.map-steps .tree-question { padding: 0; margin: 0; }
.map-steps .tree-ask { font-size: 14.5px; line-height: 1.45; color: var(--text); }
.map-steps li.focus .tree-question { background: var(--crimson-subtle); border-radius: 6px; padding: 6px 8px; margin: -6px -8px; }
.map-steps li.end { padding-bottom: 0; }
.map-steps li.end::before { background: var(--text-muted); width: 11px; height: 11px; left: -1px; top: 14px; }
.map-steps li.end.k-eligible::before { background: var(--success); }

.map-verdict { background: var(--bg); border-radius: 8px; padding: 9px 14px; }
.k-eligible .map-verdict { background: var(--success-bg); }
.map-verdict strong { display: block; font-size: 15px; }
.k-eligible .map-verdict strong { color: var(--success); }
.map-verdict span { font-size: 13px; color: var(--text-secondary); line-height: 1.5; }

.map-scene { overflow-x: auto; padding-bottom: 8px; }
.map-scene svg { height: auto; display: block; margin: 0 auto; }

.map-lane { cursor: pointer; outline: none; transition: opacity 0.35s; }
.has-pick .map-lane:not(.on) { opacity: 0.4; }
.map-lane:hover, .map-lane:focus-visible { opacity: 1 !important; }
.map-hit { fill: transparent; }
.map-lane:focus-visible .map-hit { fill: var(--crimson-subtle); }

.map-lab { fill: var(--text-muted); font: 500 12px Inter, system-ui, sans-serif; }
.map-lane.on .map-lab { fill: var(--crimson); font-weight: 700; }

.map-line {
  stroke: var(--border);
  stroke-width: 1.5;
}
.intro .map-line {
  stroke-dasharray: 1;
  animation: map-draw 0.9s cubic-bezier(0.2, 0.7, 0.2, 1) both;
  animation-delay: calc(var(--i) * 45ms);
}
.map-lane:hover .map-line { stroke: var(--crimson-light); }
.map-lane.on .map-line { stroke: var(--crimson); stroke-width: 3; stroke-linecap: round; }

.map-ramp { stroke: var(--border); stroke-width: 1.2; fill: none; }
.map-out { fill: var(--bg); stroke: var(--border); stroke-width: 1.2; }
.map-out.k-notYet { stroke: var(--warning, #b45309); }
.map-lane.on .map-ramp { stroke: var(--crimson-light); opacity: 0.55; }
.map-lane.on .map-out { stroke: var(--crimson-light); }

.map-node { fill: var(--bg); stroke: var(--text-muted); stroke-width: 1.2; transition: fill 0.25s, stroke 0.25s; }
.map-node:hover { stroke: var(--crimson); stroke-width: 2; }
.map-lane.on .map-node { fill: var(--crimson); stroke: var(--crimson); }
.map-node.focus { stroke-width: 5; stroke: var(--crimson-subtle); paint-order: stroke; }
.map-lane.on .map-node.focus { stroke: var(--crimson-light); stroke-width: 4; fill: var(--surface); }

.map-end { fill: var(--bg); stroke: var(--text-muted); stroke-width: 1.2; }
.map-end.k-eligible { fill: var(--success-bg); stroke: var(--success); }
.map-lane.on .map-end.k-eligible { fill: var(--success); }

@keyframes map-draw { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }

@media (prefers-reduced-motion: reduce) {
  .intro .map-line { animation: none; }
}

/* A narrow screen reads before it looks: the pane on top, the map under it, scrolling sideways. */
@media (max-width: 860px) {
  .rules-map { grid-template-columns: minmax(0, 1fr); gap: 24px; }
  .map-pane { position: static; max-height: none; overflow: visible; }
}
