/* ISO/IEC 42001 Initiation Workbook
   A technical standard you fill in: strict grid, hairline rules,
   clause references hung in a margin column, lavender only for
   where you are and what is selected. */

/* ---------- tokens ---------- */
:root {
  --paper: #FFFFF9;
  --paper-sunk: #F4F3EA;
  --paper-raised: #FBFAF2;
  --ink: #313638;
  --ink-2: #565B5E;
  --ink-3: #6B7073;
  --rule: #DEDCD1;
  --rule-strong: #BDBAAE;
  --lav: #6A57BC;
  --lav-ink: #57449F;
  --lav-tint: #EEEAF9;
  --lav-tint-2: #DFD8F4;
  --lav-line: #B9AEE6;
  --field: #FFFFF9;
  --field-hover: #FAF9F0;

  --ok: #2F7350;
  --ok-tint: #E2EFE6;
  --warn: #93600F;
  --warn-tint: #F6EBD3;
  --high: #A4511C;
  --high-tint: #F7E3D4;
  --bad: #AA3434;
  --bad-tint: #F6DEDC;

  --shadow: 0 1px 2px rgba(49, 54, 56, .06), 0 6px 18px rgba(49, 54, 56, .08);

  --font: "Public Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --margin: 104px;
  --side: 288px;
  --gutter: 40px;
  --radius: 4px;
  --ease: cubic-bezier(.16, 1, .3, 1);

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #313638;
    --paper-sunk: #2A2E30;
    --paper-raised: #373C3F;
    --ink: #F1F0E8;
    --ink-2: #C4C6C1;
    --ink-3: #A3A6A2;
    --rule: #464B4E;
    --rule-strong: #5E6467;
    --lav: #C7BCF6;
    --lav-ink: #D9D1FA;
    --lav-tint: #3F3D55;
    --lav-tint-2: #4C4868;
    --lav-line: #7F74B4;
    --field: #353A3C;
    --field-hover: #3A3F42;
    --ok: #8FCCA8;
    --ok-tint: #34473D;
    --warn: #E5BC72;
    --warn-tint: #4A4334;
    --high: #EFA77A;
    --high-tint: #4C3D34;
    --bad: #F09A95;
    --bad-tint: #4F3A3A;
    --shadow: 0 1px 2px rgba(20, 23, 24, .3), 0 8px 24px rgba(20, 23, 24, .35);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #313638;
  --paper-sunk: #2A2E30;
  --paper-raised: #373C3F;
  --ink: #F1F0E8;
  --ink-2: #C4C6C1;
  --ink-3: #A3A6A2;
  --rule: #464B4E;
  --rule-strong: #5E6467;
  --lav: #C7BCF6;
  --lav-ink: #D9D1FA;
  --lav-tint: #3F3D55;
  --lav-tint-2: #4C4868;
  --lav-line: #7F74B4;
  --field: #353A3C;
  --field-hover: #3A3F42;
  --ok: #8FCCA8;
  --ok-tint: #34473D;
  --warn: #E5BC72;
  --warn-tint: #4A4334;
  --high: #EFA77A;
  --high-tint: #4C3D34;
  --bad: #F09A95;
  --bad-tint: #4F3A3A;
  --shadow: 0 1px 2px rgba(20, 23, 24, .3), 0 8px 24px rgba(20, 23, 24, .35);
  color-scheme: dark;
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scrollbar-color: var(--rule-strong) transparent; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 15px/1.55 var(--font);
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}
::selection { background: var(--lav-tint-2); color: var(--ink); }
:focus-visible { outline: 2px solid var(--lav); outline-offset: 2px; border-radius: 2px; }
a { color: var(--lav-ink); text-underline-offset: 3px; text-decoration-thickness: 1px; }
b, strong { font-weight: 600; }
h1, h2, h3 { margin: 0; text-wrap: balance; letter-spacing: -0.015em; }
p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--rule-strong); border-radius: 10px; border: 3px solid var(--paper); }
::-webkit-scrollbar-track { background: transparent; }

.i { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: 12px; top: -48px; z-index: 50; background: var(--ink); color: var(--paper); padding: 8px 12px; border-radius: var(--radius); }
.skip:focus { top: 12px; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: var(--side) minmax(0, 1fr); min-height: 100vh; }
.topbar { display: none; }

