/* Meu CDN · NFS-e — tokens, reset e componentes compartilhados */

:root {
  color-scheme: light;
  --font-ui: "Schibsted Grotesk", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;

  --bg: oklch(0.974 0.004 95);
  --surface: oklch(0.994 0.002 95);
  --surface-2: oklch(0.952 0.006 95);
  --surface-3: oklch(0.93 0.007 95);
  --line: oklch(0.885 0.007 95);
  --line-strong: oklch(0.79 0.009 95);
  --ink: oklch(0.22 0.016 255);
  --ink-2: oklch(0.40 0.016 255);
  --ink-3: oklch(0.50 0.013 255);
  --accent: oklch(0.45 0.13 258);
  --accent-hover: oklch(0.40 0.13 258);
  --accent-ink: oklch(0.99 0.004 258);
  --accent-soft: oklch(0.94 0.03 258);
  --focus: oklch(0.55 0.16 258);

  --ok: oklch(0.47 0.11 155);
  --ok-soft: oklch(0.945 0.04 155);
  --bad: oklch(0.50 0.17 27);
  --bad-soft: oklch(0.95 0.03 27);
  --warn: oklch(0.50 0.11 62);
  --warn-soft: oklch(0.95 0.05 85);
  --info: oklch(0.48 0.10 228);
  --info-soft: oklch(0.945 0.03 228);
  --neutral-soft: oklch(0.925 0.006 95);

  --shadow-1: 0 1px 2px oklch(0.3 0.02 255 / 0.06), 0 1px 1px oklch(0.3 0.02 255 / 0.04);
  --shadow-2: 0 12px 32px -8px oklch(0.25 0.03 255 / 0.18), 0 2px 6px oklch(0.25 0.03 255 / 0.08);
  --backdrop: oklch(0.2 0.02 255 / 0.42);

  --r-1: 4px;
  --r-2: 6px;
  --r-3: 10px;

  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);
  --ease-drawer: cubic-bezier(0.32, 0.72, 0, 1);

  --sidebar-w: 236px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: oklch(0.185 0.01 255);
    --surface: oklch(0.215 0.012 255);
    --surface-2: oklch(0.165 0.01 255);
    --surface-3: oklch(0.255 0.012 255);
    --line: oklch(0.30 0.012 255);
    --line-strong: oklch(0.40 0.014 255);
    --ink: oklch(0.94 0.005 95);
    --ink-2: oklch(0.80 0.009 95);
    --ink-3: oklch(0.68 0.01 255);
    --accent: oklch(0.74 0.11 258);
    --accent-hover: oklch(0.80 0.10 258);
    --accent-ink: oklch(0.18 0.03 258);
    --accent-soft: oklch(0.30 0.05 258);
    --focus: oklch(0.74 0.13 258);
    --ok: oklch(0.78 0.12 155);
    --ok-soft: oklch(0.29 0.045 155);
    --bad: oklch(0.76 0.13 27);
    --bad-soft: oklch(0.30 0.06 27);
    --warn: oklch(0.82 0.11 80);
    --warn-soft: oklch(0.31 0.05 75);
    --info: oklch(0.78 0.09 228);
    --info-soft: oklch(0.29 0.045 228);
    --neutral-soft: oklch(0.28 0.01 255);
    --shadow-1: 0 1px 2px oklch(0 0 0 / 0.3);
    --shadow-2: 0 16px 40px -8px oklch(0 0 0 / 0.55), 0 2px 8px oklch(0 0 0 / 0.3);
    --backdrop: oklch(0.08 0.01 255 / 0.6);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: oklch(0.185 0.01 255);
  --surface: oklch(0.215 0.012 255);
  --surface-2: oklch(0.165 0.01 255);
  --surface-3: oklch(0.255 0.012 255);
  --line: oklch(0.30 0.012 255);
  --line-strong: oklch(0.40 0.014 255);
  --ink: oklch(0.94 0.005 95);
  --ink-2: oklch(0.80 0.009 95);
  --ink-3: oklch(0.68 0.01 255);
  --accent: oklch(0.74 0.11 258);
  --accent-hover: oklch(0.80 0.10 258);
  --accent-ink: oklch(0.18 0.03 258);
  --accent-soft: oklch(0.30 0.05 258);
  --focus: oklch(0.74 0.13 258);
  --ok: oklch(0.78 0.12 155);
  --ok-soft: oklch(0.29 0.045 155);
  --bad: oklch(0.76 0.13 27);
  --bad-soft: oklch(0.30 0.06 27);
  --warn: oklch(0.82 0.11 80);
  --warn-soft: oklch(0.31 0.05 75);
  --info: oklch(0.78 0.09 228);
  --info-soft: oklch(0.29 0.045 228);
  --neutral-soft: oklch(0.28 0.01 255);
  --shadow-1: 0 1px 2px oklch(0 0 0 / 0.3);
  --shadow-2: 0 16px 40px -8px oklch(0 0 0 / 0.55), 0 2px 8px oklch(0 0 0 / 0.3);
  --backdrop: oklch(0.08 0.01 255 / 0.6);
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 0.9375rem;
  line-height: 1.5;
  font-feature-settings: "ss01", "cv11";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
