/* RinBot console. Sections: tokens → base → shell → controls → pages → responsive.
   Prefer one class per selector. Colours come from the tokens, and spacing, radii, weights and font sizes
   from fixed sets; test_console_contrast holds the stylesheet to both. */

/* ── Tokens ─────────────────────────────────────────── */
:root {
    --img-line: rgba(24, 24, 27, .1);
    --bg: #F7F7F8;
    --panel: #FFFFFF;
    --side: #F0F0F2;
    --line: #E4E4E8;
    --field: #FFFFFF;
    --field-line: #8A8A93;
    --text: #18181B;
    --muted: #5F5F68;
    --accent: #D6336C;
    --accent-hover: #C42A60;
    --on-accent: #FFFFFF;
    --accent-soft: #FDECF2;
    --accent-soft-hover: #FBDDE8;
    --accent-text: #B32457;
    --ok: #1A7A43;
    --ok-soft: #E7F5EC;
    --warn: #A15C00;
    --warn-soft: #FFF4E0;
    --bad: #B42318;
    --bad-soft: #FDECEA;
    --bad-soft-hover: #FAD9D5;
    --cur: #FFFFFF;
    --hover: #E7E7EA;
    --bar: #18181B;
    --bar-text: #FAFAFA;
    --scrim: rgba(24, 24, 27, .4);
    --shadow-sm: 0 1px 2px rgba(24, 24, 27, .06), 0 1px 1px rgba(24, 24, 27, .04);
    --shadow-pop: 0 12px 32px rgba(24, 24, 27, .16), 0 2px 6px rgba(24, 24, 27, .06);
    --font-body: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
    --font-display: "Fredoka", var(--font-body);
    --side-w: 252px;
    --content-w: 680px;
    --radius: 12px;
    --control-h: 40px;
    --ease-out: cubic-bezier(.22, 1, .36, 1);
    --dur-fast: 120ms;
    --dur-base: 160ms;
    --dur-slow: 200ms;
    --btn-fg: currentColor;
    --limit: 0;
    --ink-x: 0;
    --ink-w: 0;
    --seg-i: 0;
    --seg-n: 1;
    color-scheme: light;
}
/* Night palette: chosen by the appearance switch, or by the system when the viewer has not picked day. */
:root[data-theme="dark"] {
    --img-line: rgba(255, 255, 255, .1);
    --bg: #17171B;
    --panel: #1F1F24;
    --side: #121215;
    --line: #2C2C33;
    --field: #17171B;
    --field-line: #6A6A74;
    --text: #EDEDF0;
    --muted: #9A9AA5;
    --accent: #FF6FA3;
    --accent-hover: #FF8DB7;
    --on-accent: #2A0A17;
    --accent-soft: #3A1A28;
    --accent-soft-hover: #4A2233;
    --accent-text: #FF8DB7;
    --ok: #3DD68C;
    --ok-soft: #13291D;
    --warn: #F5B94A;
    --warn-soft: #33270F;
    --bad: #FF8A80;
    --bad-soft: #3A1715;
    --bad-soft-hover: #4A1F1C;
    --cur: #303038;
    --hover: #28282F;
    --bar: #EDEDF0;
    --bar-text: #18181B;
    --scrim: rgba(0, 0, 0, .55);
    --shadow-sm: none;
    --shadow-pop: 0 16px 40px rgba(0, 0, 0, .5);
    color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --img-line: rgba(255, 255, 255, .1);
        --bg: #17171B;
        --panel: #1F1F24;
        --side: #121215;
        --line: #2C2C33;
        --field: #17171B;
        --field-line: #6A6A74;
        --text: #EDEDF0;
        --muted: #9A9AA5;
        --accent: #FF6FA3;
        --accent-hover: #FF8DB7;
        --on-accent: #2A0A17;
        --accent-soft: #3A1A28;
        --accent-soft-hover: #4A2233;
        --accent-text: #FF8DB7;
        --ok: #3DD68C;
        --ok-soft: #13291D;
        --warn: #F5B94A;
        --warn-soft: #33270F;
        --bad: #FF8A80;
        --bad-soft: #3A1715;
        --bad-soft-hover: #4A1F1C;
        --cur: #303038;
        --hover: #28282F;
        --bar: #EDEDF0;
        --bar-text: #18181B;
        --scrim: rgba(0, 0, 0, .55);
        --shadow-sm: none;
        --shadow-pop: 0 16px 40px rgba(0, 0, 0, .5);
        color-scheme: dark;
    }
}

/* ── Base ───────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
html { text-autospace: normal; interpolate-size: allow-keywords; }
body {
    background: var(--bg);
    color: var(--text);
    font: 14px/1.6 var(--font-body);
    -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4, p { margin: 0; }
h1, h2, h3 { text-wrap: balance; }
p { text-wrap: pretty; }
a { color: inherit; text-decoration: none; }
ul { margin: 0; padding: 0; list-style: none; }
button, input, select, textarea { font: inherit; color: inherit; }
img { max-width: 100%; }
[hidden][hidden] { display: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.icon { flex-shrink: 0; vertical-align: middle; }
.display { font-family: var(--font-display); font-weight: 600; }
.stat-value, .lb-rank, .item-meta, .count, .tn { font-variant-numeric: tabular-nums; }

/* ── Shell ──────────────────────────────────────────── */
.shell { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); height: 100dvh; }
.sidebar { view-transition-name: console-sidebar; display: flex; flex-direction: column; gap: 4px; width: var(--side-w); min-height: 0; padding: 12px 8px 0; background: var(--side); border-right: 1px solid var(--line); color: var(--muted); }

