/* SONIQ design system layer — tokens from @soniq/soniq-ui/theme (v4 app).
   Loaded after app.css. Partner brands override --accent / --accent2 at runtime. */
:root {
  --accent: #8b5cf6; --accent2: #ec4899;
  --grad: linear-gradient(135deg, var(--accent) 0%, var(--accent2) 100%);
  --bg: #f6f5fb; --panel: rgba(255,255,255,.94); --side: rgba(255,255,255,.72);
  --text: #1e1b4b; --muted: #6b6489; --line: rgba(139,92,246,.14);
  --bubble: linear-gradient(135deg, rgba(139,92,246,.12), rgba(236,72,153,.10));
  --code: rgba(139,92,246,.06); --danger: #dc2626;
  --soft: rgba(139,92,246,.08); --hover: rgba(30,27,75,.04);
  --radius: 14px;
  --shadow: 0 18px 40px rgba(30,27,75,.14), 0 2px 6px rgba(30,27,75,.05), 0 0 0 1px rgba(255,255,255,.6) inset;
  --soft-shadow: 0 2px 8px rgba(30,27,75,.06);
  --cta-shadow: 0 10px 24px color-mix(in srgb, var(--accent2) 32%, transparent), 0 0 0 1px rgba(255,255,255,.12) inset;
  --glow: radial-gradient(1200px 600px at 85% -10%, rgba(236,72,153,.10), transparent 60%), radial-gradient(900px 500px at -10% 110%, rgba(139,92,246,.12), transparent 60%);
  --font: "SF Pro Display", "SF Pro Text", -apple-system, BlinkMacSystemFont, "Segoe UI Variable", "Segoe UI", Inter, system-ui, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0a0510; --panel: rgba(28,18,44,.86); --side: rgba(18,9,30,.78);
    --text: #fdf4ff; --muted: rgba(253,244,255,.62); --line: rgba(236,72,153,.16);
    --bubble: linear-gradient(135deg, rgba(139,92,246,.26), rgba(236,72,153,.18));
    --code: rgba(139,92,246,.10); --danger: #f87171; --soft: rgba(139,92,246,.16); --hover: rgba(253,244,255,.05);
    --shadow: 0 22px 60px rgba(0,0,0,.55), 0 0 0 1px rgba(255,255,255,.02) inset, 0 -1px 0 rgba(139,92,246,.18) inset;
    --soft-shadow: 0 2px 8px rgba(0,0,0,.35);
    --glow: radial-gradient(1200px 700px at 85% -10%, rgba(236,72,153,.16), transparent 60%), radial-gradient(900px 600px at -10% 110%, rgba(139,92,246,.20), transparent 60%);
    color-scheme: dark;
  }
}

body { font-family: var(--font); background: var(--bg) var(--glow) fixed; -webkit-font-smoothing: antialiased; letter-spacing: -.005em; }
::selection { background: color-mix(in srgb, var(--accent) 30%, transparent); }
* { scrollbar-width: thin; scrollbar-color: color-mix(in srgb, var(--accent) 30%, transparent) transparent; }

/* Buttons */
.btn { border-radius: 12px; transition: transform .12s, box-shadow .2s, border-color .2s, background .2s; }
.btn:hover:not(:disabled) { border-color: color-mix(in srgb, var(--accent) 40%, transparent); }
.btn.primary { background: var(--grad); border: 0; box-shadow: var(--cta-shadow); }
.btn.primary:hover:not(:disabled) { transform: translateY(-1px); filter: brightness(1.05); }
.btn.ghost:hover:not(:disabled) { background: var(--soft); }
.icon-btn:hover { background: var(--soft); color: var(--accent); }
.pill { background: var(--soft); color: var(--accent); }
input:focus, textarea:focus, select:focus { outline: 3px solid color-mix(in srgb, var(--accent) 25%, transparent); border-color: color-mix(in srgb, var(--accent) 60%, transparent); }

/* Brand */
.brand-mark { background: var(--grad); box-shadow: var(--cta-shadow); }
.brand-mark.has-logo { background: transparent; box-shadow: none; }
.brand-name { font-weight: 800; letter-spacing: -.02em; }
.login-card { backdrop-filter: blur(20px) saturate(1.4); -webkit-backdrop-filter: blur(20px) saturate(1.4); border-radius: 22px; }
.login-card h1 { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; font-weight: 800; letter-spacing: -.02em; }

