/* Sounding by Munetris: certificate checker */
:root {
  --bg: #f4f7f8;
  --surface: #ffffff;
  --surface-2: #eef3f5;
  --ink: #0d2230;
  --muted: #536472;
  --line: #d7e0e5;
  --accent: #0d6b74;
  --accent-ink: #ffffff;
  --accent-soft: #e0f0f1;
  --ok: #1d7448;
  --ok-soft: #e3f3ea;
  --info: #285c8c;
  --info-soft: #e6eef7;
  --warn: #9a5800;
  --warn-soft: #fbf0dc;
  --bad: #b3222b;
  --bad-soft: #fbe6e7;
  --shadow: 0 1px 2px rgba(13, 34, 48, 0.06), 0 4px 16px rgba(13, 34, 48, 0.05);
  --radius: 10px;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --mono: ui-monospace, "SFMono-Regular", "Cascadia Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0a161e;
    --surface: #102029;
    --surface-2: #142a35;
    --ink: #e4edf1;
    --muted: #93a6b2;
    --line: #233a48;
    --accent: #4db1ba;
    --accent-ink: #062027;
    --accent-soft: #123940;
    --ok: #55c48d;
    --ok-soft: #12301f;
    --info: #86b5e3;
    --info-soft: #152b40;
    --warn: #f0a641;
    --warn-soft: #33260f;
    --bad: #ff7a7f;
    --bad-soft: #3a1619;
    --shadow: none;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
    --bg: #0a161e;
    --surface: #102029;
    --surface-2: #142a35;
    --ink: #e4edf1;
    --muted: #93a6b2;
    --line: #233a48;
    --accent: #4db1ba;
    --accent-ink: #062027;
    --accent-soft: #123940;
    --ok: #55c48d;
    --ok-soft: #12301f;
    --info: #86b5e3;
    --info-soft: #152b40;
    --warn: #f0a641;
    --warn-soft: #33260f;
    --bad: #ff7a7f;
    --bad-soft: #3a1619;
    --shadow: none;
    color-scheme: dark;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.55 var(--sans);
}

a { color: var(--accent); }
code { font-family: var(--mono); font-size: 0.9em; background: var(--surface-2); padding: 0.05em 0.35em; border-radius: 4px; }

.wrap { max-width: 880px; margin: 0 auto; padding: 0 16px; }

/* Header */
.top { border-bottom: 1px solid var(--line); background: var(--surface); }
.top-inner { display: flex; align-items: center; justify-content: space-between; height: 60px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; }
.mark { width: 30px; height: 30px; }
.mark-bg { fill: var(--ink); }
.mark-line { stroke: var(--surface); stroke-width: 1.6; fill: none; stroke-linecap: round; }
.mark-lead { fill: var(--accent); }
.word { font-family: var(--serif); font-size: 1.35rem; font-weight: 600; letter-spacing: 0.01em; }
.by { color: var(--muted); font-size: 0.9rem; }
.tag { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--accent); border: 1px solid var(--accent); border-radius: 999px; padding: 2px 10px; }

.tools-nav { display: flex; align-items: center; gap: 4px; }
.tools-nav a { color: var(--muted); text-decoration: none; font-size: 0.9rem; padding: 6px 10px; border-radius: 6px; }
.tools-nav a:hover { color: var(--ink); background: var(--surface-2); }
.tools-nav a[aria-current="page"] { color: var(--accent); font-weight: 600; background: var(--accent-soft); }

[hidden] { display: none !important; }

/* Intro */
.intro { padding: 40px 0 20px; }
h1 { font-family: var(--serif); font-weight: 600; font-size: clamp(1.7rem, 4.2vw, 2.45rem); line-height: 1.15; margin: 0 0 14px; letter-spacing: -0.01em; max-width: 22em; }
.lede { font-size: 1.08rem; color: var(--muted); margin: 0 0 16px; max-width: 40em; }
.privacy { display: flex; gap: 10px; align-items: flex-start; margin: 0; padding: 10px 14px; background: var(--accent-soft); border-radius: var(--radius); font-size: 0.93rem; max-width: 46em; }
.privacy svg { flex: none; width: 18px; height: 18px; margin-top: 2px; }
.lock-arc { fill: none; stroke: var(--accent); stroke-width: 1.8; }
.lock-body { fill: var(--accent); }

/* Cards */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; margin: 20px 0; }

.input-card { position: relative; }
.label { display: block; font-weight: 600; margin-bottom: 8px; }
textarea {
  width: 100%; min-height: 190px; resize: vertical;
  font: 13.5px/1.5 var(--mono);
  color: var(--ink); background: var(--surface-2);
  border: 1px solid var(--line); border-radius: 8px; padding: 12px;
}
textarea:focus, button:focus-visible, .button:focus-within, summary:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
textarea::placeholder { color: var(--muted); opacity: 0.75; }

.actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 12px; }
.spacer { flex: 1; }
.hint { color: var(--muted); font-size: 0.86rem; margin: 12px 0 0; }