h1, h2, h3, h4, p, dl, dd, figure, ol, ul { margin: 0; }
ol, ul { padding: 0; list-style: none; }
h1, h2, h3, h4 { font-weight: 600; line-height: 1.2; text-wrap: balance; letter-spacing: -0.012em; }
img, svg { display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); text-underline-offset: 0.18em; text-decoration-thickness: 1px; }
a:hover { color: var(--accent-hover); }
::selection { background: var(--accent-soft); color: var(--ink); }
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: var(--r-1); }
[hidden] { display: none !important; }

* { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 10px; border: 3px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-track { background: transparent; }

.mono { font-family: var(--font-mono); font-size: 0.92em; letter-spacing: 0; font-variant-numeric: tabular-nums slashed-zero; }
.num { font-variant-numeric: lining-nums; }
.muted { color: var(--ink-3); }
.soft { color: var(--ink-2); }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.sr-only {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Icon ---------- */
.i { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.i-sm { width: 15px; height: 15px; }
.i-lg { width: 22px; height: 22px; }

/* ---------- Buttons ---------- */
.btn {
  --btn-bg: var(--surface);
  --btn-fg: var(--ink);
  --btn-bd: var(--line-strong);
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  min-height: 36px; padding: 0 0.875rem;
  border: 1px solid var(--btn-bd); border-radius: var(--r-2);
  background: var(--btn-bg); color: var(--btn-fg);
  font-size: 0.875rem; font-weight: 500; line-height: 1; white-space: nowrap;
  text-decoration: none; cursor: pointer; user-select: none;
  box-shadow: var(--shadow-1);
  transition: background-color 140ms ease, border-color 140ms ease, color 140ms ease, transform 140ms var(--ease-out);
}
.btn:hover { --btn-bg: var(--surface-2); color: var(--btn-fg); }
.btn:active:not(:disabled) { transform: scale(0.97); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; }
.btn-primary { --btn-bg: var(--accent); --btn-fg: var(--accent-ink); --btn-bd: var(--accent); }
.btn-primary:hover { --btn-bg: var(--accent-hover); --btn-bd: var(--accent-hover); }
.btn-danger { --btn-bg: var(--bad); --btn-fg: oklch(0.99 0 0); --btn-bd: var(--bad); }
.btn-danger:hover { --btn-bg: color-mix(in oklch, var(--bad) 88%, black); }
:root[data-theme="dark"] .btn-danger { --btn-fg: oklch(0.18 0.02 27); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn-danger { --btn-fg: oklch(0.18 0.02 27); } }
.btn-danger-ghost { --btn-fg: var(--bad); --btn-bd: color-mix(in oklch, var(--bad) 40%, var(--line)); }
.btn-danger-ghost:hover { --btn-bg: var(--bad-soft); }
.btn-ghost { --btn-bg: transparent; --btn-bd: transparent; box-shadow: none; color: var(--ink-2); }
.btn-ghost:hover { --btn-bg: var(--surface-3); color: var(--ink); }
.btn-sm { min-height: 30px; padding: 0 0.625rem; font-size: 0.8125rem; gap: 0.375rem; }
.btn-icon { width: 36px; padding: 0; }
.btn-sm.btn-icon { width: 30px; }
.btn[data-busy="true"] { pointer-events: none; }
.btn[data-busy="true"] > .i { animation: spin 700ms linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin 650ms linear infinite; flex: none; }

/* ---------- Forms ---------- */
.field { display: grid; gap: 0.375rem; min-width: 0; align-content: start; }
.field > label, .label { font-size: 0.8125rem; font-weight: 500; color: var(--ink-2); }
.field .hint { font-size: 0.78rem; color: var(--ink-3); line-height: 1.45; }
.field .err { font-size: 0.78rem; color: var(--bad); font-weight: 500; }
.req::after { content: " *"; color: var(--bad); }
.input, .select, .textarea {
  width: 100%; min-height: 38px; padding: 0.5rem 0.7rem;
  border: 1px solid var(--line-strong); border-radius: var(--r-2);
  background: var(--surface); color: var(--ink);
  font-size: 0.9rem; line-height: 1.35;
  transition: border-color 140ms ease, box-shadow 140ms ease;
}
.input::placeholder, .textarea::placeholder { color: var(--ink-3); opacity: 1; }
.input:hover, .select:hover, .textarea:hover { border-color: var(--ink-3); }
.input:focus-visible, .select:focus-visible, .textarea:focus-visible {
  outline: none; border-color: var(--focus);
  box-shadow: 0 0 0 3px color-mix(in oklch, var(--focus) 22%, transparent);
}
.input[aria-invalid="true"], .select[aria-invalid="true"], .textarea[aria-invalid="true"] { border-color: var(--bad); }
.input:disabled, .select:disabled, .textarea:disabled, .input[readonly] { background: var(--surface-2); color: var(--ink-2); cursor: not-allowed; }
.input.mono { font-size: 0.86rem; }
.textarea { min-height: 96px; resize: vertical; }
.select {
  appearance: none; padding-right: 2rem; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--ink-3) 50%), linear-gradient(135deg, var(--ink-3) 50%, transparent 50%);
  background-position: calc(100% - 15px) 55%, calc(100% - 10px) 55%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}
.input-group { position: relative; display: flex; align-items: center; }
.input-group > .i { position: absolute; left: 0.65rem; color: var(--ink-3); pointer-events: none; }
.input-group > .input { padding-left: 2.1rem; }
.input-group > .btn-affix { position: absolute; right: 3px; }

.check { display: flex; align-items: flex-start; gap: 0.625rem; cursor: pointer; font-size: 0.875rem; }
.check input[type="checkbox"], .check input[type="radio"] { margin: 0.2rem 0 0; width: 16px; height: 16px; accent-color: var(--accent); flex: none; }
.check .check-text { display: grid; gap: 0.125rem; }
.check .check-text small { color: var(--ink-3); font-size: 0.78rem; line-height: 1.45; }

/* Switch */
.switch { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .track {
  position: relative; flex: none; width: 36px; height: 20px; margin-top: 0.1rem;
  border-radius: 20px; background: var(--line-strong);
  transition: background-color 160ms ease;
}
.switch .track::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%;
  background: var(--surface); box-shadow: 0 1px 2px oklch(0 0 0 / 0.25);
  transition: transform 180ms var(--ease-out);
}
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track::after { transform: translateX(16px); }
.switch input:focus-visible + .track { outline: 2px solid var(--focus); outline-offset: 2px; }
.switch input:disabled + .track { opacity: 0.5; }

/* ---------- Status chip ---------- */
.chip {
  --chip-fg: var(--ink-2); --chip-bg: var(--neutral-soft);
  display: inline-flex; align-items: center; gap: 0.4rem;
  padding: 0.18rem 0.5rem 0.18rem 0.45rem; border-radius: 999px;
  background: var(--chip-bg); color: var(--chip-fg);
  font-size: 0.75rem; font-weight: 600; line-height: 1.3; white-space: nowrap;
}
.chip::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.chip[data-tone="success"] { --chip-fg: var(--ok); --chip-bg: var(--ok-soft); }
.chip[data-tone="danger"] { --chip-fg: var(--bad); --chip-bg: var(--bad-soft); }
.chip[data-tone="warning"] { --chip-fg: var(--warn); --chip-bg: var(--warn-soft); }
.chip[data-tone="info"] { --chip-fg: var(--info); --chip-bg: var(--info-soft); }
.chip[data-tone="muted"] { --chip-fg: var(--ink-3); --chip-bg: transparent; box-shadow: inset 0 0 0 1px var(--line-strong); }
.chip[data-live="true"]::before { animation: pulse 1.4s ease-in-out infinite; }
.chip-lg { font-size: 0.8125rem; padding: 0.3rem 0.7rem 0.3rem 0.6rem; }
.chip.changed { animation: chip-changed 900ms var(--ease-out); }
@keyframes pulse { 50% { opacity: 0.25; } }
@keyframes chip-changed {
  0% { box-shadow: 0 0 0 0 color-mix(in oklch, var(--chip-fg) 45%, transparent); }
  100% { box-shadow: 0 0 0 7px transparent; }
}

.tag {
  display: inline-flex; align-items: center; gap: 0.3rem;
  padding: 0.1rem 0.4rem; border-radius: var(--r-1);
  border: 1px solid var(--line-strong); color: var(--ink-2);
  font-family: var(--font-mono); font-size: 0.7rem; font-weight: 500; letter-spacing: 0.02em; text-transform: uppercase; white-space: nowrap;
}
.tag[data-tone="warning"] { border-color: color-mix(in oklch, var(--warn) 50%, var(--line)); color: var(--warn); background: var(--warn-soft); }
.tag[data-tone="success"] { border-color: color-mix(in oklch, var(--ok) 40%, var(--line)); color: var(--ok); }
.tag[data-tone="danger"] { border-color: color-mix(in oklch, var(--bad) 40%, var(--line)); color: var(--bad); }

/* ---------- Panels ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-3); box-shadow: var(--shadow-1); min-width: 0; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 0.875rem 1.125rem; border-bottom: 1px solid var(--line); }
.panel-head h2, .panel-head h3 { font-size: 0.9375rem; }
.panel-body { padding: 1.125rem; }
.panel-foot { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 0.75rem 1.125rem; border-top: 1px solid var(--line); flex-wrap: wrap; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; overscroll-behavior-x: contain; }
.table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
.table th {
  position: sticky; top: 0; z-index: 1;
  padding: 0.6rem 0.875rem; text-align: left; white-space: nowrap;
  background: var(--surface-2); color: var(--ink-3);
  font-size: 0.72rem; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase;
  border-bottom: 1px solid var(--line);
}
.table td { padding: 0.7rem 0.875rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tr.row-link { cursor: pointer; }
.table tr.row-link:hover td { background: color-mix(in oklch, var(--surface-2) 70%, transparent); }
.table .cell-main { font-weight: 500; color: var(--ink); text-decoration: none; }
.table a.cell-main:hover { color: var(--accent); text-decoration: underline; }
.table .cell-sub { display: block; font-size: 0.78rem; color: var(--ink-3); margin-top: 0.1rem; }
.table th.right, .table td.right { text-align: right; }
.table td.actions { text-align: right; white-space: nowrap; width: 1%; }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 0.25rem; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  position: relative; display: inline-flex; align-items: center; gap: 0.45rem;
  padding: 0.7rem 0.8rem; border: 0; background: none; cursor: pointer; white-space: nowrap;
  color: var(--ink-3); font-size: 0.875rem; font-weight: 500;
  transition: color 140ms ease;
}
.tab:hover { color: var(--ink); }
.tab[aria-selected="true"] { color: var(--ink); }
.tab::after {
  content: ""; position: absolute; left: 0.5rem; right: 0.5rem; bottom: -1px; height: 2px; border-radius: 2px;
  background: var(--accent); transform: scaleX(0); transition: transform 200ms var(--ease-out);
}
.tab[aria-selected="true"]::after { transform: scaleX(1); }
.tab .dot-err { width: 7px; height: 7px; border-radius: 50%; background: var(--bad); }
.tab-panel:focus-visible { outline-offset: 4px; }

/* ---------- Segmented ---------- */
.seg { display: inline-flex; padding: 3px; border-radius: var(--r-2); background: var(--surface-3); gap: 2px; }
.seg button {
  border: 0; background: transparent; padding: 0.35rem 0.7rem; border-radius: 4px; cursor: pointer;
  font-size: 0.8125rem; font-weight: 500; color: var(--ink-2);
  transition: background-color 140ms ease, color 140ms ease;
}
.seg button:hover { color: var(--ink); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1); }

