:root {
    color-scheme: dark;
    --bg: #090b0e;
    --sidebar: #0d1014;
    --surface: #12161b;
    --surface-2: #181d23;
    --surface-3: #20262e;
    --border: #292f38;
    --border-soft: #20252c;
    --text: #f5f7fa;
    --muted: #929ba8;
    --muted-2: #69727f;
    --red: #ed3348;
    --red-bright: #ff4a5d;
    --red-soft: rgba(237, 51, 72, 0.12);
    --green: #36c68b;
    --green-soft: rgba(54, 198, 139, 0.12);
    --amber: #e6ad4a;
    --amber-soft: rgba(230, 173, 74, 0.12);
    --blue: #5b9df0;
    --blue-soft: rgba(91, 157, 240, 0.12);
    --danger: #ff5266;
    --radius: 8px;
    --shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; letter-spacing: 0; }
html, body { width: 100%; min-width: 320px; height: 100%; margin: 0; background: var(--bg); color: var(--text); }
body { overflow: hidden; font-size: 14px; line-height: 1.45; }
button, input, select, textarea { font: inherit; letter-spacing: 0; }
button { color: inherit; }
img { display: block; max-width: 100%; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: 27px; line-height: 1.15; }
h2 { font-size: 20px; line-height: 1.2; }
h3 { font-size: 16px; line-height: 1.3; }
code { color: #ff8a98; background: var(--red-soft); border-radius: 4px; padding: 1px 5px; }
.hidden { display: none !important; }
.mobile-only { display: none !important; }
.muted { color: var(--muted); }
.eyebrow { color: var(--muted-2); font-size: 10px; line-height: 1.2; font-weight: 800; text-transform: uppercase; }

.login-shell { min-height: 100dvh; display: grid; place-items: center; padding: 24px; background: var(--bg); }
.login-panel { width: min(410px, 100%); display: grid; gap: 22px; padding: 34px; background: var(--surface); border: 1px solid var(--border); border-top: 3px solid var(--red); border-radius: var(--radius); box-shadow: var(--shadow); }
.login-logo { width: 68px; height: 68px; border-radius: 50%; object-fit: cover; border: 2px solid var(--border); }
.login-panel h1 { margin-top: 5px; }
.login-panel .muted { margin-top: 8px; }
.form-error { padding: 10px 12px; color: #ff9aa6; background: var(--red-soft); border: 1px solid rgba(237, 51, 72, 0.3); border-radius: 6px; }

.app-shell { display: grid; grid-template-columns: 264px minmax(0, 1fr); height: 100dvh; }
.sidebar { min-width: 0; display: flex; flex-direction: column; background: var(--sidebar); border-right: 1px solid var(--border-soft); overflow: hidden; z-index: 30; }
.brand { height: 74px; flex: 0 0 74px; display: flex; align-items: center; gap: 11px; padding: 0 17px; border-bottom: 1px solid var(--border-soft); }
.brand-logo { width: 39px; height: 39px; border-radius: 50%; object-fit: cover; border: 1px solid #3b434d; }
.brand > div { min-width: 0; display: flex; align-items: baseline; gap: 6px; }
.brand strong { font-size: 16px; }
.brand span { color: var(--muted); font-weight: 600; }
.brand .icon-button { margin-left: auto; }
.nav { flex: 1; overflow-y: auto; padding: 15px 11px 24px; scrollbar-width: thin; scrollbar-color: #343b45 transparent; }
.nav-label { margin: 19px 9px 7px; color: #646d79; font-size: 10px; font-weight: 800; text-transform: uppercase; }
.nav-label:first-child { margin-top: 2px; }
.nav-item { width: 100%; min-height: 39px; display: flex; align-items: center; gap: 11px; padding: 8px 10px; border: 0; border-radius: 6px; background: transparent; color: #aeb6c1; cursor: pointer; text-align: left; transition: color 140ms ease, background 140ms ease; }
.nav-item:hover { color: var(--text); background: var(--surface-2); }
.nav-item.active { color: #fff; background: var(--red-soft); box-shadow: inset 3px 0 var(--red); }
.nav-item svg { width: 18px; height: 18px; flex: 0 0 18px; }
.nav-item span:not(.nav-badge) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-badge { margin-left: auto; min-width: 20px; height: 20px; display: inline-grid; place-items: center; padding: 0 6px; border-radius: 10px; background: var(--red); color: white; font-size: 11px; font-weight: 800; }
.sidebar-footer { min-height: 68px; display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-top: 1px solid var(--border-soft); }
.mini-status { min-width: 0; flex: 1; display: flex; align-items: center; gap: 10px; }
.mini-status > div { min-width: 0; display: grid; }
.mini-status strong, .mini-status span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-status strong { font-size: 13px; }
.mini-status div span { color: var(--muted); font-size: 11px; }

.main { min-width: 0; height: 100dvh; display: grid; grid-template-rows: 74px minmax(0, 1fr); overflow: hidden; }
.topbar { min-width: 0; display: flex; align-items: center; gap: 14px; padding: 0 25px; background: rgba(13, 16, 20, 0.97); border-bottom: 1px solid var(--border-soft); }
.page-heading { min-width: 0; flex: 1; }
.page-heading h2, .page-heading p { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.page-heading p { margin-top: 3px; color: var(--muted); font-size: 12px; }
.topbar-actions { display: flex; align-items: center; gap: 9px; }
.content { min-width: 0; min-height: 0; overflow-y: auto; scrollbar-width: thin; scrollbar-color: #39414c transparent; }
.view { display: none; width: min(1480px, 100%); margin: 0 auto; padding: 27px 30px 45px; }
.view.active { display: block; }

.icon-button { width: 38px; height: 38px; flex: 0 0 38px; display: inline-grid; place-items: center; padding: 0; border: 1px solid var(--border); border-radius: 6px; background: var(--surface-2); color: #c8ced6; cursor: pointer; transition: border 140ms ease, background 140ms ease, color 140ms ease; }
.icon-button:hover { color: #fff; border-color: #454d58; background: var(--surface-3); }
.icon-button.small { width: 32px; height: 32px; flex-basis: 32px; }
.icon-button svg { width: 17px; height: 17px; }
.button { min-height: 38px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 8px 14px; border: 1px solid transparent; border-radius: 6px; font-weight: 700; cursor: pointer; white-space: nowrap; transition: background 140ms ease, border 140ms ease, opacity 140ms ease; }
.button svg { width: 17px; height: 17px; }
.button.primary { background: var(--red); color: white; }
.button.primary:hover { background: var(--red-bright); }
.button.secondary { background: var(--surface-2); border-color: var(--border); color: #d8dde4; }
.button.secondary:hover { background: var(--surface-3); border-color: #454d58; }
.button.danger { background: var(--red-soft); border-color: rgba(237, 51, 72, 0.34); color: #ff8491; }
.button.danger:hover { background: rgba(237, 51, 72, 0.2); }
.button.wide { width: 100%; }
.button:disabled, .icon-button:disabled { opacity: 0.5; cursor: wait; }
.button.loading svg, .icon-button.loading svg { animation: spin 800ms linear infinite; }
.button-row { min-width: 0; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
@keyframes spin { to { transform: rotate(360deg); } }

.status-dot { width: 8px; height: 8px; flex: 0 0 8px; border-radius: 50%; background: var(--muted-2); box-shadow: 0 0 0 3px rgba(105, 114, 127, 0.13); }
.status-dot.online { background: var(--green); box-shadow: 0 0 0 3px var(--green-soft); }
.connection-badge { height: 30px; display: inline-flex; align-items: center; gap: 8px; padding: 0 11px; border: 1px solid var(--border); border-radius: 15px; color: var(--muted); background: var(--surface); font-size: 12px; font-weight: 700; }
.connection-badge.online { color: #8ee1bd; border-color: rgba(54, 198, 139, 0.27); background: var(--green-soft); }
.connection-badge.online .status-dot { background: var(--green); box-shadow: none; }
.dirty-indicator { display: inline-flex; align-items: center; gap: 7px; color: var(--amber); font-size: 12px; font-weight: 700; }
.dirty-indicator > span { width: 7px; height: 7px; border-radius: 50%; background: var(--amber); }

.status-hero { min-height: 126px; display: flex; align-items: center; justify-content: space-between; gap: 24px; margin: -27px -30px 25px; padding: 24px 30px; background: #101419; border-bottom: 1px solid var(--border); }
.bot-identity { min-width: 0; display: flex; align-items: center; gap: 16px; }
.bot-identity img { width: 67px; height: 67px; flex: 0 0 67px; border-radius: 50%; object-fit: cover; border: 2px solid #3a424d; }
.bot-identity h3 { margin-top: 4px; font-size: 21px; }
.bot-identity .muted { margin-top: 4px; }
.hero-actions { display: flex; gap: 9px; }
.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.metric-card { min-width: 0; min-height: 112px; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 9px; padding: 17px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.metric-card > div { min-width: 0; }
.metric-card .metric-label { color: var(--muted); font-size: 12px; }
.metric-card strong { display: block; margin-top: 9px; font-size: 22px; line-height: 1; overflow: hidden; text-overflow: ellipsis; }
.metric-card small { display: block; margin-top: 8px; color: var(--muted-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.metric-icon { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 6px; color: var(--blue); background: var(--blue-soft); }
.metric-icon.green { color: var(--green); background: var(--green-soft); }
.metric-icon.amber { color: var(--amber); background: var(--amber-soft); }
.metric-icon.red { color: #ff7182; background: var(--red-soft); }
.metric-icon svg { width: 18px; height: 18px; }
.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(320px, 0.75fr); gap: 14px; margin-top: 14px; }

.surface { min-width: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.section-header { min-width: 0; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 16px 18px; border-bottom: 1px solid var(--border-soft); }
.section-header > div:first-child { min-width: 0; }
.section-header h3 + p, .section-header .eyebrow + h3 { margin-top: 4px; }
.section-header p:not(.eyebrow) { color: var(--muted); font-size: 12px; }
.section-header > svg { width: 19px; color: var(--muted); }
.service-list, .issue-list { padding: 7px 18px 12px; }
.service-row, .issue-row { min-width: 0; display: flex; align-items: center; gap: 11px; padding: 11px 0; border-bottom: 1px solid var(--border-soft); }
.service-row:last-child, .issue-row:last-child { border-bottom: 0; }
.service-row > div, .issue-row > div { min-width: 0; flex: 1; }
.service-row strong, .issue-row strong { display: block; font-size: 13px; }
.service-row small, .issue-row small { display: block; margin-top: 2px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.state-pill { display: inline-flex; align-items: center; min-height: 24px; padding: 3px 8px; border: 1px solid var(--border); border-radius: 12px; color: var(--muted); background: var(--surface-2); font-size: 11px; font-weight: 800; white-space: nowrap; }
.state-pill.ok { color: #86dfb7; background: var(--green-soft); border-color: rgba(54, 198, 139, 0.25); }
.state-pill.warning { color: #f1c46f; background: var(--amber-soft); border-color: rgba(230, 173, 74, 0.25); }
.state-pill.error { color: #ff8d99; background: var(--red-soft); border-color: rgba(237, 51, 72, 0.26); }

.view-intro, .editor-heading { min-width: 0; display: flex; align-items: center; justify-content: space-between; gap: 22px; margin-bottom: 19px; }
.view-intro > div:first-child, .editor-heading > div:first-child { min-width: 0; }
.view-intro h3, .editor-heading h3 { font-size: 18px; }
.view-intro p, .editor-heading p { margin-top: 5px; color: var(--muted); }
.editor-heading { margin-top: 25px; }
.form-page { display: block; }
.sub-page { margin-top: 36px; padding-top: 28px; border-top: 1px solid var(--border); }
.form-section { margin-bottom: 14px; }
.form-section > .settings-grid { padding: 18px; }
.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 17px 18px; }
.settings-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.settings-grid.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; }

.field { min-width: 0; display: grid; align-content: start; gap: 7px; border: 0; margin: 0; padding: 0; }
.field > span:first-child, .field legend { color: #d8dde4; font-size: 12px; font-weight: 750; }
.field small, .toggle-field small { color: var(--muted-2); font-size: 11px; line-height: 1.4; }
input, select, textarea { width: 100%; min-width: 0; border: 1px solid #343b45; border-radius: 6px; outline: none; background: #0d1115; color: var(--text); transition: border 140ms ease, box-shadow 140ms ease; }
input, select { min-height: 39px; padding: 8px 10px; }
textarea { resize: vertical; min-height: 76px; padding: 10px; line-height: 1.5; }
select[multiple] { min-height: 112px; padding: 5px; }
select[multiple] option { padding: 6px 7px; border-radius: 4px; }
input:focus, select:focus, textarea:focus { border-color: var(--red); box-shadow: 0 0 0 3px var(--red-soft); }
input[type="color"] { min-height: 39px; padding: 4px; cursor: pointer; }
.input-with-icon, .search { min-width: 0; position: relative; display: flex; align-items: center; }
.input-with-icon > svg, .search > svg { position: absolute; left: 11px; width: 16px; height: 16px; color: var(--muted-2); pointer-events: none; }
.input-with-icon input, .search input { padding-left: 35px; }
.input-suffix { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: stretch; }
.input-suffix input { border-radius: 6px 0 0 6px; }
.input-suffix span { display: grid; place-items: center; min-width: 54px; padding: 0 9px; border: 1px solid #343b45; border-left: 0; border-radius: 0 6px 6px 0; color: var(--muted); background: var(--surface-2); font-size: 11px; }
.number-pair { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 8px; }
.number-pair span { color: var(--muted); font-size: 11px; }
.field-row { display: flex; align-items: flex-start; gap: 12px; }
.field-row .grow { flex: 1; }
.color-field { width: 80px; flex: 0 0 80px; }
.toggle-field { min-width: 0; min-height: 64px; position: relative; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 11px 12px; border: 1px solid var(--border); border-radius: 6px; background: #101419; cursor: pointer; }
.toggle-field > span:first-child { min-width: 0; display: grid; gap: 3px; }
.toggle-field strong { font-size: 12px; }
.toggle-field input[type="checkbox"] { width: 1px; height: 1px; min-height: 0; position: absolute; inset: 0 auto auto 0; margin: 0; padding: 0; overflow: hidden; border: 0; opacity: 0; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }
.toggle-field:focus-within { border-color: var(--red); box-shadow: 0 0 0 3px var(--red-soft); }
.toggle { width: 38px; height: 22px; flex: 0 0 38px; position: relative; border-radius: 12px; background: #343b45; transition: background 140ms ease; }
.toggle::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform 140ms ease; }
.toggle-field input:checked + .toggle { background: var(--red); }
.toggle-field input:checked + .toggle::after { transform: translateX(16px); }
.compact-toggle { width: 40px; min-height: 36px; justify-content: center; gap: 0; padding: 0; border: 0; background: transparent; }
.compact-toggle:focus-within { border-color: transparent; }
.form-page.is-dirty .button[type="submit"] { box-shadow: 0 0 0 3px var(--red-soft); }

.toolbar { min-width: 0; min-height: 52px; display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius); background: #0f1317; }
.toolbar .search { width: min(340px, 100%); }
.toolbar select { width: auto; max-width: 220px; }
.segmented { display: inline-flex; padding: 3px; border: 1px solid var(--border); border-radius: 6px; background: #0b0f13; }
.segmented button { min-height: 30px; padding: 5px 10px; border: 0; border-radius: 4px; color: var(--muted); background: transparent; cursor: pointer; font-size: 12px; font-weight: 700; }
.segmented button.active { color: #fff; background: var(--surface-3); }
.summary-strip { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1px; margin-bottom: 14px; overflow: hidden; border: 1px solid var(--border); border-radius: var(--radius); background: var(--border); }
.summary-item { padding: 14px 16px; background: var(--surface); }
.summary-item span { color: var(--muted); font-size: 11px; }
.summary-item strong { display: block; margin-top: 4px; font-size: 20px; }
.summary-item.ok strong { color: var(--green); }
.summary-item.warning strong { color: var(--amber); }
.summary-item.error strong { color: var(--danger); }
.check-groups { display: grid; gap: 12px; }
.check-group { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.check-group-header { display: flex; align-items: center; justify-content: space-between; padding: 13px 16px; border-bottom: 1px solid var(--border-soft); }
.check-list { padding: 2px 16px; }
.check-row { display: grid; grid-template-columns: 22px minmax(180px, 0.55fr) minmax(0, 1fr); align-items: center; gap: 10px; min-height: 50px; border-bottom: 1px solid var(--border-soft); }
.check-row:last-child { border-bottom: 0; }
.check-row svg { width: 17px; height: 17px; }
.check-row.ok svg { color: var(--green); }
.check-row.warning svg { color: var(--amber); }
.check-row.error svg { color: var(--danger); }
.check-row span { color: var(--muted); }

.stack { display: grid; gap: 12px; }
.role-group, .custom-command { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); overflow: visible; }
.editor-card-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 13px 15px; border-bottom: 1px solid var(--border-soft); }
.editor-card-header > div { min-width: 0; }
.editor-card-header strong { display: block; }
.editor-card-header small { color: var(--muted); }
.editor-card-body { padding: 16px; }
.role-list { display: grid; gap: 8px; margin-top: 16px; }
.role-row { min-width: 0; display: grid; grid-template-columns: minmax(130px, 1fr) 112px minmax(170px, 1fr) 142px 38px; gap: 8px; align-items: end; padding: 10px; border: 1px solid var(--border-soft); border-radius: 6px; background: #0f1317; }
.role-row .field > span:first-child { font-size: 10px; color: var(--muted); }
.emoji-control { position: relative; }
.emoji-inline { display: grid; grid-template-columns: minmax(0, 1fr) 39px; gap: 5px; }
.emoji-inline input { padding-left: 7px; padding-right: 7px; text-align: center; }
.emoji-button { width: 100%; min-height: 39px; display: grid; place-items: center; border: 1px solid #343b45; border-radius: 6px; background: #0d1115; cursor: pointer; font-size: 19px; }
.emoji-menu { width: 310px; max-width: calc(100vw - 42px); position: absolute; top: calc(100% + 6px); right: 0; z-index: 20; padding: 9px; border: 1px solid #3a424c; border-radius: var(--radius); background: #171c22; box-shadow: var(--shadow); }
.emoji-menu.open-up { top: auto; bottom: calc(100% + 6px); }
.emoji-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 3px; max-height: 230px; overflow-y: auto; }
.emoji-grid button { width: 31px; height: 31px; display: grid; place-items: center; border: 0; border-radius: 4px; background: transparent; cursor: pointer; font-size: 18px; }
.emoji-grid button:hover { background: var(--surface-3); }
.color-options { min-height: 39px; display: flex; align-items: center; gap: 7px; }
.color-option { width: 24px; height: 24px; flex: 0 0 24px; border: 2px solid transparent; border-radius: 5px; cursor: pointer; box-shadow: inset 0 0 0 1px rgba(255,255,255,0.14); }
.color-option.active { border-color: #fff; box-shadow: 0 0 0 2px #0d1115, 0 0 0 3px #fff; }
.color-option.blue { background: #5865f2; }
.color-option.gray { background: #4e5058; }
.color-option.green { background: #248046; }
.color-option.red { background: #da373c; }
.add-row-button { margin-top: 12px; }

.command-list { display: grid; gap: 8px; }
.command-row { min-width: 0; display: grid; grid-template-columns: 40px minmax(140px, 0.55fr) minmax(220px, 1.2fr) 150px 150px 38px; align-items: center; gap: 10px; padding: 11px 12px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); }
.command-row.disabled { opacity: 0.58; }
.command-row .command-name strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.command-row .command-name small { color: var(--muted); }
.command-row input, .command-row select { min-height: 36px; }
.command-details { grid-column: 2 / -1; display: none; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; padding-top: 10px; border-top: 1px solid var(--border-soft); }
.command-row.expanded .command-details { display: grid; }
.command-row.hidden-by-filter { display: none; }

.table-wrap { width: 100%; overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
table { width: 100%; border-collapse: collapse; }
th, td { min-width: 90px; padding: 11px 13px; border-bottom: 1px solid var(--border-soft); text-align: left; vertical-align: middle; }
th { color: var(--muted); background: #0f1317; font-size: 10px; font-weight: 800; text-transform: uppercase; }
td { font-size: 12px; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: rgba(255,255,255,0.018); }
.member-cell { display: flex; align-items: center; gap: 9px; min-width: 190px; }
.member-cell img { width: 30px; height: 30px; flex: 0 0 30px; border-radius: 50%; object-fit: cover; }
.member-cell > div { min-width: 0; }
.member-cell strong, .member-cell small { display: block; max-width: 210px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.member-cell small { color: var(--muted); }
.table-input { width: 82px; min-height: 34px; }
.row-actions { display: flex; justify-content: flex-end; gap: 6px; }
.action-chip { display: inline-flex; padding: 3px 7px; border-radius: 4px; color: #d8dde4; background: var(--surface-3); font-size: 10px; font-weight: 800; text-transform: uppercase; }
.action-chip.warn, .action-chip.mute { color: #f1c46f; background: var(--amber-soft); }
.action-chip.ban { color: #ff8d99; background: var(--red-soft); }
.action-chip.kick, .action-chip.unmute { color: #84bafa; background: var(--blue-soft); }

.inline-states { display: flex; gap: 8px; padding: 0 18px 18px; flex-wrap: wrap; }
.composer-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(330px, 0.72fr); gap: 25px; align-items: start; }
.composer-fields { min-width: 0; display: grid; gap: 15px; }
.discord-preview { position: sticky; top: 20px; min-width: 0; padding: 18px; border: 1px solid var(--border); border-radius: var(--radius); background: #313338; }
.discord-preview > .eyebrow { margin-bottom: 17px; color: #b5bac1; }
.preview-message { display: grid; grid-template-columns: 40px minmax(0, 1fr); gap: 11px; color: #dbdee1; }
.preview-message > img { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; }
.preview-message > div > div:first-child { display: flex; align-items: center; gap: 6px; }
.preview-message small { color: #949ba4; font-size: 10px; }
.app-tag { padding: 1px 4px; border-radius: 3px; color: white; background: #5865f2; font-size: 9px; font-weight: 800; }
#previewContent { margin-top: 4px; white-space: pre-wrap; }
.preview-embed { position: relative; display: grid; gap: 8px; margin-top: 6px; padding: 12px 13px 9px 16px; overflow: hidden; border-radius: 4px; background: #2b2d31; }
.preview-embed::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 4px; background: var(--red); }
.preview-embed strong { color: #f2f3f5; }
.preview-embed p { color: #dbdee1; white-space: pre-wrap; }
.preview-embed img { width: 100%; max-height: 260px; object-fit: cover; border-radius: 4px; }
.preview-embed small { padding-top: 2px; }

.system-view { padding-bottom: 20px; }
.log-section { margin-top: 15px; }
.log-section > .section-header { padding-left: 0; padding-right: 0; border-top: 1px solid var(--border); border-bottom: 0; }
.search.compact { width: 220px; }
.log-output { height: min(470px, calc(100dvh - 360px)); min-height: 270px; margin: 0; padding: 15px; overflow: auto; border: 1px solid var(--border); border-radius: var(--radius); background: #080a0d; color: #c6cdd6; font-family: "Cascadia Code", "SFMono-Regular", Consolas, monospace; font-size: 11px; line-height: 1.65; white-space: pre-wrap; word-break: break-word; scrollbar-width: thin; scrollbar-color: #343b45 transparent; }

.empty-state { min-height: 155px; display: grid; place-items: center; align-content: center; gap: 7px; padding: 24px; color: var(--muted); text-align: center; }
.empty-state svg { width: 25px; height: 25px; color: var(--muted-2); }
.empty-state strong { color: #c4cad2; }
.empty-state p { font-size: 12px; }
.toast-region { position: fixed; right: 18px; bottom: 18px; z-index: 100; width: min(370px, calc(100vw - 36px)); display: grid; gap: 8px; }
.toast { min-height: 48px; display: grid; grid-template-columns: 20px minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 11px 12px; border: 1px solid var(--border); border-left: 3px solid var(--green); border-radius: 6px; background: #171c22; box-shadow: var(--shadow); animation: toast-in 180ms ease; }
.toast.error { border-left-color: var(--danger); }
.toast.warning { border-left-color: var(--amber); }
.toast svg { width: 17px; height: 17px; color: var(--green); }
.toast.error svg { color: var(--danger); }
.toast.warning svg { color: var(--amber); }
.toast button { border: 0; background: transparent; color: var(--muted); cursor: pointer; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }
.confirm-dialog { width: min(420px, calc(100vw - 32px)); padding: 0; border: 1px solid #3c444f; border-radius: var(--radius); background: #151a20; color: var(--text); box-shadow: var(--shadow); }
.confirm-dialog::backdrop { background: rgba(0,0,0,0.72); }
.confirm-dialog form { display: grid; justify-items: center; gap: 12px; padding: 25px; text-align: center; }
.dialog-icon { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 50%; color: var(--amber); background: var(--amber-soft); }
.dialog-icon svg { width: 21px; height: 21px; }
.confirm-dialog p { color: var(--muted); }
.dialog-actions { width: 100%; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; }

@media (max-width: 1180px) {
    .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .settings-grid.four { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .command-row { grid-template-columns: 40px minmax(120px, .65fr) minmax(180px, 1fr) 135px 38px; }
    .command-row > [data-command-field="category"] { display: none; }
    .role-row { grid-template-columns: minmax(120px, 1fr) 104px minmax(155px, 1fr) 120px 38px; }
}

@media (max-width: 900px) {
    .mobile-only { display: inline-grid !important; }
    .app-shell { grid-template-columns: minmax(0, 1fr); }
    .sidebar { width: min(290px, 86vw); position: fixed; inset: 0 auto 0 0; transform: translateX(-102%); transition: transform 180ms ease; box-shadow: var(--shadow); }
    .sidebar.open { transform: translateX(0); }
    .nav-backdrop { display: block; position: fixed; inset: 0; z-index: 20; border: 0; background: rgba(0,0,0,.67); }
    .main { grid-column: 1; }
    .topbar { padding: 0 16px; }
    .view { padding: 23px 18px 40px; }
    .status-hero { margin: -23px -18px 22px; padding: 22px 18px; }
    .dashboard-grid, .composer-layout { grid-template-columns: 1fr; }
    .discord-preview { position: static; }
    .settings-grid.three { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .role-row { grid-template-columns: minmax(0, 1fr) 52px 38px; }
    .role-row .role-select { grid-column: 1 / 3; }
    .role-row .role-style { grid-column: 1 / 3; }
}

@media (max-width: 640px) {
    body { font-size: 13px; }
    .topbar { height: 66px; gap: 9px; }
    .main { grid-template-rows: 66px minmax(0, 1fr); }
    .page-heading p { display: none; }
    .connection-badge span:last-child, .dirty-indicator { display: none; }
    .connection-badge { width: 30px; padding: 0; justify-content: center; }
    .view { padding: 19px 13px 34px; }
    .status-hero { min-height: 0; align-items: flex-start; flex-direction: column; margin: -19px -13px 18px; padding: 18px 13px; }
    .hero-actions { width: 100%; }
    .hero-actions .button { flex: 1; }
    .metric-grid, .settings-grid, .settings-grid.three, .settings-grid.four, .dashboard-grid { grid-template-columns: 1fr; }
    .span-2 { grid-column: span 1; }
    .metric-card { min-height: 96px; }
    .view-intro, .editor-heading { align-items: flex-start; flex-direction: column; gap: 12px; }
    .view-intro > .button, .view-intro > .button-row, .editor-heading > .button-row { width: 100%; }
    .view-intro .button-row .button, .editor-heading .button-row .button { flex: 1; }
    .toolbar { align-items: stretch; flex-direction: column; }
    .toolbar .search, .toolbar select { width: 100%; max-width: none; }
    .segmented { width: 100%; overflow-x: auto; }
    .segmented button { flex: 1; }
    .summary-strip { grid-template-columns: 1fr; }
    .check-row { grid-template-columns: 22px minmax(0, 1fr); padding: 10px 0; }
    .check-row span { grid-column: 2; }
    .role-row { grid-template-columns: minmax(0, 1fr) 52px 38px; }
    .role-row .role-select, .role-row .role-style { grid-column: 1 / 3; }
    .command-row { grid-template-columns: 36px minmax(0, 1fr) 38px; }
    .command-row > input, .command-row > select { grid-column: 2 / -1; }
    .command-details, .command-row.expanded .command-details { grid-column: 1 / -1; grid-template-columns: 1fr; }
    .composer-layout { gap: 18px; }
    .log-section .section-header { align-items: flex-start; flex-direction: column; }
    .log-section .button-row, .search.compact { width: 100%; }
    .log-output { height: 390px; min-height: 300px; }
    .toast-region { right: 10px; bottom: 10px; width: calc(100vw - 20px); }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