button, .button {
  font: inherit; font-size: 0.95rem; cursor: pointer; border-radius: 8px;
  padding: 9px 16px; border: 1px solid transparent; line-height: 1.2;
  display: inline-flex; align-items: center; gap: 6px; text-decoration: none;
}
button:disabled { cursor: default; opacity: 0.8; }
.primary { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.primary:hover { filter: brightness(1.08); }
.secondary { background: var(--surface); color: var(--ink); border-color: var(--line); }
.secondary:hover { border-color: var(--accent); }
.link { background: none; color: var(--accent); padding: 9px 6px; }
.link:hover { text-decoration: underline; }
.mini { font-size: 0.75rem; padding: 2px 8px; background: var(--surface); border: 1px solid var(--line); color: var(--muted); border-radius: 6px; vertical-align: 1px; }
.mini:hover { color: var(--ink); border-color: var(--accent); }

.file-button { position: relative; overflow: hidden; }
.file-button input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

.file-list { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.chip { display: inline-flex; align-items: center; gap: 4px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; padding: 3px 4px 3px 12px; font-size: 0.85rem; font-family: var(--mono); }
.chip-x { padding: 0 8px; background: none; color: var(--muted); font-size: 1.1rem; line-height: 1; }
.chip-x:hover { color: var(--bad); }

.drop-overlay { display: none; }
.input-card.dragging .drop-overlay {
  display: flex; position: absolute; inset: 0; align-items: center; justify-content: center;
  border: 2px dashed var(--accent); border-radius: var(--radius); background: color-mix(in srgb, var(--surface) 88%, transparent);
  font-weight: 600; color: var(--accent); pointer-events: none;
}

.alert { margin: 20px 0; padding: 14px 16px; border-radius: var(--radius); background: var(--bad-soft); color: var(--ink); border-left: 4px solid var(--bad); }

/* Results */
.results { scroll-margin-top: 16px; }
.summary { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; padding: 14px 16px; border-radius: var(--radius); margin: 24px 0 16px; border-left: 4px solid; }
.summary p { margin: 0; }
.tone-ok { background: var(--ok-soft); border-color: var(--ok); }
.tone-warn { background: var(--warn-soft); border-color: var(--warn); }
.tone-bad { background: var(--bad-soft); border-color: var(--bad); }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; margin: 16px 0; }
.panel h2 { font-size: 1rem; margin: 0 0 10px; }

.result {
  --tone: var(--ok); --tone-soft: var(--ok-soft);
  background: var(--surface); border: 1px solid var(--line); border-top: 4px solid var(--tone);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; margin: 16px 0;
}
.status-ok { --tone: var(--ok); --tone-soft: var(--ok-soft); }
.status-notice { --tone: var(--info); --tone-soft: var(--info-soft); }
.status-warning { --tone: var(--warn); --tone-soft: var(--warn-soft); }
.status-critical, .status-expired, .status-not-yet-valid { --tone: var(--bad); --tone-soft: var(--bad-soft); }
.status-host { --tone: var(--accent); --tone-soft: var(--accent-soft); }

.result-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.result-head h3 { margin: 0; font-size: 1.15rem; word-break: break-word; }
.sub { margin: 2px 0 0; color: var(--muted); font-size: 0.9rem; word-break: break-word; }
.pills { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; flex: none; }
.pill-bad { background: var(--bad-soft) !important; color: var(--bad) !important; }
.result.has-problem { border-top-color: var(--bad); }
.pill { flex: none; background: var(--tone-soft); color: var(--tone); font-weight: 600; font-size: 0.82rem; padding: 4px 12px; border-radius: 999px; white-space: nowrap; }

.gauge { margin: 16px 0 6px; }
.gauge-bar { height: 10px; background: var(--surface-2); border-radius: 999px; overflow: hidden; border: 1px solid var(--line); }
.gauge-fill { height: 100%; background: var(--tone); border-radius: 999px; min-width: 0; }
.gauge-labels { display: flex; justify-content: space-between; gap: 8px; font-size: 0.82rem; color: var(--muted); margin-top: 6px; }
.gauge-mid { color: var(--tone); font-weight: 600; text-align: center; }

.findings { list-style: none; padding: 0; margin: 12px 0 0; display: grid; gap: 6px; }
.finding { display: flex; gap: 10px; align-items: baseline; padding: 8px 12px; border-radius: 8px; background: var(--surface-2); font-size: 0.93rem; border-left: 3px solid var(--muted); }
.finding .level { flex: none; font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; min-width: 5.2em; }
.level-ok { border-color: var(--ok); } .level-ok .level { color: var(--ok); }
.level-info { border-color: var(--info); } .level-info .level { color: var(--info); }
.level-warn { border-color: var(--warn); background: var(--warn-soft); } .level-warn .level { color: var(--warn); }
.level-bad { border-color: var(--bad); background: var(--bad-soft); } .level-bad .level { color: var(--bad); }

.more { margin-top: 14px; }
.more summary { cursor: pointer; color: var(--accent); font-weight: 600; font-size: 0.93rem; }
.details { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; margin: 12px 0 0; font-size: 0.9rem; }
.details dt { color: var(--muted); }
.details dd { margin: 0; word-break: break-word; min-width: 0; }
.mono { font-family: var(--mono); font-size: 0.82rem; }
.plain { list-style: none; margin: 0; padding: 0; }

.result-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }

