/* Layout: a phone-first ward handbook.  Teal app bar and bottom tabs; each topic carries a coloured index tile,
   like the thumb index of a pocket handbook; protocols read as flowchart boxes joined by arrows.  From 1000px wide
   the bottom tabs move into the bar and a guideline index sits on the left. */
:root {
  --paper: #f3f6f5;
  --sheet: #ffffff;
  --sheet-2: #e8efed;
  --ink: #142628;
  --ink-2: #485c5d;
  --ink-3: #66797a;
  --rule: #d3dedb;
  --rule-strong: #95aba7;
  --scrub: #0b6b66;
  --scrub-hover: #08534f;
  --scrub-ink: #ffffff;
  --scrub-soft: #dcefeb;
  --bar: #0b5f5b;
  --bar-ink: #ffffff;
  --bar-ink-2: #c3e5df;
  --bar-hi: rgba(255, 255, 255, 0.14);
  --alarm: #b3261e;
  --alarm-soft: #fbe8e6;
  --alarm-line: #e7a59f;
  --note: #6b4d00;
  --note-soft: #fff4d6;
  --note-line: #e3c97f;
  --mark: #ffe08a;
  --focus: #1f6feb;
  --shadow: 0 1px 2px rgba(20, 38, 40, 0.06), 0 2px 8px rgba(20, 38, 40, 0.05);
  --tab-0: #2f7d6d;
  --tab-1: #b4532a;
  --tab-2: #3b6fb6;
  --tab-3: #9b3d6b;
  --tab-4: #8f6c0e;
  --tab-5: #4d7a2a;
  --tab-6: #6b57a8;
  --tab-7: #22769a;
  --tab-8: #8c5a3c;
  --tab-ink: #ffffff;
  --radius: 10px;
  --font-display: "Literata", Georgia, "Times New Roman", serif;
  --font-body: "Atkinson Hyperlegible", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, Consolas, monospace;
  --gutter-l: max(16px, env(safe-area-inset-left, 0px));
  --gutter-r: max(16px, env(safe-area-inset-right, 0px));
  --bar-h: 60px;
  --tabbar-h: 66px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #0d1718;
    --sheet: #142224;
    --sheet-2: #1b2d2f;
    --ink: #e3eeec;
    --ink-2: #a9bdba;
    --ink-3: #849a97;
    --rule: #26393b;
    --rule-strong: #4f6a67;
    --scrub: #5cc6b8;
    --scrub-hover: #84d7cc;
    --scrub-ink: #052220;
    --scrub-soft: #173b38;
    --bar: #0f2e2c;
    --bar-ink: #e3f3f0;
    --bar-ink-2: #8fc7bf;
    --bar-hi: rgba(255, 255, 255, 0.1);
    --alarm: #ff9b91;
    --alarm-soft: #3a1a18;
    --alarm-line: #7a3530;
    --note: #f0cf7a;
    --note-soft: #30270f;
    --note-line: #6b5520;
    --mark: #6b5a12;
    --focus: #7aa7ff;
    --shadow: none;
    --tab-0: #3f9e8a;
    --tab-1: #c86a40;
    --tab-2: #5486cc;
    --tab-3: #b45584;
    --tab-4: #a8851f;
    --tab-5: #64933c;
    --tab-6: #8571c0;
    --tab-7: #3a91b8;
    --tab-8: #a5714f;
    --tab-ink: #ffffff;
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.5 var(--font-body);
}
img { max-width: 100%; }
[hidden] { display: none !important; }
a { color: var(--scrub); }
a:hover { color: var(--scrub-hover); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
h1, h2, h3 { text-wrap: balance; }
button { font: inherit; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.ic { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.ic.fill { fill: currentColor; }

/* App bar */
.bar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--bar);
  color: var(--bar-ink);
  padding-top: env(safe-area-inset-top, 0px);
}
.bar-in {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: var(--bar-h);
  max-width: 1320px;
  margin: 0 auto;
  padding-left: var(--gutter-l);
  padding-right: var(--gutter-r);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1 1 auto; color: inherit; text-decoration: none; }
.brand:hover { color: inherit; }
.mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  flex: none;
  border-radius: 10px;
  background: var(--bar-ink);
  color: var(--bar);
  font: 700 15px/1 var(--font-display);
}
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-short { font-size: 12px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--bar-ink-2); }
.brand-name { font: 600 17px/1.25 var(--font-display); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topnav { display: none; gap: 2px; }
.topnav a, .bar-link {
  color: var(--bar-ink-2);
  text-decoration: none;
  padding: 8px 12px;
  border-radius: 8px;
  font-weight: 700;
  font-size: 15px;
  white-space: nowrap;
}
.topnav a:hover, .bar-link:hover { color: var(--bar-ink); background: var(--bar-hi); }
.topnav a[aria-current="page"], .bar-link[aria-current="page"] { color: var(--bar-ink); background: var(--bar-hi); }
.bar-actions { display: flex; align-items: center; gap: 4px; flex: none; }
.bar-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 10px;
  color: var(--bar-ink);
}
.bar-icon:hover { color: var(--bar-ink); background: var(--bar-hi); }
.bar-icon .ic { width: 22px; height: 22px; }

