/* bytepatch admin panel -- "Quartz" design system.
   Dark, boxy (zero radius), purple accent. Structure comes from hairlines
   and type, not nested boxes: only overlays (dialogs, the drawer, toasts)
   get a surface of their own. Served from /assets so the
   Content-Security-Policy can drop 'unsafe-inline' for scripts. */

:root {
  color-scheme: dark;
  --ground: #0b0a0f;
  --panel: #0f0e14;
  --surface: #15131b;
  --raised: #1c1a25;
  --line: #201e29;
  --line-2: #322e3e;
  --text: #ebe7f1;
  --muted: #a39db1;
  --faint: #7b758b;
  --accent: #75438f;
  --accent-deep: #361647;
  --accent-ink: #c29cdb;
  --on-accent: #f4eef8;
  --ok: #7fd694;   --ok-bg: #132a1c;
  --warn: #e2b355; --warn-bg: #30250f;
  --bad: #e2748c;  --bad-bg: #34151f;
  --ui: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", sans-serif;
  --mono: "Cascadia Mono", "Cascadia Code", ui-monospace, "SF Mono", Consolas, monospace;
  --side-w: 204px;
  --ctl-h: 32px;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--ground); color: var(--text);
  font: 13.5px/1.5 var(--ui);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
h1, h2, h3, p, dl, dd, ul { margin: 0; padding: 0; }
h1, h2, h3 { font-weight: 600; }
ul { list-style: none; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; }
code, kbd, .mono { font-family: var(--mono); font-size: .94em; }
[hidden] { display: none !important; }
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--accent-ink); outline-offset: 2px; }
::selection { background: var(--accent); color: var(--on-accent); }
* { scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }

.link { color: var(--accent-ink); cursor: pointer; background: none; border: 0; padding: 0; }
.link:hover { text-decoration: underline; text-underline-offset: 3px; }
.muted { color: var(--muted); }
.t-warn { color: var(--warn); }
.t-bad { color: var(--bad); }
.faint { color: var(--faint); }
.num { font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.grow { flex: 1; min-width: 0; }
.id { font-family: var(--mono); font-size: 12.5px; font-variant-numeric: tabular-nums; }

/* ---------- controls ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: var(--ctl-h); padding: 0 13px;
  background: transparent; color: var(--text);
  border: 1px solid var(--line-2);
  font-size: 13px; font-weight: 500; white-space: nowrap;
  transition: background .12s, border-color .12s, color .12s;
}
.btn:hover { background: var(--raised); border-color: #454054; }
.btn:active { background: var(--line); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .45; cursor: not-allowed; pointer-events: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 600; }
.btn.primary:hover { background: #8450a0; border-color: #8450a0; }
.btn.danger { color: var(--bad); border-color: #6d3a48; }
.btn.danger:hover { background: var(--bad-bg); border-color: var(--bad); }
.btn.quiet { border-color: transparent; color: var(--muted); padding: 0 9px; }
.btn.quiet:hover { color: var(--text); background: var(--raised); }
.btn.sm { height: 26px; padding: 0 9px; font-size: 12.5px; }
.btn.block { width: 100%; }
.btn.busy { color: transparent !important; position: relative; pointer-events: none; }
.btn.busy::after {
  content: ""; position: absolute; width: 12px; height: 12px;
  border: 2px solid var(--on-accent); border-right-color: transparent; border-radius: 50%;
  animation: spin .6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

input[type=text], input[type=password], input[type=number], input[type=date], input[type=search], select, textarea {
  height: var(--ctl-h); width: 100%;
  background: #0e0d13; color: var(--text);
  border: 1px solid var(--line-2); border-radius: 0;
  font: inherit; padding: 0 10px;
  transition: border-color .12s;
}
input:hover, select:hover, textarea:hover { border-color: #454054; }
input:focus, select:focus, textarea:focus { border-color: var(--accent-ink); outline: none; }
input::placeholder, textarea::placeholder { color: var(--faint); }
textarea { height: auto; min-height: 76px; padding: 8px 10px; resize: vertical; line-height: 1.45; }
select {
  appearance: none; padding-right: 28px;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 15px) 14px, calc(100% - 10px) 14px;
  background-size: 5px 5px, 5px 5px; background-repeat: no-repeat;
}
input[type=color] { width: 40px; height: var(--ctl-h); padding: 2px; background: #0e0d13; border: 1px solid var(--line-2); }
input[type=file] { font: inherit; color: var(--muted); }

input[type=checkbox] {
  appearance: none; flex: none; width: 15px; height: 15px; margin: 0;
  border: 1px solid #4a4459; background: #0e0d13; vertical-align: -2px; cursor: pointer;
  display: inline-grid; place-content: center;
}
input[type=checkbox]:hover { border-color: var(--accent-ink); }
input[type=checkbox]:checked, input[type=checkbox]:indeterminate { background: var(--accent); border-color: var(--accent); }
input[type=checkbox]:checked::after {
  content: ""; width: 8px; height: 4px; margin-top: -2px;
  border: solid var(--on-accent); border-width: 0 0 2px 2px; transform: rotate(-45deg);
}
input[type=checkbox]:indeterminate::after { content: ""; width: 7px; height: 2px; background: var(--on-accent); }

.field { display: grid; gap: 6px; }
.field > span, .field > label { font-size: 12.5px; color: var(--muted); }
.field .hint { font-size: 12px; color: var(--faint); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.check { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); cursor: pointer; white-space: nowrap; }

/* square on/off switch */
.switch {
  flex: none; width: 34px; height: 18px; padding: 0; position: relative;
  background: #0e0d13; border: 1px solid #4a4459;
  transition: background .12s, border-color .12s;
}
.switch::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 12px; height: 12px;
  background: var(--muted); transition: transform .12s, background .12s;
}
.switch[aria-checked="true"] { background: var(--accent); border-color: var(--accent); }
.switch[aria-checked="true"]::after { transform: translateX(16px); background: var(--on-accent); }