.chain-list { list-style: none; margin: 0 0 6px; padding: 0; display: grid; gap: 0; }
.chain-list li { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; padding: 8px 0 8px 14px; border-left: 3px solid var(--tone, var(--ok)); position: relative; }
.chain-list li.status-ok { --tone: var(--ok); }
.chain-name { font-weight: 600; word-break: break-word; }
.chain-meta { color: var(--muted); font-size: 0.85rem; text-align: right; }
.chain-link { grid-column: 1 / -1; font-size: 0.8rem; color: var(--muted); }
.chain-link.broken { color: var(--bad); font-weight: 600; }

/* Upsell + FAQ */
.upsell { display: flex; gap: 20px; align-items: center; justify-content: space-between; margin-top: 36px; background: linear-gradient(135deg, var(--surface), var(--accent-soft)); }
.upsell h2 { font-family: var(--serif); font-size: 1.4rem; margin: 0 0 6px; }
.upsell p { margin: 0; color: var(--muted); max-width: 36em; }
.upsell .button { flex: none; }

.faq { margin: 36px 0 24px; }
.faq h2 { font-family: var(--serif); font-size: 1.4rem; margin: 0 0 10px; }
.faq details { border-top: 1px solid var(--line); padding: 12px 0; }
.faq details:last-child { border-bottom: 1px solid var(--line); }
.faq summary { cursor: pointer; font-weight: 600; }
.faq p { color: var(--muted); margin: 8px 0 0; }

.foot { border-top: 1px solid var(--line); color: var(--muted); font-size: 0.85rem; padding: 18px 0 28px; margin-top: 20px; }
.foot-inner { display: flex; flex-wrap: wrap; gap: 8px 20px; justify-content: space-between; }

.offscreen { position: fixed; left: -9999px; top: 0; }

/* Simple pages (root, 404) */
.simple { padding: 64px 0; }
.simple p { color: var(--muted); max-width: 36em; }

@media (max-width: 640px) {
  .intro { padding-top: 28px; }
  .tag { display: none; }
  .tools-nav a { padding: 6px 7px; font-size: 0.85rem; }
  .by { display: none; }
  .card { padding: 16px; }
  .result { padding: 14px; }
  .result-head { flex-direction: column; }
  .details { grid-template-columns: 1fr; gap: 0; }
  .details dt { margin-top: 8px; }
  .upsell { flex-direction: column; align-items: flex-start; }
  .chain-list li { grid-template-columns: 1fr; }
  .chain-meta { text-align: left; }
  .actions .spacer { display: none; }
}

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

/* ---------- Bearing ---------- */
.wrap.wide { max-width: 1180px; }
.mark-ring { fill: none; stroke: var(--surface); stroke-width: 1.1; opacity: 0.55; }
.mark-needle-back { fill: var(--surface); opacity: 0.85; }

.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.workbench { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; align-items: start; margin: 20px 0; }
.workbench > .card, .expr-col > .card { margin: 0; }
.expr-col { display: grid; gap: 20px; min-width: 0; }

.card-head { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; margin-bottom: 8px; }
.card-head .label { margin: 0; }
.card-head h2 { font-size: 1rem; margin: 0; }
.example-flag { font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--info); background: var(--info-soft); border-radius: 999px; padding: 2px 8px; }
.file-link { position: relative; overflow: hidden; }
.file-link input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

.pd-card { position: relative; }
.pd-card textarea { min-height: 440px; font-size: 13px; tab-size: 2; white-space: pre; overflow-x: auto; }
.status { margin: 8px 0 0; font-size: 0.86rem; }
.status-ok { color: var(--ok); }
.status-bad { color: var(--bad); }
textarea[aria-invalid], input[aria-invalid] { border-color: var(--bad); }

