/* =========================================================================
   Dashboard design system
   Palettes: data-palette on <html> (violet default). Appearance: data-theme.
   ========================================================================= */
:root, [data-palette="violet"] {
  --bg: #0b0d12; --bg-elev: #0f121a; --surface: #141823; --surface-2: #1a1f2c; --surface-3: #222839;
  --border: #222938; --border-strong: #303950;
  --accent: #7c6cff; --accent-strong: #978aff; --accent-soft: rgba(124, 108, 255, .15); --accent-text: #b8afff; --on-accent: #fff;
}
[data-palette="blurple"] {
  --bg: #17181b; --bg-elev: #1e1f22; --surface: #2b2d31; --surface-2: #313338; --surface-3: #383a40;
  --border: #3a3c42; --border-strong: #4e5058;
  --accent: #5865f2; --accent-strong: #7480f5; --accent-soft: rgba(88, 101, 242, .2); --accent-text: #c9cdfb; --on-accent: #fff;
}
[data-palette="teal"] {
  --bg: #071014; --bg-elev: #0b161b; --surface: #0f1d23; --surface-2: #13252c; --surface-3: #1a303a;
  --border: #1b2f37; --border-strong: #28434d;
  --accent: #35c4d9; --accent-strong: #62d6e8; --accent-soft: rgba(53, 196, 217, .14); --accent-text: #92e7f3; --on-accent: #03141a;
}
[data-palette="ember"] {
  --bg: #0e0a09; --bg-elev: #14100e; --surface: #1b1512; --surface-2: #221a16; --surface-3: #2c221d;
  --border: #2e241e; --border-strong: #423328;
  --accent: #ff7a45; --accent-strong: #ff956a; --accent-soft: rgba(255, 122, 69, .15); --accent-text: #ffb393; --on-accent: #1c0b04;
}
[data-palette="emerald"] {
  --bg: #07100b; --bg-elev: #0b1510; --surface: #0f1c15; --surface-2: #13231a; --surface-3: #1a2d22;
  --border: #1b2e23; --border-strong: #284233;
  --accent: #22c55e; --accent-strong: #4ade80; --accent-soft: rgba(34, 197, 94, .14); --accent-text: #86efac; --on-accent: #03130a;
}
[data-palette="rose"] {
  --bg: #0f0a0c; --bg-elev: #150e11; --surface: #1c1216; --surface-2: #23171c; --surface-3: #2d1e25;
  --border: #2f1f26; --border-strong: #452c37;
  --accent: #f43f5e; --accent-strong: #fb7185; --accent-soft: rgba(244, 63, 94, .15); --accent-text: #fda4af; --on-accent: #fff;
}
[data-palette="slate"] {
  --bg: #0b0b0c; --bg-elev: #101012; --surface: #161618; --surface-2: #1c1c1f; --surface-3: #252528;
  --border: #26262a; --border-strong: #38383e;
  --accent: #e4e4e7; --accent-strong: #ffffff; --accent-soft: rgba(228, 228, 231, .1); --accent-text: #f4f4f5; --on-accent: #0b0b0c;
}
:root {
  --text: #e9ebf2; --text-2: #9ba1b4; --text-3: #6c7287;
  --ok: #3ba55d; --warn: #f0a92b; --bad: #ef4f52;
  --ok-soft: rgba(59, 165, 93, .15); --warn-soft: rgba(240, 169, 43, .15); --bad-soft: rgba(239, 79, 82, .15);
  --r-sm: 8px; --r: 12px; --r-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3); --shadow: 0 16px 40px rgba(0, 0, 0, .4);
  --ring: 0 0 0 3px color-mix(in srgb, var(--accent) 35%, transparent);
  --sidebar: 256px; --topbar: 60px;
  --ease: cubic-bezier(.2, .8, .2, 1);
  color-scheme: dark;
}
/* Light appearance: neutrals change, the palette accent stays. */
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f4f5f9; --bg-elev: #ffffff; --surface: #ffffff; --surface-2: #f5f6fa; --surface-3: #eceef4; --border: #e3e5ed; --border-strong: #d2d5e0;
    --text: #161922; --text-2: #575e72; --text-3: #8a90a4; --accent-text: color-mix(in srgb, var(--accent) 72%, #000); --shadow: 0 16px 40px rgba(22, 25, 34, .12); --shadow-sm: 0 1px 2px rgba(22, 25, 34, .06); color-scheme: light;
  }
  :root:not([data-theme="dark"])[data-palette="slate"] { --accent: #18181b; --accent-strong: #3f3f46; --accent-soft: rgba(24, 24, 27, .08); --on-accent: #fff; }
}
:root[data-theme="light"] {
  --bg: #f4f5f9; --bg-elev: #ffffff; --surface: #ffffff; --surface-2: #f5f6fa; --surface-3: #eceef4; --border: #e3e5ed; --border-strong: #d2d5e0;
  --text: #161922; --text-2: #575e72; --text-3: #8a90a4; --accent-text: color-mix(in srgb, var(--accent) 72%, #000); --shadow: 0 16px 40px rgba(22, 25, 34, .12); --shadow-sm: 0 1px 2px rgba(22, 25, 34, .06); color-scheme: light;
}
:root[data-theme="light"][data-palette="slate"] { --accent: #18181b; --accent-strong: #3f3f46; --accent-soft: rgba(24, 24, 27, .08); --on-accent: #fff; }

/* ---------- base ---------- */
* { box-sizing: border-box; }
html { background: var(--bg); }
html, body { margin: 0; color: var(--text); }
body { font: 14px/1.5 Inter, "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif; -webkit-font-smoothing: antialiased; background: var(--bg); transition: background .25s; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4, p { margin: 0; }
h1 { font-size: 24px; font-weight: 700; letter-spacing: -.02em; line-height: 1.2; }
h2 { font-size: 15px; font-weight: 650; line-height: 1.35; }
h3 { font-size: 13px; font-weight: 650; }
code, .mono { font-family: ui-monospace, "Cascadia Code", SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }
.muted { color: var(--text-2); } .faint { color: var(--text-3); } .small { font-size: 13px; } .tiny { font-size: 12px; }
.ok-text { color: var(--ok); } .warn-text { color: var(--warn); } .bad-text { color: var(--bad); }
.grow { flex: 1; min-width: 0; }
.t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
[hidden] { display: none !important; }
:focus-visible { outline: none; box-shadow: var(--ring); border-radius: var(--r-sm); }
::selection { background: var(--accent-soft); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 999px; border: 2px solid var(--bg); }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- animation ---------- */
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: scale(.96); } }
@keyframes grow-y { from { transform: scaleY(0); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmer { to { background-position: -200% 0; } }
@keyframes slide-up { from { opacity: 0; transform: translate(-50%, 16px); } }
@keyframes toast-in { from { opacity: 0; transform: translateX(24px); } }
@keyframes pulse { 70% { box-shadow: 0 0 0 7px transparent; } }
@keyframes flash { 0%, 40% { box-shadow: 0 0 0 2px var(--accent); } }
.enter { animation: rise .42s var(--ease) both; }
.pop-in { animation: pop .3s var(--ease) both; }
.skeleton { border-radius: var(--r-sm); background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 37%, var(--surface-2) 63%); background-size: 200% 100%; animation: shimmer 1.3s linear infinite; }
.sk-line { height: 12px; margin: 12px 0; } .sk-block { height: 140px; }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--border-strong); border-top-color: var(--accent); animation: spin .8s linear infinite; }
.flash { animation: flash 1.2s var(--ease); }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; } }

