@font-face { font-family: Jakarta; src: url(fonts/jakarta-400.woff2) format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: Jakarta; src: url(fonts/jakarta-600.woff2) format("woff2"); font-weight: 600; font-display: swap; }
@font-face { font-family: Jakarta; src: url(fonts/jakarta-800.woff2) format("woff2"); font-weight: 800; font-display: swap; }

:root {
  --night0: #030a17; --night1: #091427; --night2: #0f1e37; --night3: #1a2b4a; --night4: #253a60;
  --paper: #eaf1fb; --ink: #c3cfe4; --muted: #93a1be; --faint: #6b7a98;
  --signal: #0362ff; --cyan: #05d5ff; --mint: #02e89d; --coral: #ff5d6c; --amber: #ffb547;
  --aurora: linear-gradient(135deg, #0340e6, #0473f5 55%, #03a9d6);
  --brand: linear-gradient(120deg, #0473f5, #02d9fa 50%, #08f7ce);
  --line: rgb(255 255 255 / .07); --line2: rgb(255 255 255 / .12);
  --panel: rgb(15 30 55 / .55); --raised: #0d1a30;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  /* One spacing scale and one control height for every page, so nothing
     sits flush against its neighbour and a row of controls lines up.
     relay_console_layout_test.dart holds the stylesheet to them. */
  --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px; --space-5: 24px; --space-6: 32px;
  --control-h: 40px; --control-h-sm: 32px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--night0); color: var(--paper); font: 400 15px/1.55 Jakarta, system-ui, -apple-system, "Segoe UI", sans-serif; -webkit-font-smoothing: antialiased; }
a { color: var(--cyan); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { letter-spacing: -0.02em; line-height: 1.15; margin: 0; }
h1 { font-size: 26px; font-weight: 800; }
h2 { font-size: 17px; font-weight: 700; }
h3 { font-size: 15px; font-weight: 600; }
p { margin: 6px 0 12px; }
b, strong { font-weight: 600; color: var(--paper); }
code { font: 12.5px/1.4 var(--mono); background: var(--night1); border: 1px solid var(--line); padding: 1px 6px; border-radius: 6px; color: var(--cyan); overflow-wrap: anywhere; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 13px; }
.mono { font-family: var(--mono); font-size: 12.5px; overflow-wrap: anywhere; }
.ico { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; vertical-align: -3px; }
:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; border-radius: 8px; }
[hidden] { display: none !important; }

/* ---------- Controls ---------- */
textarea, input, select {
  font: inherit; color: var(--paper); background: var(--night1); border: 1px solid var(--night3);
  border-radius: 10px; padding: 9px 12px; max-width: 100%; transition: border-color .15s, box-shadow .15s;
}
input:not([type=checkbox]), select { height: var(--control-h); padding-top: 0; padding-bottom: 0; }
textarea:focus, input:focus, select:focus { outline: none; border-color: var(--signal); box-shadow: 0 0 0 3px rgb(3 98 255 / .25); }
textarea { width: 100%; resize: vertical; }
input, select { width: 100%; }
input::placeholder, textarea::placeholder { color: var(--faint); }
input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--signal); padding: 0; }
select { padding-right: 30px; }
textarea:disabled, input:disabled, select:disabled { opacity: .55; }
.code { font: 12px/1.5 var(--mono); color: var(--ink); word-break: break-all; }

button, .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: 600 14px/1 Jakarta, system-ui, sans-serif; color: var(--paper); cursor: pointer;
  background: rgb(255 255 255 / .04); border: 1px solid var(--night3); border-radius: 999px;
  height: var(--control-h); padding: 0 18px; transition: background .15s, border-color .15s, box-shadow .15s, opacity .15s; white-space: nowrap;
}
button:hover, .btn:hover { border-color: var(--night4); background: rgb(255 255 255 / .07); text-decoration: none; }
button.primary, .btn.primary { background: var(--signal); border-color: var(--signal); color: #fff; }
button.primary:hover, .btn.primary:hover { background: #1a72ff; border-color: #1a72ff; }
button.danger { color: var(--coral); }
button.danger:hover { border-color: rgb(255 93 108 / .5); background: rgb(255 93 108 / .08); }
button.danger.solid { background: var(--coral); color: #2a0509; border-color: transparent; }
button.ghost { background: none; border-color: transparent; color: var(--ink); }
button.ghost:hover { background: rgb(255 255 255 / .05); }
button.small, .btn.small { height: var(--control-h-sm); padding: 0 13px; font-size: 13px; }
button.icon { width: var(--control-h); padding: 0; border-radius: 10px; }
button.icon.small { width: var(--control-h-sm); }
button.wide { width: 100%; height: 48px; font-size: 15px; }
button.link { height: auto; background: none; border: 0; padding: 0; color: var(--cyan); font-weight: 600; }
button:disabled { opacity: .45; cursor: default; }
button svg, .btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
button.busy { position: relative; color: transparent !important; }
button.busy::after { content: ""; position: absolute; width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--paper); border-right-color: transparent; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.row { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; }
.row.end { justify-content: flex-end; }
.row.between { justify-content: space-between; }
.stack { display: grid; gap: var(--space-4); }
.grow { flex: 1 1 220px; min-width: 0; }
.label { display: block; font-size: 11.5px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }

/* Field: a label, its control and a line of help. */
.field { display: grid; gap: var(--space-2); align-content: start; }
.field > .field-label { font-size: 13px; font-weight: 600; color: var(--ink); }
.field > .row > .field-label { font-size: 13px; font-weight: 600; color: var(--ink); }
.field > .field-help { font-size: 12.5px; color: var(--muted); }
.field > .seg-box, .field > .chips, .field > .switch { justify-self: start; }
.settings-table { table-layout: fixed; }
.settings-table td.setting-input { width: 36%; }
.settings-table td.actions { width: 168px; padding-left: 0; }
.settings-table.readonly td.setting-input { width: 40%; }
.settings-table td.actions .fixed-note { white-space: normal; }
.unit-field { display: flex; gap: var(--space-2); }
.unit-field .unit-n { width: 7.5em; flex: none; }
.unit-field select { flex: 1; min-width: 0; }
.fields { display: grid; gap: var(--space-4); grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); align-items: start; }
.price-dialog { display: grid; gap: var(--space-4); }
.price-grid { display: grid; gap: var(--space-3); grid-template-columns: repeat(2, minmax(0, 1fr)); }
/* A value that can only be read here, in place of a control. */
.readonly-value { display: flex; align-items: center; gap: var(--space-2); min-height: var(--control-h); padding: 0 13px; color: var(--paper); overflow-wrap: anywhere; }
.readonly-value.empty { color: var(--faint); }

/* Switch: a checkbox drawn as a toggle. */
.switch { display: flex; align-items: flex-start; gap: 12px; cursor: pointer; padding: 4px 0; }
.switch input { appearance: none; -webkit-appearance: none; flex: none; width: 38px; height: 22px; border-radius: 999px; background: var(--night3); border: 1px solid var(--night4); position: relative; cursor: pointer; transition: background .15s; margin: 1px 0 0; padding: 0; }
.switch input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: var(--paper); transition: transform .15s; }
.switch input:checked { background: var(--signal); border-color: var(--signal); }
.switch input:checked::after { transform: translateX(16px); }
.switch input:disabled { opacity: .5; cursor: default; }
.switch .switch-text { display: grid; gap: 1px; }
.switch .switch-text b { font-size: 14px; }
.switch .switch-text span { font-size: 12.5px; color: var(--muted); }

/* Chips: pick several. */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 7px; height: var(--control-h-sm); padding: 0 12px; border-radius: 999px; font-size: 13px; font-weight: 600; color: var(--ink); background: var(--night1); border: 1px solid var(--night3); }
.chip:hover { border-color: var(--night4); background: var(--night2); }
.chip[aria-pressed=true] { color: var(--paper); background: rgb(3 98 255 / .18); border-color: rgb(5 213 255 / .45); }
.chip[aria-pressed=true]::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--cyan); }
.chip:disabled { opacity: .4; }