.expr {
  width: 100%; font: 15px/1.4 var(--mono); color: var(--ink); background: var(--surface-2);
  border: 1px solid var(--line); border-radius: 8px; padding: 11px 12px;
}
.expr:focus, .filter:focus { outline: 2px solid var(--accent); outline-offset: 2px; }
.expr-card .hint { margin-top: 8px; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.chip {
  font: 12.5px/1.3 var(--mono); padding: 5px 9px; border-radius: 6px;
  background: var(--surface-2); color: var(--ink); border: 1px solid var(--line);
}
.chip:hover { border-color: var(--accent); color: var(--accent); }

.result-card { min-height: 160px; }
.result-card .result-head { align-items: center; margin-bottom: 4px; }
.pill.tone-ok { background: var(--ok-soft); color: var(--ok); }
.pill.tone-warn { background: var(--warn-soft); color: var(--warn); }
.pill.tone-bad { background: var(--bad-soft); color: var(--bad); }
button.small { font-size: 0.85rem; padding: 6px 12px; }
.muted { color: var(--muted); margin: 0; }
.tip { color: var(--muted); font-size: 0.86rem; margin: 12px 0 0; }

.nodes { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 8px; }
.node { background: var(--surface-2); border-radius: 8px; padding: 9px 12px; border-left: 3px solid var(--accent); min-width: 0; }
.node-top { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.node-path {
  background: none; border: 0; padding: 0; color: var(--muted); font: 12px/1.4 var(--mono);
  text-align: left; word-break: break-all; cursor: pointer;
}
.node-path:hover { color: var(--accent); text-decoration: underline; }
.node-kind { flex: none; font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.node-value { font: 14px/1.45 var(--mono); margin-top: 3px; word-break: break-word; white-space: pre-wrap; }
.empty { color: var(--muted); font-style: italic; font-family: var(--sans); }
.node-xml summary { cursor: pointer; color: var(--accent); font-size: 0.82rem; margin-top: 6px; }
.node-xml pre { margin: 6px 0 0; padding: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: 6px; overflow-x: auto; font: 12px/1.45 var(--mono); max-height: 320px; }

.scalar { margin-top: 10px; font: 600 1.35rem/1.35 var(--mono); padding: 12px 14px; background: var(--surface-2); border-radius: 8px; word-break: break-word; white-space: pre-wrap; border-left: 3px solid var(--accent); }
.scalar-boolean { text-transform: lowercase; }

.paths-card { margin-top: 0; }
.paths-card .hint { margin: 0 0 10px; }
.count { color: var(--muted); font-size: 0.85rem; font-variant-numeric: tabular-nums; }
.filter { font: inherit; font-size: 0.9rem; padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); color: var(--ink); min-width: 0; width: 240px; max-width: 100%; }
.paths-scroll { max-height: 420px; overflow: auto; border: 1px solid var(--line); border-radius: 8px; }
.paths { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.paths th { position: sticky; top: 0; background: var(--surface-2); text-align: left; font-weight: 600; color: var(--muted); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.05em; padding: 8px 12px; border-bottom: 1px solid var(--line); }
.paths td { padding: 6px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.paths tr:last-child td { border-bottom: 0; }
.path-btn { background: none; border: 0; padding: 0; font: 12.5px/1.45 var(--mono); color: var(--accent); text-align: left; word-break: break-all; cursor: pointer; }
.path-btn:hover { text-decoration: underline; }
.path-btn.kind-attribute { color: var(--info); }
.path-value { font: 12.5px/1.45 var(--mono); color: var(--ink); word-break: break-word; }

@media (max-width: 900px) {
  .workbench { grid-template-columns: minmax(0, 1fr); }
  .expr-col { order: -1; }
  .pd-card textarea { min-height: 260px; }
}
@media (max-width: 640px) {
  .result-card .result-head { flex-direction: row; justify-content: space-between; }
  .filter { width: 100%; }
  .paths th:last-child, .paths td:last-child { max-width: 40vw; }
}

@media (max-width: 760px) {
  .top-inner { flex-wrap: wrap; height: auto; padding-block: 10px 0; row-gap: 6px; }
  .tools-nav { width: 100%; overflow-x: auto; padding-bottom: 8px; scrollbar-width: none; }
  .tools-nav::-webkit-scrollbar { display: none; }
  .tools-nav a { flex: none; }
}

/* ---------- Passage ---------- */
.mark-route { fill: none; stroke: var(--surface); stroke-width: 1.8; stroke-linecap: round; stroke-dasharray: 2.4 2.6; }
.mark-dot { fill: var(--surface); }

.src-card { position: relative; }
.src-card textarea { min-height: 460px; font-size: 12.5px; white-space: pre; overflow-x: auto; tab-size: 2; }
.check-card { max-height: 640px; overflow: auto; }
.check-card .findings { margin-top: 4px; }
.counts { display: flex; flex-wrap: wrap; gap: 6px; }
.count-pill { font-size: 0.8rem; font-weight: 600; padding: 3px 10px; border-radius: 999px; font-variant-numeric: tabular-nums; }
.count-pill.tone-ok { background: var(--ok-soft); color: var(--ok); }
.count-pill.tone-warn { background: var(--warn-soft); color: var(--warn); }
.count-pill.tone-bad { background: var(--bad-soft); color: var(--bad); }
.count-pill.tone-info { background: var(--info-soft); color: var(--info); }
.finding .finding-text { flex: 1; min-width: 0; }
.line-link { flex: none; background: none; border: 0; padding: 0 0 0 6px; font: 12px/1.4 var(--mono); color: var(--accent); cursor: pointer; white-space: nowrap; }
.line-link:hover { text-decoration: underline; }

.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin: 18px 0 0; }
.stat-grid div { background: var(--surface-2); border-radius: 8px; padding: 8px 10px; }
.stat-grid dt { font-size: 0.74rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.stat-grid dd { margin: 2px 0 0; font: 600 1.25rem/1.2 var(--mono); font-variant-numeric: tabular-nums; }
.services h3 { font-size: 0.9rem; margin: 18px 0 8px; }
.services ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.services li { display: inline-flex; gap: 6px; align-items: baseline; background: var(--surface-2); border: 1px solid var(--line); border-radius: 6px; padding: 4px 9px; font: 12.5px/1.3 var(--mono); }
.svc-count { color: var(--muted); }

.mono-cell { font: 12.5px/1.5 var(--mono); word-break: break-word; }
.num { white-space: nowrap; font-size: 0.86rem; }
.pad { padding: 6px 0; }

/* Flow diagram */
.flow-card .hint { margin: 0 0 12px; }
.flow-scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); padding: 16px; }
.flow { width: max-content; min-width: 100%; }
.kind { font-size: 0.68rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.proc-head { display: inline-flex; align-items: center; gap: 8px; background: var(--ink); color: var(--surface); padding: 6px 12px; border-radius: 999px; }
.proc-head .kind { color: inherit; opacity: 0.7; }
.proc-head .blk-name { font-weight: 600; }
.proc-body { margin-top: 14px; padding-left: 14px; border-left: 2px solid var(--line); }

.blk { border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.blk.anon { border: 0; background: none; }
.blk-head { list-style: none; display: flex; align-items: center; gap: 8px; padding: 8px 12px; cursor: pointer; border-radius: 10px; }
.blk-head::-webkit-details-marker { display: none; }
.blk-head::before { content: "\25BE"; color: var(--muted); font-size: 0.8rem; width: 0.8em; }
details.blk:not([open]) > .blk-head::before { content: "\25B8"; }
.blk-name { font-weight: 600; }
.blk-body { padding: 4px 12px 12px; }
.blk-seq > .blk-head { background: var(--surface-2); }
.blk-choice { border-color: color-mix(in srgb, var(--info) 40%, var(--line)); }
.blk-choice > .blk-head { background: var(--info-soft); }
.blk-all { border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); }
.blk-all > .blk-head { background: var(--accent-soft); }
.is-loop { box-shadow: inset 3px 0 0 var(--accent); }
.loop-tag { font-size: 0.75rem; color: var(--accent); font-weight: 600; }

.steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 16px; }
.step { position: relative; }
.step + .step::before { content: ""; position: absolute; left: 22px; top: -16px; height: 16px; border-left: 2px solid var(--line); }

.act { border: 1px solid var(--line); border-radius: 8px; background: var(--surface); padding: 8px 12px; min-width: 200px; max-width: 340px; box-shadow: var(--shadow); }
.act-top { display: flex; align-items: center; gap: 8px; }
.act-op { border-left: 4px solid var(--accent); }
.op-svc { font: 600 14px/1.35 var(--mono); margin-top: 2px; word-break: break-word; }
.op-svc.small { font-size: 13px; font-weight: 500; }
.op-name { color: var(--muted); font-size: 0.86rem; margin-top: 1px; }
.op-more { margin-top: 6px; }
.op-more summary { cursor: pointer; font-size: 0.8rem; color: var(--accent); }
.msg { margin-top: 6px; }
.msg-head { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); display: flex; gap: 6px; }
.msg-name { text-transform: none; letter-spacing: 0; font-family: var(--mono); }
.assigns { list-style: none; margin: 4px 0 0; padding: 0; display: grid; gap: 2px; }
.assign-line, .assign-inline { font: 12px/1.45 var(--mono); word-break: break-word; }
.assign-inline { display: inline; }
.to { color: var(--ink); font-weight: 600; }
.arrow { color: var(--muted); margin: 0 4px; }
.from { color: var(--info); }
.lit { color: var(--warn); }
.act-assign { display: flex; align-items: baseline; gap: 8px; min-width: 0; padding: 5px 10px; box-shadow: none; background: var(--surface-2); }
.act-repeat { display: inline-flex; align-items: center; gap: 6px; min-width: 0; font: inherit; font-size: 0.88rem; color: var(--accent); background: var(--accent-soft); border: 1px dashed var(--accent); cursor: pointer; box-shadow: none; }
.act-repeat:hover { filter: brightness(1.05); }
.loop-icon { font-size: 1.05rem; }
.act-other { border-left: 4px solid var(--muted); }

.branches { display: flex; gap: 14px; align-items: flex-start; margin-top: 8px; }
.branch { border-top: 2px solid var(--info); padding-top: 8px; min-width: 220px; }
.branch.never { border-top-style: dashed; border-top-color: var(--warn); opacity: 0.8; }
.branch.fallthrough { border-top: 2px dashed var(--line); min-width: 150px; }
.blk-all .branch { border-top-color: var(--accent); }
.branch-head { margin-bottom: 8px; display: grid; gap: 4px; }
.case { font-size: 0.86rem; }
.case-if { color: var(--muted); }
.case-missing { color: var(--bad); text-decoration: underline wavy; }
.case-never { color: var(--warn); }
.case-cond { font: 11.5px/1.4 var(--mono); color: var(--muted); max-width: 320px; word-break: break-word; }

.faults { margin-top: 14px; display: grid; gap: 10px; }
.fault { border: 1px solid color-mix(in srgb, var(--bad) 45%, var(--line)); background: var(--bad-soft); border-radius: 8px; padding: 8px 12px 12px; }
.fault-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.fault-head .kind { color: var(--bad); }
.fault-code { font: 12.5px/1.3 var(--mono); }

.mark-badge { display: inline-grid; place-items: center; min-width: 1.4em; height: 1.4em; padding: 0 4px; border-radius: 999px; font-size: 0.72rem; font-weight: 700; margin-left: auto; }
.mb-bad { background: var(--bad); color: var(--surface); }
.mb-warn { background: var(--warn); color: var(--surface); }
.mb-info { background: var(--info-soft); color: var(--info); }
.marked-bad { outline: 2px solid var(--bad); outline-offset: 1px; }
.marked-warn { outline: 2px solid color-mix(in srgb, var(--warn) 70%, transparent); outline-offset: 1px; }
.flash { animation: flash 1.4s ease-out; }
@keyframes flash { 0%, 30% { box-shadow: 0 0 0 4px var(--accent); } 100% { box-shadow: 0 0 0 0 transparent; } }
@media (prefers-reduced-motion: reduce) { .flash { animation: none; outline: 3px solid var(--accent); } }

@media (max-width: 900px) {
  .check-card { max-height: none; }
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.fallthrough .muted-inline { font-size: 0.86rem; }

/* Flow: viewport-sized box, zoom, pan, full screen */
.flow-scroll { max-height: 75vh; overflow: auto; cursor: grab; overscroll-behavior: contain; }
.flow-scroll.panning { cursor: grabbing; user-select: none; }
.flow-scroll .act, .flow-scroll summary, .flow-scroll button { cursor: pointer; }
.zoom { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.zoom-btn { background: var(--surface); color: var(--ink); border: 0; border-radius: 0; padding: 5px 10px; font-size: 0.88rem; min-width: 2.2em; justify-content: center; }
.zoom-btn + .zoom-btn { border-left: 1px solid var(--line); }
.zoom-btn:hover { background: var(--surface-2); color: var(--accent); }
.zoom-level { min-width: 3.6em; font-variant-numeric: tabular-nums; }
.flow-card:fullscreen { margin: 0; border-radius: 0; overflow: auto; display: flex; flex-direction: column; background: var(--surface); }
.flow-card:fullscreen .flow-scroll { max-height: none; flex: 1; }
.flow-card:fullscreen .hint { display: none; }
.flow-card::backdrop { background: var(--bg); }

/* ---------- Loft ---------- */
.mark-route { fill: none; stroke: var(--surface); stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: none; }
.eyebrow { margin: 0 0 10px; }
.muted-inline { color: var(--muted); }
.small { font-size: 0.85rem; }

.editor-card { position: relative; padding-bottom: 14px; }
.toolbar { gap: 6px; margin-bottom: 12px; }
.proc-title { font-family: var(--mono); font-size: 0.88rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 24em; }
.sep { width: 1px; align-self: stretch; background: var(--line); margin: 2px 4px; }
.tool-btn { background: var(--surface); color: var(--ink); border: 1px solid var(--line); font-size: 0.85rem; padding: 6px 11px; border-radius: 7px; }
.tool-btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.tool-btn:disabled { opacity: 0.45; }
.tool-btn.danger:hover:not(:disabled) { border-color: var(--bad); color: var(--bad); }
label.tool-btn { cursor: pointer; }

.editor { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 16px; align-items: stretch; }
.canvas-wrap { border: 1px solid var(--line); border-radius: 8px; background: var(--bg); overflow: auto; max-height: 76vh; min-height: 420px; overscroll-behavior: contain; }
.canvas { padding: 16px; width: max-content; min-width: 100%; outline: none; }
.canvas-empty { color: var(--muted); padding: 24px 8px; max-width: 34em; }
.canvas-empty p { margin: 0 0 12px; }

/* Selectable boxes */
.canvas .act, .canvas .blk-head, .canvas .proc-head, .canvas .rule-chip, .canvas .fault-head { cursor: pointer; }
.canvas .blk { cursor: default; }
.canvas .act:hover, .canvas .rule-chip:hover { border-color: var(--accent); }
.canvas .blk:hover > .blk-head { color: var(--accent); }
.sel { outline: 2px solid var(--accent) !important; outline-offset: 2px; box-shadow: 0 0 0 5px var(--accent-soft) !important; }
.blk.sel > .blk-head, .fault.sel > .fault-head { color: var(--accent); }
.blk-head::before { content: none; }
.canvas .blk-head { cursor: pointer; }

.rules-strip { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 12px 0 0; padding-left: 16px; }
.rule-chip { display: inline-flex; align-items: center; gap: 6px; background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 3px 9px; font: 12.5px/1.4 var(--mono); }
.rule-chip .mark-badge { margin-left: 2px; }

.adders { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 6px 0; font-size: 0.86rem; }
.chip-btn { font-size: 0.8rem; padding: 4px 9px; border-radius: 999px; background: var(--surface); color: var(--accent); border: 1px dashed color-mix(in srgb, var(--accent) 55%, var(--line)); }
.chip-btn:hover { background: var(--accent-soft); border-style: solid; }

/* Inspector */
.inspector { border: 1px solid var(--line); border-radius: 8px; padding: 14px; background: var(--surface); overflow: auto; max-height: 76vh; min-width: 0; }
.ins-head { margin-bottom: 8px; }
.ins-title { font-size: 1.05rem; margin: 2px 0 0; word-break: break-word; }
.ins-findings { list-style: none; margin: 0 0 10px; padding: 0; display: grid; gap: 4px; font-size: 0.84rem; }
.ins-findings li { padding: 6px 9px; border-radius: 6px; border-left: 3px solid; }
.ins-findings .tone-bad { background: var(--bad-soft); border-color: var(--bad); }
.ins-findings .tone-warn { background: var(--warn-soft); border-color: var(--warn); }
.ins-findings .tone-info { background: var(--info-soft); border-color: var(--info); }
.ins-sec { border-top: 1px solid var(--line); padding: 10px 0 4px; display: grid; gap: 8px; }
.ins-sec:first-of-type { border-top: 0; padding-top: 0; }
.ins-sec h3 { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 0; }
.fld { display: grid; gap: 3px; min-width: 0; }
.fld-label { font-size: 0.8rem; font-weight: 600; color: var(--muted); }
.fld-hint { font-size: 0.78rem; color: var(--muted); margin: 0; }
.in { font: inherit; font-size: 0.9rem; width: 100%; min-width: 0; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface-2); color: var(--ink); }
.in:focus { outline: 2px solid var(--accent); outline-offset: 1px; background: var(--surface); }
.mono-in { font-family: var(--mono); font-size: 12.5px; }
textarea.in { min-height: 0; resize: vertical; line-height: 1.45; }
select.in { padding: 5px 6px; }
.chk { display: inline-flex; align-items: center; gap: 6px; font-size: 0.86rem; }
.x-btn { background: none; border: 0; color: var(--muted); font-size: 1.15rem; padding: 2px 6px; line-height: 1; align-self: end; }
.x-btn:hover { color: var(--bad); }
.assign-rows { display: grid; gap: 8px; }
.assign-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr) auto; gap: 6px; align-items: end; padding-bottom: 8px; border-bottom: 1px dashed var(--line); }
.cond-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px; }
.case-rows { display: grid; gap: 6px; }
.case-row { display: grid; grid-template-columns: auto auto minmax(0, 1fr) auto minmax(0, 1fr) auto; gap: 5px; align-items: center; font-size: 0.86rem; }
.act-row { display: flex; gap: 6px; align-items: center; }

