/* ================= Buttons ================= */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 32px; padding: 0 14px;
  border-radius: var(--r-ctl);
  border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text);
  font-size: var(--fs-base); font-weight: 600; white-space: nowrap;
  transition: background .12s, border-color .12s, color .12s, opacity .12s;
}
.btn:hover { background: var(--raised); color: var(--text); }
.btn:disabled { opacity: .45; }
.btn:disabled:hover { background: var(--surface); }
.btn svg { flex: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn-primary:hover, .btn-primary:disabled:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--on-accent); }
.btn-primary:disabled:hover { background: var(--accent); border-color: var(--accent); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--raised); color: var(--text); }
.btn-ghost:disabled:hover { background: transparent; }
.btn-danger { background: transparent; border-color: var(--danger-line); color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); color: var(--danger); }
.btn-danger:disabled:hover { background: transparent; }
.btn-danger-text { background: transparent; border-color: transparent; color: var(--danger); }
.btn-danger-text:hover { background: var(--danger-soft); color: var(--danger); }
.btn-danger-text:disabled:hover { background: transparent; }
.btn-sm { height: 26px; padding: 0 10px; font-size: var(--fs-xs); gap: 5px; }
.btn-lg { height: 40px; padding: 0 18px; font-size: var(--fs-md); border-radius: 8px; }
.link { padding: 0; border: 0; background: none; color: var(--accent-hover); font: inherit; }
.link:hover { color: var(--text); }

.icon-btn {
  display: inline-grid; place-items: center; flex: none;
  width: 28px; height: 28px; padding: 0;
  border: 1px solid transparent; border-radius: var(--r-ctl);
  background: transparent; color: var(--muted);
}
.icon-btn:hover { background: var(--raised); color: var(--text); }
.icon-btn-sm { width: 22px; height: 22px; }

/* ================= Brand, avatar, page head ================= */
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); }
.brand:hover { color: var(--text); }
.brand-mark {
  width: 26px; height: 26px; border-radius: 7px; flex: none;
  display: grid; place-items: center; background: var(--accent);
  font: 700 16px/1 var(--display); color: var(--on-accent);
}
.brand-name { font: 700 18px/1 var(--display); letter-spacing: .04em; text-transform: uppercase; }

.avatar {
  position: relative; display: grid; place-items: center; flex: none;
  width: 28px; height: 28px; border-radius: 50%; overflow: hidden;
  background: var(--raised); border: 1px solid var(--border-strong);
  color: var(--text-2); font: 700 var(--fs-2xs)/1 var(--font);
}
.avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.avatar-lg {
  width: 52px; height: 52px; border-radius: var(--r-hero); font-size: 18px;
  background: linear-gradient(135deg, var(--accent-deep), var(--raised));
  border-color: var(--accent-line); color: var(--accent-hover);
}

.crumbs { display: flex; align-items: center; gap: 6px; min-width: 0; font-size: var(--fs-xs); color: var(--muted); }
.crumbs a { color: var(--accent-hover); white-space: nowrap; }
.crumbs a:hover { color: var(--text); }
.crumbs .sep { color: var(--faint); }
.crumbs .current { color: var(--text-2); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.page-head { display: flex; align-items: flex-end; gap: var(--s4); min-height: 40px; }
.page-head.centered { align-items: center; }
.page-head .titles { min-width: 0; flex: 1 1 auto; }
.page-head h1 { overflow-wrap: anywhere; }
.page-head h2 { font-size: 22px; }
.page-head .subtitle { margin-top: var(--s1); color: var(--muted); }
.page-head .subtitle.row { gap: 10px; }
.page-head .actions { display: flex; gap: var(--s2); align-items: center; flex: none; }

/* ================= Surfaces ================= */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  min-width: 0; overflow: hidden;
}
.card-head {
  display: flex; align-items: center; gap: var(--s3);
  min-height: 48px; padding: 12px var(--pad);
  border-bottom: 1px solid var(--divider);
}
.card-head h2 { white-space: nowrap; }
.card-head .sub { color: var(--muted); font-size: var(--fs-base); min-width: 0; }
.card-head .tail { margin-left: auto; display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; justify-content: flex-end; }
.card-body { padding: var(--pad); display: flex; flex-direction: column; gap: var(--s4); }
.card-body.flush { padding: 0; gap: 0; }
.card-body.flush > .callout, .card-body.flush > .note { margin: var(--s3) var(--pad); }
.card-foot {
  display: flex; align-items: center; justify-content: center; gap: var(--s2);
  padding: 10px var(--pad); border-top: 1px solid var(--divider);
}