/* ---------- Definition lists ---------- */
.dl { display: grid; grid-template-columns: minmax(120px, 34%) 1fr; gap: 0.55rem 1rem; font-size: 0.875rem; }
.dl dt { color: var(--ink-3); }
.dl dd { color: var(--ink); min-width: 0; overflow-wrap: anywhere; }

/* ---------- Callouts ---------- */
.callout {
  display: grid; grid-template-columns: auto 1fr; gap: 0.75rem; align-items: start;
  padding: 0.875rem 1rem; border-radius: var(--r-2);
  background: var(--neutral-soft); color: var(--ink);
  font-size: 0.875rem;
}
.callout > .i { margin-top: 0.1rem; color: var(--ink-2); }
.callout[data-tone="danger"] { background: var(--bad-soft); }
.callout[data-tone="danger"] > .i { color: var(--bad); }
.callout[data-tone="warning"] { background: var(--warn-soft); }
.callout[data-tone="warning"] > .i { color: var(--warn); }
.callout[data-tone="info"] { background: var(--info-soft); }
.callout[data-tone="info"] > .i { color: var(--info); }
.callout[data-tone="success"] { background: var(--ok-soft); }
.callout[data-tone="success"] > .i { color: var(--ok); }
.callout strong { font-weight: 600; }