.editor-card.dragging .drop-overlay { display: grid; place-items: center; position: absolute; inset: 0; background: color-mix(in srgb, var(--accent-soft) 88%, transparent); border: 2px dashed var(--accent); border-radius: var(--radius); font-weight: 600; color: var(--accent); z-index: 5; }

@media (max-width: 980px) {
  .editor { grid-template-columns: minmax(0, 1fr); }
  .canvas-wrap { max-height: 60vh; min-height: 300px; }
  .inspector { max-height: none; }
}
@media (max-width: 640px) {
  .case-row { grid-template-columns: auto auto minmax(0, 1fr); }
  .assign-row { grid-template-columns: minmax(0, 1fr) auto; }
  .assign-row .fld:nth-child(2) { grid-column: 1; }
  .proc-title { display: none; }
}

/* Header: keep each tool name on one line; scroll the nav sideways when it is longer than the bar. */
.top-inner { gap: 16px; }
.brand { flex: none; }
.tools-nav { min-width: 0; overflow-x: auto; scrollbar-width: none; }
.tools-nav::-webkit-scrollbar { display: none; }
.tools-nav a { flex: none; white-space: nowrap; padding-inline: 8px; font-size: 0.86rem; }
@media (max-width: 1240px) and (min-width: 761px) {
  .tools-nav { mask-image: linear-gradient(to right, #000 calc(100% - 32px), transparent); padding-right: 24px; }
}

/* Loft: Flow / Split / XML views */
.view-switch { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.view-btn { background: var(--surface); color: var(--muted); border: 0; border-radius: 0; padding: 6px 12px; font-size: 0.85rem; }
.view-btn + .view-btn { border-left: 1px solid var(--line); }
.view-btn:hover { color: var(--accent); }
.view-btn[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

.editor-card[data-view="flow"] .editor { grid-template-columns: minmax(0, 1fr) 360px; }
.editor-card[data-view="split"] .editor { grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr) 330px; }
.editor-card[data-view="xml"] .editor { grid-template-columns: minmax(0, 1fr) 360px; }
.editor-card[data-view="flow"] .xml-pane, .editor-card[data-view="xml"] .canvas-wrap { display: none; }

.xml-pane { display: flex; flex-direction: column; min-width: 0; }
.xml-box { position: relative; flex: 1; min-height: 420px; max-height: 76vh; height: 76vh; }
.xml-box textarea, .xml-backdrop {
  position: absolute; inset: 0; margin: 0; width: 100%; height: 100%; min-height: 0;
  font: 12.5px/1.5 var(--mono); tab-size: 2; white-space: pre; overflow-wrap: normal;
  padding: 12px; border: 1px solid var(--line); border-radius: 8px; box-sizing: border-box;
}
.xml-backdrop { overflow: hidden; color: transparent; background: var(--surface-2); pointer-events: none; }
.xml-backdrop mark { color: transparent; background: color-mix(in srgb, var(--accent) 22%, transparent); border-radius: 3px; box-shadow: -3px 0 0 color-mix(in srgb, var(--accent) 22%, transparent); }
.xml-box textarea { background: transparent; color: var(--ink); resize: none; overflow: auto; caret-color: var(--ink); }
.xml-pane .status { margin-top: 6px; }
.workbench.single { grid-template-columns: minmax(0, 1fr); }

@media (max-width: 1100px) {
  .editor-card[data-view] .editor { grid-template-columns: minmax(0, 1fr); }
  .xml-box { height: 55vh; min-height: 300px; }
}

/* The editor uses the width of the window (up to 1840px); the text around it keeps its column.
   48px of slack leaves room for a vertical scrollbar, so the page never scrolls sideways. */
.editor-card {
  --editor-w: min(calc(100vw - 48px), 1840px);
  width: var(--editor-w);
  margin-inline: calc((100% - var(--editor-w)) / 2);
}
.editor-card[data-view="split"] .editor { grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr) 340px; }
@media (min-width: 1600px) {
  .editor-card[data-view="flow"] .editor, .editor-card[data-view="xml"] .editor { grid-template-columns: minmax(0, 1fr) 380px; }
}

/* Loft: coloured XML. The textarea's own text is transparent; the layer behind it draws the
   same characters in colour. Colour only, never bold or italic, so every glyph keeps its width. */
:root { --xpath: #6c3fb5; --x-str: #9a5800; --tag-other: #536472; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --xpath: #c3a6ff; --x-str: #f0b46a; --tag-other: #93a6b2; } }
:root[data-theme="dark"] { --xpath: #c3a6ff; --x-str: #f0b46a; --tag-other: #93a6b2; }

.xml-box { --gutter-ch: 4; --gutter-w: calc(var(--gutter-ch) * 1ch + 10px); font: 12.5px/1.5 var(--mono); }
.xml-box textarea, .xml-backdrop { padding-left: calc(var(--gutter-w) + 10px); }
.xml-box textarea { color: transparent; caret-color: var(--ink); }
.xml-box textarea::selection { color: transparent; background: color-mix(in srgb, var(--accent) 32%, transparent); }
.xml-backdrop { color: var(--ink); }

.xml-gutter {
  position: absolute; z-index: 1; left: 1px; top: 1px; bottom: 1px; width: var(--gutter-w); margin: 0;
  padding: 12px 8px 12px 0; overflow: hidden; text-align: right; white-space: pre;
  font: inherit; color: var(--muted); opacity: 0.75; border-right: 1px solid var(--line);
  border-radius: 8px 0 0 8px; background: var(--surface-2); pointer-events: auto; user-select: none;
}
.gl-bad, .gl-warn, .gl-info { opacity: 1; font-weight: inherit; cursor: help; border-radius: 3px; }
.gl-bad { color: var(--surface); background: var(--bad); box-shadow: 0 0 0 2px var(--bad); }
.gl-warn { color: var(--surface); background: var(--warn); box-shadow: 0 0 0 2px var(--warn); }
.gl-info { color: var(--info); }
.xml-lines { position: absolute; inset: 1px; overflow: hidden; pointer-events: none; border-radius: 8px; }
.xml-lines-inner { position: relative; }
.line-tint { position: absolute; left: 0; right: 0; }
.lt-bad { background: color-mix(in srgb, var(--bad) 14%, transparent); }
.lt-warn { background: color-mix(in srgb, var(--warn) 12%, transparent); }
.lt-info { display: none; }
.xml-backdrop { background: transparent; }
.xml-box { background: var(--surface-2); border-radius: 8px; }

/* Token colours */
.h-punct, .h-quote { color: var(--muted); }
.h-attr { color: var(--muted); }
.h-value { color: var(--ink); }
.h-path { color: var(--ink); }
.h-text { color: var(--ink); }
.h-literal { color: var(--warn); }
.h-entity { color: var(--info); }
.h-comment, .h-pi, .h-cdata { color: var(--muted); opacity: 0.8; }
.h-tag.r-process, .h-tag.r-struct { color: var(--ink); }
.h-tag.r-op { color: var(--accent); }
.h-tag.r-choice { color: var(--info); }
.h-tag.r-fault { color: var(--bad); }
.h-tag.r-assign { color: var(--tag-other); }
.h-tag.r-loop { color: var(--accent); }
.h-tag.r-other { color: var(--tag-other); }
.x-path { color: var(--xpath); }
.x-fn { color: var(--xpath); text-decoration: underline dotted color-mix(in srgb, var(--xpath) 50%, transparent); text-underline-offset: 3px; }
.x-str { color: var(--x-str); }
.x-num { color: var(--x-str); }

.xml-backdrop mark { background: color-mix(in srgb, var(--accent) 13%, transparent); box-shadow: -3px 0 0 color-mix(in srgb, var(--accent) 13%, transparent); }