.sidebar {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column;
  background: var(--paper-sunk);
  border-right: 1px solid var(--rule);
}
.brand { position: relative; padding: 26px 24px 20px; border-bottom: 1px solid var(--rule); display: grid; gap: 2px; }
.brand-std { font-size: 12px; font-weight: 600; letter-spacing: .02em; color: var(--ink-2); }
.brand-name { font-size: 17px; font-weight: 600; line-height: 1.25; letter-spacing: -0.01em; }
.brand .menu-close { display: none; position: absolute; right: 12px; top: 16px; }

.nav { flex: 1; overflow-y: auto; padding: 12px 12px 16px; }
.nav-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 1px; }
.nav-rule { height: 1px; background: var(--rule); margin: 8px 12px; }
.nav-item {
  position: relative;
  display: grid; grid-template-columns: 1fr auto; align-items: baseline; gap: 10px;
  padding: 8px 12px 10px;
  border-radius: var(--radius);
  color: var(--ink);
  text-decoration: none;
  font-size: 14px; line-height: 1.35;
  transition: background-color .18s var(--ease), color .18s var(--ease);
}
.nav-item:hover { background: var(--paper-raised); }
.nav-item.is-current { background: var(--lav-tint); color: var(--lav-ink); font-weight: 600; }
.nav-pct { font-size: 12px; color: var(--ink-3); font-weight: 500; }
.nav-item.is-current .nav-pct { color: var(--lav-ink); }
.nav-pct.is-full { color: var(--ok); font-weight: 600; }
.nav-meter { position: absolute; left: 12px; right: 12px; bottom: 4px; height: 2px; background: transparent; border-radius: 2px; overflow: hidden; }
.nav-meter > span { display: block; height: 100%; background: var(--lav-line); border-radius: 2px; transition: width .5s var(--ease); }
.nav-item:not(.is-current) .nav-meter > span { background: var(--rule-strong); }

.sidebar-foot { height: 68px; flex: none; border-top: 1px solid var(--rule); }
.theme-dock { position: fixed; left: 16px; bottom: 15px; z-index: 35; }
.theme-switch {
  display: inline-grid; grid-template-columns: 1fr 1fr;
  padding: 3px; gap: 2px;
  background: var(--paper); border: 1px solid var(--rule); border-radius: 8px;
}
.theme-switch button {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border: 0; border-radius: 6px;
  background: transparent; color: var(--ink-2); font-size: 13px; font-weight: 500; cursor: pointer;
  transition: background-color .18s var(--ease), color .18s var(--ease);
}
.theme-switch button .i { width: 16px; height: 16px; }
.theme-switch button:hover { color: var(--ink); }
.theme-switch button[aria-pressed="true"] { background: var(--lav-tint); color: var(--lav-ink); }

.main { min-width: 0; outline: none; }
#view { padding: 40px var(--gutter) 96px; max-width: 1480px; margin: 0 auto; }

/* ---------- the sheet grid: margin column + body ---------- */
.sheet-head, .sec { display: grid; grid-template-columns: var(--margin) minmax(0, 1fr); column-gap: 24px; }
.margin { position: relative; }
.ref {
  display: block; position: sticky; top: 20px;
  font-size: 13px; font-weight: 600; color: var(--ink-2);
  padding-top: 4px; text-align: right; letter-spacing: .01em;
  line-height: 1.3;
}
.sheet-head { padding-bottom: 28px; border-bottom: 1px solid var(--ink); }
.sheet-head .ref { color: var(--lav-ink); padding-top: 34px; }
.std { font-size: 13px; font-weight: 600; color: var(--ink-2); margin-bottom: 6px; }
.sheet-title h1 { font-size: clamp(26px, 2.6vw, 34px); line-height: 1.15; font-weight: 700; letter-spacing: -0.022em; }
.lede { margin-top: 12px; max-width: 72ch; color: var(--ink-2); font-size: 15.5px; }

.sec { padding: 40px 0 36px; border-bottom: 1px solid var(--rule); }
.sec:last-of-type { border-bottom: 0; }
.sec-body { min-width: 0; }
.sec-body > h2 { font-size: 19px; font-weight: 650; line-height: 1.3; margin-bottom: 12px; }
.sec-intro { max-width: 72ch; color: var(--ink-2); margin-bottom: 16px; }