/* Bottom tabs (phone) */
.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  background: var(--sheet);
  border-top: 1px solid var(--rule);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  padding-left: env(safe-area-inset-left, 0px);
  padding-right: env(safe-area-inset-right, 0px);
}
.tabbar a {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 7px 2px 6px;
  color: var(--ink-3);
  text-decoration: none;
  font-size: 12px;
  font-weight: 700;
}
.tabbar a .ic { width: 24px; height: 24px; padding: 3px 14px; border-radius: 14px; box-sizing: content-box; }
.tabbar a[aria-current="page"] { color: var(--scrub); }
.tabbar a[aria-current="page"] .ic { background: var(--scrub-soft); }

/* Page layout */
.layout { max-width: 1320px; margin: 0 auto; }
.index { display: none; }
.main {
  min-width: 0;
  padding-top: 24px;
  padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px) + 32px);
  padding-left: var(--gutter-l);
  padding-right: var(--gutter-r);
}
.main:focus { outline: none; }
.page { max-width: 780px; margin: 0 auto; display: flex; flex-direction: column; gap: 28px; }
.page.wide { max-width: 1240px; }
.page.narrow { max-width: 440px; }
.stack { display: flex; flex-direction: column; gap: 28px; }

@media (min-width: 1000px) {
  .topnav { display: flex; }
  .tabbar { display: none; }
  .layout { display: grid; grid-template-columns: 290px minmax(0, 1fr); }
  .layout.no-index { grid-template-columns: minmax(0, 1fr); }
  .layout.no-index .index { display: none; }
  .index {
    display: block;
    position: sticky;
    top: calc(var(--bar-h) + env(safe-area-inset-top, 0px));
    height: calc(100vh - var(--bar-h) - env(safe-area-inset-top, 0px));
    overflow-y: auto;
    border-right: 1px solid var(--rule);
    padding: 22px 14px 40px var(--gutter-l);
  }
  .main { padding-top: 32px; padding-bottom: 64px; }
}

/* Type */
.display { font: 700 clamp(28px, 6vw, 38px)/1.12 var(--font-display); letter-spacing: -0.01em; margin: 0; }
.page-title { font: 700 clamp(26px, 5vw, 32px)/1.15 var(--font-display); margin: 0; }
.sec { font: 600 21px/1.25 var(--font-display); margin: 0 0 12px; }
.eyebrow { margin: 0; font-size: 13px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-3); }
.lede { margin: 0; font-size: 18px; color: var(--ink-2); max-width: 62ch; }
.muted { color: var(--ink-2); }
.small { font-size: 14px; }
.empty { margin: 0; color: var(--ink-2); }
.page-head { display: flex; flex-direction: column; gap: 8px; }
.page-head p { margin: 0; color: var(--ink-2); max-width: 65ch; }
.back {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  align-self: flex-start;
  font-weight: 700;
  font-size: 15px;
  text-decoration: none;
  padding: 4px 0;
}
.back .ic { width: 18px; height: 18px; }

