/* ============================================================================
   document.css — THE DOCUMENT DESIGN SYSTEM
   Shared verbatim with the standalone HTML export. Contains ZERO editor chrome.
   Clean editorial / scientific report look:
   a centered white sheet on a soft background, refined blue/teal accent,
   generous typography, status pills, dark code block, inline bar chart,
   bordered tables, two-column comparison, and base styles for every
   interactive component.
   ============================================================================ */

/* ----------------------------------------------------------------------------
   Design tokens
   ---------------------------------------------------------------------------- */
:root {
  /* Accent — refined blue/teal */
  --accent:       #1f8a8c;
  --accent-deep:  #146567;
  --accent-soft:  #e3f3f3;

  /* Ink (text) */
  --ink:          #1b2733;
  --ink-soft:     #46596b;
  --ink-faint:    #7d8f9e;

  /* Surfaces */
  --paper:        #eef1f5;   /* page background behind the sheet */
  --sheet:        #ffffff;   /* the document sheet */
  --line:         #e1e6ec;   /* hairline borders */
  --soft-bg:      #f6f8fa;   /* subtle fills (table headers, insets) */

  /* Status colors */
  --red:          #c5443c;
  --amber:        #b07410;
  --green:        #2f8a4f;
  --blue:         #2f6fb0;
  --red-bg:       #fbe9e8;
  --amber-bg:     #fbf1df;
  --green-bg:     #e7f4ec;
  --blue-bg:      #e7f0fa;

  /* Typography */
  --sans: "Noto Sans", "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI",
          Roboto, Helvetica, Arial, "Noto Sans SC", sans-serif;
  --mono: "JetBrains Mono", "Noto Sans Mono", "SFMono-Regular", Menlo, Consolas,
          "Liberation Mono", "Noto Sans SC", monospace;

  /* Rhythm */
  --radius:    12px;
  --radius-sm: 8px;
  --shadow:    0 1px 2px rgba(27, 39, 51, 0.04),
               0 12px 36px rgba(27, 39, 51, 0.10);
}

/* ----------------------------------------------------------------------------
   The document sheet
   ---------------------------------------------------------------------------- */
