:root {
  color-scheme: dark;
  --void: #0b0c0f;
  --rail: #0f1013;
  --bg: #15161a;
  --panel: #1b1c21;
  --panel-solid: #1e2026;
  --raised: #262830;
  --hover: rgba(255, 255, 255, 0.05);
  --selected: #2c2f38;
  --text: #eef0f3;
  --secondary: #c3c7cf;
  --muted: #8a8f99;
  --line: rgba(255, 255, 255, 0.07);
  --line-hover: rgba(255, 255, 255, 0.13);
  --primary: #e8eaf0;
  --primary-hover: #ffffff;
  --primary-text: #15161a;
  --focus: #9aa3b5;
  --mine: rgba(255, 255, 255, 0.035);
  --mine-hover: rgba(255, 255, 255, 0.06);
  --accent: #f0b35a;
  --accent-hover: #ffc978;
  --accent-pressed: #d89838;
  --accent-soft: rgba(240, 179, 90, 0.12);
  --accent-line: rgba(240, 179, 90, 0.38);
  --error: #ffb4bb;
  --error-soft: rgba(255, 180, 187, 0.10);
  --success: #8ee3c4;
  --elevation: 0 8px 22px rgba(0, 0, 0, 0.35);
  --elevation-dialog: 0 24px 60px rgba(0, 0, 0, 0.55);
  --font: Inter, 'Segoe UI Variable', 'Segoe UI', system-ui, sans-serif;
  --mono: Consolas, 'Cascadia Mono', monospace;
  --text-meta: 12px; --text-ui: 14px; --text-body: 15px; --text-title: 18px; --text-page: 28px;
  --radius-s: 6px; --radius-m: 12px; --radius-l: 18px; --radius-pill: 999px;
  --rail-width: 76px; --sidebar-width: 260px; --thread-width: 260px;
  --header-height: 68px; --security-header-height: 92px;
  --message-avatar: 36px; --row-avatar: 26px; --empty-symbol: 84px;
}
[data-theme="violet"] {
  color-scheme: dark;
  --void: #0c0b14; --rail: #141220; --bg: #1a1828; --panel: #1f1c30; --panel-solid: #201d33; --raised: #2a2642;
  --hover: rgba(167, 150, 255, 0.10); --selected: #3a3360;
  --text: #f4f1ff; --secondary: #c7c2e0; --muted: #8f8aab; --line: rgba(255, 255, 255, 0.07); --line-hover: rgba(255, 255, 255, 0.14);
  --primary: #b5a4ff; --primary-hover: #c7b9ff; --primary-text: #120f1f; --focus: #b5a4ff;
  --mine: rgba(169, 150, 255, 0.08); --mine-hover: rgba(169, 150, 255, 0.14);
}