/* Search */
.searchbox { position: relative; }
.searchbox .ic { position: absolute; left: 15px; top: 50%; transform: translateY(-50%); color: var(--ink-3); pointer-events: none; }
.searchbox input[type="search"] {
  width: 100%;
  font: inherit;
  font-size: 17px;
  padding: 14px 18px 14px 46px;
  border: 1px solid var(--rule-strong);
  border-radius: 999px;
  background: var(--sheet);
  color: var(--ink);
  box-shadow: var(--shadow);
  -webkit-appearance: none;
  appearance: none;
}
.searchbox input::placeholder { color: var(--ink-3); }
.results { display: flex; flex-direction: column; gap: 24px; }
.result-group h2 { margin: 0 0 8px; }
.snippet { display: block; color: var(--ink-2); font-size: 14px; margin-top: 2px; }
mark { background: var(--mark); color: inherit; border-radius: 2px; padding: 0 1px; }

/* Home */
.home-head { display: flex; flex-direction: column; gap: 14px; padding-top: 4px; }
.home-pic { margin: 0; }
.home-pic img { display: block; width: 100%; max-height: 360px; object-fit: cover; border-radius: 14px; }

/* Thumb-index tiles for topics */
.thumb {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  flex: none;
  border-radius: 8px;
  background: var(--tab);
  color: var(--tab-ink);
  font: 700 13px/1 var(--font-body);
  letter-spacing: 0.03em;
}
.thumb.sm { width: 24px; height: 24px; border-radius: 6px; font-size: 10px; }
.c0 { --tab: var(--tab-0); } .c1 { --tab: var(--tab-1); } .c2 { --tab: var(--tab-2); }
.c3 { --tab: var(--tab-3); } .c4 { --tab: var(--tab-4); } .c5 { --tab: var(--tab-5); }
.c6 { --tab: var(--tab-6); } .c7 { --tab: var(--tab-7); } .c8 { --tab: var(--tab-8); }

.topic-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.topic-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--sheet);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  color: var(--ink);
  text-decoration: none;
  min-height: 64px;
}
.topic-card:hover { color: var(--ink); border-color: var(--rule-strong); }
.topic-text { display: flex; flex-direction: column; min-width: 0; }
.topic-name { font-weight: 700; line-height: 1.3; }
.topic-count { font-size: 14px; color: var(--ink-3); }

/* Lists of rows */
.rows { list-style: none; margin: 0; padding: 0; background: var(--sheet); border: 1px solid var(--rule); border-radius: var(--radius); overflow: hidden; }
.rows > li + li { border-top: 1px solid var(--rule); }
.row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 52px;
  padding: 12px 14px;
  color: var(--ink);
  text-decoration: none;
}
a.row:hover { color: var(--ink); background: var(--sheet-2); }
.row-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.row-title { font-weight: 400; }
.row .chev { color: var(--ink-3); width: 18px; height: 18px; }
.tag {
  flex: none;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--ink-2);
  border: 1px solid var(--rule-strong);
  border-radius: 6px;
  padding: 1px 6px;
}

.topic-sec { display: flex; flex-direction: column; gap: 10px; scroll-margin-top: calc(var(--bar-h) + 16px); }
.topic-h { display: flex; align-items: center; gap: 10px; margin: 0; font: 600 21px/1.25 var(--font-display); }

/* Updates */
.updates { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.updates li { display: grid; grid-template-columns: 92px minmax(0, 1fr); gap: 12px; padding: 10px 0; border-top: 1px solid var(--rule); }
.updates li:first-child { border-top: 0; }
.updates time { font-size: 14px; color: var(--ink-3); font-variant-numeric: tabular-nums; padding-top: 1px; }
.upd-what { font-size: 14px; font-weight: 700; color: var(--ink-2); }
.upd-note { margin: 2px 0 0; font-size: 14px; color: var(--ink-2); }

/* Index sidebar */
.ix-topic { margin-bottom: 18px; }
.ix-h { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 14px; color: var(--ink); text-decoration: none; padding: 4px 6px; }
.ix-topic ul { list-style: none; margin: 4px 0 0; padding: 0; }
.ix-topic li a {
  display: block;
  padding: 6px 8px 6px 38px;
  font-size: 14px;
  line-height: 1.35;
  color: var(--ink-2);
  text-decoration: none;
  border-radius: 8px;
}
.ix-topic li a:hover { background: var(--sheet-2); color: var(--ink); }
.ix-topic li a[aria-current="page"] { background: var(--scrub-soft); color: var(--ink); font-weight: 700; }
.index .eyebrow { padding: 0 6px 10px; }

/* Guideline page */
.guide-head { display: flex; flex-direction: column; gap: 12px; }
.guide-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; font-size: 14px; color: var(--ink-2); }
.chip { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; color: var(--ink); text-decoration: none; }
.chip:hover { color: var(--ink); text-decoration: underline; }
.guide-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.callout { border-radius: var(--radius); padding: 12px 14px; border: 1px solid; }
.callout p { margin: 0; }
.callout p + p { margin-top: 8px; }
.callout.warn { background: var(--alarm-soft); border-color: var(--alarm-line); color: var(--ink); }
.callout.warn strong { color: var(--alarm); }
.callout.note { background: var(--note-soft); border-color: var(--note-line); color: var(--ink); }
.callout.plain { background: var(--sheet); border-color: var(--rule); }