/* ---------- toolbar ---------- */
.toolbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px 16px;
  margin-left: calc(var(--margin) + 24px);
  padding: 12px 0;
  background: var(--paper);
  border-bottom: 1px solid var(--rule);
}
.tb-group { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.saved { font-size: 13px; color: var(--ink-3); margin-left: 8px; }
.saved.is-warn { color: var(--bad); }

.btn {
  display: inline-flex; align-items: center; gap: 7px;
  height: 34px; padding: 0 13px;
  border: 1px solid var(--rule-strong); border-radius: var(--radius);
  background: var(--paper); color: var(--ink);
  font-size: 13.5px; font-weight: 500; cursor: pointer; white-space: nowrap;
  transition: background-color .15s var(--ease), border-color .15s var(--ease), color .15s var(--ease);
}
.btn .i { width: 16px; height: 16px; }
.btn:hover { background: var(--paper-raised); border-color: var(--ink-3); }
.btn:active { background: var(--paper-sunk); }
.btn-quiet { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn-quiet:hover { background: var(--paper-sunk); border-color: transparent; color: var(--ink); }
.btn[aria-pressed="true"] { background: var(--lav-tint); color: var(--lav-ink); }
.btn.danger:hover { color: var(--bad); background: var(--bad-tint); }

.icon-btn {
  display: inline-grid; place-items: center; width: 36px; height: 36px;
  border: 0; border-radius: var(--radius); background: transparent; color: var(--ink-2); cursor: pointer;
}
.icon-btn:hover { background: var(--paper-sunk); color: var(--ink); }
.icon-btn.sm { width: 28px; height: 28px; }
.icon-btn.sm .i { width: 15px; height: 15px; }

/* ---------- example disclosure ---------- */
.example { margin: 0 0 18px; max-width: 110ch; }
.example summary {
  display: inline-flex; align-items: center; gap: 6px;
  list-style: none; cursor: pointer;
  font-size: 13px; font-weight: 600; color: var(--lav-ink);
  padding: 2px 0;
}
.example summary::-webkit-details-marker { display: none; }
.example summary::before {
  content: ""; width: 7px; height: 7px;
  border-right: 1.6px solid currentColor; border-bottom: 1.6px solid currentColor;
  transform: rotate(-45deg); transition: transform .2s var(--ease); margin-right: 2px;
}
.example[open] summary::before { transform: rotate(45deg) translate(-2px, -1px); }
.example summary:hover span { text-decoration: underline; text-underline-offset: 3px; }
.example p {
  margin-top: 8px; padding: 12px 16px;
  background: var(--lav-tint); border-radius: var(--radius);
  font-size: 14px; line-height: 1.6; color: var(--ink);
}
.example p b { color: var(--lav-ink); }

/* ---------- form controls ---------- */
.fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 18px 24px; max-width: 1040px; }
.fields.is-stacked { grid-template-columns: 1fr; max-width: 860px; }
.field { display: grid; gap: 6px; align-content: start; }
.field.is-wide { grid-column: 1 / -1; }
.field label { font-size: 13px; font-weight: 600; color: var(--ink); }
.hint { font-size: 13px; color: var(--ink-3); margin-top: -4px; }

.field input, .field select, .field textarea, .prose-input {
  width: 100%; min-height: 38px;
  padding: 8px 11px;
  border: 1px solid var(--rule-strong); border-radius: var(--radius);
  background: var(--field); color: var(--ink);
  transition: border-color .15s var(--ease), background-color .15s var(--ease), box-shadow .15s var(--ease);
}
.field textarea, .prose-input { resize: vertical; line-height: 1.55; overflow: hidden; }
.prose-input { max-width: 860px; display: block; font-size: 15px; padding: 12px 14px; }
.field input:hover, .field select:hover, .field textarea:hover, .prose-input:hover { border-color: var(--ink-3); }
.field input:focus, .field select:focus, .field textarea:focus, .prose-input:focus {
  outline: none; border-color: var(--lav); box-shadow: 0 0 0 3px var(--lav-tint-2);
}
::placeholder { color: var(--ink-3); opacity: 1; }
/* template text: greyed, read-only by nature, gone as soon as the field is clicked */
.has-template::placeholder { color: var(--ink-3); font-style: italic; }
input:focus::placeholder, textarea:focus::placeholder { color: transparent; }
input[type="date"] { min-width: 0; }
input[type="date"]::-webkit-calendar-picker-indicator { opacity: .6; cursor: pointer; }
:root[data-theme="dark"] input[type="date"]::-webkit-calendar-picker-indicator { filter: invert(.9); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) input[type="date"]::-webkit-calendar-picker-indicator { filter: invert(.9); } }
select { cursor: pointer; }
select option { background: var(--paper); color: var(--ink); }