/* ---------- Skeleton ---------- */
.sk {
  display: block; border-radius: var(--r-1); min-height: 0.9em;
  background: linear-gradient(90deg, var(--surface-3) 0%, var(--surface-2) 50%, var(--surface-3) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.3s ease-in-out infinite;
}
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }
.sk-line { height: 0.8rem; }
.sk-block { height: 180px; border-radius: var(--r-2); }
.w-20 { width: 20%; } .w-30 { width: 30%; } .w-40 { width: 40%; } .w-50 { width: 50%; } .w-60 { width: 60%; } .w-70 { width: 70%; } .w-80 { width: 80%; } .w-90 { width: 90%; }

/* ---------- Empty state ---------- */
.empty {
  display: grid; justify-items: center; gap: 0.5rem; text-align: center;
  padding: 2.75rem 1.25rem; color: var(--ink-2);
}
.empty .empty-mark {
  display: grid; place-items: center; width: 44px; height: 44px; border-radius: 12px;
  background: var(--surface-3); color: var(--ink-3); margin-bottom: 0.25rem;
}
.empty h3 { font-size: 0.975rem; color: var(--ink); }
.empty p { max-width: 44ch; font-size: 0.875rem; color: var(--ink-3); }
.empty .btn { margin-top: 0.5rem; }