/* Protocol body: flowchart boxes */
.doc { display: flex; flex-direction: column; gap: 30px; }
.flow { display: flex; flex-direction: column; }
.flow-h { font: 700 19px/1.3 var(--font-display); text-align: center; margin: 0 0 12px; }
.box {
  position: relative;
  background: var(--sheet);
  border: 1.5px solid var(--rule-strong);
  border-radius: 12px;
  padding: 14px 16px;
  overflow-wrap: anywhere;
}
.box + .box { margin-top: 32px; }
.box + .box::before {
  content: "";
  position: absolute;
  left: 50%;
  top: -32px;
  height: 23px;
  border-left: 2px solid var(--rule-strong);
}
.box + .box::after {
  content: "";
  position: absolute;
  left: calc(50% - 5px);
  top: -10px;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 8px solid var(--rule-strong);
}
.box > * { margin: 0; }
.box > * + * { margin-top: 8px; }
.box ul, .box ol { padding-left: 22px; }
.box li + li { margin-top: 4px; }
.box li > ul, .box li > ol { margin-top: 4px; }
.box .warn, .box .note { border-radius: 8px; padding: 8px 11px; border: 1px solid; }
.box .warn { background: var(--alarm-soft); border-color: var(--alarm-line); color: var(--alarm); font-weight: 700; }
.box .note { background: var(--note-soft); border-color: var(--note-line); color: var(--note); }
.box .warn a, .box .note a { color: inherit; }
.table-wrap { overflow-x: auto; }
.box table { border-collapse: collapse; width: 100%; font-size: 15px; }
.box th, .box td { text-align: left; vertical-align: top; padding: 7px 10px; border-bottom: 1px solid var(--rule); }
.box th { background: var(--sheet-2); font-weight: 700; }
.box tr:last-child td { border-bottom: 0; }
.fig { margin: 0; }
.fig img, .inline-img { display: block; max-width: 100%; height: auto; border-radius: 6px; }
.fig figcaption { font-size: 14px; color: var(--ink-2); margin-top: 6px; }
.dead-link { text-decoration: underline dotted; color: var(--alarm); }

/* Documents attached to a guideline */
.files { display: flex; flex-direction: column; gap: 8px; }
.file {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--sheet);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  color: var(--ink);
  text-decoration: none;
}
.file:hover { color: var(--ink); border-color: var(--rule-strong); }
.file .ic { width: 26px; height: 26px; color: var(--scrub); }
.file-text { display: flex; flex-direction: column; min-width: 0; flex: 1 1 auto; }
.file-name { font-weight: 700; overflow-wrap: anywhere; }
.file-meta { font-size: 14px; color: var(--ink-3); }