.line { display: flex; align-items: center; gap: var(--s3); min-height: var(--line-h); padding: 0 var(--pad); border-top: 1px solid var(--divider); }
.line:first-child { border-top: 0; }
.line.tall { min-height: 62px; }

.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s5); align-items: start; }
.grid-aside { display: grid; grid-template-columns: minmax(0, 2fr) minmax(260px, 1fr); gap: var(--s5); align-items: start; }

/* ================= State language ================= */
.dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; flex: none; background: var(--faint); }
.dot.ok { background: var(--success); box-shadow: 0 0 0 3px var(--success-soft); }
.dot.warn { background: var(--warning); box-shadow: 0 0 0 3px var(--warning-soft); }
.dot.bad { background: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft); }
.dot.acc { background: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.dot.info { background: var(--info); box-shadow: 0 0 0 3px var(--info-soft); }

.state { display: inline-flex; align-items: center; gap: 9px; color: var(--text-2); min-width: 0; white-space: nowrap; }
.state > span:last-child { min-width: 0; }
.state small { display: block; color: var(--muted); font-size: 11.5px; line-height: 1.4; }

.key {
  display: inline-flex; align-items: center; height: 20px; padding: 0 7px;
  border: 1px solid var(--border-strong); border-radius: 5px; background: var(--surface);
  font: 600 var(--fs-2xs)/1 var(--mono); color: var(--text-2); white-space: nowrap;
}
.key.on { border-color: var(--accent-line); color: var(--accent-hover); background: var(--accent-soft); }
a.key:hover { border-color: var(--accent-line); color: var(--text); }
.keys { display: inline-flex; flex-wrap: wrap; gap: 6px; vertical-align: middle; }
table.data td .keys { flex-wrap: nowrap; }

.tag { font: 600 var(--fs-2xs)/1 var(--font); letter-spacing: .03em; text-transform: uppercase; color: var(--muted); white-space: nowrap; }
.tag.acc { color: var(--accent-hover); }
.tag.warn { color: var(--warning); }
.tag.bad { color: var(--danger); }
.tag.ok { color: var(--success); }

.track { height: 6px; border-radius: 99px; background: var(--border); overflow: hidden; }
.track > i { display: block; height: 100%; width: var(--fill, 0%); background: var(--accent); border-radius: 99px; }
.track.ok > i { background: var(--success); }
.track.warn > i { background: var(--warning); }
.track.bad > i { background: var(--danger); }

/* ================= Forms ================= */
.input, .select {
  height: 32px; padding: 0 10px;
  border-radius: var(--r-ctl);
  border: 1px solid var(--border);
  background: var(--surface); color: var(--text);
  font-size: var(--fs-base);
  min-width: 0;
  transition: border-color .12s, box-shadow .12s;
}
.input:hover, .select:hover { border-color: var(--border-strong); }
.input::placeholder { color: var(--faint); }
.input:focus, .select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); outline: none; }
.input:disabled, .select:disabled { opacity: .55; }
.input.mono { font-family: var(--mono); font-size: var(--fs-xs); }
.input[type="number"] { width: 110px; -moz-appearance: textfield; }
.input[type="number"]::-webkit-inner-spin-button, .input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.select {
  appearance: none; -webkit-appearance: none;
  padding-right: var(--s7);
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 14px) 14px, calc(100% - 10px) 14px;
  background-size: 4px 4px, 4px 4px;
  background-repeat: no-repeat;
}
.input-icon { position: relative; display: flex; align-items: center; }
.input-icon > svg { position: absolute; left: 10px; color: var(--faint); pointer-events: none; }
.input-icon > .input { padding-left: 32px; width: 100%; }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field-label { font: 700 var(--fs-2xs)/1 var(--display); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.field-hint { font-size: var(--fs-xs); color: var(--muted); line-height: 1.45; }
fieldset { margin: 0; padding: 0; border: 0; min-width: 0; }
legend { padding: 0; margin-bottom: 6px; }

.check { display: inline-flex; align-items: center; gap: var(--s2); height: 32px; cursor: pointer; color: var(--text-2); white-space: nowrap; }
.check input {
  appearance: none; -webkit-appearance: none; width: 16px; height: 16px; margin: 0;
  border-radius: 4px; border: 1px solid var(--border-strong); background: var(--surface);
  display: grid; place-items: center; flex: none; cursor: pointer;
}
.check input:checked { background: var(--accent); border-color: var(--accent); }
.check input:checked::after { content: ""; width: 8px; height: 4px; border-left: 2px solid var(--on-accent); border-bottom: 2px solid var(--on-accent); transform: translateY(-1px) rotate(-45deg); }
.check input:disabled { opacity: .4; cursor: not-allowed; }

/* Toggle switch (Kirby menu kit) */
.switch {
  appearance: none; -webkit-appearance: none; margin: 0; flex: none; cursor: pointer;
  position: relative; width: 30px; height: 16px; border-radius: 99px; background: var(--border);
  transition: background .15s;
}
.switch::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 12px; height: 12px; border-radius: 50%;
  background: var(--muted); transition: left .15s, background .15s;
}
.switch:checked { background: var(--accent); }
.switch:checked::after { left: 16px; background: var(--on-accent); }
.switch:disabled { opacity: .45; cursor: not-allowed; }
.switch:focus-visible { outline-offset: 3px; border-radius: 99px; }
label.line { cursor: pointer; }
label.line:hover { background: var(--raised); }