.text-tools { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 16px; max-width: 860px; margin-top: 6px; }
.placeholder-warn { font-size: 13px; color: var(--warn); }
.use-template { margin-left: auto; height: 30px; font-size: 13px; color: var(--lav-ink); }
.use-template[hidden] { display: none; }

.checks { border: 0; padding: 0; margin: 0 0 16px; display: grid; gap: 4px; max-width: 860px; }
.checks legend { font-size: 13px; font-weight: 600; margin-bottom: 8px; padding: 0; }
.checks.is-inline { display: flex; flex-wrap: wrap; gap: 6px 10px; }
.checks.is-inline legend { width: 100%; }
.check {
  position: relative; display: grid; grid-template-columns: 18px 1fr; gap: 12px; align-items: start;
  padding: 9px 12px; border-radius: var(--radius); cursor: pointer;
  transition: background-color .15s var(--ease);
}
.checks.is-inline .check { border: 1px solid var(--rule-strong); padding: 7px 14px 7px 10px; }
.check:hover { background: var(--paper-sunk); }
.check input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.check .box {
  width: 18px; height: 18px; margin-top: 2px;
  border: 1.5px solid var(--ink-3); border-radius: 3px; background: var(--field);
  display: grid; place-items: center;
  transition: background-color .15s var(--ease), border-color .15s var(--ease);
}
.check.is-radio .box { border-radius: 50%; }
.check input:checked + .box { background: var(--lav); border-color: var(--lav); }
.check input:checked + .box::after {
  content: ""; width: 9px; height: 5px; margin-top: -2px;
  border-left: 2px solid var(--paper); border-bottom: 2px solid var(--paper); transform: rotate(-45deg);
}
.check.is-radio input:checked + .box::after { width: 6px; height: 6px; margin: 0; border: 0; background: var(--paper); border-radius: 50%; transform: none; }
.check input:focus-visible + .box { outline: 2px solid var(--lav); outline-offset: 2px; }
.check:has(input:checked) { background: var(--lav-tint); }
.checks.is-inline .check:has(input:checked) { border-color: var(--lav-line); }
.check .desc { color: var(--ink-2); }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--rule-strong); border-radius: var(--radius); background: var(--field); }
.table-wrap.is-legend { max-width: 860px; background: transparent; }
.grid { width: 100%; border-collapse: collapse; font-size: 14px; }
.grid th, .grid td { border-bottom: 1px solid var(--rule); border-right: 1px solid var(--rule); vertical-align: top; text-align: left; }
.grid th:last-child, .grid td:last-child { border-right: 0; }
.grid tbody tr:last-child > * { border-bottom: 0; }
.grid thead th {
  position: sticky; top: 0;
  background: var(--paper-sunk); color: var(--ink);
  font-size: 12.5px; font-weight: 600; line-height: 1.3;
  padding: 10px 10px; border-bottom: 1px solid var(--rule-strong);
}
.legend td, .legend th { padding: 9px 12px; }
.legend td { color: var(--ink-2); }

.grid td > input, .grid td > select, .grid td > textarea,
.grid .mark-cell > select {
  display: block; width: 100%; min-height: 40px;
  border: 0; border-radius: 0; background: transparent;
  padding: 10px 10px; line-height: 1.45;
}
.grid td > textarea { resize: none; overflow: hidden; }
.grid td:has(input:hover, select:hover, textarea:hover) { background: var(--field-hover); }
.grid td:focus-within { background: var(--lav-tint); box-shadow: inset 0 0 0 1.5px var(--lav); }
.grid td > input:focus, .grid td > select:focus, .grid td > textarea:focus, .grid .mark-cell > select:focus { outline: none; }

.w-xs { min-width: 84px; width: 84px; }
.w-s { min-width: 140px; }
.w-m { min-width: 200px; }
.w-l { min-width: 280px; }
.w-ro { min-width: 300px; }