/* Option list: switches in columns, for longer choices. */
.options { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 4px 22px; }
.option-group { grid-column: 1 / -1; font-size: 11px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--faint); margin: 10px 0 2px; }
.option-group:first-child { margin-top: 0; }

/* Segmented control. */
.seg-box { display: inline-grid; max-width: 100%; min-width: 0; }
.seg-box > * { grid-area: 1 / 1; min-width: 0; }
.seg-box > .seg-pick { display: none; }
.seg-box.tight > .seg { visibility: hidden; }
.seg-box.tight > .seg-pick { display: block; width: 100%; }
.seg { display: inline-flex; align-items: stretch; height: var(--control-h); padding: 3px; gap: 2px; background: var(--night1); border: 1px solid var(--night3); border-radius: 999px; max-width: 100%; overflow: hidden; }
.seg button { white-space: nowrap; }
.seg button { height: auto; border: 0; background: none; padding: 0 14px; font-size: 13px; color: var(--muted); border-radius: 999px; }
.seg button:hover { background: rgb(255 255 255 / .05); color: var(--paper); }
.seg button[aria-pressed=true] { background: var(--night3); color: var(--paper); box-shadow: 0 1px 0 rgb(255 255 255 / .06) inset; }
.seg .n { font-size: 11px; color: var(--faint); margin-left: 2px; }

/* Tags. */
.tag { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 600; background: var(--night2); border: 1px solid var(--line); color: var(--ink); border-radius: 999px; padding: 2px 9px; white-space: nowrap; vertical-align: 1px; }
.tag.good { color: var(--mint); background: rgb(2 232 157 / .1); border-color: rgb(2 232 157 / .25); }
.tag.bad { color: var(--coral); background: rgb(255 93 108 / .1); border-color: rgb(255 93 108 / .25); }
.tag.warn { color: var(--amber); background: rgb(255 181 71 / .1); border-color: rgb(255 181 71 / .25); }
.tag.info { color: var(--cyan); background: rgb(5 213 255 / .08); border-color: rgb(5 213 255 / .22); }
.tags { display: inline-flex; flex-wrap: wrap; gap: 5px; vertical-align: middle; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--mint); box-shadow: 0 0 0 0 rgb(2 232 157 / .6); animation: ping 2.4s infinite; flex: none; display: inline-block; }
.dot.warn { background: var(--amber); animation: none; }
.dot.bad { background: var(--coral); animation: none; }
.dot.off { background: var(--faint); animation: none; }
@keyframes ping { 0% { box-shadow: 0 0 0 0 rgb(2 232 157 / .55); } 70%, 100% { box-shadow: 0 0 0 8px rgb(2 232 157 / 0); } }