.brand-row { display: flex; align-items: center; gap: 8px; flex-shrink: 0; margin-bottom: 4px; min-height: 36px; padding: 4px 8px; border-radius: 8px; color: var(--text); }
.brand-row:hover { background: var(--hover); }
.brand-row img, .server-icon img, .switcher-btn img, .avatar-prev, .user-avatar { outline: 1px solid var(--img-line); outline-offset: -1px; }
.brand-row img { width: 24px; height: 24px; flex-shrink: 0; border-radius: 50%; }
.brand-name { min-width: 0; font: 16px/1.2 var(--font-display); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-home { display: inline-flex; align-items: center; gap: 4px; flex-shrink: 0; margin-left: auto; font-size: 12px; color: var(--muted); }
.brand-row:hover .brand-home { color: var(--text); }
.switcher { position: relative; flex-shrink: 0; margin-bottom: 4px; }
.switcher-btn { display: flex; align-items: center; gap: 8px; width: 100%; padding: 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); box-shadow: var(--shadow-sm); color: var(--text); text-align: left; cursor: pointer; }
.switcher-btn:hover { border-color: var(--field-line); }
.switcher-btn > .icon { color: var(--muted); }
.switcher-icon { display: grid; place-items: center; width: 32px; height: 32px; flex-shrink: 0; overflow: hidden; border-radius: 8px; background: var(--accent); color: var(--on-accent); font-weight: 600; }
.switcher-icon img { width: 100%; height: 100%; object-fit: cover; }
.switcher-icon.is-muted { background: var(--side); color: var(--muted); border: 1px solid var(--line); }
.switcher-text { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.switcher-name { flex: 1; min-width: 0; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.switcher-sub { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.switcher-pop { position: absolute; z-index: 60; top: calc(100% + 6px); left: 0; width: max(100%, 280px); max-height: min(420px, calc(100dvh - 120px)); overflow-y: auto; overscroll-behavior: contain; padding: 8px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); box-shadow: var(--shadow-pop); }
.switcher-pop > .input { margin-bottom: 4px; }
.switcher-group { padding: 8px 8px 4px; font-size: 12px; color: var(--muted); }
.switcher-item { display: flex; align-items: center; gap: 8px; min-height: 36px; padding: 4px 8px; border-radius: 4px; color: var(--text); }
.switcher-item:hover { background: var(--hover); }
.switcher-item > .switcher-icon { width: 24px; height: 24px; border-radius: 8px; font-size: 12px; }
.switcher-item > .switcher-name { font-weight: 400; }
.switcher-item[aria-current="page"] > .switcher-name { font-weight: 600; }
.switcher-item > .icon { color: var(--accent-text); }
.switcher-invite { flex-shrink: 0; font-size: 12px; color: var(--accent-text); }
.switcher-empty { padding: 12px 8px; color: var(--muted); font-size: 13px; }
.switcher-foot { margin-top: 4px; padding-top: 4px; border-top: 1px solid var(--line); }
.switcher-foot .icon { color: var(--muted); }

.nav-body { flex: 1; min-height: 0; overflow-y: auto; margin: 0 -4px; padding: 0 4px 8px; overscroll-behavior: contain; }
.nav-group-title { display: block; padding: 12px 8px 4px; font-size: 13px; font-weight: 600; color: var(--muted); }
.nav-item {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 36px;
    padding: 6px 8px;
    border-radius: 8px;
    color: var(--muted);
}
.nav-item:hover { background: var(--hover); color: var(--text); }
.nav-item[aria-current="page"] { background: var(--cur); color: var(--text); font-weight: 600; box-shadow: var(--shadow-sm); }
.nav-item[aria-disabled="true"] { opacity: .6; cursor: not-allowed; }
.nav-label { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-badge { font-size: 12px; padding: 0 4px; border-radius: 4px; background: var(--hover); }
.nav-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; border: 2px solid var(--muted); }
.nav-dot--on { background: var(--ok); border-color: var(--ok); }
.nav-dot--off { background: transparent; }
.nav-dot--warn { background: var(--warn); border-color: var(--warn); }
.nav-dot--unknown { background: var(--field-line); border-color: var(--field-line); }
.nav-dot:not(.nav-dot--warn) { display: none; }

.theme-row { display: flex; align-items: center; gap: 8px; margin: 4px 8px 0; padding: 8px 4px 0; border-top: 1px solid var(--line); }
.theme-label { flex: 1; font-size: 13px; color: var(--muted); }
.user-row { display: flex; align-items: center; gap: 8px; margin: 0 8px 8px; padding: 8px 4px 4px; }
.theme-switch { position: relative; display: inline-flex; flex-shrink: 0; padding: 2px; border: 1px solid var(--line); border-radius: 8px; background: var(--field); }
.theme-switch button { position: relative; display: grid; place-items: center; width: 26px; height: 24px; padding: 0; border: 0; border-radius: 6px; background: none; color: var(--muted); cursor: pointer; }
.theme-switch button:hover { color: var(--text); }
.theme-switch button[aria-pressed="true"] { color: var(--text); }
/* One highlight that travels between the options; which option it sits under comes from :has() below. */
.theme-switch::before { content: ""; position: absolute; top: 2px; bottom: 2px; left: 2px; width: calc((100% - 4px) / 3); border-radius: 4px; background: var(--hover); transform: translateX(calc(100% * var(--seg-i))); transition: transform 180ms var(--ease-out); }
.theme-switch:has(> button:nth-child(2)[aria-pressed="true"]) { --seg-i: 1; }
.theme-switch:has(> button:nth-child(3)[aria-pressed="true"]) { --seg-i: 2; }
.user-avatar { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; flex-shrink: 0; }
.user-name { flex: 1; min-width: 0; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-logout { display: flex; padding: 8px; border-radius: 8px; color: var(--muted); }
.user-logout:hover { background: var(--hover); color: var(--text); }

.main { min-width: 0; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: none;
    align-items: center;
    gap: 12px;
    min-height: 56px;
    padding: 8px 32px;
    background: var(--bg);
    background: color-mix(in srgb, var(--bg) 88%, transparent);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--line);
}
.topbar-title { flex: 1; min-width: 0; font-size: 14px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.menu-btn { display: none; }
.bot-status {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
    padding: 4px 8px;
    border-radius: 999px;
    background: var(--line);
    color: var(--muted);
    font-size: 13px;
    white-space: nowrap;
}
.bot-status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.bot-status[data-state="online"] { background: var(--ok-soft); color: var(--ok); }
.bot-status[data-state="offline"], .bot-status[data-state="not_joined"] { background: var(--bad-soft); color: var(--bad); }

.content { padding: 40px 48px 140px; }
.content--column > * { max-width: 680px; }
.drawer-backdrop { display: none; }

/* ── Controls ───────────────────────────────────────── */
.page { display: none; max-width: 680px; }
.page--editor { max-width: 1032px; }
.page.is-active { display: block; }
.page.is-entering { animation: page-in var(--dur-base) var(--ease-out); }
.is-fresh { animation: fade-in var(--dur-fast) ease-out; }
.page.is-entering.is-fresh { animation: page-in var(--dur-base) var(--ease-out), fade-in var(--dur-fast) ease-out; }
@keyframes page-in { from { opacity: 0; transform: translateY(4px); } }
@keyframes fade-in { from { opacity: 0; } }
@keyframes skeleton-in { from { opacity: 0; } }
.page-head { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 24px; }
.page-head-text { flex: 1; min-width: 0; }
.page-head h1, .page-head h2 { font: 600 22px/1.35 var(--font-body); overflow-wrap: anywhere; }
.page-head p { margin-top: 4px; color: var(--muted); }
.page-head h2:focus { outline: none; }
.master-hint { margin: -16px 0 16px; color: var(--warn); font-size: 13px; }
.tab-panel > .section { margin: 0; }

.section { margin: 0 0 32px; }
.section-title { font-size: 16px; font-weight: 600; margin: 0; }
.section-hint { font-size: 13px; color: var(--muted); margin: 4px 0 0; }
:is(.section-title, .section-hint, .section-head) + :is(.list, .case-list, .lb-list) { margin-top: 8px; }

.list { border-block: 1px solid var(--line); }
.row { display: flex; align-items: center; gap: 16px; padding: 12px 0; border-top: 1px solid var(--line); transition: opacity 150ms ease; }
.row:first-child { border-top: 0; }
.row--block { flex-direction: column; align-items: stretch; gap: 8px; }
/* A setting that depends on the switch row above it; its own top hairline starts at the indent. */
.row--sub { margin-left: 16px; }
.row-text { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.row-title { display: block; font-size: 14px; }
.row-hint { display: block; font-size: 13px; color: var(--muted); }
.row-hint--warn { color: var(--warn); }
.row-control { display: flex; align-items: center; gap: 8px; flex-shrink: 0; max-width: 100%; }
.row[aria-disabled="true"] { opacity: .5; }
.row[aria-disabled="true"] .row-control, .row[aria-disabled="true"].row--block > :not(.row-text) { pointer-events: none; }

.input, .select, .textarea, .num, .select-trigger {
    width: 240px;
    max-width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--field-line);
    border-radius: 8px;
    background: var(--field);
    color: var(--text);
}
.input, .select, .num, .select-trigger { flex-shrink: 0; height: var(--control-h); padding-block: 0; }
.input:focus, .select:focus, .textarea:focus, .num:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.row--block .input, .row--block .select, .row--block .textarea, .row--block .select-trigger { width: 100%; }
.textarea { min-height: 96px; resize: vertical; line-height: 1.6; }
.num { width: 120px; text-align: left; appearance: textfield; -moz-appearance: textfield; }
.num::-webkit-inner-spin-button, .num::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.num-field { display: inline-grid; flex: 0 1 120px; width: 120px; min-width: 96px; }
.num-field > * { grid-area: 1 / 1; }
.num-field .num { width: 100%; padding-right: calc(3em + 16px); }
.num-unit { align-self: center; justify-self: end; margin-right: 12px; pointer-events: none; color: var(--muted); font-size: 14px; white-space: nowrap; }
.unit { font-size: 13px; color: var(--muted); }
.limit-field { position: relative; display: inline-grid; width: 240px; max-width: 100%; flex-shrink: 0; }
.row--block .limit-field { display: grid; width: 100%; }
.limit-field > .input, .limit-field > .textarea, .limit-meter { grid-area: 1 / 1; }
.limit-field > .input, .limit-field > .textarea { width: 100%; }
.limit-field.is-shown > .input { padding-right: 48px; }
.limit-meter { display: none; align-self: center; justify-self: end; align-items: center; gap: 4px; margin-right: 12px; pointer-events: none; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.limit-field--area .limit-meter { align-self: end; margin-right: 24px; margin-bottom: 8px; }
.limit-field--area.is-shown > .textarea { padding-bottom: 32px; }
.limit-field.is-shown .limit-meter { display: inline-flex; }
.limit-field.is-full .limit-meter { color: var(--bad); }
.limit-ring svg { display: block; transform: rotate(-90deg); }
.limit-track, .limit-fill { fill: none; stroke-width: 2.5; }
.limit-track { stroke: var(--line); }
.limit-fill { stroke: var(--accent); stroke-linecap: round; stroke-dasharray: 50.27; stroke-dashoffset: calc(50.27 * (1 - var(--limit))); transition: stroke-dashoffset var(--dur-fast) var(--ease-out); }
.limit-field.is-full .limit-fill { stroke: var(--bad); }

.tog { position: relative; display: inline-flex; flex-shrink: 0; width: 40px; height: 22px; cursor: pointer; }
.tog--head { width: auto; flex-direction: row-reverse; align-items: center; gap: 8px; margin-top: 4px; }
.tog--head .tog-track { width: 40px; flex-shrink: 0; }
.tog-on, .tog-off { font-size: 13px; color: var(--muted); white-space: nowrap; }
.tog input:checked ~ .tog-off, .tog input:not(:checked) ~ .tog-on { display: none; }
.tog input { position: absolute; inset: -9px 0; margin: 0; opacity: 0; cursor: inherit; z-index: 1; }
.tog-track { position: relative; width: 100%; height: 100%; border-radius: 999px; background: var(--field-line); transition: background .15s; }
.tog-track::after {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #FFFFFF;
    box-shadow: 0 1px 2px rgba(0, 0, 0, .2);
    transition: transform .15s, width .15s;
}
.tog input:checked + .tog-track { background: var(--accent); }
.tog input:checked + .tog-track::after { transform: translateX(18px); }
.tog input:active + .tog-track::after { width: 20px; }
.tog input:checked:active + .tog-track::after { transform: translateX(14px); }
.tog input:focus-visible + .tog-track { outline: 2px solid var(--accent); outline-offset: 2px; }
.tog input:disabled { cursor: not-allowed; }
.tog input:disabled + .tog-track { opacity: .5; }
.tog[aria-busy="true"] .tog-track { opacity: .6; }

.btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: var(--control-h);
    padding: 0 16px;
    border: 0;
    border-radius: 8px;
    color: var(--btn-fg);
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    transition: background-color 150ms ease, color 150ms ease, box-shadow 150ms ease, transform 150ms var(--ease-out);
}
.btn:active:not(:disabled, [aria-busy="true"]) { transform: scale(.97); transition-duration: 60ms; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn:not(.btn--icon, .btn--text):has(> svg:first-child) { padding-inline-start: 12px; }
.btn--primary { --btn-fg: var(--on-accent); background: var(--accent); }
.btn--secondary { --btn-fg: var(--accent-text); background: var(--accent-soft); }
/* A text button acts on this page, so it has no underline; links, which go elsewhere, keep theirs. The outer edges
   pull back by the padding so the words line up with the content above while the hover fill still has room. */
.btn--text { --btn-fg: var(--accent-text); padding-inline: 8px; background: none; }
.btn--text:first-child { margin-inline-start: -8px; }
.btn--text:last-child { margin-inline-end: -8px; }
.btn--text:active:not(:disabled, [aria-busy="true"]) { transform: none; background: color-mix(in srgb, currentColor 16%, transparent); }
.btn--danger { --btn-fg: var(--bad); background: var(--bad-soft); }
.btn--icon { --btn-fg: var(--muted); padding: 6px; min-height: 32px; background: none; }
.btn--icon:active:not(:disabled, [aria-busy="true"]) { transform: none; background: color-mix(in srgb, currentColor 16%, transparent); }
.btn--sm { min-height: 32px; padding-inline: 12px; font-size: 13px; }
.btn--text.btn--sm { padding-inline: 8px; }
/* The label stays in place, invisible, so the button keeps its width while the spinner sits on top. */
.btn[aria-busy="true"] { color: transparent; cursor: default; }
.btn[aria-busy="true"]:disabled { opacity: 1; }
.btn[aria-busy="true"]::after { content: ""; position: absolute; inset: 0; width: 16px; height: 16px; margin: auto; border: 2px solid var(--btn-fg); border-right-color: transparent; border-radius: 50%; animation: btn-spin .7s linear infinite; }
@keyframes btn-spin { to { transform: rotate(360deg); } }
@media (hover: hover) {
    .btn--primary:hover:not(:disabled) { background: var(--accent-hover); }
    .btn--secondary:hover:not(:disabled) { background: var(--accent-soft-hover); }
    .btn--danger:hover:not(:disabled) { background: var(--bad-soft-hover); }
    .btn--discord:hover { background: #3C45A5; }
    .btn--text:hover:not(:disabled) { background: color-mix(in srgb, currentColor 9%, transparent); }
    .btn--icon:hover { --btn-fg: var(--text); background: var(--line); }
}
.btn:has(+ .sr-only:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.confirm-pop { position: fixed; z-index: 130; width: max-content; max-width: min(320px, calc(100vw - 32px)); padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); box-shadow: var(--shadow-pop); transform-origin: top right; transition: opacity var(--dur-fast) var(--ease-out), transform var(--dur-fast) var(--ease-out); }
.confirm-pop[data-side="top"] { transform-origin: bottom right; }
@starting-style { .confirm-pop { opacity: 0; transform: scale(.97); } }
.confirm-text { overflow-wrap: anywhere; }
.confirm-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 16px; }
.actions > .section-hint { margin: 0; }
.actions + .section-hint { margin-top: 24px; }
.actions > .unit { min-width: 0; overflow-wrap: anywhere; }

.seg { position: relative; display: inline-grid; grid-auto-flow: column; grid-auto-columns: minmax(72px, 1fr); align-self: flex-start; flex-shrink: 0; height: var(--control-h); border: 1px solid var(--field-line); border-radius: 8px; overflow: hidden; background: var(--field); }
.seg-option { position: relative; padding: 0 12px; border: 0; border-left: 1px solid var(--line); background: none; cursor: pointer; white-space: nowrap; }
.seg-option:first-child { border-left: 0; }
/* Reserves the bold width of each label, so selecting an option never widens the equal columns. */
.seg-option::after { content: attr(data-label); display: block; height: 0; overflow: hidden; visibility: hidden; font-weight: 600; }
.seg-option[aria-pressed="true"] { color: var(--accent-text); font-weight: 600; }
.seg::before { content: ""; position: absolute; top: 0; bottom: 0; left: 0; width: calc(100% / var(--seg-n)); background: var(--accent-soft); transform: translateX(calc(100% * var(--seg-i))); transition: transform 180ms var(--ease-out); }
.seg:not(:has(> .seg-option[aria-pressed="true"]))::before { display: none; }
.seg:has(> .seg-option:nth-child(2)[aria-pressed="true"]) { --seg-i: 1; }
.seg:has(> .seg-option:nth-child(3)[aria-pressed="true"]) { --seg-i: 2; }
.seg:has(> .seg-option:nth-child(4)[aria-pressed="true"]) { --seg-i: 3; }
.seg:has(> .seg-option:nth-child(5)[aria-pressed="true"]) { --seg-i: 4; }
.seg:has(> .seg-option:nth-child(2)) { --seg-n: 2; }
.seg:has(> .seg-option:nth-child(3)) { --seg-n: 3; }
.seg:has(> .seg-option:nth-child(4)) { --seg-n: 4; }
.seg:has(> .seg-option:nth-child(5)) { --seg-n: 5; }
.seg-custom { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.seg-custom .select { width: 96px; }

.note { display: flex; gap: 8px; align-items: flex-start; margin-top: 12px; padding: 8px 12px; border-radius: 8px; font-size: 13px; overflow-wrap: anywhere; }
.note:not(:last-child) { margin-bottom: 16px; }
.note--warn { background: var(--warn-soft); color: var(--warn); }
.note--info { background: var(--accent-soft); color: var(--accent-text); }

.chip { display: inline-flex; align-items: center; gap: 4px; max-width: 100%; padding: 2px 4px 2px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-text); font-size: 13px; overflow-wrap: anywhere; }
.chip-remove { position: relative; display: flex; padding: 2px; border: 0; border-radius: 50%; background: none; color: inherit; cursor: pointer; }
.chip-remove:hover { background: var(--panel); }
.chip-remove::after { content: ""; position: absolute; inset: -6px; }
.chip, .rr-row { transition: opacity 140ms ease-out; }
@starting-style {
    .chip, .rr-row { opacity: 0; }
}
.chip-list { display: flex; flex-wrap: wrap; gap: 4px; }
.chip-add { display: flex; gap: 8px; margin-top: 8px; }
.chip-add .input { flex: 1; min-width: 0; }

.check-chip { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border: 1px solid var(--field-line); border-radius: 999px; background: var(--field); cursor: pointer; }
.check-chip:has(input:checked) { background: var(--accent-soft); border-color: var(--accent-soft); color: var(--accent-text); }
.check-chip input { accent-color: var(--accent); margin: 0; }
.check-list { display: flex; flex-wrap: wrap; gap: 8px; }

.search-select { position: relative; width: 240px; max-width: 100%; }
.row--block .search-select { width: 100%; }
.select-trigger { position: relative; display: block; width: 100%; padding-right: 32px; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; }
.select-trigger::after { content: ""; position: absolute; right: 13px; top: calc(50% - 5px); width: 7px; height: 7px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(45deg); }
.select-trigger:disabled { opacity: .6; cursor: not-allowed; }
.select-popup { position: fixed; z-index: 110; display: flex; flex-direction: column; gap: 8px; max-height: min(320px, calc(100dvh - 24px)); padding: 8px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-pop); }
.select-search { width: 100%; }
.select-popup, .palette, .switcher-pop, .emoji-picker { transform-origin: top; transition: opacity 140ms var(--ease-out), transform 140ms var(--ease-out); }
@starting-style {
    .select-popup, .palette, .switcher-pop, .emoji-picker { opacity: 0; transform: scale(.97); }
}
.select-options { min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.select-option { display: block; width: 100%; padding: 8px 8px; border: 0; border-radius: 4px; background: none; text-align: left; overflow-wrap: anywhere; cursor: pointer; }
.select-option:hover, .select-option.is-highlighted { background: var(--accent-soft); }
.select-option[aria-selected="true"] { color: var(--accent-text); }
.search-feedback { font-size: 12px; color: var(--muted); }

.unsaved-bar {
    position: fixed;
    z-index: 60;
    bottom: 20px;
    left: calc(var(--side-w) + 48px);
    width: min(var(--content-w), calc(100vw - var(--side-w) - 96px));
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 12px;
    padding: 8px 12px 8px 16px;
    border-radius: 12px;
    background: var(--bar);
    color: var(--bar-text);
    box-shadow: var(--shadow-pop);
    transform: translateY(calc(100% + 40px));
    visibility: hidden;
    transition: transform var(--dur-slow) var(--ease-out), visibility 0s linear var(--dur-slow);
}
.unsaved-bar.is-open { transform: none; visibility: visible; transition: transform var(--dur-slow) var(--ease-out); }
.unsaved-bar.is-shaking { animation: bar-shake .4s; }
.unsaved-text { flex: 1; min-width: 0; }
.unsaved-error { flex-basis: 100%; order: 3; color: var(--bar-text); font-size: 13px; }
.unsaved-bar .btn--text { --btn-fg: var(--bar-text); }
@keyframes bar-shake { 20%, 60% { translate: -6px 0; } 40%, 80% { translate: 6px 0; } }

.toast {
    position: fixed;
    z-index: 120;
    top: 16px;
    left: 50%;
    max-width: min(440px, calc(100vw - 32px));
    padding: 8px 16px;
    border-radius: 12px;
    background: var(--bar);
    color: var(--bar-text);
    box-shadow: var(--shadow-pop);
    overflow-wrap: anywhere;
    translate: -50% -12px;
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s, translate .2s;
}
.toast.is-shown { opacity: 1; translate: -50% 0; pointer-events: auto; }
.toast--ok { background: var(--ok); }
.toast--bad { background: var(--bad); }

@keyframes shimmer { to { background-position: -200% 0; } }
.page[aria-busy="true"] .list {
    background: linear-gradient(90deg, var(--line) 25%, var(--bg) 50%, var(--line) 75%) 0 0 / 200% 100%;
    animation: shimmer 1.4s infinite linear, skeleton-in var(--dur-fast) ease-out .15s backwards;
}
.page[aria-busy="true"] .list > * { visibility: hidden; }

.empty { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 24px 16px; text-align: center; color: var(--muted); }
.empty img { width: 96px; height: 96px; object-fit: contain; }
/* A list showing only its empty state draws no hairlines, whichever list it is. */
:is(.list, .case-list, .lb-list, .item-list):has(> .empty:only-child) { border-block: 0; }
.load-feedback { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 16px; padding: 8px 12px; border-radius: 8px; background: var(--bad-soft); color: var(--bad); }

.tabs { position: relative; display: flex; gap: 24px; margin: 0 0 16px; border-bottom: 1px solid var(--line); overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
.tab { display: inline-flex; align-items: center; gap: 6px; padding: 8px 0; margin-bottom: -1px; border-bottom: 2px solid transparent; color: var(--muted); white-space: nowrap; }
.tab:hover { color: var(--text); }
.tab[aria-selected="true"] { border-bottom-color: var(--accent); color: var(--text); font-weight: 600; }
.tabs.has-ink .tab[aria-selected="true"] { border-bottom-color: transparent; }
.tabs.has-ink::after { content: ""; position: absolute; left: 0; bottom: 0; width: 1px; height: 2px; background: var(--accent); transform-origin: left; transform: translateX(var(--ink-x)) scaleX(var(--ink-w)); transition: transform 180ms var(--ease-out); }
.tab-dot { width: 6px; height: 6px; flex-shrink: 0; border-radius: 50%; background: var(--warn); }
.tab-panel { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.tab-panel:has(> .section + .section) { gap: 32px; }

.search-btn { display: flex; align-items: center; gap: 8px; width: 100%; flex-shrink: 0; margin-bottom: 4px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--field); color: var(--muted); cursor: pointer; text-align: left; }
.search-btn:hover { border-color: var(--field-line); color: var(--text); }
.search-btn span { flex: 1; }
.search-btn kbd { padding: 0 6px; border: 1px solid var(--line); border-radius: 4px; font: 12px/1.6 var(--font-body); color: var(--muted); }
.palette-scrim { position: fixed; z-index: 120; inset: 0; display: flex; align-items: flex-start; justify-content: center; padding: 12vh 16px 16px; background: var(--scrim); }
.palette { display: flex; flex-direction: column; width: min(560px, 100%); max-height: min(440px, 76vh); overflow: hidden; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); box-shadow: var(--shadow-pop); }
.palette-input { display: flex; align-items: center; gap: 8px; padding: 12px 16px; border-bottom: 1px solid var(--line); color: var(--muted); }
.palette-input input { flex: 1; min-width: 0; border: 0; outline: none; background: none; font-size: 16px; color: var(--text); }
.palette-list { overflow-y: auto; padding: 8px; }
.palette-item { display: flex; align-items: center; gap: 12px; padding: 8px 8px; border-radius: 4px; cursor: pointer; }
.palette-item span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.palette-item small { flex-shrink: 0; color: var(--muted); font-size: 12px; }
.palette-item:hover { background: var(--hover); }
.palette-item[aria-selected="true"] { background: var(--accent-soft); color: var(--accent-text); }
.palette-item[aria-selected="true"] small { color: var(--accent-text); }
.palette-empty { padding: 24px 12px; text-align: center; color: var(--muted); }
.row.is-flash { animation: row-flash 1s ease-out; }
@keyframes row-flash { from { background: var(--accent-soft); } }

/* ── Pages ──────────────────────────────────────────── */

/* Page: server list */
.server-search { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-bottom: 24px; }
.server-search .input { flex: 1 1 260px; max-width: 420px; }
.count { display: inline-block; min-width: 24px; padding: 0 8px; border-radius: 999px; background: var(--line); color: var(--muted); font-size: 13px; text-align: center; vertical-align: 2px; }
.server-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); color: var(--text); }
.server-row:first-child { border-top: 0; }
a.server-row:hover .server-name { color: var(--accent-text); }
.server-icon { width: 40px; height: 40px; flex-shrink: 0; border-radius: 8px; overflow: hidden; display: flex; align-items: center; justify-content: center; background: var(--accent-soft); color: var(--accent-text); font-weight: 600; }
.server-icon img { width: 100%; height: 100%; object-fit: cover; }
.server-name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.server-go { display: inline-flex; align-items: center; gap: 4px; flex-shrink: 0; color: var(--accent-text); font-size: 13px; }
.server-row.is-unjoined .server-icon { background: var(--line); color: var(--muted); }
.server-row.is-unjoined .server-icon img { filter: grayscale(.4); }
.server-row.is-unjoined .btn { flex-shrink: 0; }

/* Page: overview */
.hero { display: flex; align-items: center; gap: 16px; margin: 0 0 24px; }
.hero img { width: 88px; height: 88px; flex-shrink: 0; object-fit: contain; margin: -12px 0 -8px; }
.hero .bot-status { margin-left: auto; align-self: flex-start; }
.hero-text { flex: 1; min-width: 0; }
.hero-text h2 { font-size: 22px; font-weight: 600; line-height: 1.35; overflow-wrap: anywhere; }
.hero-text p { margin-top: 4px; font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.hero-text p:empty { display: none; }
.attention { display: flex; flex-direction: column; gap: 8px; margin-bottom: 24px; }
.notice { display: flex; align-items: center; gap: 12px; padding: 8px 12px; border-radius: 8px; }
.notice--warn { background: var(--warn-soft); color: var(--warn); }
.notice span { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.notice a { flex-shrink: 0; text-decoration: underline; text-underline-offset: 3px; }
.ov-error { display: flex; align-items: center; gap: 12px; margin: 12px 0; padding: 12px 12px; border-radius: 8px; background: var(--bad-soft); color: var(--bad); }
.ov-error span { flex: 1; }
.mod-row { position: relative; display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.mod-row:first-child { border-top: 0; }
.mod-row-link { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; color: var(--text); }
.mod-row-link::after { content: ""; position: absolute; inset: 0; }
.mod-row:hover .mod-name { color: var(--accent-text); }
.mod-row .tog { position: relative; z-index: 1; }
.mod-icon { width: 36px; height: 36px; flex-shrink: 0; border-radius: 8px; display: flex; align-items: center; justify-content: center; background: var(--side); color: var(--text); }
.mod-row.is-on .mod-icon { background: var(--accent-soft); color: var(--accent-text); }
.mod-text { flex: 1; min-width: 0; }
.mod-name { display: block; }
.mod-summary { display: block; margin-top: 4px; font-size: 13px; line-height: 1.5; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mod-summary.is-warn { color: var(--warn); }
.mod-go { display: flex; color: var(--muted); }
.ov-modules[aria-busy="true"] .mod-summary { color: transparent; border-radius: 4px; background: var(--hover); }

/* Pages with a Discord preview: welcome, role panel */
.editor { display: grid; grid-template-columns: minmax(0, 680px) 320px; gap: 32px; align-items: start; }
.editor-form { min-width: 0; }
.editor-form > .list, .editor-form > .fold { margin-bottom: 24px; }
.row-text--split { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.fold { margin: 0 0 24px; }
.fold > summary { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; padding: 8px 0; font-size: 16px; font-weight: 600; cursor: pointer; list-style: none; }
.fold > summary::-webkit-details-marker { display: none; }
.fold > summary::before { content: ""; width: 7px; height: 7px; margin-right: 4px; border-right: 2px solid var(--accent-text); border-bottom: 2px solid var(--accent-text); transform: rotate(-45deg); transition: transform .15s; }
.fold[open] > summary::before { transform: rotate(45deg); }
.fold::details-content { opacity: 0; block-size: 0; overflow-y: clip; transition: content-visibility var(--dur-slow) allow-discrete, opacity var(--dur-slow) var(--ease-out), block-size var(--dur-slow) var(--ease-out); }
.fold[open]::details-content { opacity: 1; block-size: auto; }
.fold[open] > .list, .fold[open] > .item-list { margin-top: 4px; }
.upload-preview { display: block; width: min(100%, 440px); max-height: 220px; object-fit: contain; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); }
.variable-tools { display: flex; flex-wrap: wrap; gap: 8px; }

.message-preview { position: sticky; top: 24px; min-width: 0; max-height: calc(100dvh - 48px); overflow-y: auto; }
.message-preview > summary { padding: 0 0 8px; font-size: 16px; font-weight: 600; cursor: pointer; }
.preview-content { padding: 0; }
.preview-disclaimer { margin: 12px 0 0; font-size: 12px; color: var(--muted); }
.discord-preview { padding: 14px; border-radius: 10px; background: #313338; color: #E9E9EC; font-size: 13px; overflow-wrap: anywhere; }
.preview-author { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.preview-author img { border-radius: 50%; }
.preview-bot { padding: 1px 4px; border-radius: 3px; background: #5865F2; color: #FFFFFF; font-size: 10px; }
.preview-embed { display: flow-root; padding: 12px 14px; border-left: 4px solid #EB8BAC; border-radius: 4px; background: #2B2D31; }
.preview-title { display: block; color: #F3F3F5; }
.preview-body { margin-top: 6px; white-space: pre-wrap; line-height: 1.7; }
.preview-image-thumb, .preview-image-large { display: flex; align-items: center; justify-content: center; min-height: 64px; margin-top: 10px; padding: 10px; border: 1px dashed #92949C; border-radius: 6px; background: #43454C; color: #E1DCE0; font-size: 12px; text-align: center; }
.preview-image-thumb { max-width: 100px; }
.preview-image-large { min-height: 100px; }
.preview-notice { margin: 8px 0; font-size: 12.5px; }
.preview-role-buttons { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.preview-role-button { padding: 6px 10px; border-radius: 5px; background: #4E5058; color: #FFFFFF; font-size: 12.5px; }

.rr-list { display: flex; flex-direction: column; gap: 8px; }
.rr-list:empty { display: none; }
.rr-row { display: grid; grid-template-columns: 44px minmax(0, 1fr) 36px; align-items: center; gap: 8px; }
.rr-row .search-select { width: 100%; }
.lv-channel-row > .row { border-top: 1px solid var(--line); }
.lv-rewards { display: flex; flex-direction: column; margin-top: 12px; }
.lv-rewards:empty { display: none; }
.lv-reward { position: relative; display: grid; grid-template-columns: 104px 12px minmax(0, 1fr) 36px; align-items: center; column-gap: 8px; padding-bottom: 16px; }
.lv-reward:last-child { padding-bottom: 0; }
.lv-reward:not(:last-child)::before { content: ""; position: absolute; left: 20px; top: var(--control-h); bottom: 0; border-left: 1px solid var(--field-line); }
.lv-reward .num-field { width: 100%; min-width: 0; }
.lv-reward .search-select { width: 100%; }
.lv-reward .num { font-variant-numeric: tabular-nums; }
.lv-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--muted); outline: 1px solid var(--img-line); outline-offset: -1px; }
.lv-note { grid-column: 3 / -1; margin-top: 4px; font-size: 13px; color: var(--warn); }
.lv-note--bad { color: var(--bad); }
.emoji-trigger { width: 44px; height: var(--control-h); display: flex; align-items: center; justify-content: center; border: 1px solid var(--field-line); border-radius: 8px; background: var(--field); font-size: 16px; cursor: pointer; }
.emoji-trigger:hover { border-color: var(--accent); background: var(--accent-soft); }
.emoji-trigger img { width: 22px; height: 22px; }
.ep-placeholder { opacity: .4; }
.emoji-picker { position: fixed; z-index: 100; display: flex; flex-direction: column; gap: 8px; width: min(300px, calc(100vw - 24px)); max-height: min(340px, calc(100dvh - 24px)); padding: 8px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); box-shadow: var(--shadow-pop); }
.emoji-picker .input { width: 100%; }
.ep-tabs { display: flex; align-self: stretch; }
.ep-tabs .seg-option { flex: 1; }
.ep-grid { flex: 1; min-height: 0; overflow-x: hidden; overflow-y: auto; display: grid; grid-template-columns: repeat(8, 1fr); gap: 4px; }
.ep-item { width: 100%; height: 32px; display: flex; align-items: center; justify-content: center; padding: 0; border: 0; border-radius: 4px; background: none; font-size: 16px; cursor: pointer; }
.ep-item:hover { background: var(--accent-soft); }
.ep-item img { width: 22px; height: 22px; }
.ep-empty { grid-column: 1 / -1; padding: 24px 8px; text-align: center; color: var(--muted); font-size: 13px; }

/* Pages: automod, moderation */
.duration-field { display: flex; flex-direction: column; align-items: flex-start; }
.case-list { display: flex; flex-direction: column; }
.case-list:has(.case) { border-block: 1px solid var(--line); }
.case { padding: 12px 0; border-top: 1px solid var(--line); }
.case:first-child { border-top: 0; }
.case-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 12px; margin-bottom: 4px; }
.case-body { font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.chip--warn, .chip--mute { background: var(--warn-soft); color: var(--warn); }
.chip--kick, .chip--ban, .chip--tempban { background: var(--bad-soft); color: var(--bad); }
.chip--unban, .chip--unmute { background: var(--ok-soft); color: var(--ok); }

/* Pages: giveaway, leveling, general, commands */
#gw-end { width: 240px; margin-top: 8px; }
.lb-list { display: flex; flex-direction: column; border-block: 1px solid var(--line); }
.lb-row { display: flex; align-items: center; gap: 12px; padding: 8px 0; border-top: 1px solid var(--line); }
.lb-row:first-child { border-top: 0; }
.lb-rank { width: 32px; flex-shrink: 0; text-align: center; color: var(--muted); }
.lb-name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lb-stat { flex-shrink: 0; font-size: 13px; color: var(--muted); }
.lb-row--top .lb-rank { font-size: 16px; }
.lb-row--top .lb-name { font-size: 16px; }
.command-search .select { width: 150px; }
.cmd-group > summary { justify-content: flex-start; }
/* The group name is a bare text node, so this button counts as :first-child; say auto with enough weight to win. */
.btn--text.cmd-bulk { margin-inline-start: auto; }

/* Page: global settings */
.settings-panel[hidden] { display: none; }
.section-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; margin-bottom: 16px; }
.stat { padding: 12px 16px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); min-width: 0; }
.stat-value { font-size: 22px; overflow-wrap: anywhere; }
.stat-label { font-size: 13px; color: var(--muted); }
.chip--static { padding-right: 8px; }
.item-list { display: flex; flex-direction: column; margin-top: 8px; }
.item-list:has(.item) { border-block: 1px solid var(--line); }
.item { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 0; border-top: 1px solid var(--line); font-size: 13px; }
.item:first-child { border-top: 0; }
.item-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-meta { flex-shrink: 0; color: var(--muted); }
.avatar-prev { width: 72px; height: 72px; flex-shrink: 0; border-radius: 50%; object-fit: cover; border: 1px solid var(--line); background: var(--bg); }
.inline-fields { display: flex; flex-wrap: wrap; gap: 8px; }
.inline-fields .input { flex: 1 1 160px; width: auto; }
.draft-hint { margin-top: 8px; font-size: 13px; color: var(--accent-text); }
.draft-hint:empty { display: none; }

/* Login gate and error page */
.gate-body { display: flex; align-items: center; justify-content: center; min-height: 100dvh; padding: 24px 16px; }
.gate { width: 100%; max-width: 440px; padding: 32px 24px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); text-align: center; }

/* A blurred, non-interactive sketch of the console sits behind the login card. */
.gate-backdrop { position: fixed; inset: -24px; z-index: 0; display: flex; overflow: hidden; pointer-events: none; user-select: none; filter: blur(10px) saturate(.8); opacity: .9; }
.gate-backdrop::after { content: ""; position: absolute; inset: 0; background: var(--bg); opacity: .35; }
.gate-backdrop ~ .gate { position: relative; z-index: 1; box-shadow: var(--shadow-pop); animation: gate-in .4s cubic-bezier(.34, 1.3, .64, 1) both; }
@keyframes gate-in { from { opacity: 0; transform: scale(.94) translateY(12px); } }
.fake-side { width: 252px; flex-shrink: 0; display: flex; flex-direction: column; gap: 6px; padding: 36px 10px 12px 34px; background: var(--side); border-right: 1px solid var(--line); }
.fake-switcher { display: flex; align-items: center; gap: 10px; padding: 8px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); }
.fake-search { height: 32px; margin-bottom: 6px; border: 1px solid var(--line); border-radius: 9px; background: var(--field); }
.fake-item { display: flex; align-items: center; gap: 10px; height: 34px; padding: 0 10px; border-radius: 8px; }
.fake-item.is-current { background: var(--cur); box-shadow: var(--shadow-sm); }
.fake-dot { width: 7px; height: 7px; flex-shrink: 0; border-radius: 50%; background: var(--ok); }
.fake-line { display: block; width: 70%; height: 10px; border-radius: 5px; background: var(--hover); }
.fake-line--group { width: 40%; height: 8px; margin: 14px 10px 2px; }
.fake-line--title { width: 50%; height: 12px; background: var(--field-line); opacity: .5; }
.fake-main { flex: 1; min-width: 0; background: var(--bg); }
.fake-topbar { height: 80px; padding: 50px 32px 0; border-bottom: 1px solid var(--line); }
.fake-content { max-width: 1184px; margin: 0 auto; padding: 28px 32px; }
.fake-content > .fake-line--group { margin: 26px 0 12px; }
.fake-hero { display: flex; align-items: center; gap: 18px; padding: 18px 22px; border: 1px solid var(--line); border-radius: 16px; background: var(--panel); }
.fake-avatar { width: 80px; height: 80px; flex-shrink: 0; border-radius: 50%; background: var(--accent-soft); }
.fake-lines { flex: 1; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.fake-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.fake-card { display: flex; align-items: flex-start; gap: 12px; padding: 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
.fake-tile { width: 32px; height: 32px; flex-shrink: 0; border-radius: 9px; background: var(--accent-soft); }
.fake-switch { width: 36px; height: 20px; flex-shrink: 0; border-radius: 10px; background: var(--accent); }
.gate-art { width: 160px; height: 160px; object-fit: contain; margin: -8px auto 8px; display: block; }
.gate h1 { font-size: 22px; margin-bottom: 8px; }
.gate p { color: var(--muted); }
.gate-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 24px; }
.btn--discord { --btn-fg: #FFFFFF; background: #4752C4; }
.gate-notes { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 12px; margin-top: 16px; font-size: 13px; color: var(--muted); }
.gate-notes li { display: inline-flex; align-items: center; gap: 4px; }
.gate-notes .icon { color: var(--ok); }
.gate-error { margin: 16px 0 0; padding: 12px 12px; border-radius: 8px; background: var(--bad-soft); color: var(--bad); font: 13px/1.6 ui-monospace, monospace; text-align: left; white-space: pre-wrap; overflow-wrap: anywhere; }

/* ── Responsive ─────────────────────────────────────── */
@media (max-width: 1199px) {
    .editor { grid-template-columns: minmax(0, 1fr); }
    .message-preview { position: static; max-height: none; }
}
@media (max-width: 1079px) {
    .content { padding: 32px 32px 140px; }
    .unsaved-bar { left: calc(var(--side-w) + 32px); width: min(var(--content-w), calc(100vw - var(--side-w) - 64px)); }
}
@media (max-width: 859px) {
    :root { --control-h: 44px; }
    .tog { width: 48px; height: 28px; }
    .tog--head { width: auto; }
    .tog--head .tog-track { width: 48px; }
    .tog-track::after { top: 2px; left: 2px; width: 24px; height: 24px; }
    .tog input { inset: -8px 0; }
    .tog input:checked + .tog-track::after { transform: translateX(20px); }
    .nav-item { min-height: 44px; }
    .brand-row { min-height: 44px; }
    .search-btn { min-height: 44px; }
    .switcher-item { min-height: 44px; }
    .btn--icon { min-width: 44px; min-height: 44px; }
    .btn--sm { min-height: 44px; }
    .user-logout { align-items: center; justify-content: center; min-width: 44px; min-height: 44px; }
    .theme-switch button { position: relative; width: 44px; height: 36px; }
    .theme-switch button::after { content: ""; position: absolute; inset: -4px 0; }
    .shell { grid-template-columns: minmax(0, 1fr); }
    .sidebar {
        position: fixed;
        inset: 0 auto 0 0;
        z-index: 80;
        max-width: calc(100vw - 48px);
        transform: translateX(-100%);
        visibility: hidden;
        transition: transform var(--dur-slow) var(--ease-out), visibility 0s linear var(--dur-slow);
    }
    .shell.is-drawer-open .sidebar { transform: none; visibility: visible; transition: transform var(--dur-slow) var(--ease-out); }
    .shell.is-drawer-open .drawer-backdrop { display: block; position: fixed; inset: 0; z-index: 75; background: var(--scrim); }
    .menu-btn { display: flex; align-items: center; justify-content: center; min-width: 44px; min-height: 44px; flex-shrink: 0; border: 0; border-radius: 8px; background: var(--side); color: var(--text); cursor: pointer; }
    .topbar { display: flex; min-height: 52px; padding: 4px 16px; }
    .content { padding: 24px 16px calc(140px + env(safe-area-inset-bottom)); }
    .row { flex-direction: column; align-items: stretch; gap: 8px; }
    .row-control { flex-wrap: wrap; }
    .row-control > .input, .row-control > .select, .row-control > .search-select, .row-control > .textarea, .row-control > .limit-field { width: 100%; }
    .row--switch { flex-direction: row; align-items: center; }
    /* A sentence of fields ([5 秒] 内发 [5 条]) stays on one line; its fields shrink to 96px first. */
    .row--sentence .row-control { flex-wrap: nowrap; }
    .hero { display: grid; grid-template-columns: 64px minmax(0, 1fr); align-items: start; gap: 4px 12px; }
    .hero img { width: 64px; height: 64px; margin: 0; }
    .hero .bot-status { grid-column: 2; justify-self: start; margin: 0; }
    .rr-row { grid-template-columns: 44px minmax(0, 1fr) 44px; }
    .lv-reward { grid-template-columns: 96px 12px minmax(0, 1fr) 44px; }
    .seg { display: grid; width: 100%; grid-auto-columns: minmax(0, 1fr); }
    .seg-option { padding: 0 4px; }
    .unsaved-bar { left: 0; right: 0; bottom: 0; width: auto; border-radius: 0; padding-bottom: max(8px, env(safe-area-inset-bottom)); }
    .fake-side { display: none; }
    .fake-topbar, .fake-content { padding-left: 16px; padding-right: 16px; }
}
@view-transition { navigation: auto; }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: 180ms; }
@media (prefers-reduced-motion: reduce) {
    @view-transition { navigation: none; }
    ::view-transition-group(*), ::view-transition-old(root), ::view-transition-new(root) { animation: none; }
    .fold::details-content { transition: none; }
    /* The #_ only adds weight: this has to beat every class-level animation in the sheet. */
    *:not(#_), *:not(#_)::before, *:not(#_)::after { animation: none; transition: none; }
    .unsaved-bar, .unsaved-bar.is-open, .sidebar, .shell.is-drawer-open .sidebar, .tog-track, .tog-track::after { transition: none; }
    .unsaved-bar.is-shaking, .page[aria-busy="true"] .list { animation: none; }
    .row.is-flash { animation: none; background: var(--accent-soft); }
}