.document {
  box-sizing: border-box;
  max-width: 860px;
  margin: 40px auto;
  padding: 56px 64px 64px;
  background: var(--sheet);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.65;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.document *,
.document *::before,
.document *::after {
  box-sizing: border-box;
}

/* Vertical rhythm between top-level pieces */
.document > * + * {
  margin-top: 22px;
}

/* ----------------------------------------------------------------------------
   Imported documents (run/preview + export). An imported HTML file carries its
   OWN stylesheet (captured into doc.styles, injected scoped to
   `.document.is-imported .doc-page`). So that the page looks like the original
   file in the browser — not the tool's design system — we:
     1. strip the "sheet" framing from .document (no max-width / padding /
        background / shadow / border / sheet font), and
     2. reset every element inside the page back to browser defaults, via a
        ZERO-specificity :where(*) reset. The imported stylesheet (which carries
        the extra .is-imported class) outranks this reset, so it wins; anything
        it does NOT set falls back to the browser default — exactly as in the
        original file. Edit mode never gets .is-imported, so the editor keeps the
        normal design-system look for structural editing.
   ---------------------------------------------------------------------------- */
.document.is-imported {
  max-width: none;
  margin: 0;
  padding: 0;
  background: none;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  color: revert;
  font: revert;
  line-height: normal;
}
.document.is-imported > * + * {
  margin-top: 0;
}
.document.is-imported .doc-page :where(*:not(.tool-inserted, .tool-inserted *)) {
  all: revert;
}

/* Modules added (WYSIWYG ＋ Add) into an imported page are NOT imported content:
   keep them OUT of the all:revert reset above (the :not() exclusion) and re-assert
   the tool's design-system typography on the island, so an inserted block/component
   looks like a proper module instead of unstyled "too simple" text. Their own
   classes (.text-block, .statement, .lang-toggle, …) and component CSS then govern
   the rest, exactly as outside an import. :where() keeps the reset zero-specificity. */
.document.is-imported .doc-page .tool-inserted {
  font-family: var(--sans, system-ui, -apple-system, "Segoe UI", sans-serif);
  color: var(--ink, #1f2733);
  line-height: 1.6;
  margin: 1.25rem 0;
}
.document.is-imported .doc-page .tool-inserted[contenteditable="false"] {
  /* Atomic islands (interactive components) read as distinct, selectable blocks. */
  -webkit-user-modify: read-only;
}

/* EDIT mode for an imported document: its scripts don't run (they're preview/
   export-only), so any view-router sections it hides (the common .view pattern,
   shown one at a time at runtime) would be invisible/uneditable. Reveal them all
   so every part is visible and editable, calm the entrance animation, and unstick
   the doc's own top bar so it can't overlap the content while editing. */
.document.is-imported[data-mode="edit"] .doc-page .view {
  display: block !important;
  opacity: 1 !important;
  transform: none !important;
  animation: none !important;
  /* A clear divider + breathing room so the stacked pages read as separate. */
  margin-top: 2.8rem !important;
  padding-top: 2.4rem !important;
  border-top: 2px dashed #c4cad4 !important;
}
.document.is-imported[data-mode="edit"] .doc-page .view:first-child {
  margin-top: 0 !important;
  padding-top: 0 !important;
  border-top: none !important;
}
/* A page-name chip (from the view's data-title) labels each stacked page so you
   can tell which one you're editing. Edit-mode only — never in preview/export. */
.document.is-imported[data-mode="edit"] .doc-page .view::before {
  content: "▸ " attr(data-title);
  display: inline-block;
  margin: 0 0 1.1rem;
  padding: 3px 12px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: #475569;
  background: #eef1f5;
  border: 1px solid #d7dce4;
  border-radius: 999px;
}
.document.is-imported[data-mode="edit"] .doc-page .topbar {
  position: static !important;
}

/* ----------------------------------------------------------------------------
   Document meta / header
   ---------------------------------------------------------------------------- */
.doc-meta {
  padding-bottom: 22px;
  border-bottom: 2px solid var(--line);
}

.doc-meta h1 {
  margin: 0;
  font-size: 2rem;
  line-height: 1.2;
  font-weight: 800;
  letter-spacing: -0.015em;
  color: var(--ink);
}

.doc-meta .subtitle {
  margin: 6px 0 0;
  font-size: 1.12rem;
  font-weight: 400;
  color: var(--ink-soft);
  line-height: 1.45;
}

/* ----------------------------------------------------------------------------
   Page navigation — internal links between the pages of a multi-page document.
   Part of the document (ships with the export). The router toggles aria-current
   on the active link and the [hidden] attribute on the inactive .doc-page
   sections; the rule below makes that hiding robust against any reset.
   ---------------------------------------------------------------------------- */
.page-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.page-nav-link {
  font-family: var(--sans);
  font-size: 0.9rem;
  color: var(--ink-soft);
  text-decoration: none;
  padding: 5px 13px;
  border-radius: 999px;
  border: 1px solid var(--line);
  transition: background-color 0.15s ease, color 0.15s ease,
    border-color 0.15s ease;
}
.page-nav-link:hover {
  color: var(--accent-deep);
  border-color: var(--accent);
}
.page-nav-link[aria-current="page"] {
  background: var(--accent-soft);
  color: var(--accent-deep);
  border-color: var(--accent);
  font-weight: 600;
}

.doc-page[hidden] {
  display: none !important;
}

/* The pill / kv row under the title */
.meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 14px;
  margin-top: 16px;
  font-size: 0.85rem;
  color: var(--ink-soft);
}

.meta .meta-item {
  display: inline-flex;
  align-items: baseline;
  gap: 5px;
}

.meta .meta-label {
  color: var(--ink-faint);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
}

.meta .meta-value {
  color: var(--ink);
  font-weight: 500;
}

/* ----------------------------------------------------------------------------
   Status pills
   ---------------------------------------------------------------------------- */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 11px;
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  line-height: 1.4;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-deep);
  border: 1px solid color-mix(in srgb, var(--accent) 22%, transparent);
  white-space: nowrap;
}

.pill::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex: none;
  opacity: 0.85;
}

/* Imported/embedded pills ship their own explicit <span class="dot">. Suppress
   our pseudo-dot when one is present so such pills show a single dot, not two. */
.pill:has(.dot)::before {
  content: none;
}

.pill-red    { background: var(--red-bg);   color: var(--red);   border-color: color-mix(in srgb, var(--red) 26%, transparent); }
.pill-amber  { background: var(--amber-bg); color: var(--amber); border-color: color-mix(in srgb, var(--amber) 26%, transparent); }
.pill-green  { background: var(--green-bg); color: var(--green); border-color: color-mix(in srgb, var(--green) 26%, transparent); }
.pill-blue   { background: var(--blue-bg);  color: var(--blue);  border-color: color-mix(in srgb, var(--blue) 26%, transparent); }

