/* Rooms by Aurmada · dark UI */
:root {
  --bg: #0a0b0f; --bg2: #0e1015; --panel: #12141a; --panel2: #181b23; --panel3: #1e222c; --line: #232733; --line2: #2e3442;
  --text: #eceef3; --text2: #c3c8d4; --muted: #8a91a2; --faint: #5d6474;
  --accent: #8b7bff; --accent-2: #4fd1c5; --accent-soft: rgba(139, 123, 255, .14);
  --ok: #4fd1a1; --warn: #ffb86b; --err: #ff6b81;
  --radius: 12px; --radius-sm: 8px;
  --shadow: 0 10px 40px -12px rgba(0, 0, 0, .6);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); }
body { line-height: 1.45; }
[hidden] { display: none !important; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.75rem; margin: 0 0 .35rem; letter-spacing: -.025em; line-height: 1.2; }
h2 { margin: .1rem 0 .6rem; font-size: 1.15rem; letter-spacing: -.01em; }
h3 { font-size: .7rem; text-transform: uppercase; letter-spacing: .09em; color: var(--muted); margin: 1.3rem 0 .5rem; font-weight: 600; }
p { margin: .3rem 0 .8rem; }
.muted { color: var(--muted); } .small { font-size: .84rem; } .tiny { font-size: .74rem; }
.center-text { text-align: center; }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