.grid td.ro { padding: 10px 12px; color: var(--ink-2); line-height: 1.5; background: var(--paper); min-width: 300px; max-width: 520px; }
.grid td.computed { padding: 10px; font-weight: 600; background: var(--paper); }
.grid .row-tools { width: 92px; min-width: 92px; padding: 6px; text-align: center; background: var(--paper); }
.grid thead th.row-tools { padding: 10px 8px; text-align: center; white-space: nowrap; background: var(--paper-sunk); }
.grid .row-tools .icon-btn { opacity: .7; }
.grid tr:hover .row-tools .icon-btn, .grid .row-tools .icon-btn:focus-visible { opacity: 1; }
.grid .row-tools .icon-btn:hover { color: var(--bad); background: var(--bad-tint); }

/* register: the reference column is the margin of the table */
.register .ref-col {
  width: 84px; min-width: 84px; padding: 11px 12px;
  font-weight: 600; font-size: 13px; color: var(--ink);
  background: var(--paper-sunk); white-space: nowrap;
  position: sticky; left: 0; z-index: 1;
}
.register thead .ref-col { z-index: 2; }
.register .ref-col.is-wide { width: 220px; min-width: 200px; white-space: normal; line-height: 1.4; }
.register tr.group th {
  padding: 18px 12px 8px; background: var(--paper);
  font-size: 13px; font-weight: 650; color: var(--lav-ink); letter-spacing: .005em;
  border-bottom: 1px solid var(--rule-strong);
  text-align: left; position: sticky; left: 0;
}
.register tbody tr.group:first-child th { padding-top: 12px; }

.add-row { margin-top: 8px; }
.table-block { max-width: 100%; }

/* ---------- status marks: filled, half, hollow, struck ---------- */
.mark-cell { display: flex; align-items: center; gap: 0; position: relative; }
.mark-cell > .mark { margin-left: 10px; }
.mark-cell > select { padding-left: 8px !important; }
.mark-cell.is-static { display: inline-flex; gap: 8px; }
.mark-cell.is-static > .mark { margin-left: 0; }
.mark {
  flex: none; width: 12px; height: 12px; border-radius: 2px;
  border: 1.5px solid var(--rule-strong); background: transparent; position: relative;
}
[data-mark="done"] > .mark { background: var(--ok); border-color: var(--ok); }
[data-mark="part"] > .mark { border-color: var(--ok); background: linear-gradient(90deg, var(--ok) 50%, transparent 50%); }
[data-mark="warn"] > .mark { border-color: var(--warn); background: linear-gradient(90deg, var(--warn) 50%, transparent 50%); }
[data-mark="open"] > .mark { border-color: var(--ink-3); }
[data-mark="fail"] > .mark { border-color: var(--bad); }
[data-mark="fail"] > .mark::after { content: ""; position: absolute; left: -3px; right: -3px; top: 50%; height: 1.5px; background: var(--bad); transform: rotate(-45deg); }
[data-mark="na"] > .mark { border-color: transparent; }
[data-mark="na"] > .mark::after { content: ""; position: absolute; left: 1px; right: 1px; top: 50%; height: 1.5px; margin-top: -.75px; background: var(--ink-3); }
[data-mark="empty"] > .mark { border-style: dashed; }

/* ---------- risk levels ---------- */
.lvl { display: inline-block; padding: 2px 8px; border-radius: 3px; font-size: 12.5px; font-weight: 600; line-height: 1.5; }
.lvl-low { background: var(--ok-tint); color: var(--ok); }
.lvl-medium { background: var(--warn-tint); color: var(--warn); }
.lvl-high { background: var(--high-tint); color: var(--high); }
.lvl-critical { background: var(--bad-tint); color: var(--bad); }

.matrix { border-collapse: separate; border-spacing: 3px; font-size: 13px; }
.table-wrap.is-matrix { border: 0; background: transparent; }
.matrix th { font-weight: 500; color: var(--ink-2); padding: 6px 10px; text-align: center; line-height: 1.25; }
.matrix th b { display: block; color: var(--ink); font-size: 14px; }
.matrix tbody th { text-align: right; min-width: 110px; }
.matrix .corner { font-size: 12px; color: var(--ink-3); vertical-align: bottom; padding: 6px 10px; text-align: right; }
.matrix td { width: 104px; height: 58px; text-align: center; border-radius: 3px; line-height: 1.2; }
.matrix td b { display: block; font-size: 17px; }
.matrix td span { font-size: 12px; font-weight: 500; }
.cell-low { background: var(--ok-tint); color: var(--ok); }
.cell-medium { background: var(--warn-tint); color: var(--warn); }
.cell-high { background: var(--high-tint); color: var(--high); }
.cell-critical { background: var(--bad-tint); color: var(--bad); }