/* People: an avatar coloured by account, a name and a short id. */
.avatar { width: 34px; height: 34px; border-radius: 50%; display: inline-grid; place-items: center; flex: none; font-weight: 700; font-size: 13px; color: #04122b; position: relative; }
.avatar.sm { width: 26px; height: 26px; font-size: 11px; }
.avatar.lg { width: 52px; height: 52px; font-size: 18px; }
.person { display: flex; gap: 11px; align-items: center; min-width: 0; }
.person .who { min-width: 0; display: grid; gap: 1px; }
.person .who .name { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; font-weight: 600; color: var(--paper); }
.person .who .sub { font-size: 12.5px; color: var(--muted); }
.idchip { font: 600 11.5px/1 var(--mono); color: var(--muted); background: var(--night1); border: 1px solid var(--line2); border-radius: 6px; padding: 3px 6px; cursor: copy; white-space: nowrap; }
.idchip:hover { color: var(--paper); border-color: var(--night4); }
.idchip.same { color: var(--amber); border-color: rgb(255 181 71 / .35); }

.qr { width: 220px; max-width: 100%; background: #fff; border-radius: 16px; padding: 10px; box-shadow: 0 20px 50px -20px rgb(5 213 255 / .45); }
.qr svg { display: block; width: 100%; height: auto; }

/* ---------- Cards ---------- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 18px; margin: 0 0 var(--space-5); }
.card-head { display: flex; align-items: flex-start; gap: 14px; padding: 18px 22px 0; }
.card-head .titles { flex: 1; min-width: 0; }
.card-head .titles p { margin: 4px 0 0; color: var(--muted); font-size: 13.5px; }
.card-body { padding: 16px 22px 20px; }
.card-body.flush { padding: 12px 0 0; }
.card-foot { display: flex; justify-content: flex-end; gap: var(--space-2); flex-wrap: wrap; padding: 0 22px 20px; }
.card-head + .card-foot { padding-top: var(--space-4); }
.card.danger-zone { border-color: rgb(255 93 108 / .25); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: separate; border-spacing: 0; }
.card > .table-wrap, .card-body.flush > .table-wrap { border-top: 1px solid var(--line); }
.table-card { background: var(--panel); border: 1px solid var(--line); border-radius: 18px; overflow: hidden; margin: 0 0 var(--space-5); }
th, td { text-align: left; padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child > td { border-bottom: 0; }
th { font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); background: rgb(255 255 255 / .02); white-space: nowrap; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.actions { text-align: right; white-space: nowrap; }
td.actions .row { justify-content: flex-end; flex-wrap: nowrap; }
td.clip { max-width: 0; width: 45%; }
td.clip .clip-text { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
tbody tr { transition: background .1s; }
tbody tr.go { cursor: pointer; }
tbody tr.go:hover td { background: rgb(255 255 255 / .03); }
tbody tr.go td:last-child::after { content: "›"; color: var(--faint); margin-left: 10px; font-size: 18px; }
tbody tr.on td { background: rgb(3 98 255 / .08); }
pre { white-space: pre-wrap; word-break: break-word; font: 12px/1.6 var(--mono); color: var(--ink); background: var(--night0); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; max-height: 480px; overflow: auto; margin: 0; }
ul { padding-left: 20px; }

/* Empty states. */
.empty-state { display: grid; justify-items: center; text-align: center; gap: 6px; padding: 38px 24px; color: var(--muted); }
.empty-state .empty-icon { width: 54px; height: 54px; border-radius: 16px; display: grid; place-items: center; background: rgb(3 98 255 / .12); border: 1px solid rgb(5 213 255 / .18); margin-bottom: 8px; }
.empty-state .empty-icon svg { width: 24px; height: 24px; fill: none; stroke: var(--cyan); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.empty-state h3 { color: var(--paper); font-size: 15.5px; }
.empty-state p { margin: 0 0 8px; max-width: 420px; font-size: 13.5px; }
.empty-state.good .empty-icon { background: rgb(2 232 157 / .1); border-color: rgb(2 232 157 / .25); }
.empty-state.good .empty-icon svg { stroke: var(--mint); }
.empty-state .empty-art { width: 240px; max-width: 100%; height: auto; margin-bottom: var(--space-2); }

/* Key-value details. */
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 10px 22px; margin: 0; }
.kv dt { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.kv dd { margin: 0; min-width: 0; word-break: break-word; }

/* Toolbar above a list. */
.toolbar { display: flex; flex-wrap: wrap; gap: var(--space-3); align-items: center; margin: 0 0 var(--space-5); }
.toolbar button.small { height: var(--control-h); }
.toolbar .search { flex: 1 1 240px; position: relative; }
.toolbar .search input { padding-left: 36px; }
.toolbar .search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; fill: none; stroke: var(--faint); stroke-width: 2; stroke-linecap: round; }
.toolbar select { width: auto; }

/* ---------- Stat tiles ---------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; margin-bottom: 18px; }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 18px 20px; position: relative; overflow: hidden; }
.tile .big { font-size: 26px; font-weight: 800; letter-spacing: -0.02em; margin: 4px 0 2px; }
.tile .sub { font-size: 13px; color: var(--muted); }
.warn-text { color: var(--amber); font-weight: 600; }
button.tile { height: auto; display: block; text-align: left; font: inherit; color: inherit; border-radius: 18px; white-space: normal; padding: 18px 20px; }
button.tile:hover { border-color: var(--night4); background: rgb(15 30 55 / .8); }
.meter { height: 6px; background: var(--night1); border-radius: 3px; overflow: hidden; margin-top: 12px; }
.meter > span { display: block; height: 100%; width: 0; background: var(--brand); border-radius: 3px; transition: width .6s ease; }
.meter.warn > span { background: linear-gradient(90deg, #ffb547, #ff5d6c); }

/* ---------- Progress steps ---------- */
.steps-v { list-style: none; margin: 4px 0 0; padding: 0; display: grid; gap: 0; }
.steps-v li { display: grid; grid-template-columns: 28px 1fr; gap: 12px; padding: 0 0 18px; position: relative; color: var(--faint); }
.steps-v li::before { content: ""; position: absolute; left: 13px; top: 28px; bottom: 2px; width: 2px; background: var(--night3); }
.steps-v li:last-child::before { display: none; }
.steps-v .mark { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; border: 2px solid var(--night3); background: var(--night1); font-size: 12px; font-weight: 700; }
.steps-v .mark svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.steps-v b { display: block; color: inherit; font-weight: 600; padding-top: 3px; }
.steps-v span.when { font-size: 12.5px; color: var(--muted); }
.steps-v li.done { color: var(--ink); }
.steps-v li.done .mark { background: var(--mint); border-color: var(--mint); color: #04122b; }
.steps-v li.done::before { background: rgb(2 232 157 / .5); }
.steps-v li.now { color: var(--paper); }
.steps-v li.now .mark { position: relative; border-color: transparent; }
/* Only the ring spins; the step number stays upright. */
.steps-v li.now .mark::after { content: ""; position: absolute; inset: -2px; border-radius: 50%; border: 2px solid var(--cyan); border-right-color: transparent; animation: spin .9s linear infinite; }
.steps-v li.failed { color: var(--coral); }
.steps-v li.failed .mark { background: var(--coral); border-color: var(--coral); color: #2a0509; }
/* Alert: a notice with an icon, toned by what it says. */
.alert { display: flex; align-items: flex-start; gap: var(--space-3); border-radius: 14px; padding: 14px 16px; background: rgb(5 213 255 / .06); border: 1px solid rgb(5 213 255 / .22); color: var(--ink); margin: 0 0 var(--space-5); }
.alert > .ico { width: 18px; height: 18px; margin-top: 2px; color: var(--cyan); }
.alert .alert-text { display: grid; gap: var(--space-1); min-width: 0; }
.alert .alert-text b { color: var(--paper); }
.alert.good { background: rgb(2 232 157 / .06); border-color: rgb(2 232 157 / .3); }
.alert.good > .ico { color: var(--mint); }
.alert.warn { background: rgb(255 181 71 / .07); border-color: rgb(255 181 71 / .3); }
.alert.warn > .ico { color: var(--amber); }
.alert.bad { background: rgb(255 93 108 / .06); border-color: rgb(255 93 108 / .3); }
.alert.bad > .ico { color: var(--coral); }

/* ---------- Drawer and dialog ---------- */
.scrim { position: fixed; inset: 0; background: rgb(1 5 12 / .62); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); z-index: 40; opacity: 0; transition: opacity .18s; }
.scrim.show { opacity: 1; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(640px, 100vw); background: var(--raised); border-left: 1px solid var(--line2); z-index: 41; display: flex; flex-direction: column; transform: translateX(30px); opacity: 0; transition: transform .2s ease, opacity .2s; box-shadow: -30px 0 80px -30px rgb(0 0 0 / .8); }
.drawer.show { transform: none; opacity: 1; }
.drawer-head { display: flex; align-items: flex-start; gap: 12px; padding: 20px 22px 16px; border-bottom: 1px solid var(--line); }
.drawer-head .titles { flex: 1; min-width: 0; }
.drawer-head h2 { font-size: 19px; word-break: break-word; }
.drawer-head p { margin: 4px 0 0; color: var(--muted); font-size: 13.5px; }
.drawer-body { flex: 1; overflow-y: auto; padding: 20px 22px 28px; display: grid; gap: 22px; align-content: start; }
.drawer-body section h3 { margin: 0 0 10px; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.drawer-foot { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; padding: 14px 22px; border-top: 1px solid var(--line); }
.drawer-foot .left { margin-right: auto; }
.dialog { position: fixed; z-index: 42; left: 50%; top: 50%; width: min(460px, calc(100vw - 32px)); max-height: calc(100vh - 40px); overflow: auto; transform: translate(-50%, -46%); opacity: 0; transition: transform .18s, opacity .18s; background: var(--raised); border: 1px solid var(--line2); border-radius: 20px; padding: 24px; box-shadow: 0 40px 100px -30px rgb(0 0 0 / .9); }
.shot { height: auto; position: relative; display: block; width: 100%; max-width: 360px; margin: 0 auto; border-radius: 14px; overflow: hidden; border: 1px solid var(--line2); background: var(--night0); cursor: zoom-in; padding: 0; }
.shot img { display: block; width: 100%; height: auto; }
.shot svg, .lightbox svg { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.shot .shot-chip { position: absolute; right: 8px; bottom: 8px; display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 999px; background: rgb(1 5 12 / .72); color: #fff; font-size: 12px; font-weight: 600; }
.shot .shot-chip .ico { width: 14px; height: 14px; }
.lightbox { position: fixed; inset: 0; z-index: 44; display: grid; place-items: center; background: rgb(1 5 12 / .9); padding: 56px 16px 16px; }
.lightbox .frame { position: relative; max-width: 100%; max-height: 100%; }
.lightbox img { display: block; max-width: calc(100vw - 32px); max-height: calc(100vh - 72px); width: auto; height: auto; border-radius: 12px; }
.lightbox .bar { position: fixed; top: 12px; right: 16px; left: 16px; display: flex; gap: 8px; justify-content: flex-end; }
.report-text { white-space: pre-wrap; word-break: break-word; font-size: 15px; line-height: 1.55; margin: 0; }
pre .j-key { color: #7cc4ff; }
pre .j-str { color: #8be3a6; }
pre .j-num { color: #ffc46b; }
pre .j-lit { color: #ff8fb1; }
pre .j-time { color: var(--muted); }
pre .j-head { color: var(--ink); font-weight: 700; }
.dialog.wide { width: min(560px, calc(100vw - 32px)); }
.dialog.show { transform: translate(-50%, -50%); opacity: 1; }
.dialog h2 { font-size: 19px; margin-bottom: 8px; }
.dialog .body { color: var(--ink); margin-bottom: 20px; }
.dialog .body img.made { display: block; max-width: 100%; height: auto; border-radius: 12px; }
.dialog .row.end { margin-top: 18px; }

/* ---------- Emoji picker ---------- */
.emoji-field { display: flex; align-items: center; gap: 10px; }
.emoji-button { width: 54px; height: 54px; border-radius: 14px; font-size: 28px; padding: 0; line-height: 1; }
.popover { position: fixed; z-index: 45; width: 340px; max-width: calc(100vw - 24px); background: var(--raised); border: 1px solid var(--line2); border-radius: 16px; box-shadow: 0 30px 80px -20px rgb(0 0 0 / .85); padding: 12px; display: grid; gap: 10px; }
.emoji-tabs { display: flex; gap: 2px; overflow-x: auto; }
.emoji-tabs button { height: auto; padding: 6px 8px; font-size: 17px; border: 0; background: none; border-radius: 8px; }
.emoji-tabs button[aria-pressed=true] { background: var(--night3); }
.emoji-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px; max-height: 236px; overflow-y: auto; }
.emoji-grid button { padding: 0; height: 36px; font-size: 22px; border: 0; background: none; border-radius: 8px; }
.emoji-grid button:hover, .emoji-grid button:focus-visible { background: var(--night3); }
.emoji-grid .none { grid-column: 1 / -1; text-align: center; color: var(--muted); padding: 22px 0; font-size: 13px; }

/* ---------- Picture and colour ---------- */
.look { display: grid; grid-template-columns: auto 1fr; gap: 26px; align-items: start; }
.badge-preview { width: 112px; height: 112px; border-radius: 30px; display: grid; place-items: center; font-size: 56px; overflow: hidden; border: 1px solid var(--line2); box-shadow: 0 24px 60px -24px rgb(5 213 255 / .45); }
.badge-preview img { width: 100%; height: 100%; object-fit: cover; }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.swatch { width: 30px; height: 30px; min-height: 0; border-radius: 50%; padding: 0; border: 2px solid transparent; box-shadow: inset 0 0 0 1px rgb(255 255 255 / .15); }
.swatch[aria-pressed=true] { border-color: var(--paper); }
.swatch-custom { position: relative; width: 30px; height: 30px; padding: 0; border-radius: 50%; overflow: hidden; background: conic-gradient(#ff5d6c, #f2b51d, #3fae4a, #05a3d6, #3d5afe, #9a5cff, #ff5d6c); }
.swatch-custom input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; padding: 0; border: 0; opacity: 0; cursor: pointer; }
.dropzone { border: 1.5px dashed var(--night4); border-radius: 14px; padding: 18px; display: flex; gap: 14px; align-items: center; cursor: pointer; transition: border-color .15s, background .15s; }
.dropzone:hover, .dropzone.over { border-color: var(--cyan); background: rgb(5 213 255 / .05); }
.dropzone .dz-icon { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--night2); flex: none; }

/* ---------- Programs ---------- */
textarea.bad, input.bad { border-color: var(--coral); }
textarea.script { font: 12.5px/1.55 var(--mono); color: var(--ink); white-space: pre; overflow-wrap: normal; overflow-x: auto; tab-size: 2; min-height: 240px; }
.test-run { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--night1); }
.test-run .top { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-bottom: 1px solid var(--line); font-size: 12.5px; }
.test-run .code { font: 600 12px var(--mono); padding: 2px 8px; border-radius: 99px; background: rgb(255 93 108 / .14); color: var(--coral); }
.test-run .code.ok { background: rgb(2 232 157 / .14); color: var(--mint); }
.test-run pre { margin: 0; padding: 10px 12px; font: 12.5px/1.55 var(--mono); white-space: pre-wrap; word-break: break-word; color: var(--paper); max-height: 260px; overflow: auto; }
.test-run pre.empty { color: var(--faint); }
.test-run pre.err { color: var(--amber); border-top: 1px solid var(--line); }
.stack.tight { gap: var(--space-2); }
.fold > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 10px; user-select: none; }
.fold > summary::-webkit-details-marker { display: none; }
.fold > summary > .ico { width: 18px; height: 18px; color: var(--muted); flex: none; transition: transform .15s; }
.fold:not([open]) > summary > .ico { transform: rotate(-90deg); }
.fold.card:not([open]) > .card-head { padding-bottom: 18px; }
.fold.plain > summary { justify-content: space-between; font-size: 13px; font-weight: 600; color: var(--ink); }
.fold.plain[open] > summary { margin-bottom: var(--space-2); }
.switch.small { padding: 0; align-items: center; gap: 8px; }
.switch.small .switch-text b { font-size: 12.5px; font-weight: 500; color: var(--muted); }
.call-list[hidden], .row[hidden] { display: none; }
.call-list { display: grid; gap: 6px; }
.call-list:empty { display: none; }
.call-row { display: grid; grid-template-columns: 14px 112px 72px minmax(0, 1fr) 116px minmax(0, .7fr) auto; gap: 6px; align-items: center; background: var(--night1); border: 1px solid var(--night3); border-radius: 10px; padding: 6px; }
.call-row.word .name { grid-column: 3 / 7; }
.call-row.group { background: var(--panel); }
.call-row.group .fill { grid-column: 3 / 7; }
.call-row.group > .call-list, .call-row.group > .inner-adds { grid-column: 1 / -1; }
.call-list.inner .call-row { background: var(--night1); }
.call-row.dragging { opacity: .4; }
.call-row.over { border-color: var(--cyan); }
.call-row .grip { color: var(--faint); cursor: grab; text-align: center; user-select: none; letter-spacing: -2px; }
.call-row input, .call-row select { height: var(--control-h-sm); font-size: 13px; padding-left: 8px; }
.call-row select { padding-right: 22px; }
.call-row .acts { display: flex; gap: 2px; grid-column: -2; }
.call-row .acts button { width: 26px; height: 26px; padding: 0; }
.call-try { display: grid; gap: 0; }
.call-try > input { border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
.call-try > .call-preview { border-top: 0; border-top-left-radius: 0; border-top-right-radius: 0; }
.call-preview { font: 12.5px/1.5 var(--mono); background: var(--night0); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.call-preview .prog { color: var(--muted); }
.call-preview .w { padding: 2px 8px; border-radius: 6px; background: var(--night2); color: var(--paper); display: inline-flex; gap: 6px; align-items: baseline; }
.call-preview .w.arg { background: rgb(5 213 255 / .12); color: var(--cyan); cursor: help; }
.call-preview .w.arg.opt { background: transparent; outline: 1px dashed rgb(5 213 255 / .45); }
.call-preview .w.gone { opacity: .35; text-decoration: line-through; }
.call-preview .more { color: var(--faint); }
.call-preview .group { display: inline-flex; gap: 4px; padding: 2px; border-radius: 8px; border: 1px solid rgb(5 213 255 / .3); }
.call-preview .group.opt { border-style: dashed; }
.call-preview .group.gone { opacity: .35; text-decoration: line-through; }
@media (max-width: 560px) {
  .call-row { grid-template-columns: 14px 1fr 1fr auto; }
  .call-row .kind { grid-column: 2 / 4; grid-row: 1; }
  .call-row .grip { grid-row: 1; }
  .call-row .acts { grid-column: 4; grid-row: 1; }
  .call-row .prefix { grid-column: 2 / 3; }
  .call-row .name { grid-column: 3 / 5; }
  .call-row.word .name, .call-row .mode, .call-row .fallback { grid-column: 2 / 5; }
  .call-row span.fallback, .call-row.group .fill { display: none; }
  .call-row.group > .call-list, .call-row.group > .inner-adds { grid-column: 1 / -1; }
}
.caution { display: flex; gap: 10px; align-items: flex-start; font-size: 13px; color: var(--muted); margin: 0; }
.caution .ico { color: var(--amber); margin-top: 2px; }
.problem { color: var(--coral); }
.secret { display: flex; gap: var(--space-2); align-items: center; background: var(--night0); border: 1px solid rgb(5 213 255 / .3); border-radius: 12px; padding: var(--space-2) var(--space-2) var(--space-2) var(--space-3); }
.secret code { flex: 1; min-width: 0; background: none; border: 0; padding: 0; overflow-wrap: anywhere; }
.scope-group { display: grid; gap: var(--space-2); }
.scope-group .option-group { margin: 0; }
.tag.mono { font-family: var(--mono); font-size: 11px; }
.api-address { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-1) var(--space-2); }
.api-address code { flex: 1 1 14em; min-width: 0; padding: 6px 10px; }
.api-address a { font-size: 13px; }
.more-perms > summary { cursor: pointer; color: var(--muted); font-size: 13px; padding: var(--space-1) 0; }
.more-perms[open] > summary { margin-bottom: var(--space-2); }
.access-table td, .access-table th { padding: 8px 12px; }
.access-table .pick { width: 36px; padding-right: 0; }
.access-table input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--signal); cursor: pointer; }
.access-table input[type=checkbox]:disabled { cursor: default; }
.access-table tr.muted td { opacity: .55; }
.access-table tr.area td { font-size: 11px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--faint); padding-top: 14px; }
.access-table td.via .tag + .tag { margin-left: 4px; }
.access-table .nowrap { white-space: nowrap; }
.picked { display: flex; gap: 10px; align-items: center; font-size: 13.5px; }
.dropzone .dz-icon svg { width: 20px; height: 20px; fill: none; stroke: var(--cyan); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.dropzone input { display: none; }

/* ---------- Log viewer ---------- */
.log { background: var(--night0); border: 1px solid var(--line); border-radius: 14px; font: 12.5px/1.55 var(--mono); max-height: 62vh; overflow: auto; }
.log .line { display: grid; grid-template-columns: 150px 64px 1fr; gap: 12px; padding: 5px 14px; border-bottom: 1px solid rgb(255 255 255 / .03); }
.log .line:hover { background: rgb(255 255 255 / .025); }
.log .line .t { color: var(--faint); white-space: nowrap; }
.log .line .k { font-weight: 600; color: var(--muted); text-transform: uppercase; font-size: 10.5px; padding-top: 2px; }
.log .line .x { color: var(--ink); white-space: pre-wrap; word-break: break-word; }
.log .line.warn .k, .log .line.warn .x { color: var(--amber); }
.log .line.error { background: rgb(255 93 108 / .05); }
.log .line.error .k, .log .line.error .x { color: var(--coral); }
.log .line.fresh { animation: fresh 1.6s ease-out; }
@keyframes fresh { from { background: rgb(5 213 255 / .14); } }
.log .none { padding: 30px; text-align: center; color: var(--muted); font-family: Jakarta, system-ui, sans-serif; }
.live { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; color: var(--muted); }
.live.on { color: var(--mint); }

/* ---------- Toast and boot ---------- */
#toast { position: fixed; bottom: 24px; left: 50%; transform: translate(-50%, 12px); background: var(--night2); border: 1px solid var(--line2); color: var(--paper); padding: 12px 18px; border-radius: 14px; box-shadow: 0 20px 50px -10px rgb(0 0 0 / .6); opacity: 0; transition: opacity .2s, transform .2s; pointer-events: none; max-width: min(520px, 90vw); z-index: 60; font-weight: 600; font-size: 14px; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.bad { border-color: rgb(255 93 108 / .45); }
.boot { min-height: 100vh; display: grid; place-items: center; }
.boot img { animation: breathe 1.6s ease-in-out infinite; }
@keyframes breathe { 50% { opacity: .5; transform: scale(.94); } }
.loading { display: grid; place-items: center; padding: 80px 0; }
.loading img { animation: breathe 1.6s ease-in-out infinite; }

/* ---------- Top bar ---------- */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 14px; height: 64px; padding: 0 24px; background: rgb(3 10 23 / .78); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; }
.brand:hover { text-decoration: none; }
.product { font-weight: 600; font-size: 13px; color: var(--muted); border-left: 1px solid var(--night3); padding-left: 14px; letter-spacing: .02em; }
.topnav { margin-left: auto; display: flex; align-items: center; gap: 18px; font-weight: 600; font-size: 14px; }
.topnav a:not(.btn) { color: var(--muted); }
.topnav a:not(.btn):hover { color: var(--paper); text-decoration: none; }
.pill { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; color: var(--ink); background: var(--night1); border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px; }
.policy-pills { display: flex; align-items: center; gap: 5px; max-width: 100%; }
.policy-pills > * { min-width: 0; }
.policy-pills .pill { padding: 4px 10px; }
.pill-x { border: 0; background: none; color: var(--muted); font: inherit; padding: 0 0 0 2px; cursor: pointer; }
.pill-x:hover { color: var(--ink); }
.pill-add { width: auto; max-width: 100%; height: var(--control-h-sm); padding: 0 10px; border-radius: 999px; }
.pill-off { display: inline-flex; align-items: center; gap: 6px; margin-left: 4px; }
.user { display: flex; align-items: center; gap: 10px; }
.user .avatar { width: 30px; height: 30px; font-size: 12px; }

/* ---------- Console layout ---------- */
.shell { display: grid; grid-template-columns: 252px 1fr; min-height: calc(100vh - 64px); }
.side { border-right: 1px solid var(--line); padding: 18px 12px; background: linear-gradient(180deg, rgb(9 20 39 / .7), rgb(3 10 23 / 0)); position: sticky; top: 64px; height: calc(100vh - 64px); overflow-y: auto; }
.side .relay { display: flex; align-items: center; gap: 10px; padding: 6px 10px 16px; margin-bottom: 8px; border-bottom: 1px solid var(--line); min-width: 0; }
.side .relay > div { min-width: 0; }
.side .relay b { display: block; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side .relay small { display: block; color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side .relay .relay-mini { width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; font-size: 18px; flex: none; overflow: hidden; }
.side .relay .relay-mini img { width: 100%; height: 100%; object-fit: cover; }
.side .group { font-size: 11px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--faint); padding: 14px 12px 4px; }
.side button { height: auto; display: flex; width: 100%; justify-content: flex-start; gap: 11px; background: none; border: 0; border-radius: 10px; padding: 8px 12px; color: var(--ink); font-weight: 600; font-size: 14px; }
.side button:hover { background: rgb(255 255 255 / .04); color: var(--paper); }
.side button.on { background: rgb(3 98 255 / .14); color: var(--paper); box-shadow: inset 2px 0 0 var(--cyan); }
.side button svg { width: 18px; height: 18px; color: var(--muted); }
.side button.on svg { color: var(--cyan); }
.side .count { margin-left: auto; background: var(--signal); color: #fff; border-radius: 999px; padding: 2px 8px; font-size: 11.5px; }
.side .count.bad { background: var(--coral); color: #2a0509; }
.content { padding: 30px 36px 60px; max-width: 1180px; width: 100%; min-width: 0; }
.page-head { display: flex; align-items: center; gap: var(--space-3); margin-bottom: var(--space-2); flex-wrap: wrap; }
.page-head h1 { flex: 1; min-width: 200px; }
.page-head .back { margin-right: 4px; }
.page-sub { color: var(--muted); margin: 0 0 var(--space-5); max-width: 760px; }
/* A page's parts, a gap apart whatever they are: notices, toolbars,
   tables, cards. Their own margins give way to it. */
.page { display: grid; gap: var(--space-5); align-content: start; }
.page > * { margin-top: 0; margin-bottom: 0; min-width: 0; }
.page > .page-intro .page-sub { margin-bottom: 0; }
.menu { display: none; }
.embed .topbar, .embed .side, .embed .menu { display: none !important; }
.embed .shell { display: block; min-height: 100vh; }

/* ---------- Sign in ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 40px 16px; position: relative; overflow: hidden; }
.auth::before { content: ""; position: absolute; inset: -30% -10% auto; height: 70vh; background: radial-gradient(closest-side, rgb(4 115 245 / .35), transparent), radial-gradient(closest-side at 70% 60%, rgb(2 232 157 / .16), transparent); filter: blur(30px); pointer-events: none; }
.auth-card { position: relative; width: min(440px, 100%); background: rgb(9 20 39 / .82); border: 1px solid var(--line2); border-radius: 24px; padding: 34px 32px 28px; box-shadow: 0 40px 100px -30px rgb(0 0 0 / .8); backdrop-filter: blur(10px); }
.auth-card.wide { width: min(520px, 100%); }
.auth-card .brand { margin-bottom: 26px; }
.auth-card h1 { font-size: 24px; margin-bottom: 6px; }
.auth-card .lede { color: var(--muted); margin-bottom: 24px; }
.auth-card .row { margin: 8px 0; flex-wrap: nowrap; }
.or { display: flex; align-items: center; gap: 12px; color: var(--faint); font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; margin: 22px 0; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--line2); }
.qr-signin { display: grid; grid-template-columns: 132px 1fr; gap: 18px; align-items: center; padding: 16px; border: 1px solid var(--line2); border-radius: 18px; background: rgb(255 255 255 / .02); }
.qr-signin .qr { width: 132px; padding: 6px; border-radius: 12px; min-height: 132px; transition: opacity .2s, filter .2s; }
.qr-signin .qr.stale { opacity: .35; filter: blur(2px); }
.qr-signin b { display: block; color: var(--paper); margin-bottom: 4px; }
.qr-signin p { margin: 0 0 8px; color: var(--muted); font-size: 13.5px; }
@media (max-width: 420px) { .qr-signin { grid-template-columns: 1fr; justify-items: center; text-align: center; } }
.auth-foot { margin-top: 24px; padding-top: 18px; border-top: 1px solid var(--line); color: var(--faint); font-size: 12.5px; display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.steps { counter-reset: s; list-style: none; padding: 0; margin: 0 0 18px; display: grid; gap: 12px; }
.steps li { counter-increment: s; display: flex; gap: 12px; color: var(--ink); }
.steps li::before { content: counter(s); flex: none; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-size: 12.5px; font-weight: 700; color: #fff; background: var(--aurora); }
.center { display: flex; justify-content: center; margin: 6px 0 18px; }

/* ---------- Home page ---------- */
body.site { background: radial-gradient(1200px 600px at 50% -10%, rgb(4 115 245 / .22), transparent 70%), var(--night0); min-height: 100vh; display: flex; flex-direction: column; }
.landing { width: min(1040px, 100%); margin: 0 auto; padding: 56px 24px 40px; flex: 1; }
.hero { text-align: center; max-width: 720px; margin: 0 auto 44px; }
.relay-badge { width: 76px; height: 76px; border-radius: 22px; display: grid; place-items: center; margin: 0 auto 22px; font-size: 40px; background: var(--night2); border: 1px solid var(--line2); object-fit: cover; box-shadow: 0 24px 60px -24px rgb(5 213 255 / .5); }
.relay-badge.plain { background: none; border: 0; box-shadow: none; padding: 0; }
.eyebrow { display: inline-flex; align-items: center; gap: 9px; font-size: 13px; font-weight: 600; color: var(--ink); background: var(--night1); border: 1px solid var(--line2); border-radius: 999px; padding: 6px 14px; margin: 0 0 18px; }
.hero h1 { font-size: clamp(34px, 6vw, 56px); letter-spacing: -0.035em; margin-bottom: 14px; }
.hero .lede { font-size: 18px; color: var(--muted); margin: 0 auto; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 20px 22px; margin: 0 0 16px; }
.join { display: grid; grid-template-columns: 1fr auto; gap: 40px; align-items: center; padding: 34px 36px; border-radius: 24px; background: linear-gradient(160deg, rgb(15 30 55 / .9), rgb(9 20 39 / .9)); }
.join h2 { font-size: 26px; font-weight: 800; margin: 4px 0 20px; }
.join-code { display: grid; gap: 12px; width: 260px; }
.open-app { display: flex; flex-wrap: wrap; gap: 10px; margin: 18px 0 0; }
.join-code .qr { width: 260px; }
.join-code .code { font-size: 11px; }
.features { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-top: 18px; }
.feature { background: var(--panel); border: 1px solid var(--line); border-radius: 20px; padding: 22px; }
.feature h3 { margin: 14px 0 6px; font-size: 16px; }
.feature-art { display: block; width: 100%; height: 132px; object-fit: contain; }
.feature p { color: var(--muted); font-size: 14px; margin: 0; }
.ficon { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; background: rgb(3 98 255 / .14); border: 1px solid rgb(5 213 255 / .18); }
.ficon svg { width: 20px; height: 20px; fill: none; stroke: var(--cyan); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.footer { border-top: 1px solid var(--line); padding: 20px 24px; display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; color: var(--faint); font-size: 13px; }
.footer a { color: var(--muted); }
.footer span:last-child a { margin-left: 18px; }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { display: none; }
  .menu { display: block; width: 100%; margin-bottom: 18px; }
  .content { padding: 20px 16px 48px; }
  .topbar { padding: 0 16px; }
  .topbar .pill, .product, .topnav a:not(.btn), .user .name { display: none; }
  .join { grid-template-columns: 1fr; padding: 24px; }
  .join-code, .join-code .qr { width: 100%; max-width: 300px; }
  .features { grid-template-columns: 1fr; }
  .hide-small { display: none; }
  th, td { padding: 11px 12px; }
  .auth-card { padding: 28px 22px 22px; }
  .look { grid-template-columns: 1fr; }
  .settings-table, .settings-table tbody, .settings-table tr, .settings-table td.setting-input, .settings-table td.actions { display: block; width: auto; }
  .settings-table td.setting-input, .settings-table td.actions { border-top: 0; padding-top: 0; }
  .settings-table td.actions { padding-left: 12px; }
  .log .line { grid-template-columns: 1fr; gap: 2px; }
  .card-head, .card-body { padding-left: 16px; padding-right: 16px; }
}
/* ---------- Usage ---------- */
.usage-filters select { width: auto; height: var(--control-h); }
.dialog td input { min-width: 70px; }
.usage-tiles { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.drawer .usage-tiles { grid-template-columns: repeat(3, 1fr); }
.usage-plot .legend { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 13px; color: var(--muted); margin-bottom: 10px; }
.usage-plot .legend > span { display: inline-flex; align-items: center; gap: 7px; }
.key { width: 10px; height: 10px; border-radius: 3px; display: inline-block; flex: none; }
.key.u-input, .usage-chart .u-input { background: #3987e5; fill: #3987e5; }
.key.u-cacheRead, .usage-chart .u-cacheRead { background: #199e70; fill: #199e70; }
.key.u-cacheWrite, .usage-chart .u-cacheWrite { background: #c98500; fill: #c98500; }
.key.u-output, .usage-chart .u-output { background: #d95926; fill: #d95926; }
.chart-box { position: relative; }
.usage-chart { width: 100%; height: auto; display: block; overflow: visible; }
.usage-chart .grid { stroke: var(--line); }
.usage-chart .axis { fill: var(--faint); font-size: 11px; font-variant-numeric: tabular-nums; }
.usage-chart .hit { fill: transparent; }
.usage-chart .bar:hover .hit { fill: rgb(255 255 255 / .04); }
.chart-tip { position: absolute; top: 0; transform: translate(-50%, -8px); min-width: 170px; background: var(--raised); border: 1px solid var(--line2); border-radius: 12px; padding: 10px 12px; font-size: 12.5px; pointer-events: none; opacity: 0; transition: opacity .1s; box-shadow: 0 12px 30px -10px rgb(0 0 0 / .7); }
.chart-tip.show { opacity: 1; }
.chart-tip b { display: block; margin-bottom: 6px; color: var(--paper); }
.chart-tip .row { flex-wrap: nowrap; gap: 8px; color: var(--muted); }
.chart-tip .row .v { margin-left: auto; color: var(--paper); font-variant-numeric: tabular-nums; }
.chart-tip .row.total { border-top: 1px solid var(--line); margin-top: 6px; padding-top: 6px; }
.projection { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.projection .label { font-size: 13px; color: var(--muted); }
.projection .big { font-size: 26px; font-weight: 800; letter-spacing: -0.02em; margin-top: 4px; font-variant-numeric: tabular-nums; }
.proj-bar { display: flex; height: 8px; background: var(--night1); border-radius: 4px; overflow: hidden; margin-top: 16px; gap: 2px; }
.proj-bar .so { background: var(--brand); border-radius: 4px; }
.proj-bar .on { background: repeating-linear-gradient(135deg, rgb(5 213 255 / .45) 0 4px, rgb(5 213 255 / .15) 4px 8px); border-radius: 4px; }
.usage-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 0 var(--space-5); align-items: start; }
.barlist { display: grid; gap: 10px; }
.barlist-row { display: grid; grid-template-columns: minmax(90px, 34%) 1fr auto; gap: 12px; align-items: center; font-size: 13.5px; }
.barlist-row .name { font-family: var(--mono); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.barlist-row .track { height: 8px; background: var(--night1); border-radius: 4px; overflow: hidden; }
.barlist-row .track > span { display: block; height: 100%; background: #3987e5; border-radius: 4px; }
.barlist-row .v { font-variant-numeric: tabular-nums; color: var(--muted); min-width: 36px; text-align: right; }
.usage-sub { font-size: 14px; margin: 22px 0 12px; }
@media (max-width: 900px) { .usage-cols { grid-template-columns: 1fr; } .projection .big { font-size: 20px; } }


/* ---------- Bot avatars ---------- */
.avatar-edit { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: var(--space-5); }
.avatar-side { display: flex; flex-direction: column; align-items: center; gap: var(--space-3); }
.avatar-chips { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--space-2); max-width: 200px; }
.avatar-main { display: flex; flex-direction: column; gap: var(--space-4); min-width: 0; }
.avatar-shapes { display: flex; flex-wrap: wrap; gap: var(--space-1); }
button.avatar-shape { width: 38px; height: 38px; padding: 4px; border-radius: 10px; border: 1px solid transparent; background: none; }
.avatar-shape svg { display: block; width: 100%; height: 100%; }
.avatar-shape path { fill: var(--night4); }
.avatar-shape[aria-checked=true] { border-color: var(--signal); }
.avatar-shape[aria-checked=true] path { fill: var(--cyan); }
.avatar-pic { display: block; flex: none; }
.avatar-fps { display: inline-flex; align-items: center; gap: var(--space-2); }
input.fps { width: 72px; }
button.avatar-drop { width: 44px; height: 44px; padding: 0; border-radius: 50%; border: 1px dashed var(--night4); background: none; display: grid; place-items: center; gap: 0; }
button.avatar-drop.full { border: 0; overflow: hidden; cursor: zoom-in; }
.avatar-plus { color: var(--faint); }
.avatar-preview { display: grid; place-items: center; padding: var(--space-2) 0; }
@media (max-width: 760px) { .avatar-edit { grid-template-columns: 1fr; } }
.avatar-new-set { grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); }
.avatar-import { display: flex; flex-direction: column; gap: var(--space-2); border: 1px dashed var(--night4); border-radius: 12px; padding: var(--space-2); }
.avatar-import.over { border-color: var(--signal); }
.avatar-import textarea { border: 0; background: none; box-shadow: none; font: 12.5px/1.55 var(--mono); }
.avatar-import .faint { overflow-wrap: anywhere; }
.avatar-import-states { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: var(--space-2); }
.avatar-import-state { display: flex; flex-direction: column; align-items: center; gap: var(--space-1); text-align: center; font-size: 12px; }
.avatar-import-state small { color: var(--faint); font-variant-numeric: tabular-nums; }
.avatar-import-state.bad small { color: var(--coral); }
.avatar-makers { display: flex; flex-wrap: wrap; gap: var(--space-2); }
button.avatar-maker { height: auto; padding: var(--space-2) var(--space-3) var(--space-2) var(--space-2); gap: var(--space-2); text-align: start; }
button.avatar-maker span { display: flex; flex-direction: column; gap: 0; }
button.avatar-maker small { color: var(--faint); font-weight: 400; }
button.avatar-maker[aria-checked=true] { border-color: var(--signal); background: rgb(3 98 255 / .12); }
.avatar-redo { position: relative; display: block; }
.avatar-redo button { position: absolute; inset-inline-end: -8px; top: -8px; border-radius: 50%; background: var(--night3); }
.avatar-making { width: 64px; height: 64px; border-radius: 50%; border: 2px dashed var(--night4); }
.avatar-making.now { border-style: solid; border-color: var(--night3); border-top-color: var(--cyan); animation: spin .9s linear infinite; }
@media (prefers-reduced-motion: reduce) { .avatar-making.now { animation: none; } }
@media (max-width: 760px) { .avatar-new-set { grid-template-columns: 1fr; } .avatar-import-states { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.story-studio { display: grid; grid-template-columns: 270px minmax(0, 1fr); gap: var(--space-5); align-items: start; }
.story-stage { position: sticky; top: var(--space-4); }
.story-preview { position: relative; width: 270px; aspect-ratio: 9 / 16; max-width: 100%; border-radius: 22px; overflow: hidden; background: linear-gradient(175deg, #7fc8e8, #b9e4f2 45%, #f3efe2); touch-action: none; user-select: none; }
.story-preview canvas { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.story-words { position: absolute; inset: 38% 8% auto; text-align: center; font-weight: 800; font-size: 26px; color: #0e3a52; }
.story-slot { position: absolute; display: grid; place-items: center; cursor: grab; font-size: 13px; font-weight: 700; color: #0e3a52; outline: 1.5px dashed rgb(14 58 82 / .35); }
.story-slot.image { background: linear-gradient(160deg, #ffcf8a, #ff8f70 45%, #7a5cff); color: #fff; outline: none; }
.story-slot.emoji { font-size: 34px; }
.story-slot.on { outline: 2px solid var(--signal); outline-offset: 2px; z-index: 2; }
.story-size { position: absolute; inset-inline-end: -6px; bottom: -6px; width: 14px; height: 14px; border-radius: 50%; background: #fff; border: 2px solid var(--signal); cursor: nwse-resize; display: none; }
.story-slot.on .story-size { display: block; }
.story-dims { display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: var(--space-2); }
input.bad { border-color: var(--coral); }
input.story-color { width: var(--control-h); padding: 2px; }
input.story-color.off { opacity: .35; }
@media (max-width: 760px) { .story-studio { grid-template-columns: 1fr; } .story-stage { position: static; justify-self: center; } }

/* ---------- Inside the app ----------
   Opened by the app with its look (see `start`): the page wears the app's
   colours, fonts and group shape in place of the dark dashboard, and the
   app's own bar carries the title and reload. --app-* are set from the
   address the app opened. */
.app {
  --night0: var(--app-bg); --night1: var(--app-field); --night2: var(--app-field); --night3: var(--app-line); --night4: var(--app-line);
  --paper: var(--app-text); --ink: var(--app-text); --muted: var(--app-muted); --faint: var(--app-muted);
  --signal: var(--app-accent); --cyan: var(--app-accent); --aurora: var(--app-accent); --brand: var(--app-accent);
  --line: var(--app-line); --line2: var(--app-line); --panel: var(--app-card); --raised: var(--app-raised);
  --btn-r: 999px; --field-r: 14px;
}
.app.light { color-scheme: light; }
.app.plat-mac { --btn-r: 7px; --field-r: 7px; --control-h: 32px; --control-h-sm: 26px; }
.app.plat-windows { --btn-r: 4px; --field-r: 4px; --control-h: 32px; --control-h-sm: 28px; }
.app.plat-android, .app.plat-ios { --field-r: 12px; }
.app body { background: var(--app-bg); font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI Variable", "Segoe UI", Roboto, sans-serif; }
.app.plat-mac body, .app.plat-windows body { font-size: 13.5px; }
/* Lower than any button or field with a class of its own, so only the
   plain ones change. */
:where(.app) button, :where(.app) .btn { font-family: inherit; border-radius: var(--btn-r); background: var(--app-field); border-color: transparent; }
:where(.app) button:hover, :where(.app) .btn:hover { border-color: var(--app-line); }
:where(.app) button.primary, :where(.app) .btn.primary { background: var(--app-accent); border-color: transparent; color: var(--app-onaccent); }
:where(.app) button.icon { border-radius: var(--btn-r); }
:where(.app) textarea, :where(.app) input, :where(.app) select { background: var(--app-field); border-color: transparent; border-radius: var(--field-r); }
:where(.app) textarea:focus, :where(.app) input:focus, :where(.app) select:focus { border-color: var(--app-accent); box-shadow: none; }
:where(.app.plat-mac) textarea:focus, :where(.app.plat-mac) input:focus, :where(.app.plat-mac) select:focus { border-color: transparent; }
/* Windows: Fluent text boxes, a faint edge and a darker bottom line that
   turns the accent while typing. */
:where(.app.plat-windows) textarea, :where(.app.plat-windows) input, :where(.app.plat-windows) select { border-color: var(--app-line); border-bottom-color: var(--app-muted); }
:where(.app.plat-windows) textarea:focus, :where(.app.plat-windows) input:focus, :where(.app.plat-windows) select:focus { border-color: var(--app-line); border-bottom-color: var(--app-accent); box-shadow: inset 0 -1px 0 var(--app-accent); }
.app .content { padding: var(--space-3) var(--space-4) 48px; max-width: 900px; margin: 0 auto; }
.app h1, .app h2, .app h3 { letter-spacing: 0; }
/* One title: the app's bar has it, and the reload. */
.app .page-head h1, .app .page-head > button.refresh { display: none; }
.app .page-head:not(:has(> :not(h1):not(.refresh))) { display: none; }
.app .page { gap: var(--space-4); }
/* A card is the app's group: its title a section label above it. */
.app .card, .app .table-card { background: none; border: 0; border-radius: 0; overflow: visible; margin-bottom: var(--space-4); }
.app .card > .card-head { padding: 0 var(--space-1) var(--space-2); align-items: center; }
.app .card > .card-head h2 { font-size: 13px; font-weight: 600; color: var(--app-muted); }
.app .card > .card-head .titles p { font-size: 12.5px; }
.app .card > .card-body, .app .card > .card-foot, .app .table-card > .table-wrap, .app .tile, .app .panel {
  background: var(--app-card); border: var(--app-edge-w) solid var(--app-edge); border-radius: var(--app-r);
}
.app .card > .card-body { padding: var(--space-4); }
.app .card > .card-body.flush { padding: 0; overflow: hidden; }
.app .card > .card-body.flush > .table-wrap, .app .card > .table-wrap { border-top: 0; }
.app .card > .card-body:has(+ .card-foot) { border-bottom: 0; border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
.app .card > .card-body + .card-foot { border-top: 0; border-top-left-radius: 0; border-top-right-radius: 0; padding: 0 var(--space-4) var(--space-4); }
.app .card > .card-head + .card-foot { padding: var(--space-3) var(--space-4); }
.app .fold.card:not([open]) > .card-head { padding-bottom: var(--space-2); }
.app th { background: none; }
.app tbody tr.go:hover td { background: none; }
/* On a phone a table is a list: one row each, its cells wrapped
   under the first, each named where it says something in words. */
@media (max-width: 640px) {
  table, tbody { display: block; }
  thead { display: none; }
  tbody tr { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; padding: 12px var(--space-4); border-bottom: 1px solid var(--line); }
  .app tbody tr { border-bottom-color: var(--app-line); }
  tbody tr:last-child { border-bottom: 0; }
  td { display: block; padding: 0; border: 0; min-width: 0; max-width: 100%; }
  td:first-child { flex: 1 1 auto; min-width: 30%; }
  td.clip { max-width: none; width: auto; flex-basis: 100%; }
  td.actions { margin-left: auto; }
  td button.avatar-drop { width: 36px; height: 36px; }
  td[data-label]:not(:first-child)::before { content: attr(data-label) " "; color: var(--muted); font-size: 12px; }
  .app td[data-label]:not(:first-child)::before { color: var(--app-muted); }
}
/* The app names the page in its own bar, and a page's parts speak for
   themselves: no intro under it. */
.app .page-sub { display: none; }
.app .page-intro:not(:has(.page-head > :not(h1):not(.refresh))) { display: none; }
/* Avatar sets: a row a set, its pictures in a line under its name. */
.avatar-sets { display: grid; gap: 0; }
.avatar-set { display: grid; gap: var(--space-2); padding: var(--space-3) var(--space-4); border-top: 1px solid var(--line); }
.avatar-set:first-child { border-top: 0; }
.app .avatar-set { border-top-color: var(--app-line); }
.avatar-set-head { display: flex; align-items: center; gap: var(--space-2); min-height: 32px; }
.avatar-set-name { flex: 1; min-width: 0; display: flex; align-items: baseline; flex-wrap: wrap; gap: 2px var(--space-2); }
.avatar-set-states { display: flex; flex-wrap: wrap; gap: var(--space-2); }
button.danger-text { color: var(--coral); }
/* On a phone a card's buttons share its width in one row, and a row of
   filters lines up rather than wrapping. */
@media (max-width: 560px) {
  .card-foot:has(> :nth-child(2)) { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: var(--space-2); }
  .card-foot:has(> :nth-child(3)) button > .ico { display: none; }
  .card-foot:has(> :nth-child(2)) > button { min-width: 0; padding-left: 8px; padding-right: 8px; justify-content: center; }
  .card-foot > .left { margin: 0; }
  .usage-filters { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--space-2); width: 100%; }
  .usage-filters > .seg-box { order: -1; }
  .usage-filters > select { grid-column: 1 / -1; width: 100%; }
}
