:root {
  --brand: #8b0000;
  --accent: #d32f2f;
  --accent-hover: #e53935;
  --bg: #0c0d10;
  --panel: #14161b;
  --panel-2: #1a1d23;
  --border: #262a31;
  --text: #e9eaed;
  --muted: #8d929c;
  --green: #2fbf71;
  --amber: #f0a834;
  --red: #ef4f4f;
  --discord: #5865f2;
  --radius: 10px;
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --display: 'Rajdhani', var(--font);
  --mono: 'JetBrains Mono', ui-monospace, 'Cascadia Code', Consolas, monospace;
  /* motion: subtle, fast, purposeful (all of it is switched off under prefers-reduced-motion) */
  --ease-out: cubic-bezier(.2,.8,.2,1);
  --ease-in-out: cubic-bezier(.65,0,.35,1);
  --ease-spring: cubic-bezier(.34,1.56,.64,1);
  --dur-1: 120ms;
  --dur-2: 200ms;
  --dur-3: 320ms;
  --dur-4: 600ms;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 14px/1.5 var(--font); -webkit-font-smoothing: antialiased; overflow-x: clip; }
h1, h2, h3 { font-family: var(--display); letter-spacing: .02em; margin: 0; }
h1 { font-size: 28px; }
h2 { font-size: 20px; margin: 28px 0 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; font-size: 14px; }
a { color: inherit; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: var(--mono); }
.err-text { color: var(--red); }
[hidden] { display: none !important; }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid transparent; border-radius: 8px; padding: 9px 16px; font: 600 14px var(--font); cursor: pointer; text-decoration: none; color: var(--text); background: var(--panel-2); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
/* One visible focus ring for everything focusable (zero specificity, so components can still restyle it). */
:where(button, a, summary, select, input, textarea, [tabindex]):focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-primary { background: var(--accent); }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-danger { background: transparent; border-color: #5a2226; color: #ff8a8a; }
.btn-danger:hover:not(:disabled) { background: #3a1518; }
.btn-ghost { background: transparent; border-color: var(--border); }
.btn-ghost:hover:not(:disabled) { background: var(--panel-2); }
.btn-discord { background: var(--discord); padding: 12px 22px; font-size: 15px; }
.btn-discord:hover { background: #4752c4; }
.link { background: none; border: 0; padding: 0; color: var(--muted); font: inherit; font-size: 12px; cursor: pointer; }
.link:hover { color: var(--text); text-decoration: underline; }

/* ---------- login / denied ---------- */
.gate { display: grid; place-items: center; min-height: 100vh; padding: 16px;
  background: radial-gradient(ellipse at top, #2a0d0f 0%, var(--bg) 60%); }
.gate-card { width: 100%; max-width: 420px; background: var(--panel); border: 1px solid var(--border); border-radius: 16px; padding: 40px 32px; text-align: center; box-shadow: 0 20px 60px rgba(0,0,0,.5); }
.gate-card h1 { font-size: 34px; text-transform: uppercase; }
.gate-card p { margin: 8px 0 20px; }
.gate-mark { font-size: 48px; margin-bottom: 8px; }
.gate-error { background: #3a1518; border: 1px solid #5a2226; color: #ffb3b3; padding: 10px 12px; border-radius: 8px; }
.fine { font-size: 12px; color: var(--muted); margin-top: 24px !important; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.sidebar { background: var(--panel); border-right: 1px solid var(--border); display: flex; flex-direction: column; padding: 20px 14px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 12px; padding: 0 8px 20px; border-bottom: 1px solid var(--border); margin-bottom: 14px; }
.brand img { width: 40px; height: 40px; border-radius: 10px; }
.brand-name { font: 700 20px var(--display); text-transform: uppercase; letter-spacing: .04em; line-height: 1.1; }
.brand-sub { font-size: 12px; color: var(--muted); }
.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-item { position: relative; display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; background: none; border: 0; border-radius: 8px; padding: 10px 12px; color: var(--muted); font: 500 14px var(--font); cursor: pointer; border-left: 3px solid transparent; transition: background-color var(--dur-1) var(--ease-out), color var(--dur-1) var(--ease-out); }
.nav-item:hover { background: var(--panel-2); color: var(--text); }
.nav-item.active { background: var(--panel-2); color: var(--text); }
/* the active item's accent bar grows in */
.nav-item::before { content: ''; position: absolute; left: -3px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent); transform: scaleY(0); transition: transform var(--dur-2) var(--ease-out); }
.nav-item.active::before { transform: scaleY(1); }
.badge { margin-left: auto; background: var(--accent); color: #fff; border-radius: 999px; padding: 0 8px; font-size: 12px; font-weight: 700; }
.me { display: flex; align-items: center; gap: 10px; padding: 14px 8px 0; border-top: 1px solid var(--border); }
.me img { width: 36px; height: 36px; border-radius: 50%; background: var(--panel-2); }
.me-text { min-width: 0; }
.me-text div { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.main { padding: 28px 32px 48px; min-width: 0; }
.view { display: none; }
.view.active { display: block; }
.view-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }

/* ---------- dashboard ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; }
.stat { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; }
.stat-label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .08em; }
.stat-value { font: 700 32px var(--display); margin: 4px 0 2px; font-variant-numeric: tabular-nums; }
.stat-sub { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.servers { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
.server { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; display: flex; flex-direction: column; gap: 12px; border-top: 3px solid var(--border); }
.server-online { border-top-color: var(--green); }
.server-offline { border-top-color: var(--red); }
.server-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.server-name { font: 700 19px var(--display); }
.server-pop { display: flex; align-items: baseline; gap: 6px; }
.pop-now { font: 700 44px/1 var(--display); font-variant-numeric: tabular-nums; }
.pop-max { color: var(--muted); font: 600 20px var(--display); }
.bar { height: 8px; background: var(--panel-2); border-radius: 999px; overflow: hidden; }
.bar-fill { height: 100%; width: 0; background: linear-gradient(90deg, var(--brand), var(--accent)); border-radius: 999px; transition: width var(--dur-4) var(--ease-out); }
.server-meta { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 13px; }
.connect { font-family: var(--mono); font-size: 12px; background: var(--panel-2); border: 1px solid var(--border); border-radius: 6px; padding: 6px 10px; user-select: all; overflow-wrap: anywhere; }
.server-actions { display: flex; gap: 8px; }
.players-list { display: flex; flex-wrap: wrap; gap: 6px; max-height: 220px; overflow: auto; padding-top: 4px; }
.chip { background: var(--panel-2); border: 1px solid var(--border); border-radius: 999px; padding: 3px 10px; font-size: 12px; }

.pill { display: inline-flex; align-items: center; gap: 6px; border-radius: 999px; padding: 3px 10px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.pill .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill-online { background: rgba(47,191,113,.12); color: var(--green); }
.pill-offline { background: rgba(239,79,79,.12); color: var(--red); }
.pill-checking { background: var(--panel-2); color: var(--muted); }
.pill-warn { background: rgba(240,168,52,.12); color: var(--amber); }

/* ---------- console ---------- */
.console { background: #08090b; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; height: calc(100vh - 150px); min-height: 360px; }
.console-out { flex: 1; overflow: auto; padding: 14px 16px; font: 13px/1.55 var(--mono); }
.line { white-space: pre-wrap; overflow-wrap: anywhere; }
.line-cmd { color: var(--amber); margin-top: 10px; }
.line-cmd:first-child { margin-top: 0; }
.line-out { color: #cfd3da; }
.line-err { color: var(--red); }
.console-in { display: flex; align-items: center; gap: 10px; border-top: 1px solid var(--border); padding: 10px 12px; background: var(--panel); }
.console-in input { flex: 1; background: transparent; border: 0; color: var(--text); font: 14px var(--mono); padding: 8px 4px; }
.console-in input:focus-visible { outline: none; }
.console-in select { max-width: 200px; }
.prompt { color: var(--accent); font: 700 18px var(--mono); }

/* ---------- tables ---------- */
.table-wrap { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.table td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table td.actions { text-align: right; white-space: nowrap; }
.table td.actions > * + * { margin-left: 6px; }
.empty { text-align: center; color: var(--muted); padding: 40px 16px !important; }
.user { display: flex; align-items: center; gap: 10px; }
.avatar { border-radius: 50%; background: var(--panel-2); flex-shrink: 0; }
.avatar-sm { width: 30px; height: 30px; }

/* ---------- warnings ---------- */
.warn-list { display: flex; flex-direction: column; gap: 10px; }
.warn { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); }
.warn summary { display: flex; align-items: center; gap: 14px; padding: 12px 16px; cursor: pointer; list-style: none; }
.warn summary::-webkit-details-marker { display: none; }
.warn summary .user { flex: 1; }
.warn ol { margin: 0; padding: 0 16px 14px 48px; display: flex; flex-direction: column; gap: 8px; }

/* ---------- forms / announce ---------- */
input, select, textarea { background: var(--panel-2); border: 1px solid var(--border); border-radius: 8px; color: var(--text); font: 14px var(--font); padding: 9px 12px; width: 100%; }
textarea { resize: vertical; }
.form { display: flex; flex-direction: column; gap: 14px; }
.form label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: 13px; }
.form .btn { align-self: flex-start; }
.announce { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 28px; align-items: start; }
.preview-label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .08em; margin-bottom: 8px; }
.embed { background: #2b2d31; border-left: 4px solid var(--brand); border-radius: 4px; padding: 12px 16px; max-width: 520px; }
.embed-author { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.embed-author img { width: 22px; height: 22px; border-radius: 50%; }
.embed-title { font-weight: 700; font-size: 16px; margin-bottom: 6px; overflow-wrap: anywhere; }
.embed-body { white-space: pre-wrap; font-size: 14px; color: #dbdee1; overflow-wrap: anywhere; }
.embed-image { max-width: 100%; border-radius: 4px; margin-top: 12px; }
.embed-footer { font-size: 12px; color: var(--muted); margin-top: 10px; }

/* ---------- toast / dialog ---------- */
/* toast stack: newest on top, anchored bottom-right (bottom-center on phones) */
.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 60; display: flex; flex-direction: column; gap: 8px; width: min(380px, calc(100vw - 40px)); pointer-events: none; }
.toast { pointer-events: auto; display: flex; align-items: flex-start; gap: 10px; padding: 10px 8px 10px 12px; border-radius: 10px; font-weight: 600; font-size: 13px; line-height: 1.45; background: #1f2229; border: 1px solid var(--border); color: var(--text); box-shadow: 0 12px 32px rgba(0,0,0,.5); animation: slide-in-right var(--dur-3) var(--ease-out), fade-in var(--dur-2) ease-out; }
.toast-ok { background: #173d2a; border: 1px solid #23633f; color: #a6f0c6; }
.toast-err { background: #3a1518; border: 1px solid #5a2226; color: #ffb3b3; }
.toast-warn { background: #3b2a0c; border: 1px solid #6b4b12; color: #f5cf8a; }
.toast-icon { display: inline-flex; padding-top: 2px; }
.toast-msg { flex: 1; min-width: 0; padding-top: 1px; overflow-wrap: anywhere; }
.toast-count { flex-shrink: 0; align-self: center; font-size: 12px; font-variant-numeric: tabular-nums; padding: 0 6px; border-radius: 999px; background: rgba(255,255,255,.1); }
.toast-count.bump { animation: scale-in var(--dur-2) var(--ease-spring); }
.toast-action { flex-shrink: 0; align-self: center; background: rgba(255,255,255,.1); color: inherit; }
.toast-action:hover { background: rgba(255,255,255,.18); }
.toast .toast-close { color: inherit; opacity: .75; padding: 4px; margin: -2px 0; }
.toast .toast-close:hover { opacity: 1; background: rgba(255,255,255,.08); border-color: transparent; color: inherit; }
.toast-out { animation: fade-out var(--dur-2) var(--ease-in-out) forwards; pointer-events: none; }
.dialog { background: var(--panel); color: var(--text); border: 1px solid var(--border); border-radius: 14px; padding: 0; width: min(440px, calc(100vw - 32px)); }
.dialog::backdrop { background: rgba(0,0,0,.6); }
.dialog-body { padding: 22px; display: flex; flex-direction: column; gap: 12px; }
.dialog-body p { margin: 0; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; }

/* ---------- responsive ---------- */
@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { min-width: 0; position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 12px 16px; gap: 10px; }
  .brand { border: 0; padding: 0; margin: 0; }
  .nav { flex-direction: row; overflow-x: auto; order: 3; flex-basis: 100%; min-width: 0; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .stat-value { font-size: 26px; }
  .nav-item { width: auto; white-space: nowrap; border-left: 0; border-bottom: 3px solid transparent; border-radius: 6px 6px 0 0; }
  .nav-item.active { border-bottom-color: var(--accent); }
  .me { margin-left: auto; border: 0; padding: 0; }
  .main { padding: 20px 16px 40px; }
  .announce { grid-template-columns: 1fr; }
  .servers { grid-template-columns: 1fr; }
  .console { height: calc(100vh - 220px); }
  .console-in { flex-wrap: wrap; }
  .console-in select { max-width: none; flex-basis: 100%; }
}

/* ---------- setup-needed page ---------- */
.setup-list { text-align: left; margin: 0 0 16px; padding: 12px 12px 12px 32px; background: #3a1518; border: 1px solid #5a2226; border-radius: 8px; color: #ffb3b3; }
.setup-list li + li { margin-top: 6px; }
.gate-card code { font-family: var(--mono); font-size: 12px; background: var(--panel-2); padding: 1px 5px; border-radius: 4px; }

/* ---------- ticket conversation ---------- */
.table tr.clickable { cursor: pointer; }
.table tr.clickable:hover td { background: var(--panel-2); }
.ticket-detail { display: flex; flex-direction: column; gap: 14px; height: calc(100vh - 56px); min-height: 480px; }
.ticket-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.ticket-title { flex: 1; min-width: 200px; }
.ticket-title h1 { font-size: 24px; }
.ticket-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.chat { flex: 1; overflow: auto; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 8px 0; }
.msg { display: flex; gap: 12px; padding: 8px 16px; }
.msg:hover { background: rgba(255,255,255,.02); }
.msg-staff { border-left: 3px solid var(--accent); padding-left: 13px; }
.avatar-md { width: 36px; height: 36px; }
.msg-main { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 6px; }
.msg-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.msg-name { font-weight: 600; }
.tag { background: var(--discord); color: #fff; font-size: 10px; font-weight: 700; border-radius: 3px; padding: 0 4px; letter-spacing: .03em; }
.msg-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.msg-embed { background: var(--panel-2); border-left: 3px solid var(--brand); border-radius: 4px; padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; max-width: 640px; }
.msg-embed-author { font-size: 12px; font-weight: 600; }
.msg-embed-title { font-weight: 700; }
.msg-embed-desc, .msg-embed-field { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 13px; }
.msg-embed-fname { font-weight: 600; font-size: 12px; color: var(--muted); }
.msg-image { max-width: min(360px, 100%); max-height: 260px; border-radius: 6px; display: block; }
.msg-file { color: #8ab4ff; }
.composer { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.composer textarea { resize: vertical; min-height: 70px; }
.composer-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.composer-row .btn { margin-left: auto; }
.check { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; cursor: pointer; }
.check input { width: auto; }

/* ---------- settings ---------- */
.subtabs { display: flex; gap: 4px; overflow-x: auto; border-bottom: 1px solid var(--border); margin-bottom: 18px; }
.subtab { background: none; border: 0; border-bottom: 2px solid transparent; color: var(--muted); font: 600 14px var(--font); padding: 10px 14px; cursor: pointer; white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; }
.subtab:hover { color: var(--text); }
.subtab.active { color: var(--text); border-bottom-color: var(--accent); }
.dot-dirty { width: 7px; height: 7px; border-radius: 50%; background: var(--amber); }
.settings-body { display: flex; flex-direction: column; gap: 16px; padding-bottom: 80px; }
.settings-card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; display: flex; flex-direction: column; gap: 12px; }
.settings-card h3 { font-size: 18px; }
.settings-card > p { margin: -6px 0 0; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px 18px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field-label { font-weight: 600; font-size: 13px; }
.hint { font-size: 12px; color: var(--muted); }
.stack { display: flex; flex-direction: column; gap: 8px; }
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: 14px; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch-ui { width: 38px; height: 22px; border-radius: 999px; background: var(--border); position: relative; transition: background .15s; flex-shrink: 0; }
.switch-ui::after { content: ''; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch input:checked + .switch-ui { background: var(--accent); }
.switch input:checked + .switch-ui::after { transform: translateX(16px); }
.switch input:focus-visible + .switch-ui { outline: 2px solid var(--accent); outline-offset: 2px; }
.color-row { display: flex; gap: 8px; }
.color-row input[type=color] { width: 46px; padding: 2px; height: 38px; flex-shrink: 0; }
.chips-field { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; background: var(--panel-2); border: 1px solid var(--border); border-radius: 8px; padding: 6px; min-height: 40px; }
.chip-role { display: inline-flex; align-items: center; gap: 6px; background: var(--bg); }
.role-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); }
.chip-x { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 15px; line-height: 1; padding: 0 2px; }
.chip-x:hover { color: var(--red); }
.chip-add { width: auto; flex: 1; min-width: 130px; border: 0; background: transparent; padding: 4px 6px; color: var(--muted); }
.list-editor { display: flex; flex-direction: column; gap: 12px; align-items: flex-start; }
.list-editor > .list-item { align-self: stretch; }
.list-item { border: 1px solid var(--border); border-radius: 8px; padding: 14px; background: var(--bg); display: flex; flex-direction: column; gap: 12px; }
.list-item .list-item { background: var(--panel); }
.list-item-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.list-item-tools { display: flex; gap: 6px; }
.btn-xs { padding: 3px 9px; font-size: 12px; }
.subhead { font-weight: 700; font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-top: 4px; }
.inline-action { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.inline-action select { max-width: 320px; }
/* inputs and selects share an inline row instead of each taking a full line (width:100% above) */
.inline-action > :is(input, select):not(.num-input) { flex: 1 1 180px; width: auto; min-width: 0; }
/* rows whose width comes from their content: a 180px basis would overflow that width and wrap */
.list-editor > .inline-action { align-self: stretch; }
.view-head > .inline-action > :is(input, select):not(.num-input) { flex-basis: auto; }
.notice { background: rgba(240,168,52,.1); border: 1px solid rgba(240,168,52,.35); color: #f5cf8a; padding: 10px 12px; border-radius: 8px; margin: 0; font-size: 13px; }
.savebar { position: sticky; bottom: 16px; margin-top: -60px; display: flex; align-items: center; gap: 10px; background: #1f2229; border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px 10px 16px; box-shadow: 0 10px 30px rgba(0,0,0,.45); z-index: 5; }
.savebar span { flex: 1; font-weight: 600; font-size: 13px; }

@media (max-width: 860px) {
  .ticket-detail { height: auto; }
  .chat { max-height: 60vh; }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .savebar { flex-wrap: wrap; }
}

/* =====================================================================
   v2 panel: navigation, cards, chart, game servers, members, permissions
   ===================================================================== */
body { background: radial-gradient(1200px 500px at 70% -10%, rgba(211,47,47,.07), transparent 60%), var(--bg); }
.icon { flex-shrink: 0; }

/* navigation */
.nav { gap: 1px; }
.nav-group { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .1em; color: #7d838e; padding: 16px 12px 6px; }
.nav-group:first-child { padding-top: 4px; }
.nav-item .icon { opacity: .8; }
.nav-item.active .icon { color: var(--accent); opacity: 1; }
.nav-item.active { background: linear-gradient(90deg, rgba(211,47,47,.14), rgba(211,47,47,0) 80%); }
.me { gap: 10px; }
.me-text { flex: 1; }
.me-role { font-size: 12px; color: var(--muted); }
.icon-btn { background: none; border: 1px solid transparent; color: var(--muted); border-radius: 8px; padding: 6px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.icon-btn:hover { color: var(--text); background: var(--panel-2); border-color: var(--border); }

/* page heads, cards */
.view-head h1 { line-height: 1.1; }
.view-sub { margin: 4px 0 0; color: var(--muted); font-size: 14px; }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; }
.card + .card, .card + .section-head { margin-top: 16px; }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.card-title { font-size: 19px; margin: 0; letter-spacing: .02em; text-transform: none; color: var(--text); }
.section-head { display: flex; align-items: center; justify-content: space-between; margin: 26px 0 12px; }
.section-title { margin: 0; }
.stats { margin-bottom: 16px; }
.stat { position: relative; overflow: hidden; }
.stat-accent { border-color: rgba(211,47,47,.45); background: linear-gradient(135deg, rgba(211,47,47,.12), var(--panel) 60%); }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.push { margin-left: auto; }
.empty-state { text-align: center; padding: 36px 16px; color: var(--muted); }
.empty-state.big { padding: 90px 16px; }
.empty-title { font-weight: 600; color: var(--text); margin-bottom: 4px; }

/* segmented control */
.seg { display: inline-flex; background: var(--panel-2); border: 1px solid var(--border); border-radius: 8px; padding: 2px; }
.seg-btn { background: none; border: 0; color: var(--muted); font: 600 13px var(--font); padding: 5px 12px; border-radius: 6px; cursor: pointer; }
.seg-btn:hover { color: var(--text); }
.seg-btn.active { background: var(--bg); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.4); }

/* chart */
.chart { min-height: 260px; }
.chart-wrap { position: relative; outline: none; border-radius: 8px; }
.chart-wrap:focus-visible { box-shadow: 0 0 0 2px var(--accent); }
.chart-svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart-svg .grid { stroke: #23262d; stroke-width: 1; }
.chart-svg .axis { fill: var(--muted); font-size: 11px; font-family: var(--font); }
.chart-svg .line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart-svg .line-total { stroke-width: 2; stroke-dasharray: 4 3; }
.chart-svg .end-label { fill: var(--text); font-size: 12px; font-family: var(--font); font-weight: 600; }
.chart-svg .crosshair { stroke: #6b717c; stroke-width: 1; }
.chart-svg .dot { stroke: var(--panel); stroke-width: 2; }
.chart-svg .overlay { fill: transparent; cursor: crosshair; }
.chart-tip { position: absolute; width: 180px; background: #0f1115; border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; box-shadow: 0 8px 24px rgba(0,0,0,.5); pointer-events: none; font-size: 12px; }
.tip-time { font-weight: 600; margin-bottom: 6px; color: var(--text); }
.tip-row { display: flex; align-items: center; gap: 6px; padding: 1px 0; }
.tip-name { flex: 1; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tip-val { font-weight: 600; font-variant-numeric: tabular-nums; }
.swatch { width: 10px; height: 10px; border-radius: 3px; display: inline-block; flex-shrink: 0; }
.swatch-total { border-radius: 1px; height: 3px; width: 14px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 10px; font-size: 13px; color: var(--muted); }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.table-compact td, .table-compact th { padding: 6px 12px; font-size: 13px; }
#chart-table { max-height: 320px; overflow: auto; margin-top: 12px; }

/* server cards */
.server { transition: border-color .15s, transform .15s; }
.server:hover { border-color: #353a43; }
.factions { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 13px; }
.faction { display: inline-flex; align-items: center; gap: 6px; }
.connect-row { display: flex; gap: 6px; align-items: center; }
.connect-row .connect { flex: 1; }
.server-actions { align-items: center; }
.meta { white-space: nowrap; }

/* game servers page */
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--red); display: inline-block; }
.status-dot.on { background: var(--green); }
.gs-header { margin-bottom: 16px; }
.gs-title { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.gs-controls { display: flex; gap: 8px; flex-wrap: wrap; }
.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px 18px; margin: 16px 0 6px; }
.facts dt { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.facts dd { margin: 2px 0 0; font-weight: 600; overflow-wrap: anywhere; }
.fact { min-width: 0; }
.pills { display: inline-flex; gap: 4px; }
.pill-tab { background: none; border: 1px solid transparent; color: var(--muted); font: 600 13px var(--font); padding: 6px 12px; border-radius: 999px; cursor: pointer; }
.pill-tab.active { background: var(--panel-2); color: var(--text); border-color: var(--border); }
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 12px; }
.player-name { font-weight: 600; }
.th-sort { background: none; border: 0; color: inherit; font: inherit; text-transform: inherit; letter-spacing: inherit; cursor: pointer; padding: 0; }
.th-sort.active { color: var(--text); }
.th-sort.active::after { content: ' ↓'; }
.warn-text { color: var(--amber); }


/* console quick commands */
.console-chips { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; padding: 10px 14px 0; }
.console-chips:empty { display: none; }
.chip-btn { cursor: pointer; font-family: var(--mono); color: var(--text); }
.chip-btn:hover { border-color: var(--accent); }
.line-info { color: var(--muted); font-style: italic; }

/* members */
.members-layout { display: grid; grid-template-columns: 320px minmax(0, 1fr); gap: 18px; align-items: start; }
.search { display: flex; gap: 8px; margin-bottom: 12px; }
.member-list { display: flex; flex-direction: column; gap: 4px; max-height: calc(100vh - 220px); overflow: auto; }
.list-caption { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); padding: 4px 4px 8px; }
.member-row { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; background: none; border: 1px solid transparent; border-radius: 8px; padding: 8px; color: var(--text); font: inherit; cursor: pointer; }
.member-row:hover, .member-row.active { background: var(--panel); border-color: var(--border); }
.member-row-text { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.member-row-text > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile { display: flex; flex-direction: column; gap: 14px; }
.profile-head { display: flex; gap: 16px; align-items: center; }
.avatar-lg { width: 72px; height: 72px; }
.profile-names h2 { font-size: 24px; margin: 0; }
.badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.roles { display: flex; flex-wrap: wrap; gap: 6px; }
.profile-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.warn-items { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 8px; }

/* activity */
.filter-input { max-width: 320px; }
.action-tag { display: inline-block; background: var(--panel-2); border: 1px solid var(--border); border-radius: 6px; padding: 2px 8px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.table td.detail { color: var(--muted); overflow-wrap: anywhere; }

/* dialogs */
.dialog-body .field { display: flex; flex-direction: column; gap: 6px; }
.dialog-body h3 { font-size: 20px; }
.btn-danger-solid { background: #b3261e; color: #fff; }
.btn-danger-solid:hover { background: #c62828; }
.invalid { border-color: var(--red) !important; }

/* settings extras */
.hint-box { background: rgba(57,135,229,.08); border: 1px solid rgba(57,135,229,.3); color: #b9d3f5; border-radius: 8px; padding: 10px 12px; margin: 0 0 12px; font-size: 13px; }
.test-result { margin-top: 10px; font-size: 13px; border-radius: 8px; padding: 10px 12px; background: var(--panel-2); border: 1px solid var(--border); overflow-wrap: anywhere; }
.test-result.ok { background: rgba(47,191,113,.08); border-color: rgba(47,191,113,.35); color: #a6f0c6; }
.test-result.err { background: #3a1518; border-color: #5a2226; color: #ffb3b3; }
.perm-roles { display: flex; flex-direction: column; gap: 8px; }
.perm-role { background: var(--bg); border: 1px solid var(--border); border-radius: 8px; }
.perm-role > summary { display: flex; align-items: center; gap: 10px; padding: 12px 14px; cursor: pointer; list-style: none; }
.perm-role > summary::-webkit-details-marker { display: none; }
.perm-role > summary::after { content: '▸'; margin-left: 8px; color: var(--muted); transition: transform var(--dur-2) var(--ease-out); }
.perm-role[open] > summary::after { transform: rotate(90deg); }
.perm-role-name { font-weight: 600; flex: 1; }
.perm-groups { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; padding: 0 14px 14px; }
.perm-group { border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.perm-group legend { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 0 4px; }
.perm { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; }
.perm input { width: auto; margin-top: 3px; accent-color: var(--accent); }
.perm > span { display: flex; flex-direction: column; }
.perm-label { font-weight: 600; font-size: 14px; }
.perm-included { opacity: .75; cursor: default; }

@media (max-width: 860px) {
  .nav-group { display: none; }
  .members-layout { grid-template-columns: 1fr; }
  .member-list { max-height: 280px; }
  .me-role { display: none; }
  .filter-input { max-width: none; width: 100%; }
  .facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.profile-names h2 { text-transform: none; letter-spacing: .01em; color: var(--text); margin: 0; }
.profile > .btn { align-self: flex-start; }
.gs-title h2, .card-title { text-transform: none; letter-spacing: .01em; }

/* ---------- Discord-style preview ---------- */
.dc-preview { background: #313338; border-radius: 8px; padding: 14px 16px; color: #dbdee1; font-size: 15px; }
.dc-message { display: flex; gap: 14px; }
.dc-avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--panel-2); flex-shrink: 0; }
.dc-body { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 4px; }
.dc-head { display: flex; align-items: baseline; gap: 6px; }
.dc-name { font-weight: 600; color: #f2f3f5; }
.dc-time { font-size: 12px; color: #949ba4; }
.dc-content { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.4; }
.dc-embed { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 16px; background: #2b2d31; border-left: 4px solid #1e1f22; border-radius: 4px; padding: 10px 14px 14px 12px; max-width: 520px; margin-top: 4px; }
.dc-embed-main { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.dc-author { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; color: #f2f3f5; }
.dc-author img, .dc-footer img { width: 22px; height: 22px; border-radius: 50%; }
.dc-footer img { width: 18px; height: 18px; }
.dc-title { font-weight: 700; color: #f2f3f5; font-size: 15px; overflow-wrap: anywhere; }
.dc-desc { white-space: pre-wrap; font-size: 14px; overflow-wrap: anywhere; line-height: 1.4; }
.dc-fields { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px 12px; }
.dc-field { grid-column: 1 / -1; font-size: 14px; min-width: 0; }
.dc-field.inline { grid-column: auto; }
.dc-fname { font-weight: 700; color: #f2f3f5; margin-bottom: 2px; }
.dc-fvalue { white-space: pre-wrap; overflow-wrap: anywhere; }
.dc-image { max-width: 100%; border-radius: 4px; margin-top: 6px; }
.dc-thumb { width: 80px; height: 80px; object-fit: cover; border-radius: 4px; }
.dc-footer { display: flex; align-items: center; gap: 8px; font-size: 12px; color: #b5bac1; margin-top: 4px; }
.dc-buttons { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.dc-button { background: #4e5058; color: #fff; border-radius: 4px; padding: 6px 16px; font-size: 14px; font-weight: 500; }
.dc-button.primary { background: #5865f2; }
.dc-button.success { background: #248046; }
.dc-button.danger { background: #da373c; }
.md-code { background: #1e1f22; border-radius: 3px; padding: 0 4px; font-family: var(--mono); font-size: 13px; }
.md-mention { background: rgba(88,101,242,.3); color: #c9cdfb; border-radius: 3px; padding: 0 2px; }

/* ---------- embed builder ---------- */
.eb-layout, .gw-builder { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 460px); gap: 20px; align-items: start; }
.eb-editor, .gw-editor { display: flex; flex-direction: column; gap: 14px; }
.eb-editor .card, .gw-editor .card { display: flex; flex-direction: column; gap: 12px; margin: 0; }
.eb-side, .gw-side { position: sticky; top: 16px; display: flex; flex-direction: column; gap: 10px; }
.eb-actions { display: flex; align-items: center; gap: 10px; }
.eb-actions #eb-count { flex: 1; }
.eb-section { border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px; }
.eb-section > summary { cursor: pointer; font-weight: 600; font-size: 13px; color: var(--muted); padding: 2px 0; }
.eb-section[open] > summary { margin-bottom: 10px; }
.pill-tab.danger { color: #ff8a8a; }
.num-input { width: 90px; }
.avatar-xs { width: 18px; height: 18px; }

/* ---------- giveaways ---------- */
.gw-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
.gw-card { display: flex; flex-direction: column; gap: 10px; margin: 0; }
.gw-top { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.gw-prize { font: 700 19px var(--display); }
.gw-card .facts { grid-template-columns: repeat(4, minmax(0, 1fr)); margin: 0; }
.gw-card .server-actions { flex-wrap: wrap; }
.gw-card .server-actions .btn { white-space: nowrap; }
.gw-card .facts dd { overflow: hidden; text-overflow: ellipsis; }
.gw-winners { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
#gw-form { margin-bottom: 24px; }

@media (max-width: 1100px) {
  .eb-layout, .gw-builder { grid-template-columns: 1fr; }
  .eb-side, .gw-side { position: static; }
}
@media (max-width: 860px) {
  .gw-card .facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dc-fields { grid-template-columns: 1fr; }
}

/* =====================================================================
   v3 shell contract (P0): motion system, accessibility, shared states and
   the responsive base. Page packages override these in their own
   css/<package>.css file with more specific selectors.
   ===================================================================== */

/* ---------- motion: keyframes (shared; packages prefix their own) ---------- */
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes rise-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes scale-in { from { opacity: 0; transform: scale(.96); } to { opacity: 1; transform: none; } }
@keyframes slide-in-right { from { transform: translateX(16px); } to { transform: none; } }
@keyframes slide-up { from { transform: translateY(100%); } to { transform: translateY(0); } }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: 0 0; } }
@keyframes flash { from { background-color: rgba(57,135,229,.28); } to { background-color: transparent; } }
@keyframes pulse-ring { 0% { box-shadow: 0 0 0 0 var(--pulse-color, rgba(47,191,113,.55)); } 70%, 100% { box-shadow: 0 0 0 6px transparent; } }
@keyframes draw { from { stroke-dashoffset: var(--len); } to { stroke-dashoffset: 0; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fade-out { to { opacity: 0; transform: translateY(4px); } }

/* ---------- motion: utilities (core.js stagger() sets --i) ---------- */
.anim-fade { animation: fade-in var(--dur-3) var(--ease-out) both; animation-delay: calc(var(--i, 0) * var(--stagger, 45ms)); }
.anim-rise { animation: rise-in var(--dur-3) var(--ease-out) both; animation-delay: calc(var(--i, 0) * var(--stagger, 45ms)); }
.anim-scale { animation: scale-in var(--dur-3) var(--ease-out) both; animation-delay: calc(var(--i, 0) * var(--stagger, 45ms)); }
.anim-out { animation: fade-out var(--dur-2) var(--ease-in-out) forwards; pointer-events: none; }
.flash { animation: flash 900ms ease-out; }
.live-dot { display: inline-block; flex-shrink: 0; width: 8px; height: 8px; border-radius: 50%; background: var(--green); animation: pulse-ring 2s var(--ease-out) infinite; }
.pill-online .dot, .status-dot.on { animation: pulse-ring 2s var(--ease-out) infinite; }
.draw { stroke-dasharray: var(--len); animation: draw 900ms var(--ease-in-out) both; }
.view-enter { animation: rise-in var(--dur-3) var(--ease-out) both; }

/* ---------- interaction polish ---------- */
.btn, .icon-btn, .seg-btn, .pill-tab { transition: background-color var(--dur-1) var(--ease-out), border-color var(--dur-1) var(--ease-out), color var(--dur-1) var(--ease-out), box-shadow var(--dur-1) var(--ease-out), opacity var(--dur-1) var(--ease-out), transform var(--dur-1) var(--ease-out); }
.btn:active:not(:disabled), .icon-btn:active:not(:disabled), .seg-btn:active:not(:disabled), .pill-tab:active:not(:disabled) { transform: scale(.97); }
.subtab { transition: color var(--dur-1) var(--ease-out), border-color var(--dur-2) var(--ease-out); }
/* clickable cards and tiles lift on hover */
button.stat { display: block; width: 100%; font: inherit; color: inherit; text-align: left; cursor: pointer; }
a.card-link, a.stat-link { display: block; color: inherit; text-decoration: none; }
.card-link, .stat-link, button.stat { cursor: pointer; transition: transform var(--dur-2) var(--ease-out), border-color var(--dur-2) var(--ease-out), box-shadow var(--dur-2) var(--ease-out); }
@media (hover: hover) {
  .card-link:hover, .stat-link:hover, button.stat:hover { transform: translateY(-2px); border-color: #3a3f49; box-shadow: 0 12px 28px rgba(0,0,0,.38); }
}
.card-link:active, .stat-link:active, button.stat:active { transform: scale(.99); }
/* disclosure: a chevron icon with class .chev rotates; opened content rises in */
summary .chev { transition: transform var(--dur-2) var(--ease-out); }
details[open] > summary .chev { transform: rotate(90deg); }
details[open] > :not(summary) { animation: rise-in var(--dur-2) var(--ease-out); }
/* dialogs */
.dialog[open] { animation: scale-in var(--dur-2) var(--ease-out); }
.dialog[open]::backdrop { animation: fade-in var(--dur-2) ease-out; }

/* ---------- accessibility ---------- */
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0; }
.skip-link { position: fixed; top: 8px; left: 8px; z-index: 100; padding: 10px 16px; border-radius: 8px; background: var(--accent); color: #fff; font-weight: 700; text-decoration: none; box-shadow: 0 8px 24px rgba(0,0,0,.5); opacity: 0; pointer-events: none; transform: translateY(calc(-100% - 24px)); transition: transform var(--dur-2) var(--ease-out), opacity var(--dur-2) var(--ease-out); }
.skip-link:focus { opacity: 1; pointer-events: auto; transform: none; outline: 2px solid #fff; outline-offset: 2px; }
/* focus lands on these programmatically (skip link, view change): no ring on a whole region/heading */
.main:focus, .view h1[tabindex="-1"]:focus { outline: none; }

/* ---------- loading skeletons ---------- */
.skel { display: block; height: 12px; max-width: 100%; border-radius: 6px; background: linear-gradient(90deg, #1b1e24 0%, #1b1e24 38%, #292d35 50%, #1b1e24 62%, #1b1e24 100%) 0 0 / 300% 100%; animation: shimmer 1.4s linear infinite; }
.skel-sm { width: 40%; height: 10px; }
.skel-lg { width: 58%; height: 24px; }
.skel-tile { display: flex; flex-direction: column; justify-content: center; gap: 10px; min-height: 102px; }
.skel-tile .skel:last-child { width: 72%; }
.skel-card { display: flex; flex-direction: column; gap: 12px; min-height: 168px; }
.skel-card .skel:nth-child(2) { width: 88%; }
.skel-card .skel:nth-child(3) { width: 66%; }
.skel-row td .skel { width: 70%; }
.skel-row td:first-child .skel { width: 50%; }
.skel-row td:nth-child(3n) .skel { width: 42%; }

/* ---------- error, empty and in-table states ---------- */
.error-state { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.error-state > .icon { color: var(--red); }
.error-state > p { margin: 0; color: var(--text); max-width: 60ch; overflow-wrap: anywhere; }
.table .table-msg td { padding: 0; }

/* ---------- connection and update banners (sticky at the top of main) ---------- */
/* one sticky stack, so the two banners sit one above the other instead of overlapping */
.banners { position: sticky; top: 8px; z-index: 30; display: flex; flex-direction: column; gap: 8px; margin: -12px 0 16px; }
.banners:not(:has(> .banner:not([hidden]))) { display: none; }
.banner { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 8px 8px 8px 14px; border-radius: 10px; font-size: 13px; font-weight: 600; box-shadow: 0 10px 28px rgba(0,0,0,.45); animation: rise-in var(--dur-3) var(--ease-out); }
.banner-icon { display: inline-flex; }
.banner-text { flex: 1 1 200px; min-width: 0; }
.banner-conn { background: #2b210e; border: 1px solid #6b4b12; color: #f5cf8a; }
.banner-conn .banner-btn { background: rgba(240,168,52,.14); border-color: rgba(240,168,52,.4); color: #f5cf8a; }
.banner-conn .banner-btn:hover:not(:disabled) { background: rgba(240,168,52,.24); }
.banner-conn.flash { animation: scale-in var(--dur-3) var(--ease-spring); }
.banner-update { background: #2a1416; border: 1px solid rgba(211,47,47,.55); color: var(--text); }
.banner-btn.busy .icon { animation: spin .8s linear infinite; }

/* ---------- broken images ---------- */
.img-broken { display: none !important; }
.img-broken-note { display: flex; align-items: center; gap: 8px; max-width: 360px; margin-top: 6px; padding: 12px 14px; border: 1px dashed #6b5a36; border-radius: 6px; background: rgba(240,168,52,.06); color: #f5cf8a; font-size: 12px; font-weight: 600; }
.img-broken[hidden] + .img-broken-note { display: none; }

/* ---------- shared form states ---------- */
.field.invalid :is(input, select, textarea, .chips-field) { border-color: var(--red); }
.field.invalid .field-label { color: #ff8a8a; }
.field-error { color: var(--red); font-size: 12px; font-weight: 600; }
.field.changed { margin-left: -12px; padding-left: 10px; border-left: 2px solid var(--amber); }
.char-count { color: var(--muted); font-size: 12px; text-align: right; font-variant-numeric: tabular-nums; }
.char-count.warn { color: var(--amber); }
.char-count.over { color: var(--red); }

/* ---------- scrolling helpers ---------- */
.table-wrap { max-width: 100%; overflow-x: auto; }
.scroll-x { display: flex; gap: 6px; overflow-x: auto; overscroll-behavior-x: contain; scroll-snap-type: x proximity; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.scroll-x::-webkit-scrollbar { display: none; }
.scroll-x > * { flex: 0 0 auto; scroll-snap-align: start; }

/* ---------- responsive base ---------- */
@media (max-width: 860px) {
  /* short pages must not stretch the top bar to fill the 100vh shell */
  .shell { grid-template-rows: auto 1fr; }
  .sidebar { align-content: flex-start; }
  /* horizontal nav: the active bar sits underneath and grows sideways */
  .nav-item::before { left: 10px; right: 10px; top: auto; bottom: -3px; width: auto; height: 3px; border-radius: 3px 3px 0 0; transform: scaleX(0); }
  .nav-item.active::before { transform: scaleX(1); }
  .nav-item.active { border-bottom-color: transparent; }
}

@media (max-width: 640px) {
  .main { padding: 16px max(16px, env(safe-area-inset-right)) calc(32px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); }
  .sidebar { padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }
  .view-head { flex-direction: column; align-items: stretch; gap: 12px; margin-bottom: 16px; }
  .view-head > :not(:first-child) { align-self: flex-start; max-width: 100%; }
  .view-head > :is(input, select, .inline-action, .toolbar, .seg) { align-self: stretch; }
  .view-head h1 { font-size: 24px; }
  .card, .settings-card, .server { padding: 14px; }
  .toolbar, .inline-action { flex-wrap: wrap; }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=color]), select, textarea { font-size: 16px !important; }
  .banners { top: 6px; margin-top: -4px; }
  /* a view-head tool row (embed templates): the select takes its own line, the buttons share the next */
  .view-head > .inline-action > :is(input, select):not(.num-input) { flex: 1 1 100%; max-width: none; }
  .view-head > .inline-action > .btn { flex: 1 1 0; }

  .dialog { width: calc(100vw - 24px); max-width: none; max-height: 90dvh; overflow-y: auto; }
  .dialog-body { padding: 18px; }
  .dialog-actions > .btn { flex: 1 1 0; }

  .toasts { left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); width: auto; max-width: 520px; margin: 0 auto; }
  .toast { animation: slide-up var(--dur-3) var(--ease-out), fade-in var(--dur-2) ease-out; }
  /* keep toasts clear of a page's sticky bottom action bar */
  body:has(.view.active :is(.savebar, .action-bar):not([hidden])) .toasts { bottom: calc(76px + env(safe-area-inset-bottom)); }

  /* .table-stack: each row becomes a labelled card (labels come from core.labelCells) */
  .table-wrap:has(> .table-stack) { background: none; border: 0; border-radius: 0; overflow: visible; }
  .table-stack, .table-stack > tbody { display: block; width: 100%; }
  .table-stack > thead { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }
  .table-stack > tbody { display: flex; flex-direction: column; gap: 10px; }
  .table-stack > tbody > tr { display: grid; gap: 8px; padding: 12px; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); }
  .table-stack > tbody > tr > td { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 8px; align-items: center; min-width: 0; padding: 0; border: 0; text-align: left; overflow-wrap: anywhere; }
  .table-stack > tbody > tr > td::before { content: attr(data-label); color: var(--muted); font-size: 12px; }
  .table-stack > tbody > tr > td:is([colspan], :not([data-label]), [data-label=""]) { display: block; }
  .table-stack > tbody > tr > td:is([colspan], :not([data-label]), [data-label=""])::before { content: none; }
  .table-stack > tbody > tr > td.actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-start; padding-top: 4px; white-space: normal; }
  .table-stack > tbody > tr > td.actions::before { content: none; }
  .table-stack td.actions > * + * { margin-left: 0; }
  .table-stack td.actions .btn { min-height: 36px; }
  .table-stack td.num { text-align: left; }
  .table-stack tr.clickable:hover td { background: none; }
  .table-stack tr.clickable:hover { border-color: #3a3f49; }
}

/* touch: comfortable targets */
@media (pointer: coarse) {
  .btn, .icon-btn, .seg-btn, .nav-item, .pill-tab, .subtab { min-height: 40px; }
  .icon-btn { min-width: 40px; }
}

/* reduced motion: no animations or transitions anywhere (core.js countUp/stagger check it too) */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
  ::backdrop { animation: none !important; }
  html { scroll-behavior: auto !important; }
}