* { box-sizing: border-box; scrollbar-width: thin; scrollbar-color: var(--raised) transparent; }
html, body { margin: 0; height: 100%; background: var(--void); color: var(--text); font: var(--text-ui)/1.45 var(--font); -webkit-font-smoothing: antialiased; }
button, input, textarea { font: inherit; color: inherit; }
button { min-height: 34px; max-width: 100%; width: fit-content; border: 1px solid var(--line-hover); background: var(--raised); border-radius: var(--radius-m); padding: 6px 14px; font-size: var(--text-ui); font-weight: 600; cursor: pointer; transition: background .18s ease, color .18s ease, border-color .18s ease, transform .12s ease; }
button:hover:not(:disabled) { background: var(--selected); color: var(--text); }
button:active:not(:disabled) { transform: translateY(1px); }
button:disabled, input:disabled { opacity: .4; cursor: not-allowed; }
button.primary, #btn-login, #prompt-ok { color: var(--primary-text); background: var(--primary); border-color: transparent; }
button.primary:hover:not(:disabled), #btn-login:hover:not(:disabled), #prompt-ok:hover:not(:disabled) { background: var(--primary-hover); color: var(--primary-text); }
button.ghost { background: transparent; border-color: transparent; color: var(--secondary); }
button.ghost:hover:not(:disabled) { background: var(--hover); color: var(--text); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
[hidden], .hidden { display: none !important; }
input, textarea { min-width: 0; min-height: 38px; background: var(--rail); border: 1px solid var(--line-hover); border-radius: var(--radius-m); padding: 8px 12px; transition: border-color .18s ease; }
input:focus, textarea:focus { outline: none; border-color: var(--focus); }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 1; }
textarea { width: 100%; resize: vertical; }
.muted, .security-line, .tag, .me { color: var(--muted); }
.row { display: flex; align-items: center; gap: 8px; }
.wrap { flex-wrap: wrap; }
label { display: grid; gap: 6px; color: var(--secondary); }
p { line-height: 1.55; }
details > summary { cursor: pointer; padding: 8px 0; color: var(--secondary); list-style: none; }
details > summary::-webkit-details-marker { display: none; }
details > summary:hover { color: var(--text); }
details button { margin: 4px 0; }
.icon { width: 18px; height: 18px; flex: none; vertical-align: middle; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; overflow: visible; }
.brand { font-size: 30px; font-weight: 700; letter-spacing: -.03em; color: var(--text); }
.brand-sm { font-size: var(--text-meta); color: var(--muted); letter-spacing: .02em; }
.eyebrow { display: block; font-size: var(--text-meta); font-weight: 700; letter-spacing: .12em; color: var(--muted); }
.avatar { width: var(--message-avatar); height: var(--message-avatar); display: grid; place-items: center; flex: none; border-radius: var(--radius-pill); background: var(--raised); color: var(--secondary); font-weight: 700; }
[data-tone="0"] { background: #3a4150; color: #e6eaf2; }
[data-tone="1"] { background: #2f4a48; color: #d9f3ee; }
[data-tone="2"] { background: #3a4466; color: #e2e7f7; }
[data-tone="3"] { background: #4d3a48; color: #f5e4ef; }
[data-tone="4"] { background: #34503f; color: #dcf4e4; }
[data-tone="5"] { background: #4d4636; color: #f6eedc; }
[data-theme="violet"] [data-tone="0"] { background: #51446d; color: #e4d9ff; }
[data-theme="violet"] [data-tone="1"] { background: #365b64; color: #c2eced; }
[data-theme="violet"] [data-tone="2"] { background: #4c537a; color: #dce1ff; }
[data-theme="violet"] [data-tone="3"] { background: #644857; color: #f5d7e3; }
[data-theme="violet"] [data-tone="4"] { background: #3f6256; color: #d0efde; }
[data-theme="violet"] [data-tone="5"] { background: #55596a; color: #e1e4ef; }

/* Shell. */
#app { display: grid; grid-template-columns: var(--rail-width) var(--sidebar-width) minmax(0, 1fr) var(--thread-width); height: 100%; overflow: hidden; }
#app > * { min-width: 0; }
.server-rail { background: var(--rail); display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 14px 0; min-height: 0; border-right: 1px solid var(--line); }
.rail-home, #server-avatars button { position: relative; display: grid; place-items: center; width: 48px; min-height: 48px; height: 48px; padding: 0; border: 0; border-radius: 16px; background: var(--raised); transition: border-radius .2s ease, background .2s ease; }
.rail-home { color: var(--secondary); background: transparent; }
.rail-home img { width: 48px; height: 48px; border-radius: 16px; object-fit: cover; display: block; }
.rail-home:hover, #server-avatars button:hover { border-radius: 14px; background: var(--selected); }
.rail-home[aria-pressed="true"], #server-avatars button.active { border-radius: 14px; background: var(--selected); color: var(--text); }
.rail-home:hover, .rail-home[aria-pressed="true"] { background: transparent; }
.rail-home::before, #server-avatars button::before { content: ''; position: absolute; left: -14px; width: 4px; height: 18px; border-radius: 0 4px 4px 0; background: var(--text); opacity: 0; transition: height .2s ease, opacity .2s ease; }
.rail-home:hover::before, #server-avatars button:hover::before { opacity: 1; }
.rail-home[aria-pressed="true"]::before, #server-avatars button.active::before { opacity: 1; height: 36px; }
#server-avatars { list-style: none; display: flex; flex-direction: column; align-items: center; gap: 10px; margin: 0; padding: 12px 0; width: 100%; min-height: 0; overflow: auto; border-top: 1px solid var(--line); }
.rail-bottom { margin-top: auto; display: grid; justify-items: center; gap: 12px; padding-bottom: 14px; flex: none; }
.rail-settings { width: 40px; height: 40px; padding: 0; display: grid; place-items: center; border-radius: 14px; }
.rail-footer { display: grid; justify-items: center; gap: 4px; color: var(--muted); font-size: 10px; }
.logo-mark { width: 32px; height: 32px; flex: none; border-radius: 8px; object-fit: cover; display: block; }
.logo-hero { width: 64px; height: 64px; flex: none; border-radius: 16px; object-fit: cover; display: block; }

.sidebar { min-height: 0; display: flex; flex-direction: column; background: var(--panel); border-right: 1px solid var(--line); }
.sidebar > header { display: flex; align-items: center; gap: 10px; min-height: var(--header-height); padding: 12px 14px; border-bottom: 1px solid var(--line); }
.account-avatar { width: 36px; height: 36px; background: var(--raised); color: var(--text); }
.account-copy { flex: 1; min-width: 0; }
.me { color: var(--text); font-weight: 600; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-menu { display: grid; place-items: center; width: 32px; min-height: 32px; padding: 0; border-radius: 10px; }
.account-menu .icon { width: 16px; height: 16px; }
#btn-sidebar-toggle { display: none; }
.sidebar-scroll { min-height: 0; flex: 1; overflow: auto; padding-bottom: 10px; }
.conversation-toolbar { flex-wrap: nowrap; padding: 14px 12px 10px; gap: 8px; }
.conversation-toolbar button { flex: 1 1 auto; min-width: 0; display: inline-flex; align-items: center; justify-content: center; gap: 8px; white-space: nowrap; }
.conversation-toolbar .icon { width: 16px; height: 16px; }
.security-entry { margin: 0 12px 10px; padding: 12px; border-radius: var(--radius-m); background: var(--accent-soft); border: 1px solid var(--accent-line); }
.security-entry button { display: flex; align-items: center; gap: 10px; width: 100%; color: var(--accent); background: transparent; border: 0; padding: 0; min-height: 0; white-space: normal; }
.security-entry button > .icon:first-child { width: 20px; height: 20px; }
.security-entry button > .icon:last-child { display: none; }
.security-entry p { margin: 4px 0 0 30px; font-size: var(--text-meta); color: var(--secondary); }
.device-settings { margin: 0 12px 6px; padding: 0 12px; border-radius: var(--radius-m); }
.device-settings summary { font-size: var(--text-meta); }
.device-settings button { display: block; text-align: left; white-space: normal; }
#device-list { max-height: 160px; overflow: auto; font: var(--text-meta)/1.5 var(--mono); color: var(--secondary); background: var(--void); border-radius: var(--radius-s); padding: 8px; }
#device-list:empty { display: none; }
.channel-category { padding: 0 12px 4px; }
.channel-category > summary { padding: 14px 8px 8px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); }
.channel-category:has(> #channels:empty) > #channels { display: none; }
#convos, #guilds, #channels { list-style: none; padding: 0; margin: 0; display: grid; gap: 2px; }
#convos button, #guilds button, #channels button { display: flex; position: relative; align-items: center; gap: 10px; width: 100%; min-height: 40px; text-align: left; padding: 6px 10px; border: 0; border-radius: var(--radius-m); font-weight: 500; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; background: transparent; }
#channels button { display: block; min-height: 34px; }
#guilds button { display: block; }
#convos button:hover, #guilds button:hover, #channels button:hover { background: var(--hover); }
#convos .active button, #guilds button.active, #channels button.active { color: var(--text); background: var(--selected); }
#convos .active button::before, #guilds button.active::before, #channels button.active::before, #security-nav [aria-current="page"]::before { content: ''; position: absolute; top: 10px; bottom: 10px; left: 0; width: 3px; background: var(--text); border-radius: var(--radius-pill); }
.conversation-avatar { width: var(--row-avatar); height: var(--row-avatar); font-size: 11px; }
.conversation-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.channel-warning { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
#guild-panel { border-top: 1px solid var(--line); margin-top: 8px; }
.public-badge { color: var(--muted); font-size: var(--text-meta); }
#guild-panel .public-badge { margin: 0 0 8px; padding: 0 10px; }
.server-actions { margin: 0 10px 6px; }
.server-actions .row { align-items: flex-start; }
#guild-id { margin: 8px 14px; overflow-wrap: anywhere; font-size: var(--text-meta); color: var(--muted); }
#guild-id:empty { display: none; }
#guild-panel > button { margin: 8px 14px; }
#guild-status { display: flex; align-items: center; gap: 8px; margin: 8px 12px; padding: 10px; border: 1px solid var(--line-hover); border-radius: var(--radius-m); color: var(--secondary); font-size: var(--text-meta); }
#guild-status button { flex: none; }
.sidebar-footer { min-height: 58px; flex: none; display: flex; align-items: center; gap: 10px; padding: 10px 14px 14px; border-top: 1px solid var(--line); background: var(--rail); color: var(--secondary); font-size: var(--text-meta); }
.device-copy { min-width: 0; }
.device-copy strong { font-weight: 600; color: var(--text); font-size: 13px; }
.presence-ring { position: relative; width: 10px; height: 10px; border: 2px solid var(--success); border-radius: var(--radius-pill); flex: none; }

/* Chat. */
main { min-width: 0; min-height: 0; position: relative; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; background: var(--bg); }
#chat-head { min-height: var(--header-height); padding: 10px 22px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 12px; flex-wrap: wrap; z-index: 1; background: var(--bg); }
.chat-heading { flex: 1; min-width: 0; }
#chat-title { font-size: 17px; line-height: 1.3; font-weight: 700; overflow-wrap: anywhere; }
.chat-status { display: inline-flex; align-items: center; gap: 6px; font-size: var(--text-meta); margin-top: 4px; }
.chat-status > .icon { display: none; }
#chat-head:has(#chat-security:not([hidden])) .chat-status { display: none; }
.chat-status:has(.e2ee-chip) { color: var(--accent); background: var(--accent-soft); border: 1px solid var(--accent-line); border-radius: var(--radius-pill); padding: 2px 10px; }
.chat-status:has(.e2ee-chip) > .icon { display: block; width: 12px; height: 12px; }
.e2ee-chip { color: var(--accent); }
.security-line { font-size: var(--text-meta); }
#chat-security { display: block; margin-top: 4px; }
.header-action { width: 36px; height: 36px; padding: 0; display: grid; place-items: center; border-radius: 12px; }
.header-action .icon { width: 19px; height: 19px; }
#log { min-height: 0; overflow: auto; padding: 14px 0; }
.bubble { position: relative; margin: 6px 16px 0; min-height: 40px; padding: 8px 14px 8px 60px; border-radius: var(--radius-l); transition: background .18s ease; }
.bubble:first-child { margin-top: 0; }
.bubble > .avatar { position: absolute; left: 14px; top: 10px; }
.bubble.mine { background: var(--mine); }
.bubble:hover, .bubble:focus-within { background: var(--hover); }
.bubble.mine:hover, .bubble.mine:focus-within { background: var(--mine-hover); }
.bubble .who { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px; min-width: 0; margin-bottom: 2px; }
.bubble .name { font-size: 14px; font-weight: 700; overflow-wrap: anywhere; }
.bubble time { color: var(--muted); font-size: var(--text-meta); font-variant-numeric: tabular-nums; }
.bubble .body { max-width: 78ch; font-size: var(--text-body); line-height: 1.55; color: var(--text); white-space: pre-wrap; overflow-wrap: anywhere; }
.bubble.grouped { margin-top: 0; min-height: 0; padding-top: 2px; padding-bottom: 2px; }
.bubble.grouped > .avatar, .bubble.grouped .name, .bubble.grouped time { display: none; }
.bubble.grouped .who { height: 0; }
.bubble .report { position: absolute; right: 12px; top: -12px; z-index: 2; background: var(--panel-solid); border-color: var(--line-hover); box-shadow: var(--elevation); opacity: 0; pointer-events: none; }
.bubble:hover .report, .bubble:focus-within .report { opacity: 1; pointer-events: auto; }
.body p { margin: 0; }
.body pre { white-space: pre-wrap; overflow-wrap: anywhere; padding: 10px 12px; margin: 6px 0; background: var(--void); border: 1px solid var(--line); border-radius: var(--radius-m); font: 13px/1.5 var(--mono); }
.body blockquote { border-left: 3px solid var(--muted); padding-left: 12px; margin: 4px 0; color: var(--secondary); }
.reaction { display: inline-flex; border: 1px solid var(--line-hover); border-radius: 999px; padding: 2px 10px; background: var(--panel-solid); font-size: var(--text-meta); }
.empty-state { position: absolute; inset: var(--header-height) 0 80px; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 24px; pointer-events: none; }
.empty-symbol { width: var(--empty-symbol); height: var(--empty-symbol); display: grid; place-items: center; border-radius: 28px; background: var(--raised); color: var(--secondary); margin-bottom: 22px; }
.empty-symbol .icon { width: 34px; height: 34px; stroke-width: 1.5; }
.empty-state h1 { font-size: var(--text-page); font-weight: 700; line-height: 1.2; letter-spacing: -.02em; margin: 8px 0; color: var(--text); }
.empty-state p { margin: 0; color: var(--muted); }
#composer { position: relative; display: flex; align-items: center; gap: 6px; margin: 14px 16px 16px; padding: 6px; background: var(--panel-solid); border: 1px solid var(--line-hover); border-radius: 22px; transition: border-color .2s ease; }
#composer:focus-within { border-color: var(--focus); }
#composer input { width: 100%; flex: 1; height: 40px; padding: 0 8px; border: 0; border-radius: 0; background: transparent; font-size: 15px; }
#composer input:focus { border: 0; }
#composer input:focus-visible { outline: none; }
#composer input::placeholder { color: var(--muted); }
#btn-compose-tools { width: 44px; height: 44px; min-width: 44px; min-height: 44px; aspect-ratio: 1; padding: 0; border-radius: 50%; display: grid; place-items: center; flex: none; color: var(--secondary); }
#btn-send { display: none; }
.composer-extra { flex: none; display: grid; place-items: center; width: 32px; height: 32px; min-width: 32px; min-height: 32px; padding: 0; border: 1px solid var(--line-hover); border-radius: 8px; color: var(--secondary); background: transparent; }
.composer-extra .icon, .gif-word { width: 22px; height: 22px; }
.gif-word { display: grid; place-items: center; font-size: 11px; font-weight: 800; letter-spacing: -.04em; line-height: 1; }
.composer-extra:hover:not(:disabled) { color: var(--text); background: var(--hover); }
.composer-extra:disabled { opacity: .35; }
#btn-compose-tools .icon { width: 20px; height: 20px; }
#btn-compose-tools:hover:not(:disabled) { background: var(--hover); color: var(--text); }
.compose-tools { position: absolute; bottom: calc(100% + 10px); left: 0; display: grid; gap: 4px; padding: 6px; background: var(--panel-solid); border: 1px solid var(--line-hover); border-radius: var(--radius-m); box-shadow: var(--elevation); z-index: 3; }
.compose-tools button { display: flex; align-items: center; gap: 10px; }

/* People column. Threads stay out of this layout until a later pass. */
.people-panel { min-height: 0; display: flex; flex-direction: column; background: var(--panel); border-left: 1px solid var(--line); }
#people-list-view { min-height: 0; flex: 1; display: flex; flex-direction: column; }
.people-switch { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 12px; }
.people-switch button { width: 100%; min-height: 32px; height: 32px; padding: 0 8px; border-radius: 8px; font-size: 13px; font-weight: 650; }
.people-switch button[aria-selected="true"] { background: var(--selected); color: var(--text); border-color: transparent; }
.people-server { margin: 0 12px 8px; color: var(--text); font-size: 13px; font-weight: 700; }
#people-list, #people-list li { list-style: none; }
#people-list { margin: 0; padding: 0 8px 12px; overflow: auto; min-height: 0; }
#people-list button { display: flex; flex-direction: row; flex-wrap: nowrap; align-items: center; gap: 10px; width: 100%; min-height: 44px; padding: 6px 8px; border: 0; border-radius: 8px; background: transparent; text-align: left; font-weight: 600; }
#people-list button span:last-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#people-list button:hover { background: var(--hover); }
#people-list .avatar { width: 32px; height: 32px; font-size: 13px; }
.people-empty { margin: 8px 16px; color: var(--muted); font-size: 13px; }
.people-profile { min-height: 0; overflow: auto; display: flex; flex-direction: column; }
#people-back { margin: 12px; min-height: 32px; height: 32px; padding: 0 10px; }
.people-banner { height: 88px; margin: 0 12px; border-radius: 12px; background: var(--raised); }
.people-profile-body { padding: 0 16px 20px; }
#people-pfp { width: 64px; height: 64px; margin-top: -28px; border: 4px solid var(--panel); font-size: 22px; }
#people-name { margin: 10px 0 4px; font-size: 18px; }
#people-description { margin: 0 0 8px; color: var(--secondary); font-size: 14px; }
#people-text { margin: 0; color: var(--text); font-size: 14px; }

/* Auth and prompts. */
#auth { display: grid; align-items: safe center; justify-items: center; overflow: auto; padding: 24px; background: var(--void); }
.card, .prompt-card { width: min(440px, calc(100vw - 32px)); background: var(--panel); border: 1px solid var(--line-hover); border-radius: 24px; padding: 32px; display: grid; gap: 14px; box-shadow: var(--elevation-dialog); }
.auth-brand { display: flex; align-items: center; gap: 16px; }
.auth-brand .tag { margin-top: 4px; font-size: 13px; }
.card h1 { font-size: 22px; margin: 0; font-weight: 700; }
.card p { margin: 0; }
.card > .row { flex-wrap: wrap; }
.card details { border-top: 1px solid var(--line); padding-top: 4px; }
.card details p { margin-bottom: 8px; }
#hub-options { display: grid; gap: 10px; border-top: 1px solid var(--line); padding-top: 12px; }
#hub-options label { display: flex; align-items: flex-start; gap: 8px; }
#hub-options input { min-height: 0; accent-color: var(--primary); }
.error { color: var(--error); background: var(--error-soft); border: 1px solid rgba(255, 180, 187, 0.25); border-radius: var(--radius-m); padding: 10px 12px; overflow-wrap: anywhere; }
.prompt { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.6); display: grid; place-items: center; z-index: 20; overflow: auto; padding: 16px; }
.prompt-card { max-height: calc(100vh - 32px); overflow: auto; }
.prompt-card p { margin: 0; font-size: 16px; font-weight: 700; }
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); width: max-content; max-width: min(440px, calc(100vw - 32px)); background: var(--panel-solid); border: 1px solid var(--line-hover); padding: 12px 16px; border-radius: var(--radius-m); box-shadow: var(--elevation); overflow-wrap: anywhere; z-index: 30; }

/* Account and settings overlay. */
#security-view { position: fixed; inset: 0; z-index: 15; display: flex; flex-direction: column; background: var(--bg); overflow: hidden; }
.security-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: var(--security-header-height); padding: 18px 28px; background: var(--panel); border-bottom: 1px solid var(--line); }
.security-header > div { min-width: 0; }
.security-header h1 { margin: 4px 0 0; font-size: var(--text-page); line-height: 1.2; font-weight: 700; }
.security-header p { margin: 4px 0 0; overflow-wrap: anywhere; }
.security-layout { display: grid; grid-template-columns: 250px minmax(0, 1fr); flex: 1; min-height: 0; }
#security-nav { display: flex; flex-direction: column; gap: 4px; padding: 20px 14px; background: var(--panel); border-right: 1px solid var(--line); overflow: auto; }
.security-nav-label { padding: 8px 10px 4px; font-size: 11px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .12em; }
#security-nav button { position: relative; display: flex; align-items: center; gap: 10px; width: 100%; min-height: 40px; padding: 6px 10px; text-align: left; background: transparent; border: 0; }
#security-nav button:hover { background: var(--hover); }
#security-nav .icon { color: var(--secondary); }
#security-nav [aria-current="page"] { color: var(--text); background: var(--selected); }
.security-content { min-width: 0; overflow: auto; padding: 28px; }
.security-content > section { max-width: 820px; margin: 0 auto; overflow-wrap: anywhere; }
.security-content h2 { margin: 0 0 16px; font-size: 20px; font-weight: 700; }
.security-card, .settings-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-l); padding: 18px; margin-bottom: 14px; min-width: 0; overflow-wrap: anywhere; }
.security-card p { margin: 8px 0; }
.security-card p:first-child, .settings-card p:first-child { margin-top: 0; }
.security-card p:last-child, .settings-card p:last-child { margin-bottom: 0; }
.security-card label { margin: 12px 0; }
.security-card input { width: 100px; font-family: var(--mono); }
.security-list { margin: 14px 0; }
.security-badge { display: inline-block; color: var(--success); background: rgba(142, 227, 196, 0.1); border: 1px solid rgba(142, 227, 196, 0.3); border-radius: var(--radius-pill); padding: 2px 10px; margin: 4px 0; font-size: var(--text-meta); }
#security-status { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--accent-line); border-radius: var(--radius-pill); background: var(--accent-soft); color: var(--accent); padding: 4px 12px; font-size: var(--text-meta); margin: 0 0 16px; }
#security-protection { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
#security-protection p { padding-left: 12px; border-left: 2px solid var(--accent); margin: 0; }
#btn-secure-account { color: var(--error); background: var(--error-soft); border-color: rgba(255, 180, 187, 0.25); margin-bottom: 20px; }
.backup-card h2 { display: flex; align-items: center; gap: 8px; font-size: 16px; }
.backup-card h2 .icon { color: var(--accent); }
.backup-card .row { margin-top: 14px; }
#btn-backup-export, #btn-security-browser { color: var(--accent); background: var(--accent-soft); border-color: var(--accent-line); }
#btn-backup-export:hover, #btn-security-browser:hover { color: var(--accent-hover); }
#security-confirm { max-width: 820px; margin: 0 auto 14px; border-color: var(--accent-line); }
.backup-password-row { margin-top: 12px; display: grid; gap: 8px; }
.security-card .backup-password-row input { width: 100%; }
#security-view button { white-space: normal; overflow-wrap: anywhere; }
.theme-options button { display: inline-flex; align-items: center; gap: 10px; }
.theme-options button[aria-pressed="true"] { border-color: var(--text); }
.theme-swatch { width: 18px; height: 18px; border-radius: 50%; border: 1px solid var(--line-hover); flex: none; }
.theme-swatch-dark { background: linear-gradient(135deg, #15161a 50%, #2c2f38 50%); }
.theme-swatch-violet { background: linear-gradient(135deg, #1a1828 50%, #b5a4ff 50%); }
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-thumb { background: var(--raised); border-radius: var(--radius-pill); }

@media (width < 1180px) { #app { grid-template-columns: var(--rail-width) var(--sidebar-width) minmax(0, 1fr); } .people-panel { display: none; } }
@media (width < 900px) { .security-layout { grid-template-columns: 200px minmax(0, 1fr); } .security-content { padding: 16px; } }
@media (width < 860px) {
  #app { grid-template-columns: var(--rail-width) minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
  .server-rail { grid-row: 1 / -1; } .sidebar { grid-column: 2; max-height: 60vh; }
  .sidebar > header { padding: 10px; } #btn-sidebar-toggle { display: block; flex: none; }
  .sidebar:not(:has(#btn-sidebar-toggle[aria-expanded="true"])) > .sidebar-scroll, .sidebar > .sidebar-footer { display: none; }
  .account-menu { display: none; } main { grid-column: 2; }
}
@media (width < 760px) {
  .security-layout { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
  #security-nav { flex-direction: row; flex-wrap: wrap; padding: 12px; border-right: 0; border-bottom: 1px solid var(--line); }
  #security-nav button { width: fit-content; } .security-nav-label { width: 100%; }
  .security-header { padding: 14px; } #security-protection { grid-template-columns: 1fr; }
}