/* ---------- tallies ---------- */
.tally { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 18px; margin-top: 12px; font-size: 13px; color: var(--ink-2); }
.tally:empty { display: none; }
.tally-total { font-weight: 600; color: var(--ink); padding-right: 18px; border-right: 1px solid var(--rule-strong); }
.tally-item { display: inline-flex; align-items: center; gap: 8px; }
.tally-item b { color: var(--ink); min-width: 1ch; }
.tally-item.is-zero { opacity: .55; }

/* ---------- How to use ---------- */
.steps-plain { margin: 0; padding: 0; list-style: none; counter-reset: s; display: grid; gap: 12px; max-width: 76ch; }
.steps-plain li { counter-increment: s; position: relative; padding-left: 38px; }
.steps-plain li::before {
  content: counter(s); width: 24px; height: 24px; border-radius: 50%;
  display: grid; place-items: center; font-size: 12.5px; font-weight: 600;
  background: var(--lav-tint); color: var(--lav-ink);
  position: absolute; left: 0; top: 0;
}
.aside-note { margin-top: 18px; max-width: 76ch; font-size: 14px; color: var(--ink-2); padding-top: 12px; border-top: 1px solid var(--rule); }
.prose p { max-width: 72ch; }

.defs { margin: 0; display: grid; max-width: 860px; }
.defs > div { display: grid; grid-template-columns: minmax(180px, 260px) 1fr; gap: 24px; padding: 12px 0; border-top: 1px solid var(--rule); }
.defs > div:last-child { border-bottom: 1px solid var(--rule); }
.defs dt { font-weight: 600; }
.defs dd { margin: 0; color: var(--ink-2); }
.defs.compact > div { grid-template-columns: minmax(160px, 220px) 1fr; padding: 9px 0; gap: 18px; }

