/* Atlas dashboard — Discord dark theme. Server rail + channel sidebar + content. */
:root {
  --bg: #313338;
  --surface: #2b2d31;
  --surface-2: #383a40;
  --surface-3: #404249;
  --bg-deep: #1e1f22;
  --field-bg: #1e1f22;
  --border: #3f4147;
  --border-soft: #26272c;
  --text: #dbdee1;
  --muted: #949ba4;
  --faint: #80848e;
  --accent: #5865f2;
  --accent-hover: #4752c4;
  --accent-soft: rgba(88, 101, 242, 0.16);
  --on-accent: #ffffff;
  --danger: #ed4245;
  --danger-btn: #da373c;
  --danger-soft: rgba(237, 66, 69, 0.12);
  --success: #23a559;
  --success-soft: rgba(35, 165, 89, 0.14);
  --warn: #f0b232;
  --focus: 0 0 0 3px rgba(88, 101, 242, 0.4);
  --radius: 8px;
  --radius-sm: 6px;
  --font: "gg sans", "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 14px/1.55 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: none; }
h1, h2, p { margin: 0; }
code { font-family: var(--mono); }
[hidden] { display: none !important; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: var(--radius-sm); }
::selection { background: rgba(88, 101, 242, 0.4); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #1a1b1e; border-radius: 5px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: #26272c; }
::-webkit-scrollbar-track { background: transparent; }

.app { min-height: 100vh; display: flex; flex-direction: column; }
.icon { flex: none; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.row { display: flex; align-items: center; gap: 8px; }
.spacer { flex: 1; }

/* Body row: server rail + app column */
.app-body { flex: 1; display: flex; min-height: 0; }
.app-col { flex: 1; min-width: 0; display: flex; flex-direction: column; }

/* Server rail — Discord server list */
.rail {
  width: 72px; flex: none;
  background: var(--bg-deep);
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 12px 0; overflow-y: auto; overflow-x: hidden;
  scrollbar-width: none;
}
.rail::-webkit-scrollbar { display: none; }
.rail-item { position: relative; display: flex; align-items: center; justify-content: center; width: 48px; height: 48px; flex: none; }
.rail-item::before {
  content: ""; position: absolute; left: -12px; top: 50%;
  width: 8px; height: 0; border-radius: 0 4px 4px 0;
  background: #fff; transform: translateY(-50%);
  transition: height 0.15s ease;
}
.rail-item:hover::before { height: 20px; }
.rail-item.active::before { height: 36px; }
.rail-icon {
  width: 48px; height: 48px; border-radius: 50%;
  object-fit: cover; display: flex; align-items: center; justify-content: center;
  background: var(--surface); color: var(--text);
  font-weight: 700; font-size: 15px;
  transition: border-radius 0.15s ease, background 0.15s;
}
.rail-item:hover .rail-icon, .rail-item.active .rail-icon { border-radius: 16px; }
.rail-logo { border-radius: 16px; }
.rail-icon-empty { background: linear-gradient(135deg, var(--accent), #8b5cf6); color: #fff; }
.rail-sep { width: 32px; height: 2px; border-radius: 1px; background: var(--surface-3); flex: none; }
.rail-home { display: none; }

/* Top bar */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px; height: 56px; padding: 0 20px;
  background: var(--bg);
  border-bottom: 1px solid var(--border-soft);
}
.topbar-guild { font-size: 15px; font-weight: 700; letter-spacing: -0.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar .input-lang { width: 76px; }
.topbar .input-theme { width: 128px; }
.user { display: flex; align-items: center; gap: 8px; }
.user-name { max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.avatar { width: 30px; height: 30px; border-radius: 50%; border: 2px solid var(--border-soft); }
.avatar-empty { display: inline-flex; align-items: center; justify-content: center; background: var(--accent-soft); color: var(--accent); font-size: 12px; font-weight: 700; }
.btn-icon.menu-btn { display: none; }

/* Layout: channel sidebar + content */
.layout { flex: 1; display: flex; min-height: 0; }
.sidebar {
  width: 240px; flex: none; padding: 16px 12px;
  background: var(--surface);
  overflow-y: auto;
}
.nav-heading { margin: 14px 8px 6px; font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--faint); }
.nav-item { display: flex; align-items: center; gap: 6px; border-radius: var(--radius-sm); padding-right: 4px; margin-bottom: 2px; }
.nav-item:hover { background: rgba(78, 80, 88, 0.35); }
.nav-item.active { background: rgba(78, 80, 88, 0.48); }
.nav-item.active .nav-link { color: #fff; font-weight: 600; }
.nav-link { flex: 1; display: flex; align-items: center; gap: 12px; min-width: 0; padding: 8px 10px; color: var(--muted); font-weight: 500; border-radius: var(--radius-sm); }
.nav-link:hover { color: var(--text); }
.nav-link .icon { color: var(--faint); }
.nav-item.active .nav-link .icon { color: var(--accent); }
.nav-link span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-item .switch { margin-right: 2px; }
.nav-item .switch-track { background: var(--surface-3); }
.nav-item .switch-input:checked + .switch-track { background: var(--accent); }
.nav-item .switch-input:checked + .switch-track::after { background: #fff; }
.scrim { display: none; }
.page { flex: 1; min-width: 0; padding: 26px 30px 120px; display: flex; flex-direction: column; }
.page > div { display: flex; flex-direction: column; gap: 18px; width: 100%; max-width: 1180px; }
.page-narrow { width: 100%; max-width: 960px; margin: 0 auto; }
.page-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 4px; }
.page-header .row { gap: 14px; }
.page-title { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.3; }

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 22px;
}
.card-title { font-size: 15px; font-weight: 650; letter-spacing: -0.01em; margin-bottom: 14px; }
.section-desc { margin: -8px 0 16px; }
.empty { display: flex; flex-direction: column; align-items: flex-start; gap: 12px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 18px; }
.stat { padding: 18px 22px; position: relative; overflow: hidden; }
.stat::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 3px; background: linear-gradient(180deg, var(--accent), transparent); opacity: 0.8; }
.stat-label { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; font-weight: 500; }
.stat-label .icon { color: var(--accent); }
.stat-value { margin-top: 6px; font-size: 26px; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }

/* Lists */
.list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.list-cols { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); column-gap: 24px; }
.list-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 8px; margin: 0 -8px; border-bottom: 1px solid var(--border-soft); color: var(--text); border-radius: var(--radius-sm); transition: background 0.12s; }
.list-row:hover { background: rgba(78, 80, 88, 0.3); }
.list-row:last-child { border-bottom: 0; }
a.list-row:hover { color: var(--text); }
a.list-row:hover .list-row-main span { color: #fff; }
.list-row-main { display: flex; align-items: center; gap: 10px; min-width: 0; font-weight: 500; }
.list-row-main .icon { color: var(--faint); }
.list-row-main span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-empty { padding: 10px 8px; }
.pill { flex: none; font-size: 12px; font-weight: 600; padding: 2px 10px; line-height: 20px; border-radius: 999px; letter-spacing: 0.01em; }
.pill-on { background: var(--success-soft); color: var(--success); }
.pill-off { background: var(--surface-2); color: var(--muted); }

/* Guild picker */
.guild-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 18px; }
.guild-card { display: flex; align-items: center; gap: 14px; color: var(--text); padding: 18px; transition: transform 0.15s, border-color 0.15s, background 0.15s; }
.guild-card:hover { border-color: var(--accent); transform: translateY(-2px); background: var(--surface-2); }
.guild-card-text { display: flex; flex-direction: column; min-width: 0; gap: 2px; }
.guild-card-text strong { font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.guild-icon { flex: none; width: 44px; height: 44px; border-radius: 50%; }
.guild-card .guild-icon { width: 52px; height: 52px; }
.guild-icon-empty { display: inline-flex; align-items: center; justify-content: center; background: linear-gradient(135deg, var(--accent), #8b5cf6); color: #fff; font-weight: 700; font-size: 15px; }

/* Account card on the server picker */
.account-card { display: flex; align-items: center; gap: 16px; }
.account-avatar { width: 56px; height: 56px; border-radius: 50%; flex: none; }
.account-avatar.avatar-empty { display: inline-flex; align-items: center; justify-content: center; background: var(--accent-soft); color: var(--accent); font-size: 20px; font-weight: 700; }
.account-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.account-name { font-size: 17px; letter-spacing: -0.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Fields */
.fields { display: flex; flex-direction: column; }

/* Collapsible sections and per-command groups */
.sec-collapse { padding: 6px 22px; }
.sec-collapse > summary, .cmd-group > summary { display: flex; align-items: center; gap: 10px; cursor: pointer; list-style: none; }
.sec-collapse > summary::-webkit-details-marker, .cmd-group > summary::-webkit-details-marker { display: none; }
.sec-summary { padding: 14px 0; border-bottom: 1px solid transparent; }
.sec-summary:hover .sec-title { color: var(--accent); }
.sec-title { font-size: 15px; font-weight: 650; letter-spacing: -0.01em; }
.sec-count { margin-inline-start: auto; font-size: 12px; font-weight: 600; color: var(--muted); background: var(--surface-2); padding: 1px 10px; border-radius: 999px; }
.sec-body { padding: 4px 0 10px; }
.sec-body .section-desc { margin: 8px 0 12px; }
.sec-caret, .cmd-caret { display: inline-flex; flex: none; color: var(--muted); transition: transform 0.18s; }
.sec-collapse[open] > .sec-summary .sec-caret, .cmd-group[open] > .cmd-summary .cmd-caret { transform: rotate(90deg); }
.cmd-group { margin: 6px 0 12px; border: 1px solid var(--border-soft); border-radius: var(--radius); background: var(--surface-2); overflow: hidden; transition: border-color 0.15s; }
.cmd-group:hover { border-color: var(--border); }
.cmd-group[open] { border-color: var(--accent); }
.cmd-summary { padding: 11px 16px; }
.cmd-summary:hover { background: var(--surface); }
.cmd-name { flex: none; font-family: var(--mono); font-size: 13px; font-weight: 700; color: #c9cdfb; background: var(--accent-soft); padding: 2px 8px; border-radius: 6px; }
.cmd-label { flex: 1; min-width: 0; overflow: hidden; color: var(--muted); text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.cmd-fields { padding: 0 16px 12px; background: var(--surface); }
.cmd-dot { flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.field { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); gap: 8px 24px; padding: 15px 0; border-top: 1px solid var(--border-soft); align-items: start; }
.fields .field:first-child { border-top: 0; padding-top: 4px; }
.field-inline { grid-template-columns: minmax(0, 1fr) auto; align-items: center; }
.field-label { display: block; font-weight: 600; font-size: 13.5px; letter-spacing: -0.005em; }
.field-help { margin-top: 4px; color: var(--muted); font-size: 12.5px; line-height: 1.45; }
.field-changed .field-label::after { content: ""; display: inline-block; width: 6px; height: 6px; margin-left: 8px; border-radius: 50%; background: var(--accent); vertical-align: middle; }
.field-error { grid-column: 1 / -1; color: var(--danger); font-size: 13px; font-weight: 500; }
.field-invalid .input { border-color: var(--danger); }
.field-control { min-width: 0; }

.input {
  width: 100%; height: 38px; padding: 0 13px;
  font: inherit; font-weight: 500; color: var(--text);
  background: var(--field-bg);
  border: 1px solid transparent; border-radius: var(--radius-sm);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.input:hover { border-color: var(--border); }
.input:focus { outline: none; border-color: var(--accent); box-shadow: var(--focus); }
select.input { padding-right: 34px; appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23949ba4' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; }
.textarea { height: auto; min-height: 100px; padding: 10px 13px; resize: vertical; line-height: 1.55; font-weight: 400; }
.input-short { width: 130px; }
.input-unit { width: 150px; }
.input-guild, .input-lang { font-weight: 600; }

.switch { position: relative; display: inline-flex; flex: none; width: 40px; height: 22px; cursor: pointer; }
.switch-input { position: absolute; inset: 0; margin: 0; opacity: 0; cursor: pointer; }
.switch-track { width: 40px; height: 22px; border-radius: 11px; background: var(--surface-3); transition: background 0.18s; position: relative; }
.switch-track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,0.4); transition: transform 0.18s; }
.switch-input:checked + .switch-track { background: var(--accent); }
.switch-input:checked + .switch-track::after { transform: translateX(18px); }
.switch-input:focus-visible + .switch-track { box-shadow: var(--focus); }
.head-toggle { display: flex; align-items: center; gap: 12px; color: var(--muted); font-weight: 500; }

.multi { display: flex; flex-direction: column; gap: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips-empty { color: var(--muted); font-size: 13px; }
.chip { display: inline-flex; align-items: center; gap: 4px; max-width: 100%; padding: 0 4px 0 13px; height: 30px; border-radius: 15px; background: var(--accent-soft); font-weight: 500; font-size: 13px; }
.chip-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip-remove { display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px; padding: 0; border: 0; border-radius: 50%; background: none; color: var(--muted); cursor: pointer; transition: background 0.12s, color 0.12s; }
.chip-remove:hover { background: rgba(255,255,255,0.12); color: var(--text); }

/* Buttons — Discord flat style */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px; padding: 0 18px;
  font: inherit; font-weight: 500; font-size: 13.5px;
  border-radius: var(--radius-sm); border: none; cursor: pointer; white-space: nowrap;
  transition: background 0.12s, filter 0.12s, transform 0.1s;
}
.btn:hover { text-decoration: none; filter: brightness(1.08); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: default; transform: none; filter: none; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: var(--surface-3); color: var(--text); }
.btn-secondary:hover { background: #4e5058; }
.btn-danger { background: var(--danger-btn); color: #fff; }
.btn-danger:hover { background: #a12828; filter: none; }
.btn-danger-outline { background: transparent; color: var(--danger); box-shadow: inset 0 0 0 1px var(--danger); }
.btn-danger-outline:hover { background: var(--danger-soft); }
.btn-block { width: 100%; }
.btn-icon { display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px; padding: 0; border: 0; border-radius: var(--radius-sm); background: none; color: var(--muted); cursor: pointer; transition: background 0.12s, color 0.12s; }
.btn-icon:hover { background: rgba(78, 80, 88, 0.4); color: var(--text); }
.actions { display: flex; flex-wrap: wrap; gap: 10px; }

/* Save bar, toasts, dialog */
.savebar {
  position: fixed; left: 50%; bottom: 18px; z-index: 30; transform: translateX(-50%);
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  width: calc(100% - 36px); max-width: 660px;
  padding: 10px 10px 10px 22px;
  background: var(--bg-deep); color: var(--text);
  border: 1px solid var(--border); border-radius: 12px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
}
.savebar .btn-secondary { background: transparent; color: var(--text); box-shadow: inset 0 0 0 1px var(--border); }
.savebar .btn-secondary:hover { background: rgba(78, 80, 88, 0.3); }
.toasts { position: fixed; top: 68px; right: 18px; z-index: 40; display: flex; flex-direction: column; gap: 8px; }
.toast {
  max-width: 380px; padding: 13px 18px; font-weight: 500;
  background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--accent);
  border-radius: var(--radius); box-shadow: 0 6px 24px rgba(0, 0, 0, 0.35);
  animation: toast-in 0.2s ease;
}
@keyframes toast-in { from { opacity: 0; transform: translateY(-6px); } }
.toast-success { border-left-color: var(--success); }
.toast-error { border-left-color: var(--danger); }
.dialog { width: calc(100% - 32px); max-width: 440px; padding: 0; color: var(--text); background: var(--bg-deep); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5); }
.dialog::backdrop { background: rgba(0, 0, 0, 0.6); backdrop-filter: blur(3px); }
.dialog-body { display: flex; flex-direction: column; gap: 14px; padding: 24px; }
.dialog-title { font-size: 17px; font-weight: 700; letter-spacing: -0.01em; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; }

/* Notices, states, login */
.notice { display: flex; align-items: flex-start; gap: 9px; padding: 10px 14px; border-radius: var(--radius-sm); font-size: 13.5px; }
.notice .icon { margin-top: 2px; }
.notice-error { background: var(--danger-soft); color: var(--danger); }
.notice-lock { margin-bottom: 14px; background: var(--surface-2); color: var(--muted); font-size: 13px; }
.input:disabled { background: var(--surface-2); color: var(--muted); cursor: not-allowed; }
.switch-input:disabled, .switch:has(.switch-input:disabled) { cursor: not-allowed; }
.switch-input:disabled + .switch-track { opacity: 0.5; }
.chip-remove:disabled { visibility: hidden; }
.state { flex: 1; display: flex; align-items: center; justify-content: center; gap: 12px; min-height: 260px; color: var(--muted); font-weight: 500; }
.spinner { width: 22px; height: 22px; border: 2.5px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.login { flex: 1; display: flex; align-items: center; justify-content: center; padding: 32px 16px; }
.login-card { width: 100%; max-width: 420px; display: flex; flex-direction: column; align-items: flex-start; gap: 14px; padding: 36px; }
.login-card .page-title { font-size: 24px; }
.command { display: inline-block; padding: 5px 10px; font-size: 13px; font-weight: 600; background: var(--accent-soft); color: #c9cdfb; border-radius: 6px; }
.login-or { display: flex; align-items: center; gap: 12px; width: 100%; color: var(--muted); font-size: 12px; }
.login-or::before, .login-or::after { content: ""; flex: 1; height: 1px; background: var(--border-soft); }
.noscript { padding: 16px; }

.footer { padding: 18px; text-align: center; color: var(--faint); font-size: 13px; border-top: 1px solid var(--border-soft); }
.footer a { font-weight: 600; color: var(--muted); }
.footer a:hover { color: var(--text); }

/* Alternate themes — applied via <html data-theme>, persisted in localStorage */
[data-theme="midnight"] {
  --bg: #0f1420;
  --surface: #161d2e;
  --surface-2: #1d2740;
  --surface-3: #25314f;
  --bg-deep: #0a0e1a;
  --field-bg: #0a0e1a;
  --border: #26324f;
  --border-soft: #1a2338;
  --text: #e6e9f2;
  --muted: #8b93ad;
  --faint: #6b7390;
  --accent: #5b8cff;
  --accent-hover: #4a7bef;
  --accent-soft: rgba(91, 140, 255, 0.18);
  color-scheme: dark;
}
[data-theme="light"] {
  --bg: #f2f3f5;
  --surface: #ffffff;
  --surface-2: #f6f7f8;
  --surface-3: #ebedef;
  --bg-deep: #e3e5e8;
  --field-bg: #f6f7f8;
  --border: #b5bac1;
  --border-soft: #e3e5e8;
  --text: #313338;
  --muted: #6d6f78;
  --faint: #80848e;
  --accent: #5865f2;
  --accent-hover: #4752c4;
  --accent-soft: rgba(88, 101, 242, 0.12);
  --on-accent: #ffffff;
  --danger: #c92a2e;
  --danger-btn: #da373c;
  --danger-soft: rgba(201, 42, 46, 0.1);
  --success: #248046;
  --success-soft: rgba(36, 128, 70, 0.12);
  --warn: #b8860b;
  --focus: 0 0 0 3px rgba(88, 101, 242, 0.35);
  color-scheme: light;
}
[data-theme="light"] .rail-icon { background: var(--surface-2); }
[data-theme="light"] .btn-secondary { background: var(--surface-3); }
[data-theme="light"] .btn-secondary:hover { background: #d7dae0; }
[data-theme="light"] .switch-track { background: #b5bac1; }
[data-theme="light"] .toast, [data-theme="light"] .dialog, [data-theme="light"] .savebar { box-shadow: 0 6px 24px rgba(0, 0, 0, 0.12); }
[data-theme="light"] ::-webkit-scrollbar-thumb { background: #c4c9d1; border-color: var(--bg); }
[data-theme="light"] .chip-remove:hover { background: rgba(0,0,0,0.08); }

/* Tablet and phone */
@media (max-width: 960px) {
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .field { grid-template-columns: minmax(0, 1fr); }
  .field-inline { grid-template-columns: minmax(0, 1fr) auto; }
  .sidebar { width: 220px; }
}

@media (max-width: 760px) {
  .rail { display: none; }
  .rail-home { display: inline-flex; }
  .btn-icon.menu-btn { display: inline-flex; margin-left: -8px; }
  .topbar { gap: 8px; padding: 0 14px; height: 52px; }
  .topbar .input-lang { width: 70px; padding-right: 26px; background-position: right 9px center; }
  .topbar .input-theme { display: none; }
  .topbar-guild { display: none; }
  .sidebar {
    position: fixed; top: 52px; bottom: 0; left: 0; z-index: 25; overflow-y: auto;
    width: 270px; transform: translateX(-105%); transition: transform 0.22s ease;
    box-shadow: 8px 0 30px rgba(0,0,0,0.5);
  }
  .menu-open .sidebar { transform: none; }
  .menu-open .scrim { display: block; position: fixed; inset: 52px 0 0 0; z-index: 24; background: rgba(0, 0, 0, 0.55); backdrop-filter: blur(2px); }
  .page { padding: 18px 16px 110px; }
  .card { padding: 18px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .page-header { flex-wrap: wrap; }
  .savebar { bottom: 10px; width: calc(100% - 20px); padding: 8px 8px 8px 18px; border-radius: 16px; }
  .toasts { top: 60px; right: 10px; left: 10px; }
  .toast { max-width: none; }
}

/* ---------- Command Center ---------- */
.cc-stats { margin-bottom: 16px; }
.cc-toolbar { margin-bottom: 18px; align-items: center; }
.cc-search { flex: 1; max-width: 460px; }
.cc-filters { flex-wrap: wrap; }
.cc-chip { height: 30px; padding: 0 14px; border: 1px solid transparent; background: var(--surface-2); color: var(--muted); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; transition: background 0.12s, color 0.12s, border-color 0.12s; }
.cc-chip:hover { background: var(--surface-3); color: var(--text); }
.cc-chip-on { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
.cc-layout { display: flex; gap: 18px; align-items: flex-start; }
.cc-side { flex: none; width: 230px; padding: 10px; position: sticky; top: 76px; }
.cc-nav-item { width: 100%; border: 0; background: none; font: inherit; color: var(--muted); cursor: pointer; text-align: start; }
.cc-nav-item .nav-link { flex: 1; min-width: 0; }
.cc-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 22px; }
.cc-cat-head { margin-bottom: 4px; }
.cc-cat-head .page-title { display: flex; align-items: center; gap: 8px; }
.cc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 14px; }
.cc-card { padding: 16px; cursor: pointer; transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s; display: flex; flex-direction: column; gap: 10px; }
.cc-card:hover { transform: translateY(-2px); border-color: var(--accent); box-shadow: 0 8px 24px rgba(0,0,0,0.25); }
.cc-card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.cc-card-top { display: flex; align-items: center; gap: 8px; }
.cc-card-top .pill { margin-inline-start: auto; }
.cc-fav { color: var(--warning, #f0b232); display: inline-flex; }
.cc-card-desc { font-size: 13px; line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: clamp; overflow: hidden; min-height: 38px; }
.cc-card-bottom { display: flex; align-items: center; justify-content: space-between; margin-top: auto; padding-top: 6px; border-top: 1px solid var(--border); }
.cc-card-bottom .switch { flex: none; }
.cmd-name-lg { font-size: 15px; padding: 4px 12px; }
.cc-desc { margin: -8px 0 16px; }
.cc-global { margin-bottom: 18px; }
@media (max-width: 900px) {
  .cc-layout { flex-direction: column; }
  .cc-side { width: 100%; position: static; display: flex; flex-wrap: wrap; gap: 4px; }
  .cc-nav-item { width: auto; flex: 1 1 auto; }
  .cc-grid { grid-template-columns: 1fr; }
}