/* ---------- buttons ---------- */
.btn { position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 36px; padding: 0 14px; border-radius: var(--r-sm); border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--text); cursor: pointer; font-weight: 600; font-size: 13.5px; white-space: nowrap; text-decoration: none !important; transition: background .15s, border-color .15s, color .15s, transform .08s, box-shadow .2s; user-select: none; }
.btn:hover { background: var(--surface-3); border-color: var(--text-3); }
.btn:active { transform: translateY(1px) scale(.99); }
.btn.primary { background: var(--accent); border-color: transparent; color: var(--on-accent); }
.btn.primary:hover { background: var(--accent-strong); box-shadow: 0 6px 18px -6px color-mix(in srgb, var(--accent) 70%, transparent); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--surface-3); color: var(--text); }
.btn.danger { color: var(--bad); }
.btn.danger:hover { background: var(--bad-soft); border-color: color-mix(in srgb, var(--bad) 50%, transparent); }
.btn.danger.solid { background: var(--bad); border-color: transparent; color: #fff; }
.btn.sm { height: 30px; padding: 0 10px; font-size: 12.5px; border-radius: 7px; gap: 6px; }
.btn.lg { height: 42px; padding: 0 20px; font-size: 14.5px; }
.btn.block { width: 100%; }
.btn.icon { width: 36px; padding: 0; font-size: 16px; }
.btn.icon.sm { width: 30px; font-size: 14px; }
.btn.discord { background: #5865f2; border-color: transparent; color: #fff; width: 100%; height: 44px; font-size: 15px; }
.btn.discord:hover { background: #4752c4; }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; box-shadow: none; }
.btn.busy { color: transparent !important; pointer-events: none; }
.btn.busy::after { content: ""; position: absolute; width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--text-2); border-right-color: transparent; animation: spin .7s linear infinite; }
.btn.primary.busy::after { border-color: var(--on-accent); border-right-color: transparent; }
.btns { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.btns.end { justify-content: flex-end; }
.btns.stretch > .btn { flex: 1; }

/* ---------- inputs ---------- */
input[type="text"], input[type="number"], input[type="search"], input[type="url"], select, textarea {
  width: 100%; height: 38px; background: var(--surface-2); border: 1px solid var(--border-strong); border-radius: var(--r-sm); padding: 0 12px; outline: none; transition: border-color .15s, box-shadow .15s, background .15s;
}
textarea { height: auto; padding: 10px 12px; resize: vertical; min-height: 96px; line-height: 1.5; }
input:hover, select:hover, textarea:hover { border-color: var(--text-3); }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: var(--ring); background: var(--surface); }
input:disabled, select:disabled, textarea:disabled { opacity: .55; cursor: not-allowed; }
input::placeholder, textarea::placeholder { color: var(--text-3); }
select { cursor: pointer; appearance: none; padding-right: 32px; background-image: linear-gradient(45deg, transparent 50%, var(--text-2) 50%), linear-gradient(135deg, var(--text-2) 50%, transparent 50%); background-position: calc(100% - 17px) 16px, calc(100% - 12px) 16px; background-size: 5px 5px; background-repeat: no-repeat; }
input[type="number"] { font-variant-numeric: tabular-nums; }
.input-group { display: flex; gap: 8px; align-items: center; }
.input-group > input, .input-group > select { flex: 1; min-width: 0; }
.readonly { height: 38px; display: flex; align-items: center; padding: 0 12px; border-radius: var(--r-sm); background: var(--surface-3); color: var(--text-2); }
.switch { position: relative; width: 42px; height: 24px; flex: none; display: inline-block; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch input:disabled { cursor: not-allowed; }
.switch i { position: absolute; inset: 0; border-radius: 999px; background: var(--border-strong); transition: background .2s var(--ease); }
.switch i::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .25s cubic-bezier(.3, 1.5, .5, 1); box-shadow: 0 1px 3px rgba(0, 0, 0, .3); }
.switch input:checked + i { background: var(--accent); }
.switch input:checked + i::after { transform: translateX(18px); }
.switch input:focus-visible + i { box-shadow: var(--ring); }
.switch input:disabled + i { opacity: .45; }
.stepper { display: inline-flex; align-items: center; border: 1px solid var(--border-strong); border-radius: var(--r-sm); background: var(--surface-2); overflow: hidden; height: 42px; }
.stepper button { width: 38px; height: 100%; border: 0; background: transparent; cursor: pointer; font-size: 18px; color: var(--text-2); }
.stepper button:hover { background: var(--surface-3); color: var(--text); }
.stepper input { width: 64px; height: 100%; border: 0; border-radius: 0; text-align: center; background: transparent; font-weight: 700; font-size: 16px; box-shadow: none !important; -moz-appearance: textfield; }
.stepper input::-webkit-outer-spin-button, .stepper input::-webkit-inner-spin-button { -webkit-appearance: none; }

/* ---------- app shell ---------- */
.app { display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; background: var(--bg-elev); border-right: 1px solid var(--border); z-index: 40; }
.sb-top { padding: 16px 14px 10px; display: flex; flex-direction: column; gap: 12px; }
.sb-brand { display: flex; align-items: center; gap: 10px; padding: 2px 6px; }
.sb-brand b { display: block; font-size: 14.5px; }
.sb-server { position: relative; display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: var(--r); background: var(--surface); border: 1px solid var(--border); transition: border-color .15s; }
.sb-server:hover { border-color: var(--border-strong); }
.sb-server select { position: absolute; inset: 0; opacity: 0; cursor: pointer; height: 100%; }
.sb-server b { display: block; font-size: 13.5px; }
.sb-nav { flex: 1; overflow-y: auto; padding: 4px 14px 14px; display: flex; flex-direction: column; gap: 16px; }
.nav-group { display: flex; flex-direction: column; gap: 2px; }
.nav-title { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .09em; color: var(--text-3); padding: 0 10px 6px; }
.nav-link { position: relative; display: flex; align-items: center; gap: 11px; height: 36px; padding: 0 10px; border-radius: var(--r-sm); color: var(--text-2); font-weight: 550; font-size: 13.5px; text-decoration: none !important; transition: background .15s, color .15s; }
.nav-link:hover { background: var(--surface-2); color: var(--text); }
.nav-link.on { background: var(--accent-soft); color: var(--text); }
.nav-link.on::before { content: ""; position: absolute; left: -14px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent); animation: fade .25s; }
.nav-link .ico { width: 20px; display: grid; place-items: center; font-size: 15px; }
.nav-link .pill { margin-left: auto; }
.sb-user { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-top: 1px solid var(--border); }
.sb-user b { display: block; font-size: 13px; }
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 30; height: var(--topbar); display: flex; align-items: center; gap: 12px; padding: 0 28px; background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: saturate(140%) blur(12px); border-bottom: 1px solid var(--border); }
.crumbs { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--text-2); }
.crumbs b { color: var(--text); font-weight: 600; }
.crumbs .sep { color: var(--text-3); }
.menu-btn { display: none; }
.scrim { display: none; }
.page { width: 100%; max-width: 1400px; margin: 0 auto; padding: 28px 32px 96px; outline: none; }

