/* XERA Business — every colour is a token; a client brand (org.json "theme") overrides them at runtime */
@font-face { font-family: "Inter"; font-style: normal; font-weight: 100 900; font-display: swap; src: url(/fonts/inter-cyrillic-wght-normal.woff2) format("woff2"); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "Inter"; font-style: normal; font-weight: 100 900; font-display: swap; src: url(/fonts/inter-latin-wght-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
:root {
  --bg: #0e0f12;
  --rail: #121317;
  --panel: #16171b;
  --card: #1d1f24;
  --card-2: #23252b;
  --hover: #22242a;
  --active: #262a33;
  --line: #24262c;
  --text: #f1f2f4;
  --text-2: #c9ccd2;
  --muted: #7d828c;
  --accent: #3b82f6;
  --accent-2: #2563eb;
  --accent-soft: rgba(59, 130, 246, .14);
  --badge: #f0573a;
  --violet: #7c3aed;
  --gold: #f5b83d;
  --ok: #22c55e;
  --danger: #f05252;
  --bubble: #1f2126;
  --accent-ink: #fff;
  --badge-ink: #fff;
  --link: #8ab4ff;
  --btn-hover: #2b2e35;
  --auth-glow: #1b2a4a;
  --bubble-me: linear-gradient(135deg, #3b82f6, #2563eb);
  --bubble-me-ink: #fff;
  --bubble-me-media: #2563eb;
  --rail-ink: #6b7079;
  --focus: #2f3a52;
  --media-bg: #0b0c0e;
  --overlay: rgba(0, 0, 0, .65);
  --toast: #2b2e35;
  --scroll: #2a2d34;
  --shadow: 0 20px 50px rgba(0, 0, 0, .5);
  --gold-text: #f6d38a;
  --gold-strong: #fff;
  --r: 18px;
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 14px/1.45 var(--font); }
body { overflow: hidden; -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; }
input, textarea, select { font: inherit; color: var(--text); }
a { color: var(--link); }
svg { width: 22px; height: 22px; fill: currentColor; flex-shrink: 0; }
.i { display: inline-flex; }
.muted { color: var(--muted); }
.accent { color: var(--accent); }
.wordmark { font-weight: 800; letter-spacing: .2em; }
.screen { height: 100vh; height: 100dvh; }

/* ---------- buttons & forms ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 11px 16px; border-radius: 14px; font-weight: 600; background: var(--card-2); text-decoration: none; color: var(--text); }
.btn:hover { background: var(--btn-hover); }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: var(--accent-2); }
.btn.ghost { background: transparent; color: var(--muted); }
.btn.danger { color: var(--danger); }
.btn.gold { background: linear-gradient(135deg, #f5b83d, #f08a3d); color: #1b1305; }
.btn.sm { padding: 7px 12px; font-size: 13px; border-radius: 11px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; cursor: default; }
.btn svg { width: 18px; height: 18px; }
.icon-btn { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; color: var(--muted); flex-shrink: 0; position: relative; }
.icon-btn:hover { background: var(--hover); color: var(--text); }
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn.prem.locked::after { content: ""; position: absolute; right: 5px; top: 5px; width: 7px; height: 7px; border-radius: 50%; background: var(--gold); }
.seg { display: flex; background: var(--card); border-radius: 14px; padding: 4px; gap: 4px; }
.seg button { flex: 1; padding: 9px; border-radius: 11px; color: var(--muted); font-weight: 600; }
.seg button.active { background: var(--card-2); color: var(--text); }
.form { display: flex; flex-direction: column; gap: 14px; margin-top: 18px; text-align: left; }
.form label { display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; color: var(--label, var(--muted)); font-weight: 600; }
.form label.check { flex-direction: row; align-items: center; gap: 8px; font-size: 13.5px; cursor: pointer; }
.form label.check input { width: 17px; height: 17px; accent-color: var(--accent); }
.field, .form input:not([type=checkbox]), .form textarea { background: var(--field, var(--card)); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; outline: none; width: 100%; }
.field:focus, .form input:focus { border-color: var(--accent); }
.hint { font-size: 12.5px; color: var(--muted); margin: 0; }
.error { color: var(--danger); font-size: 14px; }

/* ---------- auth ---------- */
#auth { display: grid; place-items: center; padding: 24px 16px; overflow: auto;
  background: radial-gradient(900px 500px at 50% -10%, var(--auth-glow) 0%, transparent 60%), var(--bg); }
.auth-card { width: 100%; max-width: 390px; text-align: center; background: var(--panel); border: 1px solid var(--line); border-radius: 28px; padding: 30px 26px; box-shadow: var(--shadow); }
.auth-logo { width: 84px; height: 84px; filter: drop-shadow(0 14px 30px rgba(0,0,0,.5)); }
.auth-card h1 { margin: 12px 0 4px; font-size: 28px; }
.auth-card > .muted { margin: 0 0 22px; }
.e2e-note { display: flex; gap: 8px; align-items: flex-start; text-align: left; margin: 20px 0 0; font-size: 12px; color: var(--muted); background: var(--accent-soft); padding: 10px 12px; border-radius: 12px; }
.e2e-note svg { width: 16px; height: 16px; color: var(--accent); margin-top: 1px; }

/* ---------- app layout ---------- */
#app { display: flex; background: var(--bg); padding: 10px; gap: 10px; }
#rail { flex-shrink: 0; display: flex; justify-content: space-around; gap: 4px; margin: 0 12px 12px; padding: 6px; background: var(--card); border-radius: 18px; }
.rail-btn { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 7px 4px 6px; border-radius: 13px; color: var(--rail-ink); position: relative; font-size: 11px; font-weight: 600; }
.rail-btn .ic { display: grid; place-items: center; position: relative; }
.rail-btn svg { width: 22px; height: 22px; }
.rail-btn:hover { color: var(--text); background: var(--hover); }
.rail-btn.active { color: var(--accent); background: var(--accent-soft); }
.rail-btn .dot { position: absolute; top: -2px; right: -5px; width: 8px; height: 8px; border-radius: 50%; background: var(--badge); border: 2px solid var(--card); }
#sidebar { width: 360px; flex-shrink: 0; background: var(--panel); border-radius: 22px; display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
#chat { flex: 1; min-width: 0; display: flex; flex-direction: column; background: var(--panel); border-radius: 22px; position: relative; overflow: hidden; }
#chatView { display: flex; flex-direction: column; height: 100%; min-height: 0; position: relative; }
.details { width: 320px; flex-shrink: 0; background: var(--panel); border-radius: 22px; overflow-y: auto; padding: 18px; }

/* me card */
.me-card { margin: 14px 14px 6px; background: var(--card); border-radius: 20px; padding: 12px; display: flex; align-items: center; gap: 12px; cursor: pointer; }
.me-card:hover { background: var(--card-2); }
.me-card .t { flex: 1; min-width: 0; }
.me-card b { display: block; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me-card small { color: var(--muted); font-size: 12.5px; }
.plan-pill { font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 8px; background: var(--card-2); color: var(--muted); letter-spacing: .03em; }
.plan-pill.premium { background: linear-gradient(135deg, #f5b83d, #f08a3d); color: #1b1305; }

.search-row { display: flex; gap: 8px; align-items: center; margin: 8px 14px 6px; }
.search-row .search { flex: 1; margin: 0; }
.new-btn { width: 44px; height: 44px; border-radius: 14px; background: var(--card); color: var(--text-2); }
.new-btn:hover { background: var(--accent); color: var(--accent-ink); }
.search { margin: 0 14px 6px; position: relative; }
.search .s-ic { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search .s-ic svg { width: 17px; height: 17px; }
.search input { width: 100%; background: var(--card); border: 1px solid transparent; border-radius: 14px; padding: 11px 14px 11px 38px; outline: none; }
.search input:focus { border-color: var(--focus); }
.list { flex: 1; overflow-y: auto; padding: 4px 10px 16px; }
.sec { display: flex; align-items: center; gap: 6px; font-size: 11.5px; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); padding: 14px 10px 6px; font-weight: 600; }
.sec svg { width: 14px; height: 14px; }
.item { display: flex; align-items: center; gap: 12px; padding: 10px; border-radius: 16px; cursor: pointer; width: 100%; text-align: left; position: relative; }
.item:hover { background: var(--hover); }
.item.active { background: var(--active); }
.item .meta { flex: 1; min-width: 0; }
.item .row { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.item .name { font-weight: 600; font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; gap: 5px; }
.item .name svg { width: 14px; height: 14px; color: var(--muted); }
.item .time { font-size: 11.5px; color: var(--muted); flex-shrink: 0; display: inline-flex; align-items: center; gap: 2px; }
.item .time svg { width: 15px; height: 15px; }
.item .time .read { color: var(--accent); }
.item .preview { color: var(--muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.item .preview b { color: var(--text-2); font-weight: 500; }
.item .preview .typ { color: var(--accent); }
.item .badge { background: var(--badge); color: var(--badge-ink); font-size: 11px; font-weight: 700; min-width: 20px; height: 20px; border-radius: 10px; display: grid; place-items: center; padding: 0 6px; flex-shrink: 0; }
.list-empty { text-align: center; color: var(--muted); padding: 40px 20px; font-size: 13.5px; }
.list-empty .btn { margin-top: 14px; }

/* avatars */
.av { position: relative; flex-shrink: 0; border-radius: 50%; display: inline-grid; place-items: center; font-weight: 700; color: #fff; user-select: none; }
.av img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; display: block; }
.av .ini { width: 100%; height: 100%; border-radius: 50%; display: grid; place-items: center; }
.av.online::after { content: ""; position: absolute; right: 0; bottom: 0; width: 24%; height: 24%; min-width: 9px; min-height: 9px; border-radius: 50%; background: var(--ok); border: 2px solid var(--panel); }
.stack-avs { display: flex; padding-left: 8px; }
.stack-avs .av { margin-left: -9px; border: 2px solid var(--panel); box-sizing: content-box; }
.stack-avs .more { margin-left: -9px; width: 30px; height: 30px; border-radius: 50%; background: var(--badge); color: var(--badge-ink); font-size: 11px; font-weight: 700; display: grid; place-items: center; border: 2px solid var(--panel); }

/* ---------- chat ---------- */
.chat-empty { margin: auto; text-align: center; color: var(--muted); padding: 20px; }
.chat-empty img { width: 84px; opacity: .8; }
.chat-empty h3 { color: var(--text); margin: 14px 0 4px; font-size: 19px; }
.code-badge { margin-top: 16px; display: inline-block; background: var(--card); padding: 9px 18px; border-radius: 14px; color: var(--text); }
.code-badge b { letter-spacing: .16em; color: var(--accent); }

.chat-head { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line); min-height: 70px; }
.back { display: none; }
.chat-title { display: flex; align-items: center; gap: 12px; text-align: left; min-width: 0; flex: 1; }
.chat-title .t { min-width: 0; display: flex; flex-direction: column; }
.chat-title b { font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-title small { color: var(--muted); font-size: 12.5px; }
.chat-title small.on { color: var(--ok); }
.chat-title small.typ { color: var(--accent); }
.head-av { display: none; }
.head-actions { display: flex; gap: 2px; }

.messages { flex: 1; overflow-y: auto; padding: 18px 26px 10px; display: flex; flex-direction: column; overscroll-behavior: contain; }
.day { align-self: center; color: var(--muted); font-size: 12px; margin: 16px 0 8px; font-weight: 500; }
.sys { align-self: center; color: var(--muted); font-size: 12.5px; background: var(--card); padding: 5px 12px; border-radius: 12px; margin: 6px 0; text-align: center; max-width: 80%; }
.grp { display: flex; gap: 12px; margin-top: 14px; align-items: flex-start; max-width: 100%; }
.grp.me { flex-direction: row-reverse; }
.grp .g-av { width: 38px; flex-shrink: 0; }
.grp .g-body { min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 4px; max-width: min(72%, 560px); }
.grp.me .g-body { align-items: flex-end; }
.g-head { display: flex; align-items: baseline; gap: 8px; font-size: 13px; margin-bottom: 2px; }
.g-head b { font-weight: 600; }
.g-head small { color: var(--muted); font-size: 11.5px; }
.grp.me .g-head { flex-direction: row-reverse; }
.bub { position: relative; display: flex; flex-direction: column; align-items: inherit; max-width: 100%; }
.msg { background: var(--bubble); padding: 9px 13px; border-radius: 16px; word-wrap: break-word; overflow-wrap: anywhere; max-width: 100%; position: relative; font-size: 14px; }
.grp.me .msg { background: var(--bubble-me); color: var(--bubble-me-ink); }
.grp.me .msg a { color: var(--bubble-me-ink); }
.msg .txt { white-space: pre-wrap; }
.msg .st { display: inline-flex; vertical-align: -4px; margin-left: 6px; opacity: .75; }
.msg .st svg { width: 15px; height: 15px; }
.msg.err { color: var(--muted); font-style: italic; background: var(--card); }
.msg.media { padding: 0; background: none !important; overflow: hidden; border-radius: 16px; }
.msg.media .txt { background: var(--bubble); padding: 8px 12px; border-radius: 0 0 16px 16px; }
.grp.me .msg.media .txt { background: var(--bubble-me-media); }
.ph { display: block; width: 300px; max-width: 100%; border-radius: 16px; background: var(--media-bg) center/cover; position: relative; cursor: zoom-in; overflow: hidden; }
.msg.media .txt + .ph, .msg.media .ph:has(+ .txt) { border-radius: 16px 16px 0 0; }
.ph img, .ph video { width: 100%; height: 100%; object-fit: cover; display: block; }
.ph .ov { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(0,0,0,.25); color: #fff; }
.ph .ov .circ { width: 52px; height: 52px; border-radius: 50%; background: rgba(0,0,0,.55); display: grid; place-items: center; backdrop-filter: blur(6px); }
.ph .ov .circ svg { width: 26px; height: 26px; }
.ph .tag { position: absolute; left: 8px; bottom: 8px; background: rgba(0,0,0,.55); color: #fff; font-size: 11.5px; padding: 2px 8px; border-radius: 8px; }
.spin { width: 26px; height: 26px; border-radius: 50%; border: 3px solid rgba(255,255,255,.3); border-top-color: #fff; animation: rot 1s linear infinite; }
@keyframes rot { to { transform: rotate(360deg); } }
.file { display: flex; gap: 12px; align-items: center; text-decoration: none; color: inherit; min-width: 220px; cursor: pointer; }
.file .ic { width: 42px; height: 42px; border-radius: 12px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; flex-shrink: 0; }
.grp.me .file .ic { background: rgba(255,255,255,.14); color: var(--bubble-me-ink); }
.file .fn { font-weight: 600; display: block; word-break: break-all; }
.file small { opacity: .7; font-size: 12px; }
.voice { display: flex; align-items: center; gap: 10px; min-width: 230px; }
.voice .pl { width: 38px; height: 38px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; flex-shrink: 0; }
.grp.me .voice .pl { background: var(--bubble-me-ink); color: var(--active); }
.voice .pl svg { width: 20px; height: 20px; }
.wave { display: flex; align-items: center; gap: 2px; height: 28px; flex: 1; }
.wave i { width: 3px; border-radius: 2px; background: currentColor; opacity: .35; min-height: 3px; }
.wave i.on { opacity: 1; }
.voice small { font-size: 11.5px; opacity: .75; min-width: 32px; }
.reacts { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 4px; }
.reacts button { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 2px 8px; font-size: 12.5px; display: inline-flex; gap: 4px; align-items: center; }
.reacts button.mine { border-color: var(--accent); background: var(--accent-soft); }
.reacts button b { font-weight: 600; font-size: 11.5px; }
.bub .hov { position: absolute; top: -14px; right: -6px; display: none; background: var(--card-2); border: 1px solid var(--line); border-radius: 12px; padding: 2px; z-index: 3; }
.grp.me .bub .hov { right: auto; left: -6px; }
.bub:hover .hov { display: flex; }
.hov button { width: 28px; height: 28px; border-radius: 9px; display: grid; place-items: center; color: var(--muted); }
.hov button:hover { background: var(--hover); color: var(--text); }
.hov svg { width: 17px; height: 17px; }
.pending .msg { opacity: .8; }
.progress { height: 4px; background: rgba(255,255,255,.18); border-radius: 2px; margin-top: 8px; overflow: hidden; }
.progress i { display: block; height: 100%; width: 0; background: #fff; transition: width .15s; }

.typing-bar { padding: 0 26px 6px; color: var(--muted); font-size: 12.5px; display: flex; align-items: center; gap: 6px; }
.typing-bar b { color: var(--text-2); font-weight: 600; }
.dots span { animation: blink 1.2s infinite; } .dots span:nth-child(2) { animation-delay: .2s; } .dots span:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 100% { opacity: .2; } 50% { opacity: 1; } }

.composer { display: flex; align-items: flex-end; gap: 4px; margin: 6px 16px 16px; padding: 6px 6px 6px 10px; background: var(--card); border-radius: 18px; border: 1px solid var(--line); }
.composer #composerAv { align-self: center; margin-right: 4px; display: flex; }
.composer textarea { flex: 1; resize: none; background: none; border: 0; outline: none; padding: 9px 6px; max-height: 160px; line-height: 1.4; min-width: 0; }
.send-btn { width: 40px; height: 40px; border-radius: 13px; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; flex-shrink: 0; }
.send-btn:hover { background: var(--accent-2); }
.send-btn svg { width: 19px; height: 19px; }
.record-bar, .blocked-bar { display: flex; align-items: center; gap: 12px; margin: 6px 16px 16px; padding: 8px 8px 8px 16px; background: var(--card); border-radius: 18px; }
.blocked-bar { justify-content: center; color: var(--muted); padding: 14px; }
.record-bar .muted { flex: 1; }
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--danger); animation: blink 1s infinite; }
.emoji-panel { position: absolute; bottom: 74px; left: 16px; width: 330px; max-width: calc(100% - 32px); max-height: 280px; overflow-y: auto; background: var(--card-2); border: 1px solid var(--line); border-radius: 18px; padding: 10px; display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px; z-index: 6; box-shadow: var(--shadow); }
.emoji-panel button { font-size: 22px; height: 36px; border-radius: 9px; }
.emoji-panel button:hover { background: var(--hover); }
.drop-hint { position: absolute; inset: 80px 18px 84px; border: 2px dashed var(--accent); border-radius: 20px; display: grid; place-items: center; background: color-mix(in srgb, var(--panel) 90%, transparent); font-size: 17px; color: var(--accent); z-index: 5; pointer-events: none; }

/* ---------- details panel ---------- */
.d-head { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 15px; margin-bottom: 14px; }
.d-head svg { color: var(--accent); width: 20px; height: 20px; }
.d-head span { flex: 1; }
.d-top { text-align: center; margin: 8px 0 16px; }
.d-top .av { margin: 0 auto 10px; }
.d-top h3 { margin: 0; font-size: 18px; }
.d-top p { margin: 3px 0 0; color: var(--muted); font-size: 12.5px; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 8px; }
.stat { background: var(--card); border-radius: 16px; padding: 12px; text-align: center; }
.stat small { color: var(--muted); font-size: 12px; display: block; }
.stat b { font-size: 24px; display: inline-flex; align-items: center; gap: 6px; }
.stat b svg { width: 20px; height: 20px; }
.stat.f b svg { color: var(--accent); } .stat.k b svg { color: var(--gold); }
.d-sec { display: flex; align-items: center; gap: 6px; font-size: 11.5px; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); margin: 18px 0 8px; font-weight: 600; }
.d-sec b { color: var(--text); }
.d-sec svg { width: 15px; height: 15px; }
.d-sec .sp { flex: 1; }
.d-sec button { color: var(--accent); text-transform: none; letter-spacing: 0; font-size: 12.5px; font-weight: 600; }
.mem { display: flex; align-items: center; gap: 10px; padding: 7px 4px; border-radius: 12px; }
.mem .t { flex: 1; min-width: 0; }
.mem b { font-weight: 600; font-size: 14px; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mem small { color: var(--muted); font-size: 12px; }
.mem .role { font-size: 11px; color: var(--accent); font-weight: 600; }
.media-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.media-grid .cell { aspect-ratio: 1; border-radius: 12px; background: var(--card) center/cover; cursor: pointer; overflow: hidden; display: grid; place-items: center; color: var(--muted); font-weight: 700; }
.media-grid .cell img { width: 100%; height: 100%; object-fit: cover; }
.ftype { display: flex; align-items: center; gap: 12px; padding: 8px 4px; }
.ftype .ic { width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; }
.ftype .ic svg { width: 22px; height: 22px; }
.ftype .t { flex: 1; }
.ftype b { display: block; font-size: 14px; }
.ftype small { color: var(--muted); font-size: 12px; }
.ic.blue { background: var(--accent-soft); color: var(--accent); } .ic.red { background: rgba(239,68,68,.15); color: #f87171; }
.ic.green { background: rgba(34,197,94,.15); color: #4ade80; } .ic.violet { background: rgba(168,85,247,.15); color: #c084fc; }
.d-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 20px; }
.d-actions .btn { justify-content: flex-start; }
.safety { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 15px; letter-spacing: .04em; line-height: 1.8; text-align: center; background: var(--card); padding: 12px; border-radius: 14px; word-spacing: 6px; }

/* ---------- modal / menu / lightbox / toast ---------- */
.modal { position: fixed; inset: 0; background: var(--overlay); display: grid; place-items: center; z-index: 50; padding: 16px; animation: fade .15s; }
.modal-card { background: var(--panel); border: 1px solid var(--line); border-radius: 24px; width: 100%; max-width: 420px; max-height: 90vh; overflow-y: auto; padding: 22px; position: relative; }
.modal-card h2 { margin: 0 0 14px; font-size: 19px; }
.modal-close { position: absolute; top: 14px; right: 14px; }
.profile-top { text-align: center; margin-bottom: 16px; }
.profile-top .av { margin: 0 auto 12px; }
.profile-top h3 { margin: 0; font-size: 20px; }
.profile-top .muted { margin: 4px 0 0; }
.id-box { display: flex; align-items: center; justify-content: space-between; background: var(--card); border-radius: 16px; padding: 12px 16px; margin: 14px 0; }
.id-box .big { font-size: 26px; font-weight: 800; letter-spacing: .22em; }
.id-box small { display: block; color: var(--muted); font-size: 12px; }
.stack { display: flex; flex-direction: column; gap: 8px; }
.row-btns { display: flex; gap: 8px; } .row-btns .btn { flex: 1; }
.avatar-edit { position: relative; display: inline-block; cursor: pointer; }
.avatar-edit .cam { position: absolute; right: 0; bottom: 0; width: 32px; height: 32px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; border: 3px solid var(--panel); }
.avatar-edit .cam svg { width: 15px; height: 15px; }
.code-input { text-align: center; font-size: 28px !important; letter-spacing: .4em; font-weight: 700; }
.pick { max-height: 300px; overflow-y: auto; margin: 10px -6px; }
.pick label { display: flex; align-items: center; gap: 10px; padding: 7px 8px; border-radius: 12px; cursor: pointer; }
.pick label:hover { background: var(--hover); }
.pick input { width: 18px; height: 18px; accent-color: var(--accent); }
.prem-list { list-style: none; padding: 0; margin: 14px 0; display: flex; flex-direction: column; gap: 10px; }
.prem-list li { display: flex; gap: 12px; align-items: center; background: var(--card); padding: 12px; border-radius: 14px; }
.prem-list li .ic { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; }
.prem-head { text-align: center; }
.prem-head .crown { width: 64px; height: 64px; border-radius: 20px; margin: 0 auto 10px; background: linear-gradient(135deg, #f5b83d, #f08a3d); color: #1b1305; display: grid; place-items: center; }
.prem-head .crown svg { width: 34px; height: 34px; }

.menu { position: fixed; z-index: 55; background: var(--card-2); border: 1px solid var(--line); border-radius: 16px; padding: 6px; min-width: 210px; box-shadow: var(--shadow); animation: fade .1s; }
.menu .quick { display: flex; gap: 2px; padding: 4px 4px 8px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.menu .quick button { font-size: 22px; width: 36px; height: 36px; border-radius: 10px; }
.menu .quick button:hover { background: var(--hover); }
.menu > button, .menu > a { display: flex; width: 100%; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 10px; text-align: left; color: var(--text); text-decoration: none; font-size: 14px; }
.menu > button:hover, .menu > a:hover { background: var(--hover); }
.menu svg { width: 18px; height: 18px; color: var(--muted); }
.menu .danger, .menu .danger svg { color: var(--danger); }

.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.94); z-index: 60; display: grid; place-items: center; animation: fade .15s; }
.lightbox img, .lightbox video { max-width: 96vw; max-height: 88vh; object-fit: contain; }
.lightbox .lb-bar { position: absolute; top: 0; right: 0; padding: 14px; padding-top: max(14px, env(safe-area-inset-top)); display: flex; gap: 6px; }
.lightbox .icon-btn { color: #fff; background: rgba(255,255,255,.12); }
.toast { position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%); background: var(--toast); color: #fff; padding: 11px 18px; border-radius: 14px; z-index: 70; font-size: 13.5px; box-shadow: var(--shadow); max-width: 90vw; text-align: center; }
@keyframes fade { from { opacity: 0; } }
::-webkit-scrollbar { width: 8px; } ::-webkit-scrollbar-thumb { background: var(--scroll); border-radius: 4px; } ::-webkit-scrollbar-track { background: transparent; }

/* ---------- responsive ---------- */
@media (max-width: 1240px) {
  .details { position: fixed; right: 10px; top: 10px; bottom: 10px; z-index: 30; box-shadow: var(--shadow); border: 1px solid var(--line); }
}
@media (max-width: 860px) {
  #app { padding: 0; gap: 0; }
  #rail { margin: 0; border-radius: 0; background: var(--panel); border-top: 1px solid var(--line); padding: 6px 8px; padding-bottom: max(6px, env(safe-area-inset-bottom)); }
  .rail-btn .dot { border-color: var(--panel); }
  #sidebar { width: 100%; flex: 1; border-radius: 0; padding-top: env(safe-area-inset-top); }
  #chat { position: fixed; inset: 0; border-radius: 0; transform: translateX(100%); transition: transform .22s ease; z-index: 20; }
  body.chat-open #chat { transform: none; }
  .chat-head { padding: 10px 10px; padding-top: max(10px, env(safe-area-inset-top)); min-height: 0; }
  .back { display: grid; }
  .head-av { display: flex; }
  .stack-avs { display: none; }
  .messages { padding: 10px 12px 6px; }
  .grp .g-body { max-width: 82%; }
  .grp .g-av { width: 32px; }
  .ph { width: 240px; }
  .composer { margin: 4px 8px; margin-bottom: max(8px, env(safe-area-inset-bottom)); }
  .composer #composerAv { display: none; }
  .bub .hov { display: none !important; }
  .details { inset: 0; right: 0; top: 0; bottom: 0; border-radius: 0; z-index: 40; padding-top: max(18px, env(safe-area-inset-top)); }
  .modal { place-items: end center; padding: 0; }
  .modal-card { border-radius: 24px 24px 0 0; max-width: none; padding-bottom: max(22px, env(safe-area-inset-bottom)); }
}

/* password meter, links, recovery phrase */
.link-btn { color: var(--link); font-size: 13.5px; font-weight: 600; padding: 4px; align-self: center; }
.link-btn:hover { text-decoration: underline; }
.pw-meter { margin-top: 2px; }
.pw-meter .bars { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.pw-meter .bars i { height: 4px; border-radius: 2px; background: var(--card-2); transition: background .2s; }
.pw-meter small { display: block; margin-top: 5px; font-size: 12px; color: var(--muted); line-height: 1.35; }
.pw-meter[data-score="0"] .bars i:nth-child(-n+1), .pw-meter[data-score="1"] .bars i:nth-child(-n+1) { background: var(--danger); }
.pw-meter[data-score="2"] .bars i:nth-child(-n+2) { background: var(--gold); }
.pw-meter[data-score="3"] .bars i:nth-child(-n+3) { background: #4ade80; }
.pw-meter[data-score="4"] .bars i { background: var(--ok); }
.phrase-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 14px 0; counter-reset: w; }
.phrase-grid span { background: var(--card); border-radius: 10px; padding: 8px 8px 8px 30px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 14px; position: relative; user-select: all; }
.phrase-grid span::before { counter-increment: w; content: counter(w); position: absolute; left: 9px; color: var(--muted); font-size: 11.5px; top: 10px; }
.warn-box { background: color-mix(in srgb, var(--gold) 10%, transparent); border: 1px solid color-mix(in srgb, var(--gold) 30%, transparent); color: var(--gold-text); border-radius: 14px; padding: 10px 12px; font-size: 13px; line-height: 1.45; }
.verify-row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.verify-row b { width: 70px; flex-shrink: 0; color: var(--muted); font-weight: 600; font-size: 13px; }
.switch-row { display: flex; align-items: center; gap: 12px; background: var(--card); padding: 12px 14px; border-radius: 14px; }
.switch-row .t { flex: 1; } .switch-row small { color: var(--muted); display: block; font-size: 12px; margin-top: 2px; }
.toggle { width: 44px; height: 26px; border-radius: 13px; background: var(--card-2); position: relative; flex-shrink: 0; transition: background .2s; }
.toggle::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform .2s; }
.toggle.on { background: var(--accent); } .toggle.on::after { transform: translateX(18px); }

/* ---------- v3 onboarding ---------- */
.tagline { color: var(--text-2); font-size: 16px; line-height: 1.45; margin: 4px 0 20px; }
.perks { list-style: none; padding: 0; margin: 0 0 24px; text-align: left; display: flex; flex-direction: column; gap: 10px; }
.perks li { display: flex; gap: 12px; align-items: center; font-size: 13.5px; color: var(--text-2); background: var(--card); padding: 11px 12px; border-radius: 14px; }
.perks .pk-ic { width: 34px; height: 34px; border-radius: 11px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; flex-shrink: 0; }
.perks svg { width: 19px; height: 19px; }
.btn.big { padding: 15px 18px; font-size: 16px; border-radius: 16px; }
#welcomeView .btn.ghost { margin-top: 8px; color: var(--text-2); }
.auth-h { margin: 6px 0 0; font-size: 20px; text-align: center; }
.key-input { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 15px; line-height: 1.6; resize: none; }
.key-count { font-size: 12.5px; color: var(--muted); margin-top: -6px; text-align: right; }
.key-count.ok { color: var(--ok); }
.muted-link { color: var(--muted); font-weight: 500; font-size: 12.5px; }
.key-banner { margin: 2px 14px 8px; display: flex; gap: 10px; align-items: center; background: color-mix(in srgb, var(--gold) 10%, transparent); border: 1px solid color-mix(in srgb, var(--gold) 28%, transparent); border-radius: 16px; padding: 10px 10px 10px 12px; cursor: pointer; }
.key-banner:hover { background: color-mix(in srgb, var(--gold) 16%, transparent); }
.key-banner .ic { color: var(--gold); display: grid; }
.key-banner .t { flex: 1; font-size: 12.5px; color: var(--gold-text); line-height: 1.35; }
.key-banner .t b { display: block; color: var(--gold-strong); font-size: 13.5px; margin-bottom: 1px; }
.key-banner .btn { padding: 7px 11px; font-size: 12.5px; background: var(--gold); color: #1b1305; border-radius: 10px; }

/* ---------- XERA Business ---------- */
.wordmark-text { font-size: 26px; margin: 12px 0 2px; letter-spacing: .02em; }
.org-name { margin: 0 0 14px; font-size: 13.5px; }
.check-code { font-size: 38px; font-weight: 800; letter-spacing: .14em; margin: 18px 0 14px; color: var(--accent); font-variant-numeric: tabular-nums; }
.spin-inline { display: inline-block; width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--line); border-top-color: var(--accent); animation: rot 1s linear infinite; vertical-align: -1px; margin-right: 6px; }
.pending-av { margin: 16px auto 8px; display: grid; place-items: center; }
.org-card { margin: 0 4px 10px; background: var(--card); border-radius: 16px; padding: 12px; }
.org-card .lbl { font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .07em; font-weight: 600; margin-bottom: 6px; display: flex; align-items: center; gap: 6px; }
.org-card .lbl svg { width: 14px; height: 14px; }
.org-link { font-family: ui-monospace, Menlo, monospace; font-size: 12px; word-break: break-all; color: var(--text-2); background: var(--panel); padding: 8px 10px; border-radius: 10px; margin-bottom: 8px; }
.emp { display: flex; align-items: center; gap: 10px; padding: 8px 6px; border-radius: 12px; }
.emp:hover { background: var(--hover); }
.emp .t { flex: 1; min-width: 0; }
.emp b { display: block; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.emp small { color: var(--muted); font-size: 12px; }
.emp .acts { display: flex; gap: 6px; }
.role-tag { font-size: 10.5px; font-weight: 700; color: var(--accent); background: var(--accent-soft); padding: 1px 6px; border-radius: 6px; margin-left: 6px; vertical-align: 1px; }
.count-badge { background: var(--badge); color: var(--badge-ink); font-size: 11px; font-weight: 700; border-radius: 9px; padding: 0 6px; margin-left: 4px; }
.readonly-bar { display: flex; align-items: center; justify-content: center; gap: 8px; margin: 6px 16px 16px; padding: 14px; background: var(--card); border-radius: 18px; color: var(--muted); font-size: 13.5px; }
.emp.wide { flex-wrap: wrap; }
.emp.wide .acts { flex-basis: 100%; padding-left: 50px; margin-top: 2px; }

/* ---------- brand layer: full logo, watermark, heading style (set from org.json) ---------- */
.brand-full { display: block; width: 168px; max-width: 60%; margin: 0 auto 6px; filter: drop-shadow(0 16px 30px rgba(0,0,0,.45)); }
.has-full-logo #auth .auth-logo, .has-full-logo #auth .wordmark-text { display: none; }
.watermark { position: fixed; pointer-events: none; z-index: 0; background: center bottom / contain no-repeat; opacity: var(--watermark-opacity, .06); }
#auth .watermark { right: max(-60px, calc(50% - 760px)); bottom: 0; width: min(46vw, 560px); height: 92vh; }
#auth .auth-card { position: relative; z-index: 1; }
.chat-empty .watermark { position: absolute; inset: auto 0 0 auto; right: 2%; width: 28%; height: 78%; }
.chat-empty > :not(.watermark) { position: relative; }
.brand-headings .chat-empty h3 { text-transform: uppercase; font-weight: 900; letter-spacing: .03em; }
@media (max-width: 860px) { .brand-full { width: 118px; } #auth .watermark { width: 70vw; right: -16vw; opacity: calc(var(--watermark-opacity, .06) * .7); } }

/* ================= v0.3: card dialogs + animated brand background ================= */
/* animated background: slow floating colour fields (brand "aurora" colours) */
.aurora { position: fixed; inset: 0; overflow: hidden; z-index: 0; background: var(--aurora-bg, var(--bg)); pointer-events: none; }
.aurora i { position: absolute; width: 70vmax; height: 70vmax; border-radius: 50%; opacity: var(--blob-opacity, .7); will-change: transform; mix-blend-mode: screen;
  background: radial-gradient(circle at center, var(--c) 0%, transparent 62%); animation: drift 28s ease-in-out infinite alternate; }
.aurora i:nth-child(1) { --c: var(--blob-1, #2563eb); top: -30%; left: -25%; animation-duration: 26s; }
.aurora i:nth-child(2) { --c: var(--blob-2, #7c3aed); top: -20%; right: -30%; animation-duration: 32s; animation-delay: -8s; }
.aurora i:nth-child(3) { --c: var(--blob-3, #0ea5e9); bottom: -35%; left: -10%; animation-duration: 30s; animation-delay: -14s; }
.aurora i:nth-child(4) { --c: var(--blob-4, #1e3a8a); bottom: -30%; right: -20%; animation-duration: 36s; animation-delay: -4s; }
.aurora i:nth-child(5) { --c: var(--blob-5, #3b82f6); top: 20%; left: 25%; width: 50vmax; height: 50vmax; opacity: calc(var(--blob-opacity, .7) * .7); animation-duration: 24s; animation-delay: -18s; }
@keyframes drift {
  0% { transform: translate3d(0, 0, 0) scale(1); }
  33% { transform: translate3d(8vw, 6vh, 0) scale(1.12); }
  66% { transform: translate3d(-6vw, 10vh, 0) scale(.92); }
  100% { transform: translate3d(5vw, -8vh, 0) scale(1.06); }
}
@media (prefers-reduced-motion: reduce) { .aurora i { animation: none; } }
#auth { background: var(--aurora-bg, var(--bg)); position: relative; }
#auth .watermark { z-index: 0; }
.auth-wrap { position: relative; z-index: 1; width: 100%; max-width: 410px; display: flex; flex-direction: column; align-items: center; gap: 18px; margin: auto; }
.auth-brand { display: flex; align-items: center; gap: 10px; color: #fff; font-weight: 800; font-size: 15px; letter-spacing: .16em; text-transform: uppercase; text-shadow: 0 2px 12px rgba(0,0,0,.25); }
.auth-brand img { width: 40px; height: 40px; object-fit: contain; filter: drop-shadow(0 4px 12px rgba(0,0,0,.35)); }
.auth-card { max-width: none; border: 0; border-radius: 26px; padding: 34px 30px 28px; box-shadow: var(--shadow); }
.auth-h { margin: 0; font-size: 22px; font-weight: 800; letter-spacing: -.01em; text-align: center; color: var(--text); }
.auth-sub { margin: 6px 0 2px; text-align: center; font-size: 14px; line-height: 1.5; color: var(--text-2); }
.auth-card .tagline { font-size: 14px; margin: 6px 0 22px; }
.auth-card .form { margin-top: 20px; gap: 16px; }
.auth-card .form .auth-h + .auth-sub { margin-top: -8px; }
.auth-foot { margin: 0; color: rgba(255,255,255,.72); font-size: 12.5px; display: flex; align-items: center; gap: 6px; text-shadow: 0 1px 8px rgba(0,0,0,.3); }
.auth-foot svg { width: 14px; height: 14px; }
.field, .form input:not([type=checkbox]), .form textarea { min-height: 46px; transition: border-color .15s, box-shadow .15s; }
.field:focus, .form input:focus, .form textarea:focus { border-color: var(--focus-ring, var(--accent)); box-shadow: 0 0 0 4px var(--accent-soft); }
.btn.primary { transition: background .15s, transform .1s; }
.btn.primary:active { transform: translateY(1px); }

/* dialogs */
.modal { backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.modal-card { border: 0; border-radius: 26px; padding: 30px 28px 26px; box-shadow: var(--shadow); }
.modal-card h2 { font-size: 21px; font-weight: 800; letter-spacing: -.01em; }
.modal-card .org-link { background: var(--card); }
.m-hero { display: grid; place-items: center; margin: 4px 0 14px; }
.m-ic { width: 60px; height: 60px; border-radius: 20px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.m-ic svg { width: 28px; height: 28px; }
.m-hero img { width: 64px; height: 64px; border-radius: 18px; }
.modal-card h2.m-title { text-align: center; margin: 0 0 6px; }
.m-sub { text-align: center; color: var(--text-2); font-size: 14.5px; line-height: 1.5; margin: 0 0 20px; }
.copy-field { display: flex; align-items: center; gap: 8px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 6px 6px 6px 14px; margin-bottom: 12px; }
.copy-field span { flex: 1; min-width: 0; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.copy-field .icon-btn { width: 34px; height: 34px; border-radius: 10px; }
.m-actions { display: flex; flex-direction: column; gap: 6px; align-items: stretch; }
.m-actions .link-btn { align-self: center; margin-top: 4px; }
.m-note { text-align: center; font-size: 12.5px; color: var(--muted); margin: 4px 0 0; line-height: 1.45; }
@media (max-width: 860px) {
  .auth-card { padding: 28px 22px 24px; border-radius: 24px; }
  .auth-wrap { gap: 14px; }
  .modal-card { border-radius: 26px 26px 0 0; padding: 26px 22px max(22px, env(safe-area-inset-bottom)); }
}
.saved-av .ini { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: var(--accent-ink); }
.saved-av svg { width: 46%; height: 46%; }

/* ---------- chat background: floating company marks, or a picture / video chosen by an admin ---------- */
.chat-bg { position: absolute; inset: 0; overflow: hidden; pointer-events: none; z-index: 0;
  background: radial-gradient(120% 80% at 100% 0%, var(--accent-soft), transparent 55%), radial-gradient(90% 70% at 0% 100%, var(--accent-soft), transparent 60%); }
.chat-bg i { position: absolute; left: var(--x); top: var(--y); width: var(--s); height: var(--s);
  background: var(--bg-mark, url(/logo.svg)) center/contain no-repeat; opacity: var(--o, .07);
  animation: mark-float var(--d, 30s) ease-in-out var(--delay, 0s) infinite alternate; will-change: transform; }
@keyframes mark-float {
  0%   { transform: translate(0, 0) rotate(var(--r0, 0deg)) scale(1); }
  50%  { transform: translate(calc(var(--dx) * .6), var(--dy)) rotate(calc(var(--r0, 0deg) + var(--rot) * .5)) scale(1.06); }
  100% { transform: translate(var(--dx), calc(var(--dy) * -.4)) rotate(calc(var(--r0, 0deg) + var(--rot))) scale(.96); }
}
@media (prefers-reduced-motion: reduce) { .chat-bg i { animation: none; } }
.chat-bg img, .chat-bg video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.chat-bg.media::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, color-mix(in srgb, var(--panel) 55%, transparent), color-mix(in srgb, var(--panel) 35%, transparent) 40%, color-mix(in srgb, var(--panel) 65%, transparent)); }
#chatView > .chat-head, #chatView > .messages, #chatView > .typing-bar, #chatView > .composer,
#chatView > .record-bar, #chatView > .blocked-bar, #chatView > .readonly-bar { position: relative; z-index: 1; }
#chatView > .chat-head { background: color-mix(in srgb, var(--panel) 82%, transparent); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
#chatView > .emoji-panel, #chatView > .drop-hint { z-index: 6; }
.day, .sys { position: relative; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.chat-bg.media ~ .messages .day, .chat-bg.media ~ .messages .sys { background: color-mix(in srgb, var(--panel) 75%, transparent); }
.bg-row { display: flex; gap: 8px; flex-wrap: wrap; }
.bg-row .btn { flex: 1; }
.bg-prev { height: 90px; border-radius: 14px; overflow: hidden; background: var(--card); margin-bottom: 8px; position: relative; }
.bg-prev img, .bg-prev video { width: 100%; height: 100%; object-fit: cover; display: block; }
.tfa-qr { display: grid; place-items: center; margin: 0 0 14px; }
.tfa-qr img { width: 180px; height: 180px; border-radius: 14px; border: 1px solid var(--line); padding: 6px; background: #fff; }

/* onboarding tour */
.tour { position: fixed; inset: 0; z-index: 80; }
.tour.center { background: var(--overlay); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
.tour-hole { position: fixed; border-radius: 16px; box-shadow: 0 0 0 9999px var(--overlay), 0 0 0 2px var(--accent); transition: all .25s ease; pointer-events: none; }
.tour-card { position: fixed; width: min(340px, calc(100vw - 24px)); background: var(--panel); color: var(--text); border-radius: 20px; padding: 18px 18px 14px; box-shadow: var(--shadow); transition: left .25s ease, top .25s ease; animation: fade .2s; }
.tour-card h3 { margin: 2px 0 6px; font-size: 17px; font-weight: 800; }
.tour-card p { margin: 0 0 14px; color: var(--text-2); font-size: 14px; line-height: 1.5; }
.tour-step { font-size: 11.5px; font-weight: 700; color: var(--muted); letter-spacing: .06em; text-transform: uppercase; }
.tour-btns { display: flex; gap: 6px; align-items: center; }
.tour-btns .sp { flex: 1; }
.tour-btns .btn { padding: 9px 14px; font-size: 13.5px; border-radius: 12px; }
.login-key { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 17px; font-weight: 700; letter-spacing: .06em; text-align: center; background: var(--card); border: 1px dashed var(--line); border-radius: 14px; padding: 14px 10px; margin: 0 0 12px; word-break: break-all; user-select: all; color: var(--text); }
.login-key-input { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; text-transform: uppercase; letter-spacing: .04em; }
#keyForm .key-input { font-size: 15px; letter-spacing: .03em; }
.tour-card.tfa { box-shadow: var(--shadow), 0 0 0 2px var(--gold); }
.tour-btns { flex-wrap: wrap; }
.send-prev { display: grid; gap: 6px; margin: 4px 0 14px; position: relative; }
.send-prev.n1 { grid-template-columns: 1fr; } .send-prev.n2 { grid-template-columns: 1fr 1fr; } .send-prev.n3 { grid-template-columns: repeat(3, 1fr); }
.send-prev img { width: 100%; aspect-ratio: 4/3; object-fit: cover; border-radius: 12px; background: var(--card); }
.send-prev.n1 img { aspect-ratio: auto; max-height: 260px; object-fit: contain; }
.send-prev .more { position: absolute; right: 8px; bottom: 8px; background: rgba(0,0,0,.6); color: #fff; font-weight: 700; padding: 2px 8px; border-radius: 8px; font-size: 13px; }
.opt-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.opt { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border: 1px solid var(--line); border-radius: 14px; cursor: pointer; background: var(--card); }
.opt:has(input:checked) { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.opt input { margin-top: 3px; accent-color: var(--accent); width: 17px; height: 17px; }
.opt b { display: block; font-size: 14.5px; } .opt small { color: var(--muted); font-size: 12.5px; }
.mention { color: var(--link); font-weight: 600; cursor: pointer; }
.mention.me { background: color-mix(in srgb, var(--accent) 22%, transparent); border-radius: 6px; padding: 0 3px; color: var(--text); }
.grp.me .mention { color: var(--bubble-me-ink); text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--bubble-me-ink) 45%, transparent); }
.item .badge.at { background: var(--accent); color: var(--accent-ink); min-width: 20px; margin-right: 4px; }
.mention-box { position: absolute; left: 16px; bottom: 74px; width: min(340px, calc(100% - 32px)); background: var(--card-2); border: 1px solid var(--line); border-radius: 16px; padding: 6px; z-index: 7; box-shadow: var(--shadow); }
.mention-box button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 7px 8px; border-radius: 11px; text-align: left; }
.mention-box button.on, .mention-box button:hover { background: var(--hover); }
.mention-box b { display: block; font-size: 13.5px; } .mention-box small { color: var(--muted); font-size: 12px; }
.nick-field { display: flex; align-items: center; background: var(--field, var(--card)); border: 1px solid var(--line); border-radius: 14px; padding-left: 14px; }
.nick-field i { font-style: normal; color: var(--muted); font-weight: 600; }
.form .nick-field input:not([type=checkbox]) { border: 0; background: transparent; padding-left: 4px; box-shadow: none; }
.nick-field:focus-within { border-color: var(--focus-ring, var(--accent)); box-shadow: 0 0 0 4px var(--accent-soft); }
.me-card .plan-pill { max-width: 38%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-transform: none; letter-spacing: 0; font-size: 11.5px; }
.nick-line { margin: 2px 0 0; color: var(--link); font-weight: 600; font-size: 14px; }
.item .time .pin-ic { display: inline-flex; color: var(--muted); margin-right: 2px; }
.item .time .pin-ic svg { width: 13px; height: 13px; transform: rotate(35deg); }
#list .item { -webkit-touch-callout: none; user-select: none; }

/* ================= v0.4 layout: icon rail · conversations · chat · details (reference-style, brand colours) ================= */
#app { padding: 12px; gap: 12px; background:
  radial-gradient(1200px 600px at -10% -20%, color-mix(in srgb, var(--active) 45%, transparent), transparent 60%),
  radial-gradient(900px 600px at 110% 120%, color-mix(in srgb, var(--accent) 10%, transparent), transparent 60%), var(--bg); }
#sidebar, #chat, .details, #rail { border: 1px solid color-mix(in srgb, var(--line) 70%, transparent); box-shadow: 0 18px 50px rgba(0,0,0,.28); }

/* icon rail */
#rail { order: 0; flex-direction: column; justify-content: flex-start; align-items: center; width: 78px; flex-shrink: 0; margin: 0; padding: 18px 0 14px; gap: 10px; background: var(--rail); border-radius: 26px; }
.rail-logo { width: 42px; height: 42px; object-fit: contain; margin-bottom: 16px; filter: drop-shadow(0 6px 14px rgba(0,0,0,.4)); }
.rail-btn { flex: none; width: 52px; height: 52px; padding: 0; border-radius: 18px; justify-content: center; color: var(--rail-ink); transition: background .15s, color .15s, box-shadow .15s; }
.rail-btn .lb { display: none; }
.rail-btn svg { width: 24px; height: 24px; }
.rail-btn.active { color: var(--accent); background: color-mix(in srgb, var(--active) 75%, transparent); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 35%, transparent), 0 8px 22px color-mix(in srgb, var(--active) 70%, transparent); }
.rail-btn .dot { top: -3px; right: -4px; border-color: var(--rail); }
.rail-sp { flex: 1; }
.rail-out { width: 46px; height: 46px; }

/* conversations column */
#sidebar { width: 360px; border-radius: 26px; }
.me-card { margin: 14px 14px 4px; padding: 14px; border-radius: 22px; background: linear-gradient(135deg, var(--card-2), var(--card)); }
.side-head { display: flex; align-items: baseline; gap: 6px; padding: 14px 22px 6px; }
.side-head h2 { margin: 0; font-size: 22px; font-weight: 800; letter-spacing: -.01em; }
.side-count { font-size: 20px; font-weight: 700; color: var(--muted); }
.side-count.hot { color: var(--accent); }
.side-head .sp { flex: 1; }
.side-head .new-btn { width: 38px; height: 38px; border-radius: 12px; align-self: center; background: transparent; color: var(--muted); }
.side-head .new-btn:hover { background: var(--hover); color: var(--text); }
.search-row { margin: 6px 16px 4px; }
.search input { border-radius: 16px; padding-top: 12px; padding-bottom: 12px; }
.list { padding: 4px 10px 16px; }
.sec { padding: 16px 12px 8px; font-size: 11px; letter-spacing: .1em; }
.item { padding: 12px; border-radius: 18px; margin-bottom: 2px; transition: background .12s; }
.item.active { background: linear-gradient(135deg, color-mix(in srgb, var(--active) 95%, #fff 3%), color-mix(in srgb, var(--active) 70%, var(--card))); box-shadow: 0 10px 24px rgba(0,0,0,.25); }
.item.active .preview, .item.active .time { color: color-mix(in srgb, var(--text) 70%, transparent); }
.item .name { font-size: 15px; }

/* chat column */
#chat { border-radius: 26px; }
.chat-head { padding: 16px 22px; min-height: 76px; }
.chat-title b { font-size: 17.5px; font-weight: 800; }
#chatCount { font-size: 15px; font-weight: 600; margin-left: 2px; }
.chat-title .t { flex-direction: row; flex-wrap: wrap; align-items: baseline; column-gap: 6px; }
.chat-title small { flex-basis: 100%; }
.head-actions .icon-btn { width: 40px; height: 40px; border-radius: 13px; }
.stack-avs .av, .stack-avs .more { width: 32px; height: 32px; }
.messages { padding: 22px 30px 12px; }
.msg { padding: 10px 15px; border-radius: 18px; font-size: 14.5px; line-height: 1.45; box-shadow: 0 4px 14px rgba(0,0,0,.18); }
.grp:not(.me) .msg { background: color-mix(in srgb, var(--bubble) 92%, #fff 3%); border: 1px solid color-mix(in srgb, var(--line) 60%, transparent); }
.grp.me .msg { box-shadow: 0 8px 22px color-mix(in srgb, var(--active) 60%, transparent); }
.g-head b { font-size: 14px; font-weight: 700; }
.reacts button { border-radius: 999px; padding: 3px 9px; }
.composer { margin: 8px 18px 18px; padding: 8px 8px 8px 12px; border-radius: 20px; background: color-mix(in srgb, var(--card) 92%, transparent); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.send-btn { width: 42px; height: 42px; border-radius: 14px; }

/* details column */
.details { width: 340px; border-radius: 26px; padding: 20px; }
.d-head { font-size: 16px; }
.d-top { margin: 14px 0 12px; }
.d-top .av { margin-bottom: 12px; box-shadow: 0 14px 30px rgba(0,0,0,.35); border-radius: 50%; }
.d-top h3 { font-size: 19px; font-weight: 800; }
.e2e-pill { display: flex; align-items: center; justify-content: center; gap: 6px; font-size: 12px; color: var(--muted); margin: 0 0 12px; }
.e2e-pill svg { width: 14px; height: 14px; color: var(--accent); }
.stats { gap: 12px; margin-bottom: 6px; }
.stat { text-align: left; padding: 14px 16px; border-radius: 20px; background: linear-gradient(160deg, var(--card-2), var(--card)); }
.stat small { margin-bottom: 4px; }
.stat b { font-size: 26px; font-weight: 800; gap: 10px; }
.st-ic { width: 30px; height: 30px; border-radius: 10px; display: grid; place-items: center; }
.st-ic svg { width: 17px; height: 17px; }
.stat.f .st-ic { background: color-mix(in srgb, var(--accent) 22%, transparent); color: var(--accent); }
.stat.k .st-ic { background: color-mix(in srgb, #204969 55%, transparent); color: #9cc3e3; }
.stat.f b svg, .stat.k b svg { color: inherit; }
.mem { padding: 8px 4px; }
.mem .mem-act { width: 32px; height: 32px; border-radius: 10px; }
.mem .mem-act svg { width: 17px; height: 17px; }
.media-grid { grid-template-columns: repeat(4, 1fr); gap: 8px; }
.media-grid .cell { border-radius: 14px; }
.media-grid .cell.more { background: var(--card-2) !important; color: var(--text); font-size: 15px; }
.ftype { padding: 9px 6px; border-radius: 16px; }
.ftype:hover { background: var(--hover); }
.ftype .ic { width: 46px; height: 46px; border-radius: 15px; }
.ftype .chev { color: var(--muted); display: grid; transform: rotate(180deg); }
.ftype .chev svg { width: 16px; height: 16px; }
.ic.blue { background: color-mix(in srgb, #204969 65%, transparent); color: #a9cdea; }
.ic.red { background: color-mix(in srgb, var(--accent) 24%, transparent); color: var(--accent); }
.ic.green { background: color-mix(in srgb, #2f6b3b 60%, transparent); color: #9fd3a6; }
.ic.violet { background: color-mix(in srgb, #536872 60%, transparent); color: #c5d3da; }
.d-actions .btn { border-radius: 14px; }

@media (max-width: 1399px) {
  .details { position: fixed; right: 12px; top: 12px; bottom: 12px; z-index: 30; }
}
@media (max-width: 860px) {
  #app { flex-direction: column; padding: 0; gap: 0; background: var(--bg); }
  #sidebar, #chat, .details, #rail { border: 0; box-shadow: none; }
  #rail { order: 2; flex-direction: row; width: auto; justify-content: space-around; padding: 6px 8px; padding-bottom: max(6px, env(safe-area-inset-bottom)); gap: 4px; border-radius: 0; background: var(--panel); border-top: 1px solid var(--line); }
  .rail-logo, .rail-sp, .rail-out { display: none; }
  .rail-btn { flex: 1; width: auto; height: auto; padding: 7px 4px 6px; flex-direction: column; gap: 2px; border-radius: 13px; box-shadow: none !important; }
  .rail-btn .lb { display: block; font-size: 11px; }
  .rail-btn svg { width: 22px; height: 22px; }
  #sidebar { order: 1; width: 100%; border-radius: 0; }
  .details { inset: 0; right: 0; top: 0; bottom: 0; width: auto; border-radius: 0; }
  .messages { padding: 12px 12px 8px; }
  .composer { margin: 4px 8px; margin-bottom: max(8px, env(safe-area-inset-bottom)); }
}
@media (max-width: 860px) {
  #chatCount { display: none; }
  .chat-title .t { flex-direction: column; flex-wrap: nowrap; }
  .chat-title b { font-size: 16.5px; }
}