.seg {
  display: inline-flex; align-items: center; gap: 2px; flex: none;
  padding: 2px; border-radius: 7px;
  background: var(--surface); border: 1px solid var(--border);
}
.seg button {
  height: 26px; padding: 0 12px; border: 0; border-radius: 5px;
  background: transparent; color: var(--muted); font-size: var(--fs-base); font-weight: 500; white-space: nowrap;
}
.seg button:hover { color: var(--text); }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); }
.seg button:disabled { cursor: default; }

.filter-bar { display: flex; align-items: flex-end; gap: var(--s3); flex-wrap: wrap; }
.filter-bar.inline { align-items: center; }
.filter-bar .field { min-width: 140px; }
.filter-bar .field.wide { flex: 1 1 220px; }
.filter-bar .count { margin-left: auto; align-self: center; color: var(--muted); white-space: nowrap; }
.filter-bar .actions { display: flex; gap: var(--s2); }
.search-box { width: 280px; max-width: 100%; }
.filter-note { flex-basis: 100%; }
.filter-note:empty { display: none; }

/* ================= Tabs ================= */
.tabs { display: flex; align-items: flex-end; gap: 22px; border-bottom: 1px solid var(--divider); overflow-x: auto; scrollbar-width: none; }
.tab {
  position: relative; display: inline-flex; align-items: center; gap: 6px;
  padding: 10px 0; border: 0; background: transparent;
  color: var(--muted); font-size: var(--fs-base); font-weight: 500; white-space: nowrap;
}
.tab:hover { color: var(--text); }
.tab[aria-selected="true"], .tab[aria-current] { color: var(--text); }
.tab[aria-selected="true"]::after, .tab[aria-current]::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 2px;
  border-radius: 2px; background: var(--accent);
}
.tab .n { font: var(--fs-2xs) var(--mono); color: var(--faint); }
.tab .n:empty { display: none; }
.tab .n.warn { color: var(--warning); }