/* Buttons and forms */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 10px 16px;
  border: 1px solid var(--rule-strong);
  border-radius: 10px;
  background: var(--sheet);
  color: var(--ink);
  font: 700 15px/1.2 var(--font-body);
  text-decoration: none;
  cursor: pointer;
}
.btn:hover { color: var(--ink); border-color: var(--ink-3); }
.btn.primary { background: var(--scrub); border-color: var(--scrub); color: var(--scrub-ink); }
.btn.primary:hover { background: var(--scrub-hover); border-color: var(--scrub-hover); color: var(--scrub-ink); }
.btn.danger { color: var(--alarm); border-color: var(--alarm-line); }
.btn.danger.solid { background: var(--alarm); border-color: var(--alarm); color: var(--sheet); }
.btn.sm { min-height: 36px; padding: 6px 11px; font-size: 14px; }
.btn.icon-only { padding: 6px; min-width: 36px; }
.btn[disabled] { opacity: 0.5; cursor: default; }
.btn .ic { width: 18px; height: 18px; }
.btn.wide { width: 100%; }
.file-btn { position: relative; overflow: hidden; }
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; font-size: 0; }
.btn-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.btn-row .spacer { flex: 1 1 auto; }

.form { display: flex; flex-direction: column; gap: 18px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
fieldset.field { border: 0; padding: 0; margin: 0; }
fieldset.field > legend { padding: 0; margin-bottom: 6px; }
.field > label, .field > .label { font-weight: 700; font-size: 15px; }
.field .hint { font-size: 14px; color: var(--ink-3); font-weight: 400; }
.fields { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
input[type="text"], input[type="search"], input[type="password"], input[type="number"], input[type="date"], input[type="url"], select, textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--rule-strong);
  border-radius: 8px;
  background: var(--sheet);
  color: var(--ink);
  font: inherit;
}
textarea { resize: vertical; line-height: 1.5; }
textarea.source { font: 15px/1.6 var(--font-mono); min-height: 460px; tab-size: 2; }
input::placeholder, textarea::placeholder { color: var(--ink-3); }
.form-error {
  margin: 0;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--alarm-soft);
  border: 1px solid var(--alarm-line);
  color: var(--ink);
}
.form-error .btn { margin-top: 8px; }

.seg { display: inline-flex; flex-wrap: wrap; gap: 3px; padding: 3px; border-radius: 10px; background: var(--sheet-2); align-self: flex-start; max-width: 100%; }
.seg button, .seg label {
  border: 0;
  background: transparent;
  color: var(--ink-2);
  font: 700 14px/1.2 var(--font-body);
  padding: 9px 12px;
  border-radius: 8px;
  cursor: pointer;
  min-height: 38px;
  display: inline-flex;
  align-items: center;
}
.seg button[aria-pressed="true"], .seg label:has(input:checked) { background: var(--sheet); color: var(--ink); box-shadow: 0 0 0 1px var(--rule-strong); }
.seg label input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.seg label:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: 1px; }

.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 6px; scrollbar-width: thin; }
.chip-btn {
  flex: none;
  border: 1px solid var(--rule-strong);
  background: var(--sheet);
  color: var(--ink-2);
  border-radius: 999px;
  padding: 7px 14px;
  font: 700 14px/1.2 var(--font-body);
  cursor: pointer;
}
.chip-btn[aria-pressed="true"] { background: var(--scrub); border-color: var(--scrub); color: var(--scrub-ink); }