/* Sidebar — glass */
.sidebar { background: var(--side); backdrop-filter: blur(24px) saturate(1.5); -webkit-backdrop-filter: blur(24px) saturate(1.5); }
.side-head { border-bottom-color: var(--line); }
.nav-item { border-radius: 11px; transition: background .15s; position: relative; }
.nav-item:hover { background: var(--hover); }
.nav-item.active { background: var(--soft); font-weight: 600; }
.nav-item.active::before { content: ""; position: absolute; left: 0; top: 7px; bottom: 7px; width: 3px; border-radius: 3px; background: var(--grad); }
.avatar { background: var(--grad); }
.unread-dot, .nav-item.space-busy::after { background: var(--accent2); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent2) 20%, transparent); }

/* Main */
.main { background: transparent; }
.topbar { background: var(--panel); backdrop-filter: blur(20px) saturate(1.4); -webkit-backdrop-filter: blur(20px) saturate(1.4); position: sticky; top: 0; z-index: 5; }
.space-title { font-size: 16px; letter-spacing: -.01em; }
.welcome h2 { font-size: 32px; font-weight: 800; letter-spacing: -.03em; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.chip { background: var(--panel); box-shadow: var(--soft-shadow); transition: transform .12s, border-color .2s; }
.chip:hover { transform: translateY(-1px); border-color: color-mix(in srgb, var(--accent) 50%, transparent); }

/* Messages */
.msg-row .who .avatar { border-radius: 10px; }
.msg-row.user .content { background: var(--bubble); border: 1px solid var(--line); border-radius: 18px 18px 6px 18px; }
.msg-row .name { color: var(--muted); letter-spacing: .01em; }
.content a { color: var(--accent); text-decoration-color: color-mix(in srgb, var(--accent) 40%, transparent); text-underline-offset: 2px; }
.content code { background: var(--code); }
.codeblock { background: var(--code); border-color: var(--line); }
.dots span { background: var(--accent); }

/* Composer */
.composer { border-radius: 20px; background: var(--panel); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); transition: border-color .2s, box-shadow .2s; }
.composer:focus-within { border-color: color-mix(in srgb, var(--accent) 50%, transparent); box-shadow: var(--shadow), 0 0 0 4px color-mix(in srgb, var(--accent) 12%, transparent); }
.send { border-radius: 14px; }

/* Dialogs */
dialog { border-radius: 20px; backdrop-filter: blur(24px) saturate(1.4); -webkit-backdrop-filter: blur(24px) saturate(1.4); }
dialog::backdrop { background: radial-gradient(60% 60% at 50% 50%, rgba(139,92,246,.22) 0%, rgba(10,5,16,.55) 100%); }
dialog h2 { font-weight: 800; letter-spacing: -.02em; }