/* ================= Tables ================= */
.table-wrap { overflow: auto; position: relative; }
table.data { width: 100%; border-collapse: separate; border-spacing: 0; }
table.data th {
  position: sticky; top: 0; z-index: 2;
  padding: 12px var(--s3); background: var(--surface);
  border-bottom: 1px solid var(--divider);
  font: 700 var(--fs-2xs)/1 var(--display); letter-spacing: .08em; text-transform: uppercase;
  color: var(--muted); text-align: left; white-space: nowrap;
}
table.data td {
  height: var(--row-h); padding: 7px var(--s3);
  border-bottom: 1px solid var(--divider);
  white-space: nowrap; vertical-align: middle; color: var(--text-2);
}
table.data td.wrap { white-space: normal; min-width: 180px; }
table.data td.wrap .state { white-space: normal; }
table.data tbody tr:hover > td { background: var(--raised); }
table.data tbody tr.is-clickable { cursor: pointer; }
table.data tbody tr.is-selected > td { background: var(--accent-soft); }
table.data tbody tr:last-child > td { border-bottom: 0; }
table.data tr:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
table.data th:first-child, table.data td:first-child { padding-left: var(--pad); }
table.data th:last-child, table.data td:last-child { padding-right: var(--pad); }
table.data td.go { width: 1%; text-align: right; color: var(--faint); }
table.data tr:hover td.go { color: var(--text-2); }
table.data td.actions { width: 1%; text-align: right; }
table.data td.actions > .row { justify-content: flex-end; }
table.data tr.detail > td { background: var(--bg); padding: var(--s4) var(--pad); white-space: normal; height: auto; }
table.data tr.detail:hover > td { background: var(--bg); }
.cell-main { color: var(--text); font-weight: 500; }
a.cell-main:hover { color: var(--accent-hover); }
.cell-sub { color: var(--muted); font-size: 11.5px; margin-top: 1px; }
.cell-sub.mono, .cell-sub .mono { font-size: 11.5px; }
.cell-stack { display: flex; flex-direction: column; align-items: flex-start; gap: 1px; min-width: 0; }
.clip { display: block; max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.who { display: flex; align-items: center; gap: 10px; min-width: 0; }
.who-name { display: flex; align-items: baseline; gap: 6px; color: var(--text); font-weight: 600; }
.who-name a { color: var(--text); }
.who-name a:hover { color: var(--accent-hover); }
.who-sub { display: block; color: var(--muted); font: 11.5px/1.4 var(--mono); }

/* Facts strip: the one summary row on detail pages (Kirby loader facts) */
.strip {
  display: grid; grid-template-columns: repeat(var(--cols, 4), minmax(0, 1fr));
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-card);
}
.strip > div, .strip > a { padding: 14px var(--pad); border-left: 1px solid var(--divider); display: grid; gap: 7px; align-content: start; min-width: 0; color: inherit; }
.strip > :first-child { border-left: 0; }
.strip > a:hover { background: var(--raised); color: inherit; }
.strip > a:first-child:hover { border-radius: var(--r-card) 0 0 var(--r-card); }
.strip > a:last-child:hover { border-radius: 0 var(--r-card) var(--r-card) 0; }
.strip .label { font: 700 var(--fs-2xs)/1 var(--display); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.strip strong { font: 700 var(--fs-stat)/1.1 var(--display); letter-spacing: .01em; color: var(--text); display: flex; align-items: center; gap: var(--s2); min-width: 0; }
.strip.large strong { font-size: var(--fs-big); }
.strip strong .unit { font: 500 var(--fs-md) var(--display); color: var(--muted); }
.strip strong.mono { font: 600 15px/1.35 var(--mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }
.strip .sub { color: var(--muted); font-size: var(--fs-xs); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Free-text values (e.g. a raw status line) wrap inside their column, two lines at most. */
.strip .state { white-space: normal; align-items: flex-start; }
.strip .state > .dot { margin-top: .45em; }
.strip .state > span:last-child {
  overflow: hidden; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2;
}

/* Compact definition grid */
.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: var(--s4) var(--s5); }
.fact { min-width: 0; display: grid; gap: 5px; align-content: start; }
.fact.wide { grid-column: span 2; }
.fact dt { font: 700 var(--fs-2xs)/1 var(--display); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.fact dd { color: var(--text); overflow-wrap: anywhere; }
.fact dd .mono, .fact dd code { overflow-wrap: anywhere; }

.copyable { display: inline-flex; align-items: center; gap: var(--s1); min-width: 0; max-width: 100%; }
.copyable code { color: var(--text-2); overflow-wrap: anywhere; }

/* Callouts are for problems; notes are for context */
.callout {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 10px 14px; border-radius: var(--r-ctl);
  background: var(--raised); border: 1px solid var(--border);
  color: var(--text-2); line-height: 1.5;
}
.callout > svg { flex: none; margin-top: 2px; color: var(--info); }
.callout > div { min-width: 0; display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.callout.warn { background: var(--warning-tint); border-color: var(--warning-line); }
.callout.warn > svg { color: var(--warning); }
.callout.danger { background: var(--danger-tint); border-color: var(--danger-line); color: var(--text); }
.callout.danger > svg { color: var(--danger); }
.callout.ok { background: var(--success-tint); border-color: var(--success-line); color: var(--text); }
.callout.ok > svg { color: var(--success); }
.callout strong { color: var(--text); font-weight: 600; }

.note { display: flex; gap: var(--s2); align-items: flex-start; color: var(--muted); font-size: var(--fs-xs); line-height: 1.55; max-width: 880px; }
.note > svg { flex: none; margin-top: 2px; color: var(--faint); }

/* Empty / loading */
.empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center;
  gap: 6px; padding: 44px var(--s6); color: var(--muted);
}
.empty .empty-icon {
  width: 40px; height: 40px; border-radius: var(--r-card); display: grid; place-items: center;
  background: var(--raised); border: 1px solid var(--border); color: var(--muted); margin-bottom: 6px;
}
.empty h3 { color: var(--text); font: 700 var(--fs-title)/1.2 var(--display); letter-spacing: .01em; }
.empty p { max-width: 440px; }
.empty .row { margin-top: var(--s2); }

.skeleton { display: grid; gap: 14px; padding: var(--pad); }
.card-body:not(.flush) > .skeleton { padding: 0; }
.skeleton i {
  display: block; height: 12px; border-radius: 99px;
  background: linear-gradient(90deg, var(--hover) 0, var(--border) 40%, var(--hover) 80%) 0 0 / 300% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
}
.skeleton i:nth-child(3n + 1) { width: 72%; }
.skeleton i:nth-child(3n + 2) { width: 88%; }
.skeleton i:nth-child(3n) { width: 54%; }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: 0 0; } }

.pager { display: flex; align-items: center; justify-content: center; gap: var(--s3); color: var(--muted); font-size: var(--fs-xs); }

/* Timeline (Kirby loader) */
.timeline { display: grid; }
.ev { display: grid; grid-template-columns: 14px minmax(0, 1fr) auto; gap: var(--s3); align-items: center; padding: 11px var(--pad); border-top: 1px solid var(--divider); }
.ev:first-child { border-top: 0; }
.ev .ev-title { color: var(--text); }
.ev .ev-sub { color: var(--muted); font-size: var(--fs-xs); display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; margin-top: 2px; }
.ev .ev-sub.bad { color: var(--danger); }
.ev time { color: var(--muted); font: var(--fs-xs) var(--mono); white-space: nowrap; }

/* Mac identities (portal and admin) */
.chip-icon {
  width: 38px; height: 38px; border-radius: 9px; flex: none; display: grid; place-items: center;
  background: var(--raised); border: 1px solid var(--border-strong);
  font: 700 var(--fs-base)/1 var(--display); color: var(--text-2);
}
.chip-icon.on { border-color: var(--accent-line); background: var(--accent-soft); color: var(--accent-hover); }
.identity { display: flex; align-items: center; gap: 14px; padding: 14px var(--pad); border-top: 1px solid var(--divider); }
.identity:first-child { border-top: 0; }
.identity > .mono { color: var(--text); font-size: var(--fs-base); letter-spacing: .03em; }
.identity-use { width: 92px; display: flex; justify-content: flex-end; flex: none; }
.identity-add { padding: var(--s4) var(--pad) var(--pad); border-top: 1px solid var(--divider); background: var(--bg); }
.identity-form { display: grid; gap: 14px; }
.identity-form .input.mono { width: 220px; font-size: var(--fs-base); letter-spacing: .04em; }
.identity-form .select { max-width: 100%; width: 460px; }
.identity-families .seg { flex-wrap: wrap; }
.identity-hints { display: grid; gap: var(--s1); }

/* JSON preview */
.code {
  margin: 0; padding: var(--s3) 14px; border-radius: var(--r-ctl);
  background: var(--bg); border: 1px solid var(--border);
  font: var(--fs-xs)/1.6 var(--mono); color: var(--text-2);
  overflow: auto; white-space: pre; tab-size: 2;
}
.code.wrap { white-space: pre-wrap; overflow-wrap: anywhere; }
.j-key { color: var(--accent-hover); }
.j-str { color: var(--success); }
.j-num { color: var(--warning); }
.j-lit { color: var(--info); }

summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: var(--s2); color: var(--text-2); }
summary:hover { color: var(--text); }
summary::-webkit-details-marker { display: none; }
summary::before { content: ""; flex: none; width: 6px; height: 6px; border-right: 1.5px solid var(--muted); border-bottom: 1.5px solid var(--muted); transform: rotate(-45deg); transition: transform .12s; }
details[open] > summary::before { transform: rotate(45deg); }
details.disclosure { border-top: 1px solid var(--divider); }
details.disclosure > summary { padding: 12px var(--pad); font-weight: 500; }
details.disclosure > .disclosure-body { display: flex; flex-direction: column; gap: var(--s3); padding-bottom: var(--s3); }
details.disclosure > .disclosure-body > .muted { padding: 0 var(--pad); }