/* ---------- page structure ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 24px; flex-wrap: wrap; }
.page-head .lead { margin-top: 6px; color: var(--text-2); max-width: 720px; font-size: 14px; }
.stack { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.stack.sm { gap: 10px; }
.grid { display: grid; gap: 20px; }
.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.cols-2-1 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.span-2 { grid-column: span 2; }
.span-all { grid-column: 1 / -1; }
.split { display: grid; grid-template-columns: minmax(0, 1fr) var(--aside, 400px); gap: 24px; align-items: start; }
.split.left { grid-template-columns: var(--aside, 360px) minmax(0, 1fr); }
.sticky { position: sticky; top: calc(var(--topbar) + 20px); }
.masonry { columns: 2; column-gap: 20px; }
.masonry > * { break-inside: avoid; margin-bottom: 20px; }
.section-gap { margin-top: 20px; }

/* ---------- cards ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); min-width: 0; box-shadow: var(--shadow-sm); transition: border-color .2s, transform .2s var(--ease), box-shadow .2s; }
.card-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 18px 20px; }
.card-header + .card-body { padding-top: 0; }
.card-header.bordered { border-bottom: 1px solid var(--border); }
.card-header.bordered + .card-body { padding-top: 18px; }
.card-header h2 { display: flex; align-items: center; gap: 8px; }
.card-header .sub { color: var(--text-2); font-size: 13px; margin-top: 3px; }
.card-body { padding: 18px 20px; }
.card-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 20px; border-top: 1px solid var(--border); background: color-mix(in srgb, var(--surface-2) 45%, transparent); border-radius: 0 0 var(--r-lg) var(--r-lg); }
.card.link { cursor: pointer; }
.card.link:hover { border-color: color-mix(in srgb, var(--accent) 55%, var(--border)); transform: translateY(-2px); box-shadow: var(--shadow); }
.card.is-off { border-style: dashed; }
.card.is-off .card-body { opacity: .7; }
.banner { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: var(--r); margin-bottom: 20px; font-size: 13.5px; }
.banner.warn { background: var(--warn-soft); border: 1px solid color-mix(in srgb, var(--warn) 40%, transparent); }
.banner.info { background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent); }
.divider { height: 1px; background: var(--border); margin: 16px 0; }

/* stats */
.stat { display: flex; align-items: center; gap: 14px; padding: 18px 20px; }
.stat-ico { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; font-size: 20px; flex: none; background: var(--accent-soft); }
.stat-ico.ok { background: var(--ok-soft); } .stat-ico.warn { background: var(--warn-soft); } .stat-ico.bad { background: var(--bad-soft); }
.stat-label { color: var(--text-2); font-size: 12.5px; font-weight: 550; }
.stat-value { font-size: 26px; font-weight: 750; letter-spacing: -.02em; line-height: 1.15; font-variant-numeric: tabular-nums; }
.stat-value.sm { font-size: 18px; }
.mini-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border-top: 1px solid var(--border); }
.mini-stat { padding: 14px 20px; border-left: 1px solid var(--border); }
.mini-stat:first-child { border-left: 0; }
.mini-stat .v { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.mini-stat .l { font-size: 12px; color: var(--text-2); display: flex; align-items: center; gap: 6px; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex: none; }
.dot.ok { background: var(--ok); } .dot.warn { background: var(--warn); } .dot.bad { background: var(--bad); } .dot.accent { background: var(--accent); } .dot.muted { background: var(--text-3); }
.dot.pulse { box-shadow: 0 0 0 0 color-mix(in srgb, var(--ok) 60%, transparent); animation: pulse 2s infinite; }

/* chart */
.chart { display: grid; grid-template-columns: repeat(14, minmax(0, 1fr)); gap: 8px; align-items: end; height: 190px; padding: 22px 20px 0; }
.bar-col { height: 100%; display: flex; flex-direction: column; justify-content: flex-end; position: relative; }
.bar { border-radius: 6px 6px 3px 3px; background: linear-gradient(180deg, var(--accent-strong), var(--accent)); transform-origin: bottom; animation: grow-y .6s var(--ease) both; position: relative; min-height: 3px; }
.bar.zero { background: var(--surface-3); }
.bar-col:hover .bar:not(.zero) { filter: brightness(1.15); }
.bar-n { position: absolute; top: -18px; left: 0; right: 0; text-align: center; font-size: 11px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.chart-x { display: grid; grid-template-columns: repeat(14, minmax(0, 1fr)); gap: 8px; padding: 8px 20px 16px; font-size: 11px; color: var(--text-3); text-align: center; }

/* lists */
.list { display: flex; flex-direction: column; }
.row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--border); min-width: 0; }
.row:first-child { border-top: 0; }
.row.top { align-items: flex-start; }
.row.dim { opacity: .55; }
.row.link { cursor: pointer; margin: 0 -10px; padding-left: 10px; padding-right: 10px; border-radius: var(--r-sm); transition: background .15s; }
.row.link:hover { background: var(--surface-2); }
.row .meta { font-size: 12px; color: var(--text-2); }
.row .actions { display: flex; gap: 6px; flex: none; }
.pos { font: 600 12px ui-monospace, Menlo, Consolas, monospace; color: var(--text-3); min-width: 36px; }
.empty { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; padding: 32px 16px; text-align: center; color: var(--text-2); }
.empty-ico { width: 52px; height: 52px; border-radius: 16px; display: grid; place-items: center; font-size: 24px; background: var(--surface-2); margin-bottom: 4px; }
.empty b { color: var(--text); }
.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; padding-top: 12px; }