/* ----------------------------------------------------------------------------
   Headings inside the body
   ---------------------------------------------------------------------------- */
.document h2 {
  margin: 36px 0 12px;
  font-size: 1.42rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.3;
  color: var(--ink);
}

.document h3 {
  margin: 26px 0 10px;
  font-size: 1.12rem;
  font-weight: 700;
  line-height: 1.35;
  color: var(--ink);
}

.document p {
  margin: 0 0 14px;
}

.document p:last-child {
  margin-bottom: 0;
}

.document a {
  color: var(--accent-deep);
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-thickness: 1px;
}

.document a:hover {
  color: var(--accent);
}

.document strong { font-weight: 700; color: var(--ink); }
.document em     { font-style: italic; }

.document code {
  font-family: var(--mono);
  font-size: 0.88em;
  background: var(--soft-bg);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 1px 5px;
}

.document blockquote {
  margin: 16px 0;
  padding: 4px 18px;
  border-left: 3px solid var(--accent);
  color: var(--ink-soft);
  font-style: italic;
}

.document ul,
.document ol {
  margin: 0 0 14px;
  padding-left: 1.4em;
}

.document li + li { margin-top: 4px; }

/* ----------------------------------------------------------------------------
   Statement (callout line)
   ---------------------------------------------------------------------------- */
.statement {
  margin: 0;
  padding: 16px 20px;
  font-size: 1.06rem;
  font-weight: 500;
  line-height: 1.5;
  color: var(--ink);
  background: linear-gradient(180deg,
              color-mix(in srgb, var(--accent-soft) 70%, white) 0%,
              var(--accent-soft) 100%);
  border: 1px solid color-mix(in srgb, var(--accent) 18%, transparent);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius-sm);
}

/* ----------------------------------------------------------------------------
   Key/value meta list (.kv)
   ---------------------------------------------------------------------------- */