/* Calculators */
.calc-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.calc-card { display: flex; flex-direction: column; gap: 4px; padding: 14px 16px; background: var(--sheet); border: 1px solid var(--rule); border-radius: var(--radius); color: var(--ink); text-decoration: none; }
.calc-card:hover { color: var(--ink); border-color: var(--rule-strong); }
.calc-card strong { font-size: 17px; }
.calc-card span { font-size: 14px; color: var(--ink-2); }
.calc { display: flex; flex-direction: column; gap: 18px; }
.criteria { display: flex; flex-direction: column; gap: 14px; }
.criteria fieldset { border: 0; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.criteria legend { font-weight: 700; padding: 0; margin-bottom: 6px; }
.result {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px 18px;
  border-radius: 12px;
  background: var(--scrub-soft);
}
.result dl { margin: 0; display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.result dt { font-size: 14px; color: var(--ink-2); }
.result dd { margin: 0; font: 700 24px/1.2 var(--font-display); font-variant-numeric: tabular-nums; }
.result dd.text { font: 700 18px/1.3 var(--font-body); }
.result p { margin: 0; }
.result .warn-text { color: var(--alarm); font-weight: 700; }

/* Codes */
.code-row {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr) auto;
  align-items: start;
  gap: 2px 12px;
  padding: 10px 10px 10px 14px;
}
.code { font: 500 15px/1.5 var(--font-mono); color: var(--scrub); font-variant-numeric: tabular-nums; }
.code-title { line-height: 1.4; padding-top: 1px; }
.code-note { grid-column: 2; font-size: 14px; color: var(--ink-2); }
.code-group-h { margin: 8px 0 8px; }
.copy-btn {
  grid-row: 1 / span 2;
  grid-column: 3;
  border: 0;
  background: transparent;
  color: var(--ink-3);
  padding: 6px;
  border-radius: 8px;
  cursor: pointer;
  display: grid;
  place-items: center;
}
.copy-btn:hover { color: var(--scrub); background: var(--sheet-2); }

/* Links */
.link-card { display: flex; align-items: center; gap: 12px; }
.link-host { font-size: 14px; color: var(--ink-3); overflow-wrap: anywhere; }
.link-note { font-size: 14px; color: var(--ink-2); }

/* Editor */
.ed-section { display: flex; flex-direction: column; gap: 10px; }
.ed-nav { display: flex; flex-wrap: wrap; gap: 8px; }
.ed-row { display: flex; align-items: center; gap: 10px; padding: 8px 8px 8px 14px; }
.ed-row .row-main { gap: 1px; }
.ed-row .row-title a { color: var(--ink); text-decoration: none; }
.ed-row .row-title a:hover { text-decoration: underline; }
.ed-tools { display: flex; gap: 4px; flex: none; }
.ed-list-row { display: grid; gap: 8px; padding: 12px; grid-template-columns: minmax(0, 1fr); }
.ed-list-row .btn-row { justify-content: flex-end; }
@media (min-width: 700px) {
  .ed-list-row.topic { grid-template-columns: auto minmax(0, 1fr) 160px auto; align-items: center; }
  .ed-list-row.link { grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr) auto; align-items: start; }
  .ed-list-row.link .note-field { grid-column: 1 / 3; }
}
.toolbar { display: flex; flex-wrap: wrap; gap: 6px; }
.toolbar .btn { min-height: 36px; padding: 6px 10px; font-size: 14px; }
.panes { display: grid; gap: 14px; }
.pane { min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.pane-label { font-weight: 700; font-size: 15px; }
.pane-preview .doc { padding: 16px; border-radius: 12px; background: var(--paper); border: 1px dashed var(--rule-strong); min-height: 200px; }
.pane-switch { display: inline-flex; }
@media (max-width: 999px) {
  .panes[data-show="write"] .pane-preview, .panes[data-show="preview"] .pane-write { display: none; }
  .pane-label { display: none; }
}
@media (min-width: 1000px) {
  .panes { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .pane-switch { display: none; }
  .pane-preview .doc { max-height: 75vh; overflow-y: auto; }
}
.help table { border-collapse: collapse; font-size: 14px; width: 100%; }
.help td { padding: 6px 10px 6px 0; border-top: 1px solid var(--rule); vertical-align: top; }
.help code { font: 500 14px var(--font-mono); white-space: pre; }
details.help { background: var(--sheet); border: 1px solid var(--rule); border-radius: var(--radius); padding: 10px 14px; }
details.help summary { font-weight: 700; cursor: pointer; }
.file-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.file-list li { display: flex; align-items: center; gap: 10px; padding: 8px 8px 8px 12px; background: var(--sheet); border: 1px solid var(--rule); border-radius: 8px; }
.file-list .file-name { flex: 1 1 auto; min-width: 0; font-weight: 400; }
.confirm { display: flex; flex-direction: column; gap: 10px; padding: 14px; border-radius: var(--radius); background: var(--alarm-soft); border: 1px solid var(--alarm-line); }
.confirm p { margin: 0; }
.busy { color: var(--ink-2); font-size: 14px; }

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px) + 14px);
  transform: translateX(-50%);
  z-index: 40;
  max-width: calc(100% - 32px);
  padding: 12px 18px;
  border-radius: 10px;
  background: var(--ink);
  color: var(--paper);
  font-weight: 700;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.25);
}
@media (min-width: 1000px) { .toast { bottom: 24px; } }

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}