/* ================= Overlays ================= */
dialog.drawer {
  position: fixed; inset: 0 0 0 auto; margin: 0; padding: 0;
  width: var(--drawer-w); max-width: 100vw; height: 100dvh; max-height: 100dvh;
  flex-direction: column;
  background: var(--surface); color: var(--text);
  border: 0; border-left: 1px solid var(--border-strong);
  box-shadow: var(--shadow-overlay);
  overflow: hidden;
}
dialog.drawer[open] { display: flex; animation: slide-in .18s ease; }
dialog::backdrop { background: var(--backdrop); }
@keyframes slide-in { from { transform: translateX(24px); opacity: 0; } }
@keyframes pop-in { from { transform: translateY(8px) scale(.985); opacity: 0; } }
.drawer-head { flex: none; padding: var(--s5) var(--s6) 0; display: grid; gap: 6px; }
.drawer-head .top { display: flex; align-items: flex-start; gap: var(--s3); }
.drawer-head h2 { font-size: 22px; overflow-wrap: anywhere; }
.drawer-head .meta { display: flex; gap: var(--s4); align-items: center; flex-wrap: wrap; color: var(--muted); font-size: var(--fs-xs); }
.drawer .tabs { flex: none; padding: 0 var(--s6); margin-top: var(--s3); }
.drawer-body { flex: 1 1 auto; min-height: 0; overflow: auto; overscroll-behavior: contain; padding: var(--s5) var(--s6) var(--s6); display: flex; flex-direction: column; gap: var(--s4); }
.drawer-body .filter-bar { padding-bottom: var(--s4); border-bottom: 1px solid var(--divider); }