/* badges & chips */
.badge { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 9px; border-radius: 999px; font-size: 11.5px; font-weight: 650; background: var(--surface-3); color: var(--text-2); white-space: nowrap; vertical-align: middle; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.accent { background: var(--accent-soft); color: var(--accent-text); }
.badge.outline { background: transparent; border: 1px solid var(--border-strong); }
.pill { font-size: 11px; font-weight: 700; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; display: inline-grid; place-items: center; background: var(--surface-3); color: var(--text-2); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 6px 0 10px; border-radius: 999px; background: var(--surface-3); font-size: 12.5px; max-width: 100%; animation: pop .2s var(--ease); }
.chip.plain { padding-right: 10px; }
.chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip button { width: 20px; height: 20px; border: 0; border-radius: 50%; background: transparent; color: var(--text-2); cursor: pointer; font-size: 14px; line-height: 1; display: grid; place-items: center; }
.chip button:hover { background: var(--bad-soft); color: var(--bad); }
.chip-picker { display: flex; flex-direction: column; gap: 8px; }
.toggle-chip { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--border-strong); background: transparent; color: var(--text-2); cursor: pointer; font-size: 12.5px; font-weight: 600; transition: all .15s; }
.toggle-chip:hover { border-color: var(--text-3); color: var(--text); }
.toggle-chip.on { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 55%, transparent); color: var(--accent-text); }
.toggle-chip.on::before { content: "✓"; font-size: 11px; }
.toggle-chip:disabled { opacity: .5; cursor: not-allowed; }