.kv {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 6px 20px;
  margin: 0;
  padding: 16px 20px;
  background: var(--soft-bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: 0.94rem;
}

.kv dt {
  margin: 0;
  font-weight: 600;
  color: var(--ink-faint);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  align-self: center;
}

.kv dd {
  margin: 0;
  color: var(--ink);
}

/* ----------------------------------------------------------------------------
   Figures
   ---------------------------------------------------------------------------- */
.document figure {
  margin: 22px 0;
}

.figure-frame {
  padding: 12px;
  background: var(--soft-bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.figure-frame img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 0 auto;
  border-radius: 4px;
}

.document figcaption {
  margin-top: 10px;
  font-size: 0.85rem;
  color: var(--ink-soft);
  text-align: center;
  line-height: 1.45;
}

.document figcaption::before {
  content: "Figure — ";
  font-weight: 600;
  color: var(--ink-faint);
}

/* ----------------------------------------------------------------------------
   Inline bar chart
   ---------------------------------------------------------------------------- */
.chart {
  margin: 22px 0;
  padding: 20px 22px;
  background: var(--sheet);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

.chart .chart-caption {
  margin: 0 0 16px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.bar-row {
  display: grid;
  grid-template-columns: 120px 1fr 56px;
  align-items: center;
  gap: 12px;
  margin: 0 0 10px;
}

.bar-row:last-child { margin-bottom: 0; }

.bar-label {
  font-size: 0.88rem;
  color: var(--ink-soft);
  text-align: right;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bar-track {
  position: relative;
  height: 22px;
  background: var(--soft-bg);
  border-radius: 6px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  min-width: 2px;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--accent) 0%, var(--accent-deep) 100%);
  transition: width 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}

.bar-fill.peak {
  background: linear-gradient(90deg,
              color-mix(in srgb, var(--accent) 75%, var(--green)) 0%,
              var(--green) 100%);
}

.bar-value {
  font-family: var(--mono);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ink);
  text-align: right;
}

/* ----------------------------------------------------------------------------
   Tables
   ---------------------------------------------------------------------------- */
.table-wrap {
  margin: 22px 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  overflow-x: auto;
}

.document table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

.document table th,
.document table td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

.document table th {
  background: var(--soft-bg);
  color: var(--ink-soft);
  font-weight: 700;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  position: sticky;
  top: 0;
}

.document table tr:last-child td {
  border-bottom: none;
}

.document table tbody tr:nth-child(even) td {
  background: color-mix(in srgb, var(--soft-bg) 55%, white);
}

.document table tbody tr:hover td {
  background: var(--accent-soft);
}

/* ----------------------------------------------------------------------------
   Code block (dark, with syntax token colors)
   ---------------------------------------------------------------------------- */
.code {
  margin: 22px 0;
  background: #16202b;
  color: #d7e2ed;
  border: 1px solid #0f1822;
  border-radius: var(--radius-sm);
  overflow: hidden;
  font-family: var(--mono);
  font-size: 0.86rem;
  line-height: 1.6;
}

.code .code-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  background: #101822;
  border-bottom: 1px solid #0a121b;
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #8aa0b4;
}

.code .code-head::before {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #f06a5d;
  box-shadow: 16px 0 0 #f5bd4f, 32px 0 0 #5fc26a;
  margin-right: 28px;
  flex: none;
}

.code pre {
  margin: 0;
  padding: 16px 18px;
  overflow-x: auto;
  white-space: pre;
}

.code code {
  background: none;
  border: none;
  padding: 0;
  font-size: inherit;
  color: inherit;
}

/* Syntax token spans */
.code .k { color: #7fb4ff; }   /* keyword */
.code .s { color: #9ee08a; }   /* string  */
.code .n { color: #f3b96b; }   /* number  */
.code .c { color: #6f8497; font-style: italic; }  /* comment */

/* ----------------------------------------------------------------------------
   Two-column comparison
   ---------------------------------------------------------------------------- */
.compare2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin: 22px 0;
}

.cmp {
  padding: 16px 18px;
  background: var(--soft-bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

.cmp-head {
  margin: -16px -18px 14px;
  padding: 10px 18px;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--accent-deep);
  background: var(--accent-soft);
  border-bottom: 1px solid color-mix(in srgb, var(--accent) 18%, transparent);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}

.cmp > *:last-child { margin-bottom: 0; }

/* ----------------------------------------------------------------------------
   Sections
   ---------------------------------------------------------------------------- */
.section {
  margin: 28px 0;
  padding: 4px 0 0;
}

.section-title {
  margin: 0 0 16px;
  padding-bottom: 8px;
  font-size: 1.42rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--ink);
  border-bottom: 2px solid var(--accent);
  display: inline-block;
}

.section > .section-title {
  display: block;
}

.section > * + * {
  margin-top: 18px;
}

/* ----------------------------------------------------------------------------
   Actions (link buttons)
   ---------------------------------------------------------------------------- */
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 22px 0;
}

.action {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 18px;
  font-size: 0.92rem;
  font-weight: 600;
  font-family: var(--sans);
  text-decoration: none;
  color: #fff;
  background: var(--accent);
  border: 1px solid var(--accent-deep);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
}

.action:hover {
  background: var(--accent-deep);
  color: #fff;
}

.action:active {
  transform: translateY(1px);
}

.action.secondary {
  background: var(--sheet);
  color: var(--accent-deep);
  border-color: var(--line);
}

.action.secondary:hover {
  background: var(--accent-soft);
  color: var(--accent-deep);
}

/* ============================================================================
   INTERACTIVE COMPONENT BASE STYLES
   Structural base shared by components.js. Component-specific tweaks may live
   in each component's css string, but these base classes keep them consistent.
   ============================================================================ */

/* Generic component wrapper niceties */
.document [data-comp] {
  margin: 22px 0;
}

/* ---- Language toggle -------------------------------------------------------- */
.lang-toggle {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--sheet);
}

.lang-toggle .lang-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px 12px;
  background: var(--soft-bg);
  border-bottom: 1px solid var(--line);
}

.lang-btn {
  appearance: none;
  font-family: var(--sans);
  font-size: 0.86rem;
  font-weight: 600;
  padding: 6px 14px;
  color: var(--ink-soft);
  background: var(--sheet);
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.lang-btn:hover {
  border-color: var(--accent);
  color: var(--accent-deep);
}

.lang-btn.is-active {
  background: var(--accent);
  border-color: var(--accent-deep);
  color: #fff;
}

.lang-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.lang-panel {
  padding: 16px 18px;
  color: var(--ink);
  line-height: 1.6;
}

.lang-panel[hidden] {
  display: none;
}

.lang-panel > *:last-child { margin-bottom: 0; }

/* ---- Collapsible / details -------------------------------------------------- */
.collapsible {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--sheet);
}

.collapsible > .collapsible-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  appearance: none;
  text-align: left;
  font-family: var(--sans);
  font-size: 0.98rem;
  font-weight: 600;
  color: var(--ink);
  padding: 13px 16px;
  background: var(--soft-bg);
  border: none;
  cursor: pointer;
  transition: background 0.15s ease;
}