/* ---------- Dialog ---------- */
dialog.dlg {
  width: min(520px, calc(100vw - 32px)); max-height: calc(100dvh - 48px);
  padding: 0; border: 1px solid var(--line); border-radius: var(--r-3);
  background: var(--surface); color: var(--ink); box-shadow: var(--shadow-2);
  overflow: hidden;
  opacity: 1; transform: none;
  transition: opacity 180ms var(--ease-out), transform 220ms var(--ease-out), overlay 220ms allow-discrete, display 220ms allow-discrete;
}
dialog.dlg-wide { width: min(680px, calc(100vw - 32px)); }
dialog.dlg[open] { display: flex; flex-direction: column; }
@starting-style { dialog.dlg[open] { opacity: 0; transform: translateY(6px) scale(0.985); } }
dialog.dlg.closing { opacity: 0; transform: scale(0.985); }
dialog.dlg::backdrop { background: var(--backdrop); transition: opacity 200ms ease, overlay 200ms allow-discrete, display 200ms allow-discrete; }
@starting-style { dialog.dlg[open]::backdrop { opacity: 0; } }
.dlg-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; padding: 1.125rem 1.25rem 0.5rem; }
.dlg-head h2 { font-size: 1.05rem; }
.dlg-head p { margin-top: 0.3rem; color: var(--ink-3); font-size: 0.85rem; }
.dlg-body { padding: 0.75rem 1.25rem 1.25rem; overflow-y: auto; display: grid; gap: 1rem; }
.dlg-foot { display: flex; justify-content: flex-end; gap: 0.5rem; padding: 0.875rem 1.25rem; border-top: 1px solid var(--line); background: var(--surface-2); flex-wrap: wrap; }