/* ---------- controls ---------- */
.stack { display: flex; flex-direction: column; gap: .85rem; } .stack.tight { gap: .45rem; }
.row { display: flex; align-items: center; gap: .5rem; } .row.wrap { flex-wrap: wrap; } .between { justify-content: space-between; } .end { justify-content: flex-end; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; align-items: end; }
label { display: flex; flex-direction: column; gap: .35rem; font-size: .84rem; color: var(--text2); font-weight: 500; }
input, textarea, select { background: var(--bg2); color: var(--text); border: 1px solid var(--line2); border-radius: var(--radius-sm); padding: .65rem .75rem; font: inherit; font-size: .92rem; width: 100%; transition: border-color .15s, box-shadow .15s; }
textarea { resize: vertical; }
input::placeholder, textarea::placeholder { color: var(--faint); }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
button, .btn { display: inline-flex; align-items: center; justify-content: center; gap: .5rem; background: var(--panel3); color: var(--text); border: 1px solid var(--line2); border-radius: var(--radius-sm); padding: .6rem 1rem; font: inherit; font-size: .9rem; font-weight: 500; cursor: pointer; text-decoration: none; transition: background .15s, border-color .15s, transform .05s; }
button:hover, .btn:hover { border-color: #3d4456; background: #232835; text-decoration: none; }
button:active, .btn:active { transform: translateY(1px); }
button.primary, .btn.primary { background: linear-gradient(135deg, #9a8cff, #7a68ff); border-color: transparent; color: #0b0a1a; font-weight: 650; box-shadow: 0 6px 20px -8px rgba(139, 123, 255, .7); }
button.primary:hover, .btn.primary:hover { filter: brightness(1.08); }
button.ghost, .btn.ghost { background: transparent; border-color: transparent; color: var(--text2); }
button.ghost:hover, .btn.ghost:hover { background: var(--panel2); }
button.small, .btn.small { padding: .42rem .75rem; font-size: .82rem; } button.tiny { padding: .15rem .45rem; font-size: .72rem; }
button.block, .btn.block { width: 100%; padding: .75rem 1rem; }
button:disabled { opacity: .5; cursor: default; }
button.danger { background: #3a1820; border-color: #5a2430; color: #ffb3bf; } button.danger:hover { background: #4a1d28; }
button.danger-ghost { background: transparent; border-color: #5a2430; color: #ff9aab; }
.linklike { background: none; border: 0; padding: 0; color: var(--muted); text-decoration: underline; text-underline-offset: 2px; cursor: pointer; font-size: inherit; }
.linklike:hover { background: none; color: var(--text2); }
.btn.google { background: #fff; color: #1f1f1f; border-color: #fff; font-weight: 600; }
.btn.google:hover { background: #f1f1f4; }
.switch { appearance: none; width: 38px; height: 22px; border-radius: 999px; background: var(--line2); position: relative; cursor: pointer; padding: 0; border: 0; flex: none; transition: background .15s; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch:checked { background: var(--accent); } .switch:checked::after { transform: translateX(16px); }
.switch:focus { box-shadow: 0 0 0 3px var(--accent-soft); }
.switch-row { flex-direction: row; align-items: center; justify-content: space-between; gap: .8rem; background: var(--bg2); border: 1px solid var(--line2); border-radius: var(--radius-sm); padding: .55rem .75rem; min-height: 44px; }
.toggle { flex-direction: row; align-items: center; gap: .4rem; cursor: pointer; font-weight: 400; }
.toggle input { width: auto; }
.notice { border-radius: var(--radius-sm); padding: .65rem .8rem; font-size: .86rem; background: var(--panel2); border: 1px solid var(--line2); color: var(--text2); }
.notice.error { background: rgba(255, 107, 129, .08); border-color: rgba(255, 107, 129, .35); color: #ffc2cc; }
.notice.warn { background: rgba(255, 184, 107, .08); border-color: rgba(255, 184, 107, .35); color: #ffd9b0; }
.notice.ok { background: rgba(79, 209, 161, .08); border-color: rgba(79, 209, 161, .35); color: #b8f0dc; }
.chip { font-size: .68rem; font-weight: 600; padding: .15rem .5rem; border-radius: 999px; background: var(--panel3); color: var(--text2); text-transform: capitalize; }
.chip.owner, .chip.accent { background: var(--accent-soft); color: #c9c1ff; }
.badge { font-size: .66rem; padding: .08rem .4rem; border-radius: 5px; background: #262c3d; color: #bcc6ff; }

/* ---------- brand ---------- */
.brandmark { display: inline-flex; align-items: center; gap: .45rem; color: var(--text); text-decoration: none; }
.brandmark:hover { text-decoration: none; }
.logo-dot { width: 22px; height: 22px; border-radius: 7px; background: conic-gradient(from 200deg, var(--accent), var(--accent-2), var(--accent)); box-shadow: 0 0 18px rgba(139, 123, 255, .45); }
.wordmark { font-size: 1.15rem; font-weight: 750; letter-spacing: -.03em; }
.by { font-size: .78rem; color: var(--muted); font-weight: 500; }

/* ---------- auth / join ---------- */
.auth-shell { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 2rem 1rem; background: radial-gradient(1000px 500px at 50% -10%, rgba(139, 123, 255, .16), transparent 60%), radial-gradient(700px 400px at 90% 110%, rgba(79, 209, 197, .08), transparent 60%), var(--bg); }
.auth-card { width: min(420px, 100%); background: rgba(18, 20, 26, .85); backdrop-filter: blur(10px); border: 1px solid var(--line); border-radius: 18px; padding: 2rem; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 1rem; }
.auth-card > .brandmark { margin-bottom: .4rem; }
.auth-title { font-size: 1.5rem; margin: 0; }
.divider { display: flex; align-items: center; gap: .8rem; color: var(--faint); font-size: .78rem; margin: .3rem 0; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.fineprint { font-size: .75rem; color: var(--faint); margin: 0; }
.fineprint a { color: var(--muted); text-decoration: underline; }
.sent-icon { width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center; font-size: 1.5rem; background: var(--accent-soft); color: #c9c1ff; margin-bottom: .5rem; }
#signin-start, #signin-sent { display: flex; flex-direction: column; gap: .9rem; }
.turnstile:empty { display: none; }

/* ---------- pages ---------- */
.page { min-height: 100vh; display: flex; flex-direction: column; background: radial-gradient(900px 380px at 15% -10%, rgba(139, 123, 255, .09), transparent 60%), var(--bg); }
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 1rem clamp(1rem, 4vw, 2.5rem); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; background: rgba(10, 11, 15, .8); backdrop-filter: blur(12px); }
.container { width: min(1080px, 100%); margin: 0 auto; padding: 2rem clamp(1rem, 4vw, 2.5rem) 3rem; flex: 1; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1.4rem; flex-wrap: wrap; }
.page-head p { margin: 0; }
.plan-badge { font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; padding: .25rem .6rem; border-radius: 999px; border: 1px solid var(--line2); color: var(--text2); }
.plan-badge.paid { border-color: rgba(79, 209, 197, .5); color: var(--accent-2); }
.avatar { width: 34px; height: 34px; padding: 0; border-radius: 50%; background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #0b0a1a; font-weight: 700; border: 0; display: inline-grid; place-items: center; }
.avatar.lg { width: 44px; height: 44px; font-size: 1.1rem; flex: none; }
.banner { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .75rem 1rem; border: 1px solid rgba(139, 123, 255, .35); background: var(--accent-soft); border-radius: var(--radius); margin-bottom: 1.4rem; font-size: .88rem; color: #dcd7ff; flex-wrap: wrap; }
.usage-full { color: var(--warn) !important; }
.room-grid { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: .9rem; }
.room-card { display: flex; flex-direction: column; gap: .5rem; padding: 1.1rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); color: var(--text); text-decoration: none; transition: border-color .15s, transform .15s, background .15s; height: 100%; }
.room-card:hover { border-color: rgba(139, 123, 255, .5); background: var(--panel2); transform: translateY(-2px); text-decoration: none; }
.room-card-top { display: flex; justify-content: space-between; align-items: center; }
.room-initial { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; font-weight: 700; background: var(--panel3); color: #c9c1ff; }
.room-card-name { font-weight: 650; font-size: 1rem; word-break: break-word; }
.room-card-meta { font-size: .78rem; color: var(--muted); }
.empty { text-align: center; padding: 3.5rem 1.5rem; border: 1px dashed var(--line2); border-radius: 18px; background: var(--panel); max-width: 560px; margin: 1rem auto; }
.empty p { max-width: 420px; margin: .4rem auto 1.4rem; }
.empty-art { display: flex; justify-content: center; margin-bottom: 1.2rem; }
.empty-art span { width: 40px; height: 40px; border-radius: 50%; border: 2px solid var(--bg); margin: 0 -6px; background: linear-gradient(135deg, var(--accent), #6a5cff); }
.empty-art span:nth-child(2) { background: linear-gradient(135deg, var(--accent-2), #2fa69b); }
.empty-art span:nth-child(3) { background: linear-gradient(135deg, #ffb86b, #ff8a65); }

/* ---------- onboarding ---------- */
.onboard { width: min(640px, 100%); margin: 0 auto; padding: 2rem 1rem 3rem; flex: 1; }
.steps { list-style: none; padding: 0; margin: 0 0 1.4rem; display: flex; gap: .5rem; }
.steps li { flex: 1; display: flex; align-items: center; gap: .5rem; font-size: .8rem; color: var(--faint); padding-top: .7rem; border-top: 3px solid var(--line); font-weight: 500; }
.steps li span { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: .72rem; background: var(--panel3); color: var(--muted); flex: none; }
.steps li.active { color: var(--text); border-top-color: var(--accent); }
.steps li.active span { background: var(--accent); color: #0b0a1a; }
.steps li.done { color: var(--text2); border-top-color: rgba(139, 123, 255, .5); }
.steps li.done span { background: var(--accent-soft); color: #c9c1ff; }
.onboard-card { background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: clamp(1.25rem, 4vw, 2rem); box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 1rem; }
.onboard-card h1 { font-size: 1.45rem; margin: 0; }
.onboard-card > p.muted { margin: -.4rem 0 .2rem; }
.copy-field { display: flex; align-items: stretch; gap: .5rem; background: var(--bg2); border: 1px solid var(--line2); border-radius: var(--radius-sm); padding: .35rem .35rem .35rem .75rem; }
.copy-field code { flex: 1; font-size: .8rem; word-break: break-all; align-self: center; color: var(--text2); background: none; border: 0; padding: 0; }
.copy-field button { flex: none; }
.tabs { display: flex; flex-wrap: wrap; gap: .25rem; background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; padding: .25rem; overflow-x: auto; }
.tabs button { flex: 1 0 auto; background: transparent; border: 0; color: var(--muted); padding: .5rem .7rem; font-size: .84rem; white-space: nowrap; }
.tabs button.active { background: var(--panel3); color: var(--text); box-shadow: 0 1px 0 rgba(255, 255, 255, .04) inset; }
.tab-body { padding-top: 1rem; }
.connect { display: flex; flex-direction: column; gap: .4rem; }
.howto { margin: 0; padding-left: 1.2rem; font-size: .88rem; color: var(--text2); line-height: 1.6; }
.howto li { margin-bottom: .2rem; }

/* ---------- room ---------- */
.room { display: grid; grid-template-columns: 260px 1fr 330px; height: 100vh; height: 100dvh; }
.room-tabs { display: none; }
.side { background: var(--bg2); border-right: 1px solid var(--line); padding: 1rem; overflow-y: auto; display: flex; flex-direction: column; }
.side.right { border-right: 0; border-left: 1px solid var(--line); }
.room-head { display: flex; flex-direction: column; gap: .4rem; padding-bottom: .4rem; }
.room-head h2 { word-break: break-word; margin: .3rem 0 0; font-size: 1.1rem; }
.back { font-size: .8rem; color: var(--muted); font-weight: 500; }
.side-foot { margin-top: auto; padding-top: 1rem; display: flex; justify-content: space-between; align-items: center; gap: .5rem; flex-wrap: wrap; }
.side-foot a { color: var(--muted); }
.plist { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: .15rem; }
.plist li { display: flex; align-items: center; gap: .5rem; font-size: .88rem; padding: .35rem .45rem; border-radius: 7px; }
.plist li:hover { background: var(--panel2); }
.plist li { position: relative; min-width: 0; }
.plist .n { flex: 0 1 auto; min-width: 3.5em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.plist .h { color: var(--muted); font-size: .76rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 0 4 auto; min-width: 0; }
.plist .badge { flex: none; }
.side.right > .row h3 { margin: 0; }
.plist .x { position: absolute; right: .3rem; top: 50%; transform: translateY(-50%); opacity: 0; background: var(--panel3); } .plist li:hover .x { opacity: 1; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #3b4250; flex: none; }
.dot.on { background: var(--ok); box-shadow: 0 0 6px var(--ok); }
.thinking { color: var(--warn); font-size: .72rem; }
.thread { display: flex; flex-direction: column; min-width: 0; height: 100vh; height: 100dvh; background: var(--bg); }
.messages { flex: 1; overflow-y: auto; padding: 1.2rem 1.4rem; display: flex; flex-direction: column; gap: .8rem; }
.msg { max-width: 760px; }
.msg .meta { font-size: .75rem; color: var(--muted); margin-bottom: .2rem; display: flex; gap: .4rem; align-items: center; flex-wrap: wrap; }
.msg .meta b { color: var(--text); font-size: .84rem; font-weight: 600; }
.msg .body { background: var(--panel); border: 1px solid var(--line); border-radius: 4px 12px 12px 12px; padding: .6rem .8rem; white-space: pre-wrap; word-wrap: break-word; line-height: 1.5; font-size: .93rem; }
.msg.agent .body { border-color: #33386a; background: #14152a; }
.msg.mine .body { border-color: #2b4f47; background: #10201d; }
.msg.summary .body { border-color: rgba(255, 184, 107, .6); }
.msg.system { color: var(--faint); font-size: .78rem; text-align: center; max-width: none; }
.msg.mentions-me .body { box-shadow: inset 3px 0 0 var(--warn); }
.mention { color: #b3a8ff; font-weight: 600; }
.typing { height: 1.3em; padding: 0 1.4rem; }
.composer { position: relative; display: flex; flex-direction: column; gap: .5rem; padding: .7rem 1.2rem calc(.8rem + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: var(--bg2); }
.composer-row { display: flex; align-items: flex-end; gap: .4rem; background: var(--panel); border: 1px solid var(--line2); border-radius: 22px; padding: .3rem .35rem; transition: border-color .15s, box-shadow .15s; }
.composer-row:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.composer textarea { flex: 1; min-height: 36px; max-height: 200px; resize: none; border: 0; background: transparent; padding: .5rem .3rem; box-shadow: none !important; line-height: 1.4; }
.icon-btn { width: 36px; height: 36px; padding: 0; border-radius: 50%; background: transparent; border: 0; color: var(--text2); font-size: 1.25rem; line-height: 1; flex: none; }
.icon-btn:hover { background: var(--panel3); color: var(--text); }
#btn-plus { font-size: 1.5rem; font-weight: 300; background: var(--panel3); }
.send-btn { width: 36px; height: 36px; padding: 0; border-radius: 50%; font-size: 1.1rem; font-weight: 700; flex: none; }
.mention-pop { position: absolute; bottom: 100%; left: 1.2rem; background: var(--panel2); border: 1px solid var(--line2); border-radius: 10px; min-width: 240px; overflow: hidden; box-shadow: var(--shadow); }
.mention-pop div { padding: .45rem .75rem; cursor: pointer; font-size: .85rem; }
.mention-pop div.active, .mention-pop div:hover { background: var(--accent-soft); }
.pinned { margin: .9rem 1.4rem 0; border: 1px solid rgba(255, 184, 107, .5); border-radius: var(--radius); background: #1b160e; }
.pinned-head { display: flex; justify-content: space-between; align-items: center; padding: .45rem .75rem; font-size: .85rem; }
.pinned-body { padding: 0 .75rem .65rem; white-space: pre-wrap; font-size: .85rem; max-height: 260px; overflow-y: auto; }
.pinned.collapsed .pinned-body { display: none; }
.capsules { list-style: none; padding: 0; margin: 1rem 0; display: flex; flex-direction: column; gap: .5rem; }
.capsule { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: .6rem .7rem; }
.capsule.shared { border-color: #2b4f47; }
.capsule .t { font-weight: 600; font-size: .88rem; }
.capsule .c { font-size: .78rem; color: #aab1bf; white-space: pre-wrap; max-height: 90px; overflow: hidden; margin: .3rem 0; }
.capsule .row { font-size: .75rem; }
.file { cursor: pointer; color: var(--accent); flex-direction: row; font-weight: 500; }
.audit summary { cursor: pointer; color: var(--muted); font-size: .8rem; }
.audit ul { padding-left: 1rem; }

/* ---------- modal ---------- */
dialog { overflow-y: auto; background: var(--panel); color: var(--text); border: 1px solid var(--line2); border-radius: 18px; padding: 0; width: min(640px, 94vw); max-height: 90vh; box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(4, 5, 8, .7); backdrop-filter: blur(3px); }
.modal-body { padding: 1.5rem; display: flex; flex-direction: column; gap: .85rem; position: relative; }
.modal-body > h2 { padding-right: 2rem; }
.modal-x { position: absolute; top: .8rem; right: .8rem; width: 32px; height: 32px; padding: 0; border-radius: 8px; color: var(--muted); }
.modal-body code:not(.copy-field code) { font-size: .8rem; background: var(--bg2); border: 1px solid var(--line); border-radius: 6px; padding: .45rem .55rem; display: block; word-break: break-all; }
.plans { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: .6rem; }
.plan { border: 1px solid var(--line); border-radius: 12px; padding: .85rem; display: flex; flex-direction: column; gap: .4rem; background: var(--bg2); }
.plan.suggested { border-color: rgba(139, 123, 255, .7); box-shadow: 0 0 0 1px rgba(139, 123, 255, .5) inset; }
.plan.current { opacity: .7; }
.plan .price { font-size: 1.3rem; font-weight: 700; letter-spacing: -.02em; }
.plan ul { margin: 0 0 .3rem; padding-left: 1rem; font-size: .76rem; color: #aab1bf; line-height: 1.5; flex: 1; }
.account-head { display: flex; gap: .8rem; align-items: center; }
.menu { display: flex; flex-direction: column; gap: .35rem; }
.menu button { justify-content: flex-start; }
.toast { position: fixed; bottom: calc(1.2rem + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); background: var(--panel3); border: 1px solid var(--line2); padding: .65rem 1rem; border-radius: 10px; font-size: .88rem; z-index: 50; box-shadow: var(--shadow); max-width: 92vw; }

/* ---------- footer + legal ---------- */
.app-footer { display: flex; gap: 1.2rem; justify-content: center; flex-wrap: wrap; padding: 1.4rem 1rem 1.8rem; font-size: .78rem; }
.app-footer a { color: var(--muted); }
.auth-shell .app-footer { padding-bottom: 0; margin-top: 1.2rem; }
.legal-body { background: var(--bg); }
.legal { width: min(760px, 100%); margin: 0 auto; padding: 2rem 1.2rem 3rem; color: var(--text2); line-height: 1.65; }
.legal h1 { color: var(--text); font-size: 2rem; margin-top: 1rem; }
.legal h2 { color: var(--text); margin-top: 2rem; font-size: 1.1rem; }
.legal li { margin-bottom: .35rem; }
.draft-banner { border: 1px solid rgba(255, 184, 107, .5); background: rgba(255, 184, 107, .08); color: #ffd9b0; padding: .8rem 1rem; border-radius: 10px; font-size: .88rem; }
.legal-table { width: 100%; border-collapse: collapse; font-size: .86rem; }
.legal-table th, .legal-table td { text-align: left; padding: .5rem; border-bottom: 1px solid var(--line); }

/* ---------- responsive ---------- */
@media (max-width: 1100px) { .room { grid-template-columns: 230px 1fr 290px; } }
@media (max-width: 900px) {
  .room { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .room-tabs { display: flex; gap: .25rem; padding: .5rem; padding-top: calc(.5rem + env(safe-area-inset-top)); background: var(--bg2); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 4; }
  .room-tabs button { flex: 1; background: transparent; border: 0; color: var(--muted); padding: .5rem; font-size: .86rem; }
  .room-tabs button.active { background: var(--panel3); color: var(--text); }
  .room [data-pane] { display: none; border: 0; }
  .room[data-tab="people"] [data-pane="people"], .room[data-tab="context"] [data-pane="context"] { display: flex; }
  .room[data-tab="chat"] [data-pane="chat"], .room:not([data-tab]) [data-pane="chat"] { display: flex; }
  .thread { height: calc(100dvh - 54px); }
  .side { min-height: calc(100dvh - 54px); }
  .messages { padding: 1rem; }
  .composer { padding-left: .8rem; padding-right: .8rem; }
}
@media (max-width: 560px) {
  .grid-2 { grid-template-columns: 1fr; }
  .steps li { font-size: 0; gap: 0; justify-content: center; }
  .steps li span { font-size: .72rem; }
  .auth-card { padding: 1.5rem 1.25rem; }
  .page-head h1 { font-size: 1.45rem; }
  .topbar .by { display: none; }
}

a.button { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }

.ai-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: .5rem; }
.ai-tile { display: flex; flex-direction: column; align-items: center; gap: .3rem; padding: .7rem .4rem; background: var(--bg2); border: 1px solid var(--line); border-radius: 12px; color: var(--text); cursor: pointer; }
.ai-tile:hover { border-color: var(--muted); }
.ai-tile.active { border-color: #8b7bff; box-shadow: 0 0 0 1px #8b7bff inset; }
.ai-logo { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 1rem; }
.ai-name { font-size: .84rem; font-weight: 600; text-align: center; }
.ai-sub { font-size: .7rem; color: var(--muted); text-align: center; }

.waiting { display: flex; flex-direction: column; gap: .35rem; padding: 0 .9rem; }
.wait-chip { display: flex; align-items: center; justify-content: space-between; gap: .6rem; flex-wrap: wrap; padding: .45rem .7rem; border-radius: 10px; background: var(--bg2); border: 1px dashed var(--line); font-size: .82rem; color: var(--muted); }
.wait-chip.live { border-style: solid; border-color: #8b7bff55; color: var(--text); justify-content: flex-start; }
.wait-chip .dots { width: 26px; height: 8px; background: radial-gradient(circle, #8b7bff 3px, transparent 3.5px) 0 0/9px 8px repeat-x; animation: dots 1s steps(3) infinite; }
@keyframes dots { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }

.dot.ready { background: #5aa9ff; box-shadow: 0 0 6px #5aa9ff88; }
.n small.st { display: block; font-size: .68rem; font-weight: 500; color: var(--muted); line-height: 1.2; }
.n small.st.on { color: var(--ok); }
.n small.st.ready { color: #5aa9ff; }

.live-line { display: flex; align-items: center; gap: .45rem; font-size: .78rem; color: var(--muted); padding: .1rem .2rem; }

/* message actions, reactions, edits, attachments */
.msg { position: relative; }
.msg-actions { position: absolute; top: -.9rem; right: .4rem; display: none; gap: .1rem; background: var(--panel2); border: 1px solid var(--line2); border-radius: 999px; padding: .15rem .25rem; box-shadow: var(--shadow); z-index: 2; }
.msg:hover .msg-actions, .msg.show-actions .msg-actions { display: flex; }
@media (hover: none) { .msg:hover .msg-actions { display: none; } .msg.show-actions .msg-actions { display: flex; } }
.msg-actions .act { background: transparent; border: 0; padding: .2rem .4rem; font-size: .95rem; border-radius: 999px; min-width: 30px; }
.msg-actions .act:hover { background: var(--panel3); }
.msg-actions .act.danger:hover { background: rgba(255, 107, 129, .15); }
.msg .edited { font-size: .7rem; color: var(--faint); }
.msg.deleted .deleted-body { font-style: italic; color: var(--faint); background: transparent; border-style: dashed; }
.reactions { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: .35rem; }
.reaction { padding: .12rem .5rem; font-size: .8rem; border-radius: 999px; background: var(--panel2); border: 1px solid var(--line2); }
.reaction.me { border-color: var(--accent); background: var(--accent-soft); }
.edit-box { display: flex; flex-direction: column; gap: .35rem; }
.edit-input { min-height: 60px; }
.edit-row { display: flex; align-items: center; gap: .4rem; justify-content: flex-end; }
.edit-row .muted { margin-right: auto; }
.att-images { display: grid; gap: .3rem; margin-top: .35rem; max-width: 420px; }
.att-images.n2, .att-images.n4 { grid-template-columns: 1fr 1fr; }
.att-images.n3 { grid-template-columns: 1fr 1fr 1fr; }
.att-img img { width: 100%; max-height: 320px; object-fit: cover; border-radius: 12px; border: 1px solid var(--line); display: block; background: var(--panel); }
.att-images.n1 .att-img img { width: auto; max-width: 100%; }
.att-files { display: flex; flex-direction: column; gap: .3rem; margin-top: .35rem; max-width: 360px; }
.att-file { display: flex; align-items: center; gap: .6rem; padding: .55rem .7rem; border: 1px solid var(--line2); border-radius: 12px; background: var(--panel); color: var(--text); }
.att-file:hover { border-color: var(--accent); }
.att-ico { font-size: 1.3rem; }
.att-meta { display: flex; flex-direction: column; min-width: 0; }
.att-meta b { font-size: .85rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att-meta small { color: var(--muted); font-size: .72rem; }
.attach-tray { display: flex; gap: .4rem; flex-wrap: wrap; }
.att-chip { display: flex; align-items: center; gap: .4rem; background: var(--panel); border: 1px solid var(--line2); border-radius: 12px; padding: .25rem .3rem .25rem .3rem; max-width: 200px; font-size: .78rem; }
.att-chip img { width: 36px; height: 36px; object-fit: cover; border-radius: 8px; }
.att-chip .att-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att-chip.busy { opacity: .6; }
.att-chip.err { border-color: var(--err); }
.att-x { padding: 0 .4rem; background: transparent; border: 0; color: var(--muted); font-size: 1rem; }
.emoji-pop { position: absolute; bottom: 100%; right: 1.2rem; width: 296px; max-height: 220px; overflow-y: auto; display: grid; grid-template-columns: repeat(8, 1fr); gap: .1rem; background: var(--panel2); border: 1px solid var(--line2); border-radius: 14px; padding: .4rem; box-shadow: var(--shadow); z-index: 6; }
.emoji-pop[style*="left"] { right: auto; }
.emoji-pop button { background: transparent; border: 0; padding: .3rem 0; font-size: 1.2rem; border-radius: 8px; }
.emoji-pop button:hover { background: var(--panel3); }
.drop-hint { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(10, 11, 15, .75); border: 2px dashed var(--accent); border-radius: 14px; color: var(--text); font-weight: 600; z-index: 8; pointer-events: none; }
.drop-hint[hidden] { display: none; }
.thread { position: relative; }