.collapsible > .collapsible-toggle:hover {
  background: var(--accent-soft);
}

.collapsible > .collapsible-toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.collapsible > .collapsible-toggle::before {
  content: "";
  width: 0;
  height: 0;
  border-left: 6px solid var(--ink-faint);
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
  flex: none;
  transition: transform 0.2s ease;
}

.collapsible > .collapsible-toggle[aria-expanded="true"]::before {
  transform: rotate(90deg);
}

.collapsible .collapsible-panel {
  padding: 16px 18px;
  border-top: 1px solid var(--line);
  line-height: 1.6;
}

.collapsible .collapsible-panel[hidden] {
  display: none;
}

.collapsible .collapsible-panel > *:last-child { margin-bottom: 0; }

/* ---- Tabs ------------------------------------------------------------------- */
.tabs {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--sheet);
}

.tabs .tab-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  padding: 0 6px;
  background: var(--soft-bg);
  border-bottom: 1px solid var(--line);
}

.tab {
  appearance: none;
  font-family: var(--sans);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--ink-soft);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 11px 16px;
  margin-bottom: -1px;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.tab:hover {
  color: var(--accent-deep);
}

.tab.is-active {
  color: var(--accent-deep);
  border-bottom-color: var(--accent);
}

.tab:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.tab-panel {
  padding: 16px 18px;
  line-height: 1.6;
}

.tab-panel[hidden] {
  display: none;
}

.tab-panel > *:last-child { margin-bottom: 0; }

/* ---- Copy-to-clipboard button ----------------------------------------------- */
.copy-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  appearance: none;
  font-family: var(--sans);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--accent-deep);
  background: var(--accent-soft);
  border: 1px solid color-mix(in srgb, var(--accent) 26%, transparent);
  border-radius: var(--radius-sm);
  padding: 9px 16px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.copy-btn::before {
  content: "";
  width: 14px;
  height: 14px;
  flex: none;
  background-color: currentColor;
  -webkit-mask: no-repeat center / contain
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='currentColor' d='M16 1H4a2 2 0 0 0-2 2v14h2V3h12V1Zm3 4H8a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h11a2 2 0 0 0 2-2V7a2 2 0 0 0-2-2Zm0 16H8V7h11v14Z'/%3E%3C/svg%3E");
          mask: no-repeat center / contain
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='currentColor' d='M16 1H4a2 2 0 0 0-2 2v14h2V3h12V1Zm3 4H8a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h11a2 2 0 0 0 2-2V7a2 2 0 0 0-2-2Zm0 16H8V7h11v14Z'/%3E%3C/svg%3E");
}

.copy-btn:hover {
  background: var(--accent);
  color: #fff;
}

.copy-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.copy-btn.is-copied {
  background: var(--green-bg);
  color: var(--green);
  border-color: color-mix(in srgb, var(--green) 30%, transparent);
}

/* ---- Filterable table ------------------------------------------------------- */
.filter-table {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--sheet);
}

.filter-table .filter-bar {
  padding: 12px 14px;
  background: var(--soft-bg);
  border-bottom: 1px solid var(--line);
}

.filter-table .filter-input {
  width: 100%;
  font-family: var(--sans);
  font-size: 0.92rem;
  color: var(--ink);
  padding: 9px 14px 9px 36px;
  background: var(--sheet)
    no-repeat 12px center / 16px
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%237d8f9e' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E");
  border: 1px solid var(--line);
  border-radius: 999px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.filter-table .filter-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}

.filter-table .filter-input::placeholder {
  color: var(--ink-faint);
}

.filter-table table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

.filter-table th,
.filter-table td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--line);
}