/* settings rows */
.srow { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr); gap: 24px; align-items: center; padding: 16px 0; border-top: 1px solid var(--border); }
.srow:first-child { border-top: 0; padding-top: 2px; }
.srow:last-child { padding-bottom: 2px; }
.srow.block { grid-template-columns: minmax(0, 1fr); gap: 12px; }
.srow.toggle .srow-control { justify-content: flex-end; }
.srow-label .name { font-weight: 600; font-size: 13.5px; display: flex; align-items: center; gap: 8px; }
.srow-label .help { color: var(--text-2); font-size: 12.5px; margin-top: 3px; }
.srow-control { display: flex; align-items: center; min-width: 0; }
.srow-control > * { width: 100%; }
.srow-control > .switch { width: 42px; }
.history { margin-top: 10px; border: 1px solid var(--border); border-radius: var(--r); overflow: hidden; }
.history summary { cursor: pointer; padding: 10px 14px; font-size: 12.5px; color: var(--text-2); list-style: none; display: flex; align-items: center; gap: 8px; }
.history summary::-webkit-details-marker { display: none; }
.history summary::before { content: "▸"; transition: transform .2s; }
.history[open] summary::before { transform: rotate(90deg); }
.history .list { padding: 0 14px 6px; }
.history .row { font-size: 13px; }
.dirty { display: inline-flex; align-items: center; gap: 8px; color: var(--warn); font-size: 12.5px; font-weight: 600; animation: fade .2s; }
.dirty::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--warn); }
.toc { display: flex; flex-direction: column; gap: 2px; }
.toc a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--r-sm); color: var(--text-2); font-size: 13px; text-decoration: none !important; transition: background .15s, color .15s; }
.toc a:hover { background: var(--surface-2); color: var(--text); }

/* form grid (composer) */
.fgrid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.field { display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.field > label, .field .label { font-size: 12.5px; font-weight: 600; color: var(--text-2); display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 18px; }
.field .help { font-size: 12px; color: var(--text-3); }
.field-inline { display: flex; align-items: center; justify-content: space-between; gap: 12px; height: 38px; padding: 0 12px; border-radius: var(--r-sm); background: var(--surface-2); border: 1px solid var(--border); font-size: 13px; }
.link-btn { border: 0; background: none; padding: 0; color: var(--accent-text); font-weight: 600; font-size: 12px; cursor: pointer; }
.link-btn:hover { text-decoration: underline; }
.swatches { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.swatch { width: 24px; height: 24px; border-radius: 7px; border: 2px solid transparent; cursor: pointer; padding: 0; transition: transform .12s; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .15); }
.swatch:hover { transform: scale(1.12); }
.swatch.on { border-color: var(--text); }
.color-input { display: flex; gap: 8px; align-items: center; }
.color-input input[type="color"] { width: 38px; height: 38px; padding: 3px; border: 1px solid var(--border-strong); border-radius: var(--r-sm); background: var(--surface-2); cursor: pointer; flex: none; }
.repeat-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.6fr) auto; gap: 8px; align-items: center; animation: rise .25s var(--ease); }
.field-row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 8px; align-items: start; padding: 12px; border: 1px solid var(--border); border-radius: var(--r); background: var(--surface-2); animation: rise .25s var(--ease); }
.field-row .stack { gap: 8px; }
.field-row textarea { min-height: 60px; }
.field-row .inline-toggle { display: flex; align-items: center; gap: 8px; height: 38px; font-size: 12.5px; color: var(--text-2); white-space: nowrap; }

/* collapsible card */
.collapse-body { display: grid; grid-template-rows: 1fr; transition: grid-template-rows .32s var(--ease), opacity .25s; }
.collapse-body > div { overflow: hidden; min-height: 0; }
.collapse.closed .collapse-body { grid-template-rows: 0fr; opacity: 0; }
.collapse.closed .card-header.bordered { border-bottom-color: transparent; }

/* editor */
.editor { display: flex; flex-direction: column; border: 1px solid var(--border-strong); border-radius: var(--r); background: var(--surface-2); transition: border-color .15s, box-shadow .15s; overflow: hidden; }
.editor:focus-within { border-color: var(--accent); box-shadow: var(--ring); }
.editor textarea { border: 0; border-radius: 0; background: transparent !important; box-shadow: none !important; min-height: 120px; }
.toolbar-md { display: flex; flex-wrap: wrap; gap: 2px; align-items: center; padding: 6px; border-bottom: 1px solid var(--border); background: color-mix(in srgb, var(--surface-3) 40%, transparent); }
.tbtn { min-width: 30px; height: 30px; border: 0; border-radius: 7px; background: transparent; color: var(--text-2); cursor: pointer; font-weight: 700; font-size: 12.5px; padding: 0 6px; transition: background .12s, color .12s; }
.tbtn:hover { background: var(--surface-3); color: var(--text); }
.tbtn.t-I { font-style: italic; font-family: Georgia, serif; } .tbtn.t-U { text-decoration: underline; } .tbtn.t-S { text-decoration: line-through; }
.tsep { width: 1px; height: 18px; background: var(--border-strong); margin: 0 4px; }
.toolbar-md .insert { width: auto; height: 30px; padding: 0 28px 0 10px; font-size: 12.5px; margin-left: 4px; background-color: var(--surface); background-position: calc(100% - 15px) 12px, calc(100% - 10px) 12px; }
.toolbar-md .count { margin-left: auto; font-size: 11.5px; color: var(--text-3); padding: 0 6px; font-variant-numeric: tabular-nums; }
.toolbar-md .count.over { color: var(--warn); }
.editor-preview { border-top: 1px solid var(--border); }
.editor-preview .label { font-size: 10.5px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; color: var(--text-3); padding: 10px 14px 6px; background: #313338; }

/* composer */
.dropzone { border: 1.5px dashed var(--border-strong); border-radius: var(--r); padding: 26px 16px; text-align: center; cursor: pointer; display: flex; flex-direction: column; gap: 4px; align-items: center; color: var(--text-2); transition: border-color .15s, background .15s, transform .15s; }
.dropzone:hover, .dropzone.over { border-color: var(--accent); background: var(--accent-soft); color: var(--text); }
.dropzone.over { transform: scale(1.01); }
.drop-ico { font-size: 26px; }
.files { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; margin-top: 12px; }
.file { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: var(--r); background: var(--surface-2); border: 1px solid var(--border); animation: pop .25s var(--ease); }
.file img, .file-ico { width: 46px; height: 46px; object-fit: cover; border-radius: 8px; flex: none; }
.file-ico { display: grid; place-items: center; font-size: 22px; background: var(--surface-3); }
.edit-banner { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-radius: var(--r); background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent); margin-bottom: 20px; animation: rise .3s var(--ease); }