.index-list { list-style: none; margin: 0; padding: 0; max-width: 980px; border-top: 1px solid var(--rule); }
.index-list a {
  display: grid; grid-template-columns: 150px minmax(200px, 300px) 1fr 20px; gap: 20px; align-items: baseline;
  padding: 12px 8px; border-bottom: 1px solid var(--rule);
  color: var(--ink); text-decoration: none;
  transition: background-color .15s var(--ease);
}
.index-list a:hover { background: var(--lav-tint); }
.index-list a:hover .i { color: var(--lav-ink); transform: translateX(3px); }
.index-list .i { width: 16px; height: 16px; color: var(--ink-3); align-self: center; transition: transform .2s var(--ease), color .2s var(--ease); }
.idx-ref { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.idx-title { font-weight: 600; }
.idx-what { color: var(--ink-2); font-size: 14px; }

.roadmap { list-style: none; margin: 4px 0 0; padding: 0; max-width: 900px; }
.roadmap > li { display: grid; grid-template-columns: 76px 1fr; gap: 20px; padding: 18px 0; border-top: 1px solid var(--rule); }
.roadmap > li:last-child { border-bottom: 1px solid var(--rule); }
.step-no { font-size: 13px; font-weight: 600; color: var(--lav-ink); padding-top: 2px; }
.roadmap h3 { font-size: 16px; font-weight: 650; margin-bottom: 6px; }
.roadmap p { color: var(--ink-2); max-width: 72ch; }
.roadmap ul { margin: 6px 0 0; padding-left: 18px; color: var(--ink-2); display: grid; gap: 3px; }
.roadmap ul li::marker { color: var(--lav); }
.roadmap .defs { margin-top: 6px; }

.howto .sheet-head .ref { padding-top: 6px; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 40;
  transform: translate(-50%, 16px); opacity: 0; pointer-events: none;
  background: var(--ink); color: var(--paper);
  padding: 10px 16px; border-radius: 6px; font-size: 14px; box-shadow: var(--shadow);
  transition: opacity .25s var(--ease), transform .35s var(--ease);
  max-width: calc(100vw - 32px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.print-foot { display: none; }

/* ---------- motion: the page settles in once ---------- */
@media (prefers-reduced-motion: no-preference) {
  .sheet { animation: settle .45s var(--ease) both; }
  @keyframes settle { from { transform: translateY(8px); } to { transform: none; } }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0s !important; animation: none !important; }
}

/* ---------- responsive ---------- */
@media (max-width: 1180px) {
  :root { --margin: 72px; --gutter: 28px; }
}
@media (max-width: 960px) {
  :root { --side: 300px; }
  .shell { grid-template-columns: minmax(0, 1fr); }
  .topbar {
    display: flex; align-items: center; gap: 8px;
    position: sticky; top: 0; z-index: 20;
    height: 52px; padding: 0 8px;
    background: var(--paper-sunk); border-bottom: 1px solid var(--rule);
  }
  .topbar-title { font-weight: 600; font-size: 15px; }
  .sidebar {
    position: fixed; z-index: 30; left: 0; top: 0; bottom: 0; width: min(var(--side), 86vw);
    transform: translateX(-102%); transition: transform .3s var(--ease); box-shadow: var(--shadow);
  }
  body.menu-open .sidebar { transform: none; }
  .brand .menu-close { display: inline-grid; }
  .scrim { position: fixed; inset: 0; z-index: 25; background: rgba(42, 46, 48, .45); }
  .theme-dock .theme-switch { box-shadow: var(--shadow); }
  #view { padding-bottom: 120px; }
  .toolbar { top: 52px; }
}
@media (max-width: 720px) {
  :root { --gutter: 16px; }
  #view { padding-top: 24px; }
  .sheet-head, .sec { grid-template-columns: minmax(0, 1fr); }
  .margin { order: -1; }
  .ref { position: static; text-align: left; padding: 0 0 6px; }
  .sheet-head .ref { padding-top: 0; }
  .toolbar { margin-left: 0; }
  .saved { width: 100%; margin: 4px 0 0; }
  .sec { padding: 28px 0; }
  .defs > div, .defs.compact > div { grid-template-columns: 1fr; gap: 2px; }
  .index-list a { grid-template-columns: 1fr 16px; gap: 2px 12px; }
  .idx-ref, .idx-title, .idx-what { grid-column: 1; }
  .index-list .i { grid-column: 2; grid-row: 1 / span 3; }
  .roadmap > li { grid-template-columns: 1fr; gap: 4px; }
  .btn { height: 36px; }
}

/* ---------- print: a clean paper copy ---------- */
@media print {
  :root, :root[data-theme="dark"] {
    --paper: #FFFFF9; --paper-sunk: #F4F3EA; --paper-raised: #FBFAF2; --field: #FFFFF9;
    --ink: #313638; --ink-2: #4A4F52; --ink-3: #6B7073; --rule: #CFCCC0; --rule-strong: #A9A69A;
    --lav: #6A57BC; --lav-ink: #57449F; --lav-tint: #F1EEFA;
    color-scheme: light;
  }
  @page { margin: 14mm 12mm; }
  body { font-size: 10.5pt; background: #FFFFF9; }
  .sidebar, .topbar, .toolbar, .theme-dock, .scrim, .add-row, .row-tools, .toast, .skip, .placeholder-warn, .example { display: none !important; }
  .shell { display: block; }
  #view { padding: 0; max-width: none; }
  .sheet { animation: none; }
  .sheet-head, .sec { grid-template-columns: 56px 1fr; column-gap: 14px; }
  .ref { position: static; }
  .sec { padding: 18px 0; break-inside: auto; }
  .sec-body > h2 { break-after: avoid; }
  .table-wrap { overflow: visible; border-color: var(--rule-strong); }
  .grid { font-size: 9pt; }
  .grid thead { display: table-header-group; }
  .grid tr { break-inside: avoid; }
  .grid thead th { position: static; }
  .register .ref-col, .register tr.group th { position: static; }
  .grid td.ro { max-width: none; min-width: 0; }
  .w-xs, .w-s, .w-m, .w-l, .w-ro { min-width: 0; width: auto; }
  .grid td > input, .grid td > select, .grid td > textarea, .grid .mark-cell > select { min-height: 0; padding: 6px; }
  select { appearance: none; -webkit-appearance: none; }
  textarea { overflow: visible; }
  .print-foot { display: block; margin-top: 18px; padding-top: 8px; border-top: 1px solid var(--rule); font-size: 8.5pt; color: var(--ink-3); }
}