/* ---------- Toasts ---------- */
.toasts {
  position: fixed; z-index: 100; right: 16px; bottom: 16px;
  display: grid; gap: 0.5rem; width: min(380px, calc(100vw - 32px));
  pointer-events: none;
}
.toast {
  display: grid; grid-template-columns: auto 1fr auto; gap: 0.625rem; align-items: start;
  padding: 0.75rem 0.75rem 0.75rem 0.875rem; border-radius: var(--r-2);
  background: var(--ink); color: var(--bg);
  box-shadow: var(--shadow-2); font-size: 0.875rem; pointer-events: auto;
  transition: opacity 220ms var(--ease-out), transform 260ms var(--ease-out);
}
@starting-style { .toast { opacity: 0; transform: translateY(10px); } }
.toast.leaving { opacity: 0; transform: translateY(6px); transition-duration: 150ms; }
.toast > .i { margin-top: 0.1rem; }
.toast[data-tone="success"] > .i { color: color-mix(in oklch, var(--ok) 55%, var(--bg)); }
.toast[data-tone="danger"] > .i { color: color-mix(in oklch, var(--bad) 55%, var(--bg)); }
.toast button { border: 0; background: none; color: inherit; opacity: 0.7; cursor: pointer; padding: 0.1rem; border-radius: var(--r-1); }
.toast button:hover { opacity: 1; }

/* ---------- Copy row ---------- */
.copy-row { display: flex; align-items: center; gap: 0.5rem; min-width: 0; }
.copy-row .mono { overflow-wrap: anywhere; }

/* ---------- Code ---------- */
pre.code {
  margin: 0; padding: 0.875rem 1rem; max-height: 420px; overflow: auto;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-2);
  font-family: var(--font-mono); font-size: 0.8rem; line-height: 1.55; color: var(--ink-2);
  tab-size: 2; white-space: pre;
}
pre.code .k { color: var(--accent); }
pre.code .s { color: var(--ok); }
pre.code .n { color: var(--warn); }
pre.code .b { color: var(--info); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; }
  .btn, .tab::after, .switch .track::after, dialog.dlg, .toast { transition-property: opacity, background-color, border-color, color !important; }
  .sk { animation: none; }
  .chip[data-live="true"]::before { animation: none; }
}
.switch .check-text { display: grid; gap: 0.125rem; font-size: 0.875rem; }
.switch .check-text small { color: var(--ink-3); font-size: 0.78rem; line-height: 1.45; }