/* Discord preview (always Discord's dark look) */
.discord { background: #313338; color: #dbdee1; border-radius: var(--r); padding: 16px; font-size: 15px; line-height: 1.375; overflow-wrap: anywhere; font-family: "gg sans", "Noto Sans", "Segoe UI", system-ui, sans-serif; }
.discord.mini { padding: 4px 14px 14px; font-size: 14px; border-radius: 0; }
.discord .muted { color: #949ba4; }
.d-msg { display: flex; gap: 14px; }
.d-avatar { width: 40px; height: 40px; border-radius: 50%; flex: none; object-fit: cover; }
.d-avatar.ph { display: grid; place-items: center; background: #5865f2; color: #fff; font-weight: 700; }
.d-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.d-head { display: flex; align-items: center; gap: 6px; }
.d-name { color: #f2f3f5; font-weight: 600; }
.d-app { background: #5865f2; color: #fff; font-size: 10px; font-weight: 700; padding: 0 5px; border-radius: 4px; line-height: 16px; }
.d-time { color: #949ba4; font-size: 12px; }
.d-embed { display: flex; gap: 16px; background: #2b2d31; border-left: 4px solid #5865f2; border-radius: 4px; padding: 10px 16px 14px 12px; max-width: 520px; margin-top: 2px; }
.d-embed-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.d-embed-author { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; color: #f2f3f5; }
.d-embed-author img { width: 24px; height: 24px; border-radius: 50%; }
.d-embed-title { font-weight: 700; color: #f2f3f5; }
.d-embed-title.link, .discord .link, .md-link { color: #00a8fc; text-decoration: none; }
.d-embed-desc { font-size: 14px; }
.d-fields { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px 12px; margin-top: 2px; }
.d-field { grid-column: 1 / -1; font-size: 14px; }
.d-field.inline { grid-column: auto; }
.d-field-name { font-weight: 700; color: #f2f3f5; margin-bottom: 2px; font-size: 13px; }
.d-embed-image { max-width: 100%; max-height: 300px; border-radius: 4px; margin-top: 6px; object-fit: contain; }
.d-embed-thumb { width: 80px; height: 80px; object-fit: cover; border-radius: 4px; flex: none; }
.d-embed-footer { display: flex; align-items: center; gap: 8px; font-size: 12px; color: #b5bac1; margin-top: 2px; }
.d-files { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.d-file-img { max-width: 100%; max-height: 260px; border-radius: 8px; }
.d-file { display: flex; gap: 10px; align-items: center; background: #2b2d31; border: 1px solid #1e1f22; border-radius: 8px; padding: 10px 14px; }
.d-buttons { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.d-button { background: #4e5058; color: #fff; border-radius: 4px; padding: 6px 14px; font-size: 14px; font-weight: 500; }
.d-button.primary { background: #5865f2; }
.d-button.success { background: #248046; }
.d-v2 { display: flex; flex-direction: column; gap: 8px; max-width: 560px; margin-top: 2px; padding: 16px; border-radius: 8px; background: #2b2d31; border-left: 4px solid #5865f2; }
.d-v2-image { width: 100%; border-radius: 6px; }
.d-sep { height: 1px; background: #3f4147; margin: 4px 0; }
.d-section { display: flex; align-items: center; gap: 16px; }
.d-select { display: flex; justify-content: space-between; align-items: center; max-width: 420px; margin-top: 4px; padding: 9px 12px; border-radius: 4px; background: #1e1f22; color: #949ba4; font-size: 14px; }
.kind-tabs { display: flex; gap: 6px; flex-wrap: wrap; padding: 8px; }
.kind-tab { display: inline-flex; align-items: center; gap: 8px; height: 38px; padding: 0 14px; border-radius: var(--r-sm); border: 1px solid transparent; background: transparent; color: var(--text-2); cursor: pointer; font-weight: 600; font-size: 13.5px; text-decoration: none !important; transition: background .15s, color .15s, border-color .15s; }
.kind-tab:hover { background: var(--surface-2); color: var(--text); }
.kind-tab.on { background: var(--accent-soft); color: var(--text); border-color: color-mix(in srgb, var(--accent) 45%, transparent); }
.item-row { display: grid; grid-template-columns: 30px minmax(0, 1fr) auto; gap: 10px; align-items: start; padding: 12px; border: 1px solid var(--border); border-radius: var(--r); background: var(--surface-2); animation: rise .25s var(--ease); }
.item-row .num { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-text); font-weight: 700; font-size: 12.5px; }
.item-row .tools { display: flex; flex-direction: column; gap: 4px; }
.item-row .two { display: grid; grid-template-columns: 90px minmax(0, 1fr); gap: 8px; }
.limit { font-size: 12px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.limit.over { color: var(--bad); font-weight: 700; }
.d-button.disabled { opacity: .5; }
.d-dm-head { display: flex; align-items: center; gap: 8px; font-size: 12px; color: #949ba4; padding-bottom: 10px; margin-bottom: 12px; border-bottom: 1px solid #3f4147; }
.md { display: flex; flex-direction: column; gap: 2px; }
.md-p { white-space: pre-wrap; }
.md-h { color: #f2f3f5; margin: 6px 0 2px; line-height: 1.25; }
.md-h1 { font-size: 24px; } .md-h2 { font-size: 20px; } .md-h3 { font-size: 16px; }
.md-sub { font-size: 12px; color: #949ba4; }
.md-quote { margin: 2px 0; padding-left: 12px; border-left: 4px solid #4e5058; }
.md-list { margin: 2px 0; padding-left: 22px; }
.md-pre { margin: 4px 0; background: #2b2d31; border: 1px solid #1e1f22; border-radius: 4px; padding: 8px; white-space: pre-wrap; font-size: 13px; color: #dbdee1; }
.md-code { background: #1e1f22; border-radius: 3px; padding: 0 3px; font-size: 13px; color: #dbdee1; }
.md-spoiler { background: #1e1f22; color: transparent; border-radius: 3px; cursor: pointer; transition: color .15s; }
.md-spoiler.shown { color: inherit; background: rgba(255, 255, 255, .1); }
.md-mention { background: rgba(88, 101, 242, .3); color: #c9cdfb; border-radius: 3px; padding: 0 2px; font-weight: 500; }
.md-time { background: rgba(255, 255, 255, .06); border-radius: 3px; padding: 0 2px; }
.md-emoji { width: 22px; height: 22px; vertical-align: -5px; object-fit: contain; }
.discord strong { color: #f2f3f5; }

/* avatars */
.av { border-radius: 50%; flex: none; object-fit: cover; background: var(--surface-3); }
.av-xs { width: 24px; height: 24px; } .av-sm { width: 32px; height: 32px; } .av-md { width: 36px; height: 36px; border-radius: 10px; } .av-lg { width: 48px; height: 48px; } .av-xl { width: 80px; height: 80px; }
.av-ph { display: inline-grid; place-items: center; font-weight: 700; color: var(--on-accent); background: linear-gradient(135deg, var(--accent), var(--accent-strong)); }
.av-xs.av-ph { font-size: 11px; } .av-sm.av-ph { font-size: 13px; } .av-xl.av-ph { font-size: 30px; }

/* members */
.profile-head { display: flex; gap: 20px; align-items: center; padding: 22px 20px; flex-wrap: wrap; }
.profile-head h2 { font-size: 20px; }
.meter { height: 6px; background: var(--surface-3); border-radius: 999px; overflow: hidden; margin-top: 10px; }
.meter > div { height: 100%; border-radius: 999px; transition: width .6s var(--ease); }
.meter.ok > div { background: var(--ok); } .meter.warn > div { background: var(--warn); } .meter.bad > div { background: var(--bad); }
.timeline { position: relative; }
.case { position: relative; display: grid; grid-template-columns: 24px minmax(0, 1fr) auto; gap: 14px; padding: 12px 0; animation: rise .3s var(--ease) both; }
.case::before { content: ""; position: absolute; left: 11px; top: 0; bottom: 0; width: 2px; background: var(--border); }
.case:first-child::before { top: 24px; } .case:last-child::before { bottom: calc(100% - 24px); }
.case:only-child::before { display: none; }
.case-dot { position: relative; z-index: 1; width: 24px; height: 24px; border-radius: 50%; background: var(--surface-3); border: 4px solid var(--surface); margin-top: 1px; }
.case-dot.warn { background: var(--warn); } .case-dot.bad { background: var(--bad); } .case-dot.accent { background: var(--accent); } .case-dot.ok { background: var(--ok); }
.case-body { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.case-top { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.case .reason { overflow-wrap: anywhere; }
.case.revoked .reason { text-decoration: line-through; color: var(--text-2); }

/* waitlist */
.select-panel { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.result { margin-top: 18px; border-radius: var(--r); border: 1px solid color-mix(in srgb, var(--ok) 40%, transparent); background: var(--ok-soft); padding: 14px 16px; animation: rise .35s var(--ease); }

/* access */
.perm-legend { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.perm-tile { display: flex; gap: 12px; align-items: flex-start; padding: 14px; border-radius: var(--r); background: var(--surface-2); border: 1px solid var(--border); }
.perm-tile .ico { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--accent-soft); flex: none; }
.perm-tile b { display: block; font-size: 13px; }
.perm-tile span { font-size: 12.5px; color: var(--text-2); }

/* commands */
.toolbar { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; padding: 12px 16px; }
.toolbar input[type="search"] { max-width: 340px; }
.toolbar .summary { margin-left: auto; color: var(--text-2); font-size: 13px; }
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-sm); padding: 3px; gap: 2px; }
.seg button { border: 0; background: none; height: 28px; padding: 0 12px; border-radius: 6px; cursor: pointer; color: var(--text-2); font-weight: 600; font-size: 12.5px; transition: background .15s, color .15s; }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.cmd-name { font: 600 13.5px ui-monospace, "Cascadia Code", Menlo, Consolas, monospace; }
.cmd-name.pending { color: var(--warn); }
.savebar { position: fixed; left: calc(50% + var(--sidebar) / 2); transform: translateX(-50%); bottom: 24px; z-index: 35; display: flex; align-items: center; gap: 12px; padding: 10px 10px 10px 18px; border-radius: var(--r); background: var(--surface); border: 1px solid var(--border-strong); box-shadow: var(--shadow); animation: slide-up .3s var(--ease); max-width: calc(100vw - 32px); }

/* sign-in */
.signin-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: radial-gradient(900px 500px at 50% -10%, var(--accent-soft), transparent 70%), var(--bg); }
.signin { width: min(400px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 20px; padding: 32px 28px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 16px; text-align: center; align-items: center; animation: pop .4s var(--ease); }
.signin h1 { font-size: 22px; }
.signin .howto { text-align: left; width: 100%; background: var(--surface-2); border-radius: var(--r); padding: 14px 16px; font-size: 13px; }
.signin ol { margin: 6px 0 0; padding-left: 20px; color: var(--text-2); }
.signin .alert { color: var(--warn); background: var(--warn-soft); padding: 10px 12px; border-radius: var(--r-sm); font-size: 13px; width: 100%; }
.or { width: 100%; display: flex; align-items: center; gap: 10px; color: var(--text-3); font-size: 11px; text-transform: uppercase; letter-spacing: .1em; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--border); }

/* popover (appearance) */
.popover-wrap { position: relative; }
.popover { position: absolute; right: 0; top: calc(100% + 8px); width: 340px; background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--r-lg); box-shadow: var(--shadow); padding: 16px; z-index: 60; animation: pop .18s var(--ease); transform-origin: top right; }
.popover h3 { margin-bottom: 10px; color: var(--text-3); text-transform: uppercase; font-size: 11px; letter-spacing: .09em; }
.palettes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-bottom: 16px; }
.palette { display: flex; align-items: center; gap: 10px; height: 40px; padding: 0 10px; border-radius: var(--r-sm); border: 1px solid var(--border); background: var(--surface-2); color: var(--text); cursor: pointer; text-align: left; font-size: 12.5px; font-weight: 600; transition: border-color .15s, transform .1s; }
.palette:hover { border-color: var(--text-3); }
.palette.on { border-color: var(--accent); box-shadow: var(--ring); }
.palette-dots { display: flex; }
.palette-dots i { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--surface-2); margin-left: -4px; }
.palette-dots i:first-child { margin-left: 0; }

/* toasts & dialog */
#toasts { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 10px; z-index: 100; max-width: min(400px, calc(100vw - 40px)); }
.toast { display: flex; gap: 10px; align-items: flex-start; background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--r); padding: 12px 14px; box-shadow: var(--shadow); font-size: 13.5px; animation: toast-in .3s var(--ease); overflow-wrap: anywhere; transition: opacity .25s, transform .25s; }
.toast.out { opacity: 0; transform: translateX(24px); }
.toast-ico { width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; font-size: 11px; font-weight: 800; flex: none; background: var(--ok); color: #fff; }
.toast.error .toast-ico { background: var(--bad); }
dialog { background: var(--surface); color: var(--text); border: 1px solid var(--border-strong); border-radius: 18px; padding: 24px; width: min(460px, calc(100vw - 32px)); box-shadow: var(--shadow); }
dialog[open] { animation: pop .22s var(--ease); }
dialog::backdrop { background: rgba(4, 5, 8, .62); backdrop-filter: blur(3px); }
dialog h2 { font-size: 18px; margin-bottom: 8px; }
dialog p { margin-bottom: 14px; color: var(--text-2); }
dialog .btns { margin-top: 18px; }

/* ---------- responsive ---------- */
@media (max-width: 1280px) {
  .split, .split.left { grid-template-columns: minmax(0, 1fr); }
  .sticky { position: static; }
  .cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cols-2-1 { grid-template-columns: minmax(0, 1fr); }
  .perm-legend { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .toc-aside { display: none; }
}
@media (max-width: 980px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: min(300px, 86vw); transform: translateX(-104%); transition: transform .28s var(--ease); box-shadow: var(--shadow); }
  .sidebar.open { transform: none; }
  .sidebar.open + .scrim { display: block; position: fixed; inset: 0; z-index: 39; background: rgba(0, 0, 0, .5); animation: fade .2s; }
  .menu-btn { display: inline-flex; }
  .topbar { padding: 0 16px; }
  .page { padding: 20px 16px 96px; }
  .cols-2, .cols-3 { grid-template-columns: minmax(0, 1fr); }
  .masonry { columns: 1; }
  .savebar { left: 50%; }
  .srow { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  .srow.toggle { grid-template-columns: minmax(0, 1fr) auto; }
}
@media (max-width: 560px) {
  .cols-4 { grid-template-columns: minmax(0, 1fr); }
  .fgrid { grid-template-columns: minmax(0, 1fr); }
  .span-2 { grid-column: auto; }
  .mini-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .mini-stat:nth-child(3) { border-left: 0; }
  .mini-stat:nth-child(n+3) { border-top: 1px solid var(--border); }
  .perm-legend { grid-template-columns: minmax(0, 1fr); }
  .stat-value { font-size: 22px; }
  .repeat-row { grid-template-columns: minmax(0, 1fr) auto; }
  .repeat-row > :nth-child(2) { grid-column: 1; grid-row: 2; }
  .field-row { grid-template-columns: minmax(0, 1fr) auto; }
  .savebar { left: 16px; right: 16px; transform: none; animation: none; }
  .page-head .btns { width: 100%; }
  .popover { position: fixed; left: 16px; right: 16px; top: 70px; width: auto; }
}