dialog.modal {
  width: 440px; max-width: calc(100vw - 32px); padding: 0;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border-strong); border-radius: var(--r-hero);
  box-shadow: var(--shadow-overlay);
}
dialog.modal[open] { animation: pop-in .16s ease; }
.modal-body { padding: 22px var(--s6) var(--s5); display: grid; gap: 10px; }
.modal-body h2 { font-size: 22px; }
.modal-body p { color: var(--text-2); }
.modal-body .mono { color: var(--text); overflow-wrap: anywhere; }
.modal-body .extra { display: grid; gap: var(--s3); margin-top: 6px; }
.modal-foot { display: flex; justify-content: flex-end; gap: var(--s2); padding: 14px var(--s6); border-top: 1px solid var(--divider); background: var(--bg); }

.toasts { position: fixed; right: var(--s6); bottom: var(--s6); z-index: 70; display: flex; flex-direction: column; gap: 10px; align-items: flex-end; }
.toast {
  max-width: min(440px, calc(100vw - 48px)); display: flex; gap: 10px; align-items: center;
  padding: 10px 10px 10px var(--s4); border-radius: var(--r-card);
  background: var(--raised); border: 1px solid var(--border-strong); box-shadow: var(--shadow-pop);
  color: var(--text); animation: pop-in .18s ease;
}

/* ================= Changelog (portal card and editor preview) ================= */
.changelog-entry { display: grid; gap: var(--s3); min-width: 0; }
.changelog-head { display: grid; gap: var(--s1); }
.changelog-title { font: 600 var(--fs-title)/1.3 var(--font); color: var(--text); overflow-wrap: anywhere; }
.changelog-meta { display: inline-flex; align-items: center; flex-wrap: wrap; gap: var(--s2); color: var(--muted); font-size: var(--fs-xs); }
.changelog-version {
  font: 600 var(--fs-2xs)/1 var(--font); letter-spacing: .03em; text-transform: uppercase; color: var(--accent-hover);
  padding: 3px 6px; border-radius: 4px; background: var(--accent-soft); border: 1px solid var(--accent-line);
}
.changelog-body { display: grid; gap: 10px; color: var(--text-2); font-size: var(--fs-md); line-height: 1.55; min-width: 0; overflow-wrap: anywhere; }
.changelog-body h4 {
  margin: var(--s2) 0 0; font: 700 var(--fs-2xs)/1 var(--display); letter-spacing: .08em; text-transform: uppercase; color: var(--muted);
}
.changelog-body h4:first-child { margin-top: 0; }
.changelog-body ul { display: grid; gap: 6px; margin: 0; padding-left: 18px; list-style: disc; }
.changelog-body li { padding-left: 2px; }
.changelog-body li::marker { color: var(--accent-hover); }
.changelog-body strong { color: var(--text); font-weight: 600; }
.changelog-body code {
  font: .9em/1 var(--mono); color: var(--text); padding: 2px 5px; border-radius: 4px;
  background: var(--raised); border: 1px solid var(--border);
}
