:root {
  --bg: #0b101b;
  --bg-2: #101827;
  --bg-3: #162034;
  --bg-4: #1e2a41;
  --panel: #121b2c;
  --ink: #eef3fb;
  --ink-2: #b9c5d8;
  --ink-3: #8695ad;
  --line: #22314a;
  --accent: #5b8cff;
  --accent-2: #3ddc97;
  --warm: #ffb454;
  --danger: #ff6b7a;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.42);
  --font: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: "JetBrains Mono", "Cascadia Code", ui-monospace, monospace;
  --font-scale: 1;
  --density: 1;
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #f4f7fc;
  --bg-2: #eaf0fa;
  --bg-3: #dde6f4;
  --bg-4: #ccd9ed;
  --panel: #ffffff;
  --ink: #0d1728;
  --ink-2: #3d4d66;
  --ink-3: #65758f;
  --line: #d5dfee;
  --shadow: 0 18px 44px rgba(24, 44, 80, 0.16);
  color-scheme: light;
}
:root[data-accent="mint"] { --accent: #2ecf8e; }
:root[data-accent="amber"] { --accent: #e39a3b; }
:root[data-accent="rose"] { --accent: #f0638a; }
:root[data-accent="violet"] { --accent: #9b7bff; }
:root[data-density="compact"] { --density: 0.82; }
:root[data-density="roomy"] { --density: 1.18; }

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: calc(15px * var(--font-scale));
  line-height: 1.45;
  overflow: hidden;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }
img { max-width: 100%; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.skip-link { position: absolute; left: 12px; top: -60px; background: var(--accent); color: #06101f; padding: 8px 14px; z-index: 100; border-radius: 8px; font-weight: 700; }
.skip-link:focus { top: 12px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.boot { height: 100%; display: grid; place-content: center; justify-items: center; gap: 12px; color: var(--ink-2); }
.boot img { animation: breathe 2.2s ease-in-out infinite; }
@keyframes breathe { 50% { transform: scale(1.06); opacity: 0.8; } }

/* ---------- auth ---------- */
.auth { height: 100%; overflow-y: auto; padding: clamp(20px, 4vw, 56px); display: flex; flex-direction: column; gap: 32px; max-width: 1180px; margin: 0 auto; }
.auth-brand { display: flex; align-items: center; gap: 16px; }
.auth-brand h1 { margin: 0; font-size: 34px; letter-spacing: -0.035em; }
.tagline { margin: 2px 0 0; color: var(--accent-2); font-weight: 600; }
.auth-grid { display: grid; grid-template-columns: 1.1fr 420px; gap: clamp(24px, 5vw, 72px); align-items: start; }
.auth-pitch h2 { font-size: clamp(28px, 4vw, 46px); line-height: 1.08; letter-spacing: -0.04em; margin: 8px 0 16px; max-width: 16ch; }
.auth-pitch p { color: var(--ink-2); max-width: 52ch; }
.pill-list { display: flex; flex-wrap: wrap; gap: 8px; list-style: none; padding: 0; margin: 22px 0; }
.pill-list li { border: 1px solid var(--line); background: var(--bg-2); padding: 7px 12px; border-radius: 999px; font-size: 0.85em; color: var(--ink-2); }
.auth-card { background: var(--panel); border: 1px solid var(--line); border-radius: 20px; padding: 22px; box-shadow: var(--shadow); }
.tabs { display: flex; gap: 4px; background: var(--bg); border-radius: 10px; padding: 4px; margin-bottom: 18px; }
.tab { flex: 1; background: none; border: 0; padding: 9px; border-radius: 7px; color: var(--ink-3); font-weight: 600; }
.tab.active { background: var(--bg-3); color: var(--ink); }
.stack { display: flex; flex-direction: column; gap: 12px; }
.stack label { display: flex; flex-direction: column; gap: 6px; font-size: 0.86em; color: var(--ink-2); font-weight: 600; }
.stack small { color: var(--ink-3); font-weight: 400; }
input, textarea, select {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  color: var(--ink);
  width: 100%;
}
input:focus, textarea:focus, select:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
input[type="checkbox"] { width: auto; accent-color: var(--accent); }
.btn { border: 1px solid var(--line); background: var(--bg-3); color: var(--ink); border-radius: 10px; padding: 9px 14px; font-weight: 650; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.btn:hover { background: var(--bg-4); }
.btn.primary { background: var(--accent); border-color: transparent; color: #071021; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { background: transparent; color: var(--danger); border-color: color-mix(in srgb, var(--danger) 50%, var(--line)); }
.btn.ghost { background: transparent; }
.btn.small { padding: 5px 9px; font-size: 0.84em; border-radius: 8px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.link { background: none; border: 0; color: var(--accent); padding: 0; font-size: 0.88em; }
.row { display: flex; align-items: center; }
.row.gap { gap: 8px; }
.row.spread { justify-content: space-between; }
.fine { color: var(--ink-3); font-size: 0.82em; }
.note { color: var(--accent-2); font-size: 0.86em; overflow-wrap: anywhere; }
.error { color: var(--danger); min-height: 1.2em; margin: 0; font-size: 0.86em; }

/* ---------- shell ---------- */
.app { height: 100%; display: grid; grid-template-columns: 74px 262px minmax(0, 1fr) 248px; background: var(--bg); }
.rail { background: var(--bg-2); border-right: 1px solid var(--line); display: flex; flex-direction: column; justify-content: space-between; padding: 10px 8px; }
.rail-top, .rail-bottom { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.rail-list { display: flex; flex-direction: column; gap: 8px; max-height: 58vh; overflow-y: auto; padding: 2px; }
.rail-home { background: none; border: 0; border-radius: 12px; padding: 6px; }
.rail-add { width: 46px; height: 46px; border-radius: 14px; border: 1px dashed var(--line); background: var(--bg-3); color: var(--ink-2); font-size: 20px; position: relative; }
.rail-add:hover { border-color: var(--accent); color: var(--ink); }
.rail-item { width: 46px; height: 46px; border-radius: 14px; border: 1px solid transparent; background: var(--bg-3); color: var(--ink); font-weight: 700; overflow: hidden; position: relative; padding: 0; }
.rail-item img { width: 100%; height: 100%; object-fit: cover; }
.rail-item.active { border-color: var(--accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 28%, transparent); }
.rail-item .dot { position: absolute; right: 4px; bottom: 4px; }
.rail-avatar { width: 42px; height: 42px; border-radius: 50%; border: 1px solid var(--line); background: var(--bg-4); overflow: hidden; font-weight: 700; }
.rail-avatar img { width: 100%; height: 100%; object-fit: cover; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--warm); display: inline-block; }

.sidebar { background: var(--bg-2); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.sidebar-head { display: flex; align-items: center; gap: 6px; padding: 12px 10px 12px 14px; border-bottom: 1px solid var(--line); }
.community-title { flex: 1; text-align: left; background: none; border: 0; font-weight: 750; font-size: 1em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-body { flex: 1; overflow-y: auto; padding: 10px; }
.sidebar-foot { border-top: 1px solid var(--line); padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.me-line { display: flex; align-items: center; gap: 7px; font-size: 0.86em; color: var(--ink-2); min-width: 0; }
.me-line span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.presence-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent-2); flex: none; }
.presence-dot.offline { background: var(--ink-3); }
.presence-dot.idle { background: var(--warm); }
.presence-dot.dnd { background: var(--danger); }

.nav-group { margin-bottom: 14px; }
.nav-label { display: flex; justify-content: space-between; align-items: center; font-size: 0.72em; text-transform: uppercase; letter-spacing: 0.09em; color: var(--ink-3); font-weight: 700; padding: 4px 8px; }
.nav-channel { width: 100%; display: flex; align-items: center; gap: 7px; background: none; border: 0; color: var(--ink-2); text-align: left; padding: 6px 8px; border-radius: 7px; font-size: 0.92em; }
.nav-channel:hover { background: var(--bg-3); color: var(--ink); }
.nav-channel.active { background: color-mix(in srgb, var(--accent) 16%, var(--bg-3)); color: var(--ink); }
.nav-channel .glyph { color: var(--ink-3); width: 14px; text-align: center; }
.nav-channel .unread { margin-left: auto; background: var(--warm); color: #1b1305; font-size: 0.72em; padding: 1px 6px; border-radius: 999px; font-weight: 700; }
.nav-tool { width: 100%; display: flex; align-items: center; gap: 8px; background: var(--bg); border: 1px solid var(--line); color: var(--ink-2); padding: 8px; border-radius: 9px; margin-bottom: 6px; font-size: 0.88em; }
.nav-tool:hover { border-color: var(--accent); color: var(--ink); }
.nav-tool .badge { margin-left: auto; background: var(--bg-4); border-radius: 6px; padding: 0 5px; font-size: 0.78em; }

.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--bg); }
.chat-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 16px; border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--bg) 84%, transparent); backdrop-filter: blur(8px); }
.chat-title { display: flex; align-items: center; gap: 8px; min-width: 0; }
.chat-title h2 { margin: 0; font-size: 1.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-title p { margin: 0; color: var(--ink-3); font-size: 0.8em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-actions { display: flex; align-items: center; gap: 6px; }
.voice-pill { display: flex; gap: 6px; align-items: center; border: 1px solid color-mix(in srgb, var(--accent-2) 40%, var(--line)); background: color-mix(in srgb, var(--accent-2) 12%, var(--bg-2)); padding: 4px 9px; border-radius: 999px; font-size: 0.78em; color: var(--accent-2); max-width: 240px; overflow: hidden; }
.icon-btn { background: none; border: 0; color: var(--ink-2); width: 34px; height: 34px; border-radius: 9px; display: inline-grid; place-items: center; font-size: 15px; flex: none; }
.icon-btn:hover { background: var(--bg-3); color: var(--ink); }
.main-view { flex: 1; overflow-y: auto; min-height: 0; padding: 16px clamp(12px, 2.2vw, 26px) 8px; }
.members { background: var(--bg-2); border-left: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.members-head { padding: 13px 14px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; font-size: 0.84em; letter-spacing: 0.04em; text-transform: uppercase; color: var(--ink-3); }
.member-list { overflow-y: auto; padding: 8px; }
.member { display: flex; gap: 9px; align-items: center; padding: 6px 7px; border-radius: 8px; width: 100%; background: none; border: 0; text-align: left; color: var(--ink-2); }
.member:hover { background: var(--bg-3); color: var(--ink); }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--bg-4); display: grid; place-items: center; font-weight: 700; font-size: 0.78em; overflow: hidden; flex: none; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.bot { background: color-mix(in srgb, var(--accent) 25%, var(--bg-4)); color: var(--accent); }
.member-name { font-size: 0.88em; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.member-sub { font-size: 0.72em; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- messages ---------- */
.messages { display: flex; flex-direction: column; gap: 2px; }
.msg { display: grid; grid-template-columns: 38px minmax(0, 1fr); gap: 10px; padding: calc(4px * var(--density)) 6px; border-radius: 9px; position: relative; }
.msg:hover { background: color-mix(in srgb, var(--bg-2) 70%, transparent); }
.msg .avatar { width: 38px; height: 38px; }
.msg-head { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.msg-author { font-weight: 700; font-size: 0.92em; }
.msg-author.bot { color: var(--accent); }
.msg-time { color: var(--ink-3); font-size: 0.7em; }
.msg-body { color: var(--ink); overflow-wrap: anywhere; font-size: 0.94em; }
.msg-body p { margin: 0 0 4px; }
.msg-body p:last-child { margin-bottom: 0; }
.msg-body code { background: var(--bg-2); border: 1px solid var(--line); padding: 1px 5px; border-radius: 5px; font-family: var(--mono); font-size: 0.88em; }
.msg-body pre { background: var(--bg-2); border: 1px solid var(--line); padding: 10px 12px; border-radius: 9px; overflow-x: auto; margin: 6px 0; }
.msg-body pre code { border: 0; background: none; padding: 0; font-size: 0.85em; }
.tok-key { color: #8fb8ff; }
.tok-str { color: #7fe0b0; }
.tok-num { color: #ffc978; }
.tok-com { color: #7f8ea8; font-style: italic; }
.msg-body blockquote { border-left: 3px solid var(--line); margin: 4px 0; padding-left: 10px; color: var(--ink-2); }
.msg-body .mention { background: color-mix(in srgb, var(--accent) 26%, transparent); color: var(--ink); border-radius: 5px; padding: 0 3px; font-weight: 600; }
.msg-body a { word-break: break-all; }
.spoiler { background: var(--ink-3); color: transparent; border-radius: 4px; padding: 0 3px; cursor: pointer; }
.spoiler.revealed { background: var(--bg-3); color: var(--ink); }
.msg.deleted { opacity: 0.55; font-style: italic; }
.msg-reply { border-left: 2px solid var(--line); padding-left: 8px; color: var(--ink-3); font-size: 0.78em; margin-bottom: 2px; }
.msg-actions { position: absolute; top: -10px; right: 8px; display: none; gap: 2px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 2px; }
.msg:hover .msg-actions, .msg:focus-within .msg-actions { display: flex; }
.msg-actions button { background: none; border: 0; color: var(--ink-2); padding: 3px 6px; border-radius: 5px; font-size: 0.85em; }
.msg-actions button:hover { background: var(--bg-3); }
.msg-edited { color: var(--ink-3); font-size: 0.7em; }
.msg-editor textarea { min-height: 70px; }
.reactions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 5px; }
.reaction { display: inline-flex; gap: 4px; align-items: center; border: 1px solid var(--line); background: var(--bg-2); border-radius: 999px; padding: 1px 7px; font-size: 0.78em; color: var(--ink-2); }
.reaction.me { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 16%, var(--bg-2)); color: var(--ink); }
.attachments { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.attachment { border: 1px solid var(--line); border-radius: 9px; padding: 6px; background: var(--bg-2); max-width: 320px; font-size: 0.82em; }
.attachment img, .attachment video { display: block; border-radius: 6px; max-width: 300px; max-height: 260px; }
.attachment audio { max-width: 300px; }
.poll { border: 1px solid var(--line); background: var(--bg-2); border-radius: 11px; padding: 10px 12px; margin-top: 6px; max-width: 480px; }
.poll h4 { margin: 0 0 8px; font-size: 0.92em; }
.poll-option { display: block; width: 100%; text-align: left; border: 1px solid var(--line); background: var(--bg); border-radius: 8px; padding: 7px 9px; margin-bottom: 5px; position: relative; overflow: hidden; color: var(--ink); }
.poll-option .fill { position: absolute; inset: 0 auto 0 0; background: color-mix(in srgb, var(--accent) 20%, transparent); }
.poll-option span { position: relative; }
.poll-meta { display: flex; justify-content: space-between; gap: 8px; color: var(--ink-3); font-size: 0.75em; }
.forwarded { font-size: 0.75em; color: var(--ink-3); border-left: 2px solid var(--accent); padding-left: 7px; margin-bottom: 3px; }
.typing { min-height: 18px; color: var(--ink-3); font-size: 0.78em; padding: 0 14px 4px; }
.day-divider { display: flex; align-items: center; gap: 10px; margin: 16px 0 8px; color: var(--ink-3); font-size: 0.72em; text-transform: uppercase; letter-spacing: 0.08em; }
.day-divider::before, .day-divider::after { content: ""; height: 1px; background: var(--line); flex: 1; }
.empty { display: grid; place-content: center; justify-items: center; gap: 10px; text-align: center; color: var(--ink-3); min-height: 40vh; padding: 20px; }
.empty h2 { color: var(--ink); margin: 0; font-size: 1.2em; }
.empty p { margin: 0; max-width: 46ch; }
.empty .btn { margin-top: 4px; }

/* ---------- composer ---------- */
.composer { padding: 8px clamp(12px, 2.2vw, 26px) 14px; }
.composer-inner { display: flex; align-items: flex-end; gap: 6px; background: var(--bg-2); border: 1px solid var(--line); border-radius: 13px; padding: 5px 7px; }
.composer-inner:focus-within { border-color: var(--accent); }
#message-input { border: 0; background: none; resize: none; max-height: 200px; padding: 7px 4px; box-shadow: none; }
#message-input:focus { box-shadow: none; }
.composer .send { border-radius: 9px; padding: 7px 14px; margin-bottom: 1px; }
.composer-hint { display: flex; justify-content: space-between; gap: 10px; color: var(--ink-3); font-size: 0.7em; padding: 5px 4px 0; }
kbd { background: var(--bg-3); border: 1px solid var(--line); border-radius: 4px; padding: 0 4px; font-family: var(--mono); font-size: 0.9em; }
.reply-banner { display: flex; justify-content: space-between; gap: 8px; background: var(--bg-3); border: 1px solid var(--line); border-radius: 9px; padding: 5px 9px; margin-bottom: 5px; font-size: 0.8em; color: var(--ink-2); }
.upload-progress { height: 4px; background: var(--bg-3); border-radius: 4px; overflow: hidden; margin-bottom: 5px; }
.upload-progress > div { height: 100%; width: 0; background: var(--accent-2); transition: width 0.15s; }

/* ---------- modal & forms ---------- */
.modal { border: 1px solid var(--line); background: var(--panel); color: var(--ink); border-radius: 18px; padding: 0; width: min(760px, 94vw); max-height: 88vh; box-shadow: var(--shadow); }
.modal::backdrop { background: rgba(3, 8, 18, 0.68); backdrop-filter: blur(3px); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.modal-head h2 { font-size: 1.05em; margin: 0; }
.modal-body { padding: 18px; overflow-y: auto; max-height: calc(88vh - 58px); }
.modal-tabs { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 16px; }
.modal-tabs button { background: var(--bg-2); border: 1px solid var(--line); color: var(--ink-2); border-radius: 999px; padding: 5px 11px; font-size: 0.8em; }
.modal-tabs button.active { background: var(--accent); border-color: transparent; color: #071021; font-weight: 700; }
.settings-grid { display: grid; grid-template-columns: 180px 1fr; gap: 18px; }
.settings-nav { display: flex; flex-direction: column; gap: 3px; }
.settings-nav button { text-align: left; background: none; border: 0; color: var(--ink-2); padding: 7px 9px; border-radius: 7px; font-size: 0.88em; }
.settings-nav button.active { background: var(--bg-3); color: var(--ink); }
.section { display: flex; flex-direction: column; gap: 12px; }
.section h3 { margin: 0; font-size: 0.98em; }
.section .hint { color: var(--ink-3); font-size: 0.8em; margin: -4px 0 0; }
.field { display: grid; grid-template-columns: 1fr 230px; gap: 12px; align-items: center; border-bottom: 1px solid var(--line); padding: 10px 0; }
.field:last-child { border-bottom: 0; }
.field .label { font-size: 0.88em; }
.field .label small { display: block; color: var(--ink-3); font-size: 0.9em; }
.field input, .field select { max-width: 230px; }
.toggle { display: flex; justify-content: space-between; align-items: center; gap: 14px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.toggle:last-child { border-bottom: 0; }
.toggle small { display: block; color: var(--ink-3); }
.chip { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--bg-2); border-radius: 999px; padding: 2px 8px; font-size: 0.74em; color: var(--ink-2); }
.chip.ok { border-color: color-mix(in srgb, var(--accent-2) 45%, var(--line)); color: var(--accent-2); }
.chip.warn { border-color: color-mix(in srgb, var(--warm) 45%, var(--line)); color: var(--warm); }
.chip.bad { border-color: color-mix(in srgb, var(--danger) 45%, var(--line)); color: var(--danger); }
.list { display: flex; flex-direction: column; gap: 7px; }
.list-item { border: 1px solid var(--line); background: var(--bg-2); border-radius: 10px; padding: 10px 12px; display: flex; gap: 10px; align-items: flex-start; justify-content: space-between; }
.list-item .grow { min-width: 0; }
.list-item h4 { margin: 0 0 2px; font-size: 0.9em; }
.list-item p { margin: 0; color: var(--ink-3); font-size: 0.8em; overflow-wrap: anywhere; }
.list-item .actions { display: flex; gap: 5px; flex: none; }
.table { width: 100%; border-collapse: collapse; font-size: 0.82em; }
.table th, .table td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--line); }
.table th { color: var(--ink-3); font-weight: 600; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; }
.stat { border: 1px solid var(--line); background: var(--bg-2); border-radius: 10px; padding: 10px; }
.stat b { display: block; font-size: 1.35em; letter-spacing: -0.03em; }
.stat span { color: var(--ink-3); font-size: 0.76em; }
.search-box { display: flex; gap: 6px; margin-bottom: 12px; }
.result { border: 1px solid var(--line); background: var(--bg-2); border-radius: 9px; padding: 8px 10px; margin-bottom: 6px; }
.result .meta { color: var(--ink-3); font-size: 0.75em; }
.ad { border: 1px dashed var(--line); background: var(--bg-2); border-radius: 10px; padding: 9px 11px; margin: 12px 6px; font-size: 0.78em; color: var(--ink-2); }
.ad .tag { text-transform: uppercase; letter-spacing: 0.09em; font-size: 0.72em; color: var(--ink-3); display: block; margin-bottom: 3px; }
.ad a { color: var(--accent); }
.toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 90; max-width: min(380px, 90vw); }
.toast { background: var(--panel); border: 1px solid var(--line); border-left: 3px solid var(--accent); border-radius: 9px; padding: 9px 12px; font-size: 0.84em; box-shadow: var(--shadow); }
.toast.error { border-left-color: var(--danger); }
.mobile-bar { display: none; }
.mobile-only { display: none !important; }

/* admin */
.admin-body { overflow-y: auto; height: 100%; padding: 20px; max-width: 1180px; margin: 0 auto; }
.admin-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 16px; }
.admin-head h1 { margin: 0; font-size: 1.4em; }
.admin-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 12px; }
.card { border: 1px solid var(--line); background: var(--panel); border-radius: 12px; padding: 14px; }

@media (max-width: 1200px) {
  .app { grid-template-columns: 74px 240px minmax(0, 1fr); }
  .members { display: none; position: fixed; right: 0; top: 0; bottom: 0; width: 280px; z-index: 20; }
  .members.open { display: flex; }
}
@media (max-width: 900px) {
  .auth-grid { grid-template-columns: 1fr; }
  .app { grid-template-columns: 64px minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
  .mobile-bar { display: flex; align-items: center; justify-content: space-between; grid-column: 1 / -1; padding: 6px 8px; border-bottom: 1px solid var(--line); background: var(--bg-2); }
  .rail { grid-row: 2; padding: 6px 4px; }
  .sidebar { position: fixed; left: 64px; top: 0; bottom: 0; width: min(300px, 78vw); z-index: 25; transform: translateX(calc(-100% - 64px)); transition: transform 0.18s ease; }
  .sidebar.open { transform: none; box-shadow: var(--shadow); }
  .main { grid-column: 2; grid-row: 2; }
  .rail-add, .rail-item, .rail-home { width: 40px; height: 40px; font-size: 15px; }
  .mobile-only { display: inline-grid !important; }
  .settings-grid { grid-template-columns: 1fr; }
  .settings-nav { flex-direction: row; overflow-x: auto; }
  .field { grid-template-columns: 1fr; gap: 6px; }
  .field input, .field select { max-width: none; }
  .composer-hint { display: none; }
}
@media (max-width: 560px) {
  .rail { display: flex; flex-direction: row; position: fixed; bottom: 0; left: 0; right: 0; height: 58px; z-index: 30; border-top: 1px solid var(--line); border-right: 0; padding: 4px 8px; }
  .rail-top, .rail-bottom { flex-direction: row; gap: 6px; }
  .rail-list { flex-direction: row; max-height: none; overflow-x: auto; }
  .rail-bottom { margin-left: auto; }
  .app { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr) 58px; }
  .main { grid-column: 1; grid-row: 2; padding-bottom: 0; }
  .sidebar { left: 0; width: 100%; transform: translateX(-100%); }
  .mobile-bar { grid-row: 1; }
  .msg { grid-template-columns: 32px minmax(0, 1fr); }
  .msg .avatar { width: 32px; height: 32px; }
  .toasts { bottom: 70px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}
:root[data-motion="off"] *, :root[data-motion="off"] *::before, :root[data-motion="off"] *::after { animation: none !important; transition: none !important; }