/* Spend meter + files */
.cost-meter { background: var(--soft); border-color: transparent; border-radius: 12px; }
.cost-meter .cm-total { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.cost-table .bar { background: var(--grad); opacity: .8; }
.files-filters button.active { background: var(--grad); border-color: transparent; }
.fcard { border-radius: 14px; box-shadow: var(--soft-shadow); transition: transform .12s; }
.fcard:hover { transform: translateY(-2px); }

.avatar.photo { background-size: cover; background-position: center; background-color: var(--soft); }

.meet-card.live { border-color: rgba(34,197,94,.45); }
.meet-card .live-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #22c55e; margin-right: 6px; vertical-align: 1px; box-shadow: 0 0 0 0 rgba(34,197,94,.6); animation: livepulse 1.6s infinite; }
@keyframes livepulse { 0% { box-shadow: 0 0 0 0 rgba(34,197,94,.55); } 70% { box-shadow: 0 0 0 7px rgba(34,197,94,0); } 100% { box-shadow: 0 0 0 0 rgba(34,197,94,0); } }
.meet-card.ended { background: var(--soft); opacity: .85; }
.meet-card.ended .mi { background: var(--line); box-shadow: none; color: var(--muted); font-size: 18px; }
/* No sideways page scroll; sidebar never clips */
html, body { overflow: hidden; }
.app { grid-template-columns: 280px minmax(0, 1fr); width: 100vw; max-width: 100%; }
.sidebar { min-width: 0; overflow: hidden; }
.side-section { min-width: 0; }

/* @mentions */
.composer { position: relative; }
.mention-pop { position: absolute; left: 8px; bottom: calc(100% + 6px); width: min(340px, calc(100% - 16px)); max-height: 300px; overflow-y: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); padding: 4px; z-index: 30; backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px); }
.mp-item { display: flex; align-items: center; gap: 10px; width: 100%; border: 0; background: transparent; color: var(--text); text-align: left; padding: 7px 8px; border-radius: 10px; }
.mp-item.on, .mp-item:hover { background: var(--soft); }
.mp-item .avatar { width: 28px; height: 28px; border-radius: 9px; font-size: 11px; }
.mp-item .avatar.ai { background: var(--grad); }
.mp-t { display: flex; flex-direction: column; min-width: 0; } .mp-t b { font-weight: 600; font-size: 13.5px; } .mp-t span { font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mention { color: var(--accent); background: var(--soft); border-radius: 6px; padding: 0 4px; font-weight: 600; }
.mention.me { color: #fff; background: var(--grad); }
.rm.mentioned { background: linear-gradient(90deg, color-mix(in srgb, var(--accent2) 10%, transparent), transparent 70%); border-radius: 10px; box-shadow: inset 3px 0 0 var(--accent2); padding-left: 6px; }

/* Right-hand Team panel */
.app.team-open { grid-template-columns: 280px minmax(0, 1fr) 380px; }
.team-panel { border-left: 1px solid var(--line); background: var(--side); backdrop-filter: blur(24px) saturate(1.5); -webkit-backdrop-filter: blur(24px) saturate(1.5); display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.tp-head { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.tp-tabs { display: flex; gap: 2px; background: var(--soft); border-radius: 10px; padding: 3px; }
.tp-tabs button { border: 0; background: transparent; color: var(--muted); font-size: 13px; font-weight: 600; padding: 5px 12px; border-radius: 8px; }
.tp-tabs button.active { background: var(--panel); color: var(--text); box-shadow: var(--soft-shadow); }
.tp-online { display: flex; margin-left: auto; } .tp-online .avatar { width: 24px; height: 24px; font-size: 10px; margin-left: -6px; border: 2px solid var(--bg); } .tp-online .avatar:first-child { margin-left: 0; }
.tp-body { flex: 1; min-height: 0; display: flex; flex-direction: column; }
#tp-people { overflow-y: auto; padding: 10px 12px; gap: 2px; }
.room-messages { flex: 1; overflow-y: auto; padding: 8px 12px 4px; }
.team-panel .rm { max-width: none; } .team-panel .day-sep { max-width: none; }
.team-panel .meet-card { max-width: none; flex-wrap: wrap; }
.team-panel .mc-acts { display: flex; gap: 6px; }
.team-panel .room-typing { padding: 0 14px 2px; }
.room-composer { margin: 0 10px 10px; width: auto; max-width: none; }
.team-toggle { position: relative; } .team-toggle.active { background: var(--soft); border-color: transparent; }
.tb-badge { position: absolute; top: -6px; right: -6px; min-width: 18px; height: 18px; border-radius: 9px; background: var(--accent2); color: #fff; font-size: 11px; font-weight: 700; display: grid; place-items: center; padding: 0 5px; box-shadow: 0 0 0 2px var(--bg); }
.pp { display: flex; align-items: center; gap: 10px; padding: 8px 6px; border-radius: 10px; } .pp:hover { background: var(--hover); }
.pp-av { position: relative; } .pp-av .avatar { width: 32px; height: 32px; border-radius: 10px; }
.on-dot { position: absolute; right: -2px; bottom: -2px; width: 10px; height: 10px; border-radius: 50%; background: #22c55e; border: 2px solid var(--bg); }
.pp-t { display: flex; flex-direction: column; min-width: 0; } .pp-t b { font-weight: 600; font-size: 14px; } .pp-t span { font-size: 12px; color: var(--muted); }
#tp-people .btn { margin-top: 10px; align-self: flex-start; }
@media (max-width: 1100px) {
  .app.team-open { grid-template-columns: 280px minmax(0, 1fr); }
  .team-panel { position: fixed; top: 0; right: 0; bottom: 0; width: min(400px, 92vw); z-index: 25; box-shadow: var(--shadow); }
}
@media (max-width: 760px) { .app.team-open { grid-template-columns: 1fr; } }

/* Comments + reactions on AI answers */
.msg-actions { flex-wrap: wrap; position: relative; }
.react-pop { position: absolute; z-index: 20; bottom: calc(100% + 4px); left: 0; display: flex; gap: 2px; padding: 4px; background: var(--panel); border: 1px solid var(--line); border-radius: 999px; box-shadow: var(--shadow); }
.react-pop button { border: 0; background: transparent; font-size: 19px; width: 34px; height: 34px; border-radius: 50%; transition: transform .1s; }
.react-pop button:hover { background: var(--soft); transform: scale(1.18); }
.r-chips { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 6px; }
.r-chip { border: 1px solid var(--line); background: var(--panel); border-radius: 999px; padding: 2px 9px; font-size: 13px; color: var(--text); }
.r-chip.mine { border-color: color-mix(in srgb, var(--accent) 50%, transparent); background: var(--soft); }
.c-thread { margin-top: 8px; border-left: 2px solid var(--line); padding-left: 12px; display: flex; flex-direction: column; gap: 8px; }
.c-item { display: flex; gap: 8px; } .c-item .avatar { width: 24px; height: 24px; font-size: 10px; border-radius: 8px; flex: none; }
.c-body { min-width: 0; flex: 1; } .c-meta { font-size: 12px; display: flex; gap: 8px; align-items: baseline; } .c-meta b { font-weight: 650; } .c-meta span { color: var(--muted); font-size: 11px; }
.c-del { border: 0; background: transparent; color: var(--muted); font-size: 11px; margin-left: auto; opacity: 0; } .c-item:hover .c-del { opacity: 1; }
.c-text { font-size: 14px; line-height: 1.5; } .c-text p { margin: 0; }
.c-form { display: flex; gap: 6px; align-items: flex-end; position: relative; }
.c-form textarea { resize: none; padding: 7px 10px; font-size: 14px; border-radius: 10px; }

/* Shared live browser */
.main { position: relative; }
.browser-view { position: absolute; inset: 62px 0 0 0; z-index: 4; display: flex; flex-direction: column; background: var(--bg); }
.bv-bar { display: flex; gap: 6px; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--line); background: var(--panel); }
.bv-bar input { flex: 1; padding: 8px 12px; border-radius: 999px; }
.bv-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); flex: none; }
.browser-view.live .bv-dot { background: #22c55e; box-shadow: 0 0 0 0 rgba(34,197,94,.55); animation: livepulse 1.6s infinite; }
.bv-note { padding: 4px 16px; min-height: 0; } .bv-note:empty { display: none; }
.bv-frame { flex: 1; min-height: 0; position: relative; }
.bv-frame iframe { width: 100%; height: 100%; border: 0; background: #fff; }
.bv-empty { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; max-width: 420px; margin: auto; padding: 16px; }
#browser-btn.active { background: var(--soft); border-color: transparent; }
.browser-card { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 14px; border: 1px solid var(--line); background: var(--bubble); margin-top: 4px; flex-wrap: wrap; }
.browser-card .mi { width: 40px; height: 40px; border-radius: 12px; background: var(--grad); display: grid; place-items: center; font-size: 20px; flex: none; box-shadow: var(--cta-shadow); }
.browser-card .mt { flex: 1; min-width: 0; } .browser-card .mt b { display: block; } .browser-card .mt span { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }

/* Lily welcome */
.lily-dialog { width: min(720px, calc(100% - 24px)); padding: 0; overflow: hidden; }
.lily-stage { position: relative; background: #0a0510; aspect-ratio: 16 / 9; }
.lily-stage video { width: 100%; height: 100%; object-fit: cover; display: block; }
.lily-stage video::cue { background: transparent; color: transparent; } /* our own synced captions below */
.lily-play { position: absolute; inset: 0; margin: auto; width: 72px; height: 72px; border-radius: 50%; border: 0; background: var(--grad); color: #fff; font-size: 26px; box-shadow: var(--cta-shadow); }
.lily-words { padding: 14px 20px 4px; font-size: 17px; line-height: 1.55; min-height: 80px; }
.lily-words span { color: var(--muted); transition: color .12s; }
.lily-words span.said { color: var(--text); }
.lily-words span.now { color: transparent; background: var(--grad); -webkit-background-clip: text; background-clip: text; font-weight: 700; }
.lily-dialog .row-end { padding: 0 16px 16px; }

/* Video assistant (Spatius AvatarKit, rendered in the browser) */
.video-stage { padding: 12px 16px 0; }
.vs-frame { position: relative; max-width: 820px; margin: 0 auto; aspect-ratio: 16 / 9; max-height: 40vh; border-radius: 18px; overflow: hidden; box-shadow: var(--shadow); }
.vs-frame[data-bg="brand"] { background: radial-gradient(120% 90% at 80% 10%, color-mix(in srgb, var(--accent2) 70%, transparent), transparent 60%), linear-gradient(135deg, color-mix(in srgb, var(--accent) 85%, #0a0510), #0a0510 85%); }
.vs-frame[data-bg="studio"] { background: radial-gradient(80% 70% at 50% 40%, #3a2d52, #0a0510 80%); }
.vs-frame[data-bg="office"] { background: radial-gradient(90% 80% at 30% 20%, #ffffff, #e9e4f5 60%, #d8d0ea); }
.vs-frame[data-bg="plain"] { background: var(--panel); }
.vs-avatar { position: absolute; inset: 0; }
.vs-mark { position: absolute; top: 14px; left: 18px; z-index: 2; font-weight: 800; letter-spacing: -.02em; color: #fff; text-shadow: 0 1px 8px rgba(0,0,0,.25); font-size: 15px; }
.vs-frame[data-bg="office"] .vs-mark, .vs-frame[data-bg="plain"] .vs-mark { color: var(--text); text-shadow: none; }
.vs-caption { position: absolute; left: 0; right: 0; bottom: 12px; z-index: 2; text-align: center; padding: 0 24px; font-size: 15px; font-weight: 600; color: #fff; text-shadow: 0 1px 6px rgba(0,0,0,.55); }
.vs-overlay { position: absolute; inset: 0; z-index: 3; display: grid; place-content: center; gap: 8px; text-align: center; background: rgba(10,5,16,.25); }
.vs-overlay .vs-status { color: #fff; }
.vs-bar { max-width: 820px; margin: 8px auto 0; display: flex; align-items: center; gap: 6px; }
.vs-bar select { width: auto; padding: 5px 8px; font-size: 13px; }
.vs-hint { margin-left: 6px; } .vs-bar .icon-btn { margin-left: auto; }
#video-btn.on { background: var(--grad); color: #fff; }
@media (max-width: 760px) { .vs-frame { max-height: 32vh; } .vs-hint { display: none; } }

/* Lily PA dock */
.lily-dock { position: fixed; right: 20px; bottom: 20px; z-index: 40; display: flex; flex-direction: column; align-items: flex-end; gap: 10px; }
.app.team-open ~ .lily-dock, .app.team-open .lily-dock { right: 400px; }
.lily-fab { border: 0; border-radius: 999px; padding: 10px 18px 10px 14px; background: var(--grad); color: #fff; font-weight: 700; box-shadow: var(--cta-shadow); display: flex; align-items: center; gap: 8px; }
.lily-fab .lf-dot { width: 10px; height: 10px; border-radius: 50%; background: #fff; box-shadow: 0 0 0 3px rgba(255,255,255,.3); }
.lily-fab.speaking .lf-dot { animation: livepulse 1.2s infinite; background: #4ade80; }
.lily-card { width: min(380px, calc(100vw - 32px)); background: var(--panel); border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--shadow); overflow: hidden; backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px); }
.lily-card .vs-frame { max-width: none; border-radius: 0; box-shadow: none; aspect-ratio: 4 / 3; max-height: 34vh; }
.lily-card .vs-bar { margin: 0; padding: 6px 10px 10px; }
.lc-log { max-height: 150px; overflow-y: auto; padding: 8px 12px 0; font-size: 13.5px; display: flex; flex-direction: column; gap: 6px; }
.lc-log:empty { display: none; }
.lc-log .me { align-self: flex-end; background: var(--bubble); border-radius: 12px 12px 4px 12px; padding: 5px 10px; max-width: 85%; }
.lc-log .her { align-self: flex-start; color: var(--text); max-width: 92%; }
.lc-log .did { align-self: flex-start; font-size: 11.5px; color: var(--muted); }
.lc-form { display: flex; gap: 6px; padding: 10px 10px 4px; }
.lc-form input { flex: 1; border-radius: 999px; padding: 8px 12px; }
.lc-form .send { width: 36px; height: 36px; border-radius: 12px; }
.lc-mic { width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--line); background: var(--panel); font-size: 16px; }
.lc-mic.rec { background: #ef4444; color: #fff; border-color: transparent; animation: livepulse 1.2s infinite; }
@media (max-width: 1100px) { .app.team-open ~ .lily-dock { right: 20px; } }
@media (max-width: 760px) { .lily-dock { right: 12px; bottom: 84px; } }

/* WebGPU canvases don't composite inside backdrop-filter ancestors in Chrome: keep Lily's card solid. */
.lily-card { backdrop-filter: none !important; -webkit-backdrop-filter: none !important; background: color-mix(in srgb, var(--bg) 92%, #fff 8%); }
@media (prefers-color-scheme: dark) { .lily-card { background: #160c22; } }
.lily-card .vs-avatar canvas { position: relative; z-index: 1; }