/* segmented choice */
.seg { display: inline-flex; border: 1px solid var(--line-2); }
.seg button {
  height: 30px; padding: 0 13px; background: transparent; border: 0;
  color: var(--muted); font-size: 13px; font-weight: 500;
}
.seg button + button { border-left: 1px solid var(--line-2); }
.seg button:hover { color: var(--text); background: var(--raised); }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); }
.seg.block { display: flex; }
.seg.block button { flex: 1; padding: 0 6px; }

/* ---------- shell ---------- */
.skip { position: absolute; left: -999px; top: 8px; background: var(--accent); color: var(--on-accent); padding: 6px 12px; z-index: 100; }
.skip:focus { left: 8px; }
.shell { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); min-height: 100vh; }

.side {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column;
  background: var(--panel); border-right: 1px solid var(--line);
  padding: 18px 12px 14px;
}
.brand { display: flex; align-items: baseline; gap: 1px; padding: 2px 10px 18px; font: 600 15px var(--mono); letter-spacing: -.02em; }
.brand::before { content: ""; width: 9px; height: 9px; background: var(--accent); margin-right: 9px; align-self: center; }
.brand span { color: var(--faint); font-weight: 400; }
.side-search {
  display: flex; align-items: center; justify-content: space-between;
  height: 30px; padding: 0 9px 0 10px; margin-bottom: 14px;
  background: transparent; border: 1px solid var(--line-2); color: var(--faint); font-size: 12.5px;
}
.side-search:hover { color: var(--muted); border-color: #454054; }
kbd { font-size: 11px; color: var(--faint); border: 1px solid var(--line-2); padding: 0 4px; line-height: 16px; }
.nav { display: grid; gap: 1px; }
.nav a {
  display: flex; align-items: center; height: 31px; padding: 0 10px;
  color: var(--muted); border-left: 2px solid transparent;
}
.nav a:hover { color: var(--text); background: var(--surface); }
.nav a.on { color: var(--text); font-weight: 600; background: var(--surface); border-left-color: var(--accent-ink); }
.nav .gap { height: 14px; }
.nav-n { margin-left: auto; font: 600 11px var(--mono); color: var(--bad); }
.side-foot { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--line); display: flex; align-items: center; gap: 6px; }
.side-foot .who { flex: 1; min-width: 0; padding: 0 10px; color: var(--muted); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-foot .who:hover { color: var(--text); }

.main { min-width: 0; }
.mobile-bar { display: none; }
.page { padding: 30px 40px 72px; max-width: 1280px; }
.page.narrow { max-width: 780px; }
.page-head { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; padding-bottom: 18px; margin-bottom: 24px; border-bottom: 1px solid var(--line); }
.page-head h1 { font-size: 21px; letter-spacing: -.012em; line-height: 1.2; }
.page-meta { color: var(--muted); font-size: 13px; margin-top: 3px; min-height: 19px; }
.page-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.page-actions .search { width: 280px; }
.page-actions:empty { display: none; }

/* ---------- sections ---------- */
.sec + .sec { margin-top: 34px; }
.sec-head { display: flex; align-items: baseline; gap: 12px; padding-bottom: 9px; border-bottom: 1px solid var(--line-2); }
.sec-head h2 { font-size: 13.5px; }
.sec-head .n { color: var(--faint); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.sec-head .end { margin-left: auto; display: flex; gap: 10px; align-items: baseline; font-size: 12.5px; }
.sec-note { color: var(--muted); font-size: 13px; padding: 10px 0 0; max-width: 68ch; }
.cols { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr); gap: 34px 48px; align-items: start; }
.cols.even { grid-template-columns: 1fr 1fr; }
.stack { display: grid; gap: 34px; align-content: start; }
.empty { padding: 16px 0; color: var(--faint); }
.mt { margin-top: 34px; }
.mt-s { margin-top: 14px; }

/* ---------- status marks ---------- */
.st { display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; }
.st::before { content: ""; flex: none; width: 7px; height: 7px; background: currentColor; }
.st.ok { color: var(--ok); } .st.warn { color: var(--warn); } .st.bad { color: var(--bad); }
.st.accent { color: var(--accent-ink); }
.st.off { color: var(--muted); }
.st.off::before { background: transparent; box-shadow: inset 0 0 0 1px var(--faint); }
.flag { font: 500 11.5px var(--mono); color: var(--muted); white-space: nowrap; }
.flag.bad { color: var(--bad); } .flag.warn { color: var(--warn); } .flag.accent { color: var(--accent-ink); }
.flag + .flag::before, .tag + .flag::before { content: "·"; color: var(--faint); margin: 0 6px 0 0; }
.tag { font: 500 11.5px var(--mono); color: var(--muted); border: 1px solid var(--line-2); padding: 0 6px; line-height: 18px; display: inline-block; white-space: nowrap; }
.ch { font: 600 10.5px var(--mono); letter-spacing: .04em; text-transform: uppercase; padding: 0 6px; line-height: 17px; display: inline-block; }
.ch.live { background: var(--accent); color: var(--on-accent); }
.ch.beta { color: var(--accent-ink); box-shadow: inset 0 0 0 1px var(--accent); }

/* ---------- overview figures ---------- */
.figs { display: grid; grid-template-columns: repeat(4, 1fr); border-bottom: 1px solid var(--line); margin-top: -8px; }
.fig { display: block; padding: 4px 20px 18px 0; }
.fig + .fig { padding-left: 20px; border-left: 1px solid var(--line); }
.fig b { display: block; font: 600 28px/1.15 var(--ui); letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.fig span { display: block; color: var(--muted); }
.fig small { display: block; color: var(--faint); font-size: 12.5px; min-height: 19px; }
.fig:hover span { color: var(--text); }
.fig.warn b { color: var(--warn); } .fig.ok b { color: var(--ok); }

/* ---------- lists ---------- */
.rows > li, .rows > .row {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 0; border-bottom: 1px solid var(--line); min-height: 40px;
}
.rows .t { flex: 1; min-width: 0; }
.rows .t b { font-weight: 600; }
.rows .t small { display: block; color: var(--faint); font-size: 12.5px; overflow-wrap: anywhere; }
.rows .when { color: var(--faint); font-size: 12.5px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.rows .acts { display: flex; gap: 6px; flex: none; }
.rows .st { align-self: flex-start; margin-top: 7px; }

.kv { display: grid; grid-template-columns: 128px minmax(0, 1fr); }
.kv dt, .kv dd { padding: 7px 0; border-bottom: 1px solid var(--line); }
.kv dt { color: var(--muted); }
.kv dd { overflow-wrap: anywhere; }
.kv dd .link { margin-left: 10px; font-size: 12.5px; }

/* ---------- event feed ---------- */
.feed .ev { display: grid; grid-template-columns: 58px 7px minmax(0, 1fr); gap: 12px; align-items: baseline; padding: 7px 0; border-bottom: 1px solid var(--line); }
.feed .ev time { color: var(--faint); font: 12px var(--mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
.feed .ev i { width: 7px; height: 7px; background: var(--faint); align-self: center; }
.feed .ev.ok i { background: var(--ok); } .feed .ev.warn i { background: var(--warn); }
.feed .ev.bad i { background: var(--bad); } .feed .ev.accent i { background: var(--accent-ink); }
.feed .ev.muted i { background: transparent; box-shadow: inset 0 0 0 1px var(--faint); }
.feed .ev p { color: var(--muted); overflow-wrap: anywhere; }
.feed .ev p b { color: var(--text); font-weight: 600; }
.feed .day { padding: 18px 0 7px; color: var(--text); font-weight: 600; font-size: 12.5px; border-bottom: 1px solid var(--line-2); }
.feed .day:first-child { padding-top: 4px; }

/* ---------- toolbar, tabs ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: center; margin-bottom: 14px; }
.toolbar .search { width: 280px; max-width: 100%; }
.toolbar select, .toolbar input[type=date], .toolbar input.short { width: auto; min-width: 140px; }
.toolbar .end { margin-left: auto; display: flex; gap: 10px; align-items: center; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line-2); overflow-x: auto; scrollbar-width: none; }
.tabs button {
  display: inline-flex; align-items: baseline; gap: 6px; height: 34px; padding: 0 11px;
  background: none; border: 0; border-bottom: 2px solid transparent; margin-bottom: -1px;
  color: var(--muted); font-weight: 500; white-space: nowrap;
}
.tabs button em { font: normal 11.5px var(--mono); color: var(--faint); font-variant-numeric: tabular-nums; }
.tabs button:hover { color: var(--text); }
.tabs button[aria-pressed="true"], .tabs button[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent-ink); }
.tabs button.zero { color: var(--faint); }
.tabs .end { margin-left: auto; align-self: center; color: var(--faint); font-size: 12.5px; padding-left: 14px; white-space: nowrap; }

.bulk {
  display: flex; align-items: center; gap: 8px; height: 44px; padding: 0 12px;
  background: var(--accent-deep); border-bottom: 1px solid var(--accent);
  position: sticky; top: 0; z-index: 5;
}
.bulk b { margin-right: auto; font-weight: 600; font-variant-numeric: tabular-nums; }
.bulk .btn { border-color: #5a3470; }
.bulk .btn:hover { background: #45205a; border-color: var(--accent-ink); }

/* ---------- tables ---------- */
.tbl-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; }
.tbl th {
  text-align: left; font-weight: 500; font-size: 12.5px; color: var(--faint);
  padding: 9px 12px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
.tbl th.sort { cursor: pointer; user-select: none; }
.tbl th.sort:hover, .tbl th[aria-sort] { color: var(--text); }
.tbl th.sort::after { content: "↕"; margin-left: 5px; opacity: .35; font-size: 11px; }
.tbl th[aria-sort="ascending"]::after { content: "↑"; opacity: 1; color: var(--accent-ink); }
.tbl th[aria-sort="descending"]::after { content: "↓"; opacity: 1; color: var(--accent-ink); }
.tbl td { padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl th:first-child, .tbl td:first-child { padding-left: 10px; }
.tbl tbody tr:hover { background: var(--panel); }
.tbl tbody tr.click { cursor: pointer; }
.tbl tbody tr.sel { background: #1a1024; }
.tbl tbody tr.dim td { color: var(--faint); }
.tbl tbody tr:focus-visible { outline-offset: -2px; }
.tbl .c-check { width: 34px; }
.tbl .r { text-align: right; }
.tbl td small { display: block; color: var(--faint); font-size: 12.5px; }
.tbl .who { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.tbl .who b { font-weight: 600; }
.copy-key { font: 12.5px var(--mono); background: none; border: 0; padding: 0; color: var(--text); letter-spacing: .01em; }
.copy-key:hover { color: var(--accent-ink); }
.tbl tr.dim .copy-key { color: var(--faint); }

/* ---------- notices ---------- */
.notice { padding: 10px 12px; border-left: 2px solid var(--line-2); background: var(--panel); color: var(--muted); }
.notice b { color: var(--text); font-weight: 600; }
.notice.bad { border-left-color: var(--bad); background: var(--bad-bg); color: #f0b6c3; }
.notice.warn { border-left-color: var(--warn); background: var(--warn-bg); color: #ecd29b; }
.notice.ok { border-left-color: var(--ok); background: var(--ok-bg); color: #b4e6c0; }
.notice button.link { float: right; margin-left: 12px; }
.err-text { color: var(--bad); font-size: 13px; min-height: 20px; }

/* ---------- release pipeline ---------- */
.pipe { display: grid; grid-template-columns: 92px minmax(0, 1fr) 132px minmax(0, 1fr); }
.pipe > * { border-bottom: 1px solid var(--line); padding: 14px 0; }
.pipe .colh { padding: 0 0 9px; color: var(--faint); font-size: 12.5px; border-bottom-color: var(--line-2); }
.pipe .kind { font-weight: 600; padding-top: 16px; }
.pipe .mid { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px; color: var(--faint); font-size: 12.5px; text-align: center; }
.pipe .mid .arrow { font: 16px var(--mono); line-height: 1; }
.slot { display: block; padding: 14px 14px !important; border-left: 2px solid transparent; text-align: left; background: none; border-top: 0; border-right: 0; width: 100%; }
button.slot:hover, a.slot:hover { background: var(--panel); }
.slot.on { background: var(--panel); border-left-color: var(--accent-ink); }
.slot .v { font: 600 14px var(--mono); display: flex; gap: 9px; align-items: center; flex-wrap: wrap; }
.slot .v .none { font: 400 13.5px var(--ui); color: var(--faint); }
.slot .d { color: var(--muted); font-size: 12.5px; margin-top: 3px; }
.slot .fp { color: var(--faint); font: 12px var(--mono); }
.slot-acts { margin-top: 10px; display: flex; gap: 6px; }
.pipe .wide { grid-column: 2 / -1; }
.pipe.compact > * { padding-top: 10px; padding-bottom: 10px; }
.pipe.compact { grid-template-columns: 76px minmax(0, 1fr) minmax(0, 1fr); }
.pipe.compact .slot { padding: 10px 12px !important; }
.pipe.compact .kind { padding-top: 11px; }

.setting { display: flex; align-items: center; gap: 20px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.setting .t { flex: 1; min-width: 0; }
.setting .t b { font-weight: 600; display: block; }
.setting .t > span { color: var(--muted); display: block; max-width: 62ch; }
.setting .acts { display: flex; gap: 8px; flex: none; align-items: center; }

/* ---------- upload ---------- */
.drop {
  display: grid; gap: 4px; justify-items: center; text-align: center;
  padding: 26px 16px; border: 1px dashed #4a4459; color: var(--muted); cursor: pointer;
  transition: border-color .12s, background .12s;
}
.drop:hover, .drop.over { border-color: var(--accent-ink); background: #130f1a; }
.drop b { color: var(--text); font-weight: 600; }
.drop small { color: var(--faint); font-size: 12.5px; }
.drop.has { border-style: solid; border-color: var(--line-2); justify-items: start; text-align: left; padding: 12px 14px; cursor: default; }
.drop.has:hover { background: none; }
.bar { height: 4px; background: var(--line-2); overflow: hidden; }
.bar > i { display: block; height: 100%; width: 0; background: var(--accent-ink); transition: width .15s linear; }
.bar.wait > i { width: 35% !important; animation: slide 1.1s ease-in-out infinite; }
@keyframes slide { from { transform: translateX(-100%); } to { transform: translateX(290%); } }

/* ---------- 30-day activity strip ---------- */
.heat { display: flex; gap: 3px; }
.heat i { flex: 1; aspect-ratio: 1; background: var(--line-2); }
.heat i.l1 { background: #3a1d4b; } .heat i.l2 { background: #5a3170; }
.heat i.l3 { background: #8a54a8; } .heat i.l4 { background: var(--accent-ink); }
.heat-cap { display: flex; justify-content: space-between; color: var(--faint); font-size: 12px; margin-top: 5px; }

/* ---------- dialogs ---------- */
dialog { color: var(--text); font: inherit; }
dialog::backdrop { background: rgba(5, 4, 8, .68); }
.dlg {
  width: min(440px, calc(100vw - 32px)); max-height: calc(100dvh - 48px);
  padding: 0; background: var(--surface); border: 1px solid var(--line-2);
  box-shadow: 0 28px 70px rgba(0, 0, 0, .6); overflow: hidden;
}
.dlg[open] { display: flex; flex-direction: column; animation: rise .14s ease-out; }
.dlg.wide { width: min(540px, calc(100vw - 32px)); }
.dlg > header { padding: 18px 20px 0; font-size: 15.5px; font-weight: 600; }
.dlg > .body { padding: 10px 20px 20px; display: grid; gap: 14px; overflow-y: auto; }
.dlg > .body > p { color: var(--muted); }
.dlg > .body > p b { color: var(--text); font-weight: 600; }
.dlg > footer { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px; border-top: 1px solid var(--line); background: var(--panel); }
.dlg > footer .left { margin-right: auto; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }
.codes {
  background: #0e0d13; border: 1px solid var(--line-2); padding: 12px 14px;
  font: 13px/1.7 var(--mono); white-space: pre-wrap; word-break: break-all;
  max-height: 260px; overflow: auto; user-select: all;
}
.qr { display: block; width: 188px; height: 188px; background: #fff; padding: 8px; justify-self: center; }
.secret { text-align: center; font: 12.5px var(--mono); color: var(--muted); word-break: break-all; }

/* full-size work sheet (Discord editor) */
.sheet {
  width: min(1180px, calc(100vw - 48px)); height: calc(100dvh - 48px); max-height: none;
  padding: 0; background: var(--surface); border: 1px solid var(--line-2);
  box-shadow: 0 28px 70px rgba(0, 0, 0, .6);
}
.sheet[open] { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; animation: rise .14s ease-out; }
.sheet > header { display: flex; align-items: center; gap: 12px; padding: 14px 20px; border-bottom: 1px solid var(--line); font-size: 15.5px; font-weight: 600; }
.sheet > header .btn { margin-left: auto; }
.sheet > .body { display: grid; grid-template-columns: minmax(0, 1fr) 420px; min-height: 0; }
.sheet > .body > * { overflow-y: auto; padding: 18px 20px; }
.sheet > .body > .side-pane { border-left: 1px solid var(--line); background: var(--panel); }
.sheet > footer { display: flex; align-items: center; gap: 10px; padding: 12px 20px; border-top: 1px solid var(--line); background: var(--panel); flex-wrap: wrap; }
.sheet > footer .grow { display: flex; gap: 10px; align-items: center; }
.sheet > footer input, .sheet > footer select { max-width: 280px; }

/* ---------- user drawer ---------- */
.drawer {
  margin: 0 0 0 auto; width: min(660px, 100vw); height: 100dvh; max-height: none; max-width: none;
  padding: 0; background: var(--surface); border: 0; border-left: 1px solid var(--line-2);
  box-shadow: -24px 0 60px rgba(0, 0, 0, .5);
}
.drawer[open] { display: block; animation: slide-in .16s ease-out; }
.drawer-in { display: flex; flex-direction: column; height: 100%; }
@keyframes slide-in { from { transform: translateX(24px); opacity: 0; } }
.drawer-in > header { padding: 20px 24px 14px; display: flex; gap: 12px; align-items: flex-start; }
.drawer-in > header h2 { font-size: 19px; letter-spacing: -.01em; overflow-wrap: anywhere; }
.drawer-in > header .sub { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 5px; color: var(--muted); }
.drawer-in > .acts { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 24px 16px; }
.drawer-in > .acts .push { margin-left: auto; }
.drawer-in > .tabs { padding: 0 13px; flex: none; }
.drawer-in > .pane { flex: 1; overflow-y: auto; padding: 20px 24px 40px; display: grid; gap: 22px; align-content: start; }
.drawer h3 { font-size: 13px; padding-bottom: 7px; border-bottom: 1px solid var(--line-2); }
.drawer .stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin: 12px 0 14px; }
.drawer .stats b { display: block; font: 600 17px var(--ui); font-variant-numeric: tabular-nums; }
.drawer .stats span { color: var(--muted); font-size: 12.5px; }
.danger-line { display: flex; align-items: center; gap: 14px; padding-top: 14px; border-top: 1px solid var(--line); color: var(--muted); }
.danger-line span { flex: 1; }
.x-btn { flex: none; width: 30px; height: 30px; display: grid; place-items: center; background: none; border: 1px solid transparent; color: var(--muted); font-size: 17px; line-height: 1; }
.x-btn:hover { color: var(--text); background: var(--raised); }

/* ---------- command palette ---------- */
.palette {
  margin-top: 13vh; width: min(540px, calc(100vw - 32px)); padding: 0;
  background: var(--surface); border: 1px solid var(--line-2); box-shadow: 0 28px 70px rgba(0, 0, 0, .6);
}
.palette input { height: 48px; border: 0; border-bottom: 1px solid var(--line); background: transparent; padding: 0 16px; font-size: 15px; }
.palette ul { padding: 6px; max-height: 46vh; overflow: auto; }
.palette li { display: flex; align-items: center; gap: 10px; height: 34px; padding: 0 10px; color: var(--muted); cursor: pointer; }
.palette li[aria-selected="true"] { background: var(--accent-deep); color: var(--on-accent); }
.palette li small { margin-left: auto; color: var(--faint); font-size: 12px; }
.palette li[aria-selected="true"] small { color: var(--accent-ink); }

/* ---------- toasts ---------- */
.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 90; display: grid; gap: 8px; width: min(360px, calc(100vw - 40px)); }
.toast {
  display: flex; align-items: center; gap: 10px; padding: 10px 8px 10px 14px;
  background: var(--raised); border: 1px solid var(--line-2); border-left: 2px solid var(--faint);
  box-shadow: 0 12px 32px rgba(0, 0, 0, .5); color: var(--text); font-size: 13.5px; font-weight: 400; animation: rise .14s ease-out;
}
.toast.ok { border-left-color: var(--ok); } .toast.bad { border-left-color: var(--bad); }
.toast span { flex: 1; min-width: 0; overflow-wrap: anywhere; }

/* ---------- auth + download pages ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-box { width: 100%; max-width: 348px; display: grid; gap: 16px; }
.auth-box .brand { padding: 0 0 10px; }
.auth-box h1 { font-size: 21px; letter-spacing: -.012em; }
.auth-box .lead { color: var(--muted); margin-top: -10px; }
.auth-box .code { font: 600 20px var(--mono); letter-spacing: .28em; height: 46px; text-align: center; }
.auth-box .foot { color: var(--faint); font-size: 12.5px; }

/* ---------- Discord hub ---------- */
.kinds { display: grid; gap: 8px; }
.kinds button { display: block; text-align: left; padding: 11px 14px; background: transparent; border: 1px solid var(--line-2); }
.kinds button:hover { border-color: var(--accent-ink); background: #130f1a; }
.kinds b { display: block; font-weight: 600; }
.kinds span { color: var(--muted); font-size: 12.5px; }
.dc-form-row { display: grid; gap: 6px; margin-bottom: 14px; }
.dc-form-row label, #editor-form > label { font-size: 12.5px; color: var(--muted); }
#editor-form > label { display: block; margin: 0 0 6px; }
.dc-form-row .muted { font-size: 12px; color: var(--faint); }
.dc-form-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; align-items: center; }
.dc-repeat-row { display: flex; gap: 8px; align-items: flex-start; margin-bottom: 6px; }
.dc-repeat-row > div { flex: 1; display: grid; gap: 6px; }
.rm { flex: none; height: var(--ctl-h); min-width: var(--ctl-h); padding: 0 9px; background: none; border: 1px solid var(--line-2); color: var(--muted); font-size: 12.5px; }
.rm:hover { color: var(--bad); border-color: var(--bad); }
.dc-add-btn { height: 26px; padding: 0 9px; font-size: 12.5px; margin-bottom: 14px; }
.v2-root, .v2-children { display: grid; gap: 8px; }
.v2-node { border: 1px solid var(--line-2); padding: 10px 12px 12px; background: var(--surface); }
.v2-node .v2-node { background: var(--panel); border-left: 2px solid var(--accent); }
.v2-node-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.v2-node-head b { font-size: 12.5px; font-weight: 600; color: var(--accent-ink); }
.v2-node-head .rm { height: 24px; }
.v2-node-body { display: grid; gap: 8px; }
.v2-add-row { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.v2-add-row .dc-add-btn { margin: 0; }
.v2-accessory { display: grid; gap: 6px; padding-top: 10px; border-top: 1px dashed var(--line-2); }
.v2-accessory label { font-size: 12.5px; color: var(--muted); }
.v2-accessory select { width: auto; justify-self: start; }
/* The preview imitates Discord's own client, so it keeps Discord's colours
   and rounded corners rather than the panel's. */
.dc-preview { background: #313338; border-radius: 4px; padding: 14px; font: 14px "gg sans", "Segoe UI", sans-serif; color: #dbdee1; display: flex; flex-direction: column; gap: 8px; }
.dc-preview .empty { color: #83878e; font-size: 12.5px; padding: 0; }
.dc-preview a { color: #00a8fc; }
.v2p-container { border-left: 4px solid var(--accent); background: #2b2d31; border-radius: 4px; padding: 11px 14px; display: flex; flex-direction: column; gap: 6px; }
.v2p-text { font-size: 13px; line-height: 1.4; white-space: pre-wrap; }
.v2p-text h1, .v2p-text h2, .v2p-text h3 { margin: 0; color: #fff; }
.v2p-text h1 { font-size: 18px; } .v2p-text h2 { font-size: 16px; } .v2p-text h3 { font-size: 14px; }
.v2-subtext { font-size: 11px; color: #b5bac1; }
.v2p-section { display: flex; gap: 10px; align-items: flex-start; }
.v2p-section-text { flex: 1; display: flex; flex-direction: column; gap: 4px; }
.v2p-thumb { width: 64px; height: 64px; object-fit: cover; border-radius: 4px; flex: none; }
.v2p-gallery { display: flex; flex-wrap: wrap; gap: 6px; }
.v2p-gallery img { max-width: 140px; max-height: 100px; border-radius: 4px; object-fit: cover; }
.v2p-separator { height: 1px; background: #3f4147; margin: 4px 0; }
.v2p-separator.no-line { background: transparent; }
.v2p-separator.large { margin: 10px 0; }
.v2p-buttons { display: flex; gap: 6px; flex-wrap: wrap; }
.v2p-linkbtn { display: inline-block; padding: 6px 10px; background: #4e5058; border-radius: 4px; font-size: 13px; color: #fff !important; }
.v2p-unknown { font-size: 12px; color: #83878e; }
.pane-label { font-size: 12.5px; color: var(--faint); margin-bottom: 10px; }

/* ---------- responsive ---------- */
@media (max-width: 1080px) {
  .page { padding: 26px 26px 64px; }
  .cols, .cols.even { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; left: 0; top: 0; width: 248px; z-index: 30; transform: translateX(-100%); transition: transform .18s ease; }
  body.nav-open .side { transform: none; box-shadow: 24px 0 60px rgba(0, 0, 0, .6); }
  body.nav-open::after { content: ""; position: fixed; inset: 0; background: rgba(5, 4, 8, .6); z-index: 29; }
  .mobile-bar { display: flex; align-items: center; gap: 12px; height: 48px; padding: 0 14px; border-bottom: 1px solid var(--line); background: var(--panel); position: sticky; top: 0; z-index: 20; font-weight: 600; }
  .mobile-bar .x-btn { border-color: var(--line-2); font-size: 14px; }
  .mobile-bar .brand { padding: 0; }
  .page-actions { margin-left: 0; width: 100%; }
  .page-actions .search { flex: 1; width: auto; min-width: 0; }
  .slot[data-ch]::before { content: attr(data-ch); display: block; color: var(--faint); font-size: 12.5px; margin-bottom: 4px; }
  .bulk { top: 48px; }
  .page { padding: 20px 16px 56px; }
  .figs { grid-template-columns: 1fr 1fr; }
  .fig { padding: 12px 12px 12px 0; }
  .fig:nth-child(3) { padding-left: 0; border-left: 0; }
  .fig:nth-child(n+3) { border-top: 1px solid var(--line); }
  .pipe, .pipe.compact { grid-template-columns: 1fr; }
  .pipe .colh { display: none; }
  .pipe .kind { border-bottom: 0; padding-bottom: 0; }
  .pipe .wide { grid-column: auto; }
  .pipe .mid { flex-direction: row; padding: 8px 0; }
  .setting { flex-wrap: wrap; }
  .sheet { width: 100vw; height: 100dvh; border: 0; }
  .sheet > .body { grid-template-columns: 1fr; overflow-y: auto; }
  .sheet > .body > * { overflow: visible; }
  .sheet > .body > .side-pane { border-left: 0; border-top: 1px solid var(--line); }
  .field-row { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  /* tables collapse to one labelled block per row */
  .tbl.stackable, .tbl.stackable tbody, .tbl.stackable tr, .tbl.stackable td { display: block; width: 100%; }
  .tbl.stackable thead { display: none; }
  .tbl.stackable tr { padding: 8px 0; border-bottom: 1px solid var(--line-2); position: relative; }
  .tbl.stackable td { border: 0; padding: 3px 0 3px 104px; min-height: 26px; position: relative; }
  .tbl.stackable td::before { content: attr(data-label); position: absolute; left: 0; color: var(--faint); font-size: 12.5px; }
  .tbl.stackable td.c-check, .tbl.stackable td:has(> .faint:only-child) { display: none; }
  .tbl.stackable td:nth-child(2) { padding-left: 0; font-size: 14px; }
  .tbl.stackable td:nth-child(2)::before { content: none; }
  .tbl.stackable td.r { text-align: left; }
  .drawer-in > header, .drawer-in > .acts { padding-left: 16px; padding-right: 16px; }
  .drawer-in > .pane { padding: 16px 16px 40px; }
  .drawer .stats { grid-template-columns: 1fr 1fr; }
  .kv { grid-template-columns: 1fr; }
  .kv dt { border-bottom: 0; padding-bottom: 0; font-size: 12.5px; }
  .kv dd { padding-top: 1px; }
  .feed .ev { grid-template-columns: 48px 7px minmax(0, 1fr); gap: 9px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001s !important; transition-duration: .001s !important; }
}