.filter-table th {
  background: color-mix(in srgb, var(--soft-bg) 55%, white);
  color: var(--ink-soft);
  font-weight: 700;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.filter-table tbody tr:last-child td {
  border-bottom: none;
}

.filter-table tbody tr[hidden] {
  display: none;
}

.filter-table .filter-empty {
  padding: 16px 14px;
  color: var(--ink-faint);
  font-size: 0.9rem;
  text-align: center;
}

/* ============================================================================
   RESPONSIVE
   ============================================================================ */
@media (max-width: 720px) {
  .document {
    margin: 0;
    padding: 32px 22px 40px;
    border-radius: 0;
    border-left: none;
    border-right: none;
    font-size: 15px;
  }

  .doc-meta h1 { font-size: 1.6rem; }

  .compare2 {
    grid-template-columns: 1fr;
  }

  .bar-row {
    grid-template-columns: 90px 1fr 48px;
    gap: 8px;
  }

  .kv {
    grid-template-columns: 1fr;
    gap: 2px 0;
  }

  .kv dt {
    margin-top: 8px;
  }

  .kv dt:first-of-type {
    margin-top: 0;
  }
}

/* ============================================================================
   REDUCED MOTION
   ============================================================================ */
@media (prefers-reduced-motion: reduce) {
  .document *,
  .document *::before,
  .document *::after {
    transition-duration: 0.001ms !important;
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
  }
}

/* ============================================================================
   EMBEDDED HTML — an imported standalone document, rendered faithfully in an
   isolated iframe (keeps its own CSS, fonts and behavior). Auto-sized by JS.
   ============================================================================ */
.embed-block {
  margin: 0;
}
/* Single imported document fills the view: drop the tool's sheet chrome so the
   embedded file's own page/sheet/background is shown exactly as designed. */
.document.is-embed {
  max-width: none;
  margin: 0;
  padding: 0;
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}
.embed-frame {
  display: block;
  width: 100%;
  border: 0;
  min-height: 240px;
  background: var(--paper, #fff);
}

/* ============================================================================
   PRINT — clean PDF output. Hide editor chrome, drop shadows, lighten code,
   avoid breaking sections / figures across pages, full-width sheet.
   ============================================================================ */
@media print {
  /* Hide all editor chrome that may surround the document when printing
     directly from the app. These :where() selectors keep specificity low
     and never affect the exported standalone file (which has no chrome). */
  :where(.app-bar, .block-toolbar, .mode-toggle, .add-menu, .settings-dialog,
         .block-add, .editor-only) {
    display: none !important;
  }

  /* Strip the block-shell outline/affordances if printing from edit view */
  :where(.block-shell) {
    border: none !important;
    outline: none !important;
    padding: 0 !important;
    margin: 0 !important;
  }

  html, body {
    background: #fff !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  .document {
    max-width: none;
    width: 100%;
    margin: 0;
    padding: 0;
    border: none;
    border-radius: 0;
    box-shadow: none !important;
    font-size: 11pt;
    color: #000;
  }

  /* Remove shadows everywhere in print */
  .document *,
  .statement,
  .chart,
  .cmp,
  .table-wrap,
  .code {
    box-shadow: none !important;
  }

  /* Lighten the dark code block so it prints legibly */
  .code {
    background: #f5f7f9 !important;
    color: #1b2733 !important;
    border: 1px solid #c9d2db !important;
  }

  .code .code-head {
    background: #e9edf1 !important;
    color: #46596b !important;
    border-bottom: 1px solid #c9d2db !important;
  }

  .code .code-head::before {
    background: #b6c0ca !important;
    box-shadow: 16px 0 0 #b6c0ca, 32px 0 0 #b6c0ca !important;
  }

  .code .k { color: #1a4f9c !important; }
  .code .s { color: #2f7d2f !important; }
  .code .n { color: #9c5a16 !important; }
  .code .c { color: #6b7785 !important; }

  /* Keep cohesive units together across page breaks */
  .section,
  figure,
  .figure-frame,
  .chart,
  .table-wrap,
  .compare2,
  .cmp,
  .statement,
  .kv,
  .collapsible,
  .tabs,
  .code {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .document h1,
  .document h2,
  .document h3,
  .section-title {
    break-after: avoid;
    page-break-after: avoid;
  }

  /* Expand any collapsed interactive content so nothing is lost on paper */
  .collapsible .collapsible-panel[hidden],
  .lang-panel[hidden],
  .tab-panel[hidden] {
    display: block !important;
  }

  .filter-table tbody tr[hidden] {
    display: table-row !important;
  }

  /* Soften interactive controls to neutral ink for print */
  .lang-btn,
  .tab,
  .copy-btn,
  .action {
    color: #000 !important;
    background: transparent !important;
    border-color: #c9d2db !important;
  }

  .lang-btn.is-active,
  .tab.is-active {
    font-weight: 800 !important;
  }

  a {
    color: #000 !important;
    text-decoration: underline !important;
  }
}
