:root {
  color-scheme: dark;
  font-family: Inter, "Segoe UI", system-ui, sans-serif;
  --rail: #10171c;
  --surface: #182127;
  --surface-2: #202d35;
  --panel: #141c23;
  --raised: #273740;
  --stroke: #2e3f49;
  --ink: #eef5f5;
  --muted: #a0b2bb;
  --subtle: #8196a0;
  --accent: #a9e6d1;
  --accent-ink: #10251c;
  --accent-dark: #203a34;
  --bubble: #213038;
  --own: #244139;
  --danger: #ffc2bb;
  --danger-bg: #462c2d;
  --message-size: 1rem;
  --photo: none;
  --photo-shade: .48;
  --shadow: 0 18px 58px #070b10a6;
}
:root[data-theme=black] {
  --rail: #07090b; --surface: #101215; --surface-2: #181b20; --panel: #0c1013;
  --raised: #252a31; --stroke: #30363c; --bubble: #191e24; --own: #1b382d;
}
:root[data-theme=gray] {
  --rail: #283039; --surface: #353f49; --surface-2: #41505a; --panel: #303b45;
  --raised: #50616b; --stroke: #576975; --bubble: #3d4a55; --own: #345850;
  --muted: #d0dde3; --subtle: #b9cdd6;
}
:root[data-theme=light] {
  color-scheme: light;
  --rail: #edf3f1; --surface: #f9fbfa; --surface-2: #f0f5f3; --panel: #f2f6f5;
  --raised: #e4edeb; --stroke: #d4e0dc; --ink: #1e3131; --muted: #526a69; --subtle: #5a7373;
  --accent: #1d634f; --accent-ink: #fff; --accent-dark: #dbeee6;
  --bubble: #ffffff; --own: #daeee4; --danger: #9e3931; --danger-bg: #fbebe8;
  --shadow: 0 18px 58px #223c3444;
}
* { box-sizing: border-box; }
svg { width: 19px; height: 19px; flex-shrink: 0; vertical-align: middle; }
[hidden] { display: none !important; }
body { margin: 0; color: var(--ink); background: var(--panel); }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
button[disabled] { opacity: .46; cursor: default; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
a { color: var(--accent); }
h1, h2, h3, p { margin: 0; }
h1 { font-size: 1.65rem; line-height: 1.1; letter-spacing: -.025em; }
h2 { font-size: 1.2rem; letter-spacing: -.018em; }
h3 { font-size: 1rem; }
input, textarea, select { width: 100%; color: var(--ink); background-color: var(--panel); border: 1px solid var(--stroke); border-radius: 9px; padding: .66rem .78rem; min-width: 0; }
input[type=checkbox] { width: 1rem; height: 1rem; accent-color: var(--accent); }
input[type=range] { accent-color: var(--accent); padding: 0; }
input[type=file] { font-size: .84rem; }
input::placeholder, textarea::placeholder { color: var(--subtle); }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 16px) 50%, calc(100% - 12px) 50%; background-size: 4px 4px; background-repeat: no-repeat; padding-right: 2rem; }
.primary, .secondary, .text-button, .danger-button { padding: .65rem .92rem; min-height: 40px; border-radius: 9px; border: 1px solid transparent; background: none; font-weight: 650; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: .42rem; font-size: .9rem; text-align: center; }
.primary { background: var(--accent); color: var(--accent-ink); }
.primary:hover { filter: brightness(1.06); }
.secondary { background: var(--surface-2); border-color: var(--stroke); }
.secondary:hover, .text-button:hover { background: var(--raised); }
.danger-button { background: var(--danger-bg); color: var(--danger); }
.small-button { min-height: 32px; padding: .3rem .55rem; font-size: .82rem; }
.icon-button, .rail-button, .brand-icon, .profile-trigger { display: inline-grid; place-items: center; width: 40px; height: 40px; border: 1px solid transparent; border-radius: 10px; background: var(--surface-2); flex: 0 0 auto; }
.icon-button svg, .rail-button svg, [data-icon] > svg { width: 19px; height: 19px; }
.icon-button:hover, .rail-button:hover { background: var(--raised); }
.icon-button.plain { background: transparent; color: var(--muted); }
.icon-button.plain:hover { background: var(--surface-2); color: var(--ink); }
.icon-button.accent { background: var(--accent-dark); color: var(--accent); border-color: var(--stroke); }
.muted { color: var(--muted); }
.small { font-size: .83rem; }
.stack { display: grid; gap: .85rem; }
.row { display: flex; gap: .55rem; flex-wrap: wrap; align-items: center; }
.row.between { justify-content: space-between; }
.stretch { flex: 1; min-width: 0; }
.wrap-text { overflow-wrap: anywhere; white-space: pre-wrap; }
.field { display: grid; gap: .36rem; font-size: .88rem; color: var(--muted); }
.field > input, .field > textarea, .field > select { color: var(--ink); font-size: .95rem; }
.checkbox { display: flex; align-items: center; gap: .55rem; }
.error { color: var(--danger); font-size: .9rem; line-height: 1.45; }

.auth-shell { min-height: 100dvh; display: grid; place-items: center; padding: 2rem 1rem; background: radial-gradient(ellipse at 66% 8%, #25423885, transparent 65%), var(--panel); }
.auth-card { width: min(100%, 426px); padding: 2rem; border: 1px solid var(--stroke); background: var(--surface); border-radius: 19px; box-shadow: var(--shadow); }
.brand { display: flex; align-items: center; gap: 10px; font-size: 1.16rem; font-weight: 750; margin-bottom: 1.7rem; }
.brand img, .brand-icon img { width: 40px; height: 40px; border-radius: 12px; }
.auth-card h1 { margin-bottom: .28rem; }
.auth-card .intro { color: var(--muted); line-height: 1.45; }
.auth-card form { margin-top: .35rem; }
.auth-card form .primary { width: 100%; }
.auth-link { padding-left: 0; justify-self: start; }
.google { width: 100%; gap: .65rem; }
.google-mark { background: #fff; color: #326fdd; width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; }
.google-unavailable { display: grid; gap: .4rem; }
.google-unavailable .google { opacity: .72; }

.workspace { height: 100dvh; display: grid; grid-template-columns: 70px minmax(278px, 338px) minmax(0, 1fr); overflow: hidden; }
.rail { padding: 1.05rem .68rem .9rem; display: flex; flex-direction: column; align-items: center; gap: 1.7rem; background: var(--rail); border-right: 1px solid var(--stroke); }
.brand-icon { border: 0; padding: 0; background: none; border-radius: 12px; }
.rail-main, .rail-bottom { display: grid; gap: .52rem; }
.rail-bottom { margin-top: auto; }
.rail-button, .profile-trigger { background: transparent; color: var(--muted); }
.rail-button.current { color: var(--accent); background: var(--accent-dark); }
.profile-trigger { padding: 0; }
.sidebar { background: var(--surface); border-right: 1px solid var(--stroke); min-width: 0; display: flex; flex-direction: column; }
.sidebar-header { display: flex; justify-content: space-between; align-items: center; min-height: 81px; padding: .92rem 1.15rem; }
.chat-filters { padding: 0 .93rem .35rem; }
.search-trigger { width: 100%; height: 41px; display: flex; gap: .56rem; align-items: center; border: 1px solid var(--stroke); color: var(--muted); background: var(--panel); border-radius: 10px; padding: 0 .68rem; text-align: left; font-size: .88rem; }
.search-trigger [data-icon] { display: flex; }
kbd { margin-left: auto; border: 1px solid var(--stroke); border-radius: 5px; padding: .08rem .3rem; color: var(--subtle); font: inherit; font-size: .74rem; white-space: nowrap; }
.chat-tabs, .tabs { display: flex; overflow-x: auto; gap: .28rem; padding: .62rem 0 .24rem; }
.tab { border: 0; background: transparent; color: var(--muted); min-height: 34px; padding: .33rem .62rem; border-radius: 8px; font-weight: 620; white-space: nowrap; font-size: .84rem; }
.tab:hover { background: var(--surface-2); }
.tab.active { color: var(--accent); background: var(--accent-dark); }
.chat-list { flex: 1; overflow: auto; min-height: 0; padding: .18rem .54rem; }
.chat-row { width: 100%; display: flex; align-items: center; gap: .68rem; padding: .72rem .58rem; border: 1px solid transparent; border-radius: 11px; background: transparent; text-align: left; }
.chat-row:hover { background: var(--surface-2); }
.chat-row.selected { background: var(--accent-dark); border-color: var(--stroke); }
.chat-text { min-width: 0; flex: 1; display: grid; gap: .26rem; }
.chat-row strong, .chat-snippet { display: block; text-overflow: ellipsis; overflow: hidden; white-space: nowrap; }
.chat-snippet { color: var(--muted); font-size: .85rem; }
.chat-row time { font-size: .76rem; color: var(--subtle); flex: 0 0 auto; font-variant-numeric: tabular-nums; }
.unread { min-width: 20px; height: 20px; display: grid; place-items: center; border-radius: 99px; padding: 0 .28rem; background: var(--accent); color: var(--accent-ink); font-size: .73rem; font-weight: 750; }
.sidebar-footer { border-top: 1px solid var(--stroke); padding: .72rem 1rem; display: flex; gap: .65rem; align-items: center; line-height: 1.15; }
.sidebar-footer .name { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 650; font-size: .92rem; }
.admin-entry { margin: .45rem .85rem .6rem; justify-content: flex-start; color: var(--ink); text-align: left; }
.admin-entry > span { display: inline-flex; color: var(--accent); }
.avatar { width: 43px; height: 43px; display: inline-grid; place-items: center; border-radius: 14px; flex: 0 0 auto; color: #f4faf8; font-size: .85rem; font-weight: 750; letter-spacing: .03em; overflow: hidden; background: #366355; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.t1 { background: #326054; }
.avatar.t2 { background: #555685; }
.avatar.t3 { background: #7a4b56; }
.avatar.t4 { background: #315b76; }
.avatar.t5 { background: #79643a; }
.avatar.small-avatar { width: 34px; height: 34px; border-radius: 11px; font-size: .72rem; }
.avatar.big-avatar { width: 54px; height: 54px; border-radius: 16px; font-size: 1rem; }

.chat-pane { min-width: 0; position: relative; background: var(--panel); display: flex; }
.welcome { flex: 1; display: grid; place-content: center; justify-items: center; gap: .72rem; padding: 1.5rem; text-align: center; }
.welcome p { color: var(--muted); }
.welcome-icon { width: 75px; height: 75px; display: grid; place-items: center; background: var(--accent-dark); color: var(--accent); border: 1px solid var(--stroke); border-radius: 24px; margin-bottom: .35rem; }
.welcome-icon > svg { width: 32px; height: 32px; }
.welcome .primary { margin-top: .35rem; }
.conversation { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.conversation-header { min-height: 81px; display: flex; align-items: center; padding: .8rem 1.4rem; gap: .72rem; background: var(--surface); border-bottom: 1px solid var(--stroke); }
.header-person { min-width: 0; flex: 1; display: grid; gap: .2rem; }
.header-person h2 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.header-actions { margin-left: auto; display: flex; align-items: center; gap: .35rem; }
.header-actions .header-files { display: flex; align-items: center; gap: .42rem; }
.mobile-back { display: none; }
.context-bar { display: grid; gap: .25rem; padding: .14rem 1.4rem .42rem; background: var(--surface); border-bottom: 1px solid var(--stroke); }
.context-bar .tabs { padding: .24rem 0 0; }
.pinned-strip { background: var(--surface-2); border-radius: 8px; padding: .48rem .7rem; display: flex; gap: .52rem; align-items: center; border: 0; text-align: left; color: var(--muted); font-size: .85rem; min-width: 0; }
.pinned-strip span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conversation-body { flex: 1; min-height: 0; display: flex; flex-direction: column; position: relative; isolation: isolate; overflow: hidden; }
.conversation-body::before { content: ""; position: absolute; inset: 0; background: linear-gradient(rgba(10, 17, 20, var(--photo-shade)), rgba(10, 17, 20, var(--photo-shade))), var(--photo) center / cover no-repeat; z-index: -1; }
.conversation-body:not(.with-photo)::before { display: none; }
.messages { flex: 1; overflow: auto; min-height: 0; padding: 1.1rem max(1.35rem, calc((100% - 840px) / 2)); overscroll-behavior: contain; }
.messages:focus-visible { outline-offset: -3px; }
.message-list { display: flex; flex-direction: column; gap: .55rem; min-height: 100%; justify-content: flex-end; }
.history-more { align-self: center; margin-bottom: .5rem; }
.chat-empty { display: grid; place-content: center; text-align: center; justify-items: center; gap: .58rem; min-height: 100%; color: var(--muted); }
.chat-empty strong { color: var(--ink); }
.date-chip { align-self: center; padding: .22rem .58rem; background: var(--surface); color: var(--muted); border: 1px solid var(--stroke); font-size: .76rem; border-radius: 25px; margin: .2rem 0; }
.message-row { display: flex; align-items: flex-end; gap: .45rem; }
.message-row.own { justify-content: flex-end; }
.message-bubble { position: relative; min-width: 105px; max-width: min(80%, 640px); border: 1px solid var(--stroke); background: var(--bubble); border-radius: 15px 15px 15px 5px; padding: .54rem .72rem .40rem; box-shadow: 0 1px 3px #0002; }
.own .message-bubble { background: var(--own); border-radius: 15px 15px 5px 15px; }
.message-bubble.highlight { outline: 2px solid var(--accent); }
.message-bubble .message-author { margin-bottom: .31rem; font-size: .81rem; color: var(--accent); font-weight: 650; }
.message-text { font-size: var(--message-size); line-height: 1.46; overflow-wrap: anywhere; white-space: pre-wrap; }
.message-meta { display: flex; align-items: center; gap: .35rem; justify-content: flex-end; margin-top: .18rem; color: var(--muted); font-size: .71rem; }
.menu-button { border: 0; background: transparent; border-radius: 6px; padding: .12rem .24rem; line-height: 1; color: var(--muted); display: inline-flex; align-items: center; }
.menu-button:hover { background: var(--raised); }
.menu-button svg { width: 16px; height: 16px; }
.reply-card { display: grid; width: 100%; text-align: left; border: 0; border-left: 3px solid var(--accent); border-radius: 4px 8px 8px 4px; background: var(--surface-2); padding: .35rem .56rem; color: var(--muted); margin: .1rem 0 .4rem; font-size: .84rem; }
.reply-card strong { color: var(--accent); }
.reply-card span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.message-image { display: block; max-width: min(330px, 100%); max-height: 275px; border-radius: 8px; object-fit: contain; }
.asset { display: grid; gap: .42rem; max-width: 360px; margin: .15rem 0 .35rem; }
.asset audio, .asset video { width: min(100%, 360px); max-height: 270px; border-radius: 8px; }
.asset audio { min-width: min(235px, 100%); height: 39px; }
.file-link { display: flex; align-items: center; gap: .45rem; overflow-wrap: anywhere; text-decoration: none; }
.file-link small { white-space: nowrap; }
.reaction-bar { display: flex; gap: .25rem; flex-wrap: wrap; padding-top: .2rem; }
.reaction { border: 1px solid var(--stroke); background: var(--surface-2); border-radius: 17px; padding: .1rem .38rem; font-size: .8rem; }
.reaction.mine { border-color: var(--accent); }
.transcript { border-top: 1px solid var(--stroke); margin-top: .38rem; padding: .35rem 0; }
.transcript summary { cursor: pointer; color: var(--accent); font-size: .85rem; padding: .15rem 0; }
.transcript .wrap-text { margin: .42rem 0; font-size: var(--message-size); }
.poll { display: grid; gap: .33rem; min-width: min(240px, 100%); margin-top: .42rem; }
.poll .secondary { justify-content: space-between; }
.poll .chosen { border-color: var(--accent); }
.composer-wrap { padding: .5rem max(1.35rem, calc((100% - 840px) / 2)) max(.95rem, env(safe-area-inset-bottom)); }
.composer { position: relative; border: 1px solid var(--stroke); background: var(--surface); border-radius: 13px; padding: .48rem; box-shadow: 0 7px 20px #02050927; }
.composer-row { display: flex; gap: .25rem; align-items: flex-end; }
.composer textarea { padding: .55rem .24rem; resize: none; min-height: 40px; max-height: 160px; border: 0; border-radius: 0; background: transparent; flex: 1; line-height: 1.35; }
.send-button { flex: 0 0 auto; }
.composer.dragging { outline: 2px dashed var(--accent); }
.compose-context { display: flex; align-items: center; gap: .45rem; padding: .25rem .45rem; color: var(--muted); font-size: .84rem; background: var(--surface-2); border-radius: 7px; margin-bottom: .3rem; }
.compose-context span { flex: 1; text-overflow: ellipsis; white-space: nowrap; overflow: hidden; }
.transfer-list { display: grid; gap: .3rem; margin-bottom: .32rem; }
.transfer, .voice-box { display: flex; align-items: center; gap: .5rem; border: 1px solid var(--stroke); background: var(--surface); border-radius: 8px; padding: .35rem .55rem; min-width: 0; }
.transfer .stretch { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .86rem; }
.transfer progress { accent-color: var(--accent); width: min(20%, 95px); }
.voice-box { margin-bottom: .35rem; flex-wrap: wrap; }
.voice-box audio { flex: 1; min-width: 135px; max-width: 100%; height: 36px; }
.recording { color: var(--danger) !important; background: var(--danger-bg) !important; }

.dialog { color: var(--ink); background: var(--surface); border: 1px solid var(--stroke); border-radius: 16px; width: min(528px, calc(100% - 1.5rem)); max-height: min(86dvh, 860px); padding: 0; box-shadow: var(--shadow); }
.dialog.wide { width: min(760px, calc(100% - 1.5rem)); }
.dialog::backdrop { background: #070c12b8; backdrop-filter: blur(5px); }
.dialog-header { display: flex; align-items: center; justify-content: space-between; gap: .55rem; position: sticky; top: 0; z-index: 1; background: var(--surface); padding: .65rem 1rem .65rem 1.2rem; border-bottom: 1px solid var(--stroke); }
.dialog-content { padding: 1rem 1.2rem 1.15rem; }
.dialog-content .tabs { padding-top: 0; margin-bottom: .4rem; }
.pdf-preview { width: 100%; height: min(62dvh, 640px); border: 1px solid var(--stroke); border-radius: 8px; background: var(--panel); }
.record { display: grid; gap: .38rem; padding: .65rem .68rem; background: var(--panel); border: 1px solid var(--stroke); border-radius: 9px; overflow-wrap: anywhere; }
.record + .record { margin-top: .46rem; }
.record button, .record a { min-width: 0; }
.who { display: flex; gap: .58rem; align-items: center; min-width: 0; }
.who strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.record .selectors { max-width: 135px; }
.rule { border: 0; border-top: 1px solid var(--stroke); margin: .26rem 0; }
.stat-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .45rem; }
.stat-grid strong { display: block; font-size: 1.1rem; }
.admin-screen { min-height: 100dvh; background: var(--panel); }
.admin-top { display: flex; justify-content: space-between; align-items: center; gap: 1rem;
  padding: .75rem max(1rem, calc((100% - 960px) / 2)); border-bottom: 1px solid var(--stroke); background: var(--surface); }
.admin-layout { width: min(100% - 2rem, 960px); margin: 0 auto; padding: 1.5rem 0 2.5rem; }
.admin-title-row { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: .8rem; margin-bottom: .65rem; }
.admin-layout > nav { margin-bottom: .75rem; border-bottom: 1px solid var(--stroke); }
.admin-layout > nav .tabs { padding-bottom: .55rem; }
.admin-screen .record { background: var(--surface); }
.admin-status { padding: .7rem .8rem; border: 1px solid var(--stroke); border-radius: 9px; background: var(--surface); }
.theme-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .45rem; }
.theme-option { border: 1px solid var(--stroke); border-radius: 9px; min-height: 65px; font-size: .82rem; font-weight: 650; }
.theme-option.active { outline: 2px solid var(--accent); outline-offset: 1px; }
.theme-option[data-choice=graphite] { background: #27363f; color: #fff; }
.theme-option[data-choice=black] { background: #0c0f10; color: #fff; }
.theme-option[data-choice=gray] { background: #445664; color: #fff; }
.theme-option[data-choice=light] { background: #eaf4f1; color: #223d36; }
.call-panel { position: fixed; z-index: 4; right: 1.3rem; bottom: 1.3rem; width: min(340px, calc(100% - 2.6rem)); padding: .98rem; border: 1px solid var(--stroke); background: var(--surface); box-shadow: var(--shadow); border-radius: 14px; }
.call-panel video { width: 100%; max-height: 200px; border-radius: 8px; background: var(--panel); }
.call-panel .self-video { width: 92px; max-height: 72px; position: absolute; right: 1.3rem; bottom: 4rem; }
.toast { position: fixed; right: 1.05rem; bottom: .94rem; max-width: min(470px, calc(100% - 2.1rem)); z-index: 7; color: var(--ink); background: var(--raised); border: 1px solid var(--stroke); border-radius: 9px; box-shadow: var(--shadow); padding: .68rem .9rem; font-size: .9rem; }
.toast.alert { color: var(--danger); background: var(--danger-bg); }

@media (max-width: 1020px) {
  .workspace { grid-template-columns: 58px minmax(240px, 282px) minmax(0, 1fr); }
  .rail { padding-left: .35rem; padding-right: .35rem; }
  .sidebar-header, .conversation-header { min-height: 69px; }
  .conversation-header { padding-inline: .86rem; }
  .header-actions .header-files .file-label { display: none; }
  .header-actions .header-files { width: 40px; padding: 0; }
}
@media (max-width: 680px) {
  .workspace { grid-template-columns: 55px minmax(0, 1fr); }
  .workspace:not(.in-chat) .chat-pane { display: none; }
  .workspace.in-chat { display: block; }
  .workspace.in-chat > .rail, .workspace.in-chat > .sidebar { display: none; }
  .workspace.in-chat .chat-pane { height: 100%; }
  .mobile-back { display: inline-grid; }
  .conversation-header { min-height: 60px; gap: .4rem; padding: .45rem .48rem; }
  .conversation-header .avatar { width: 34px; height: 34px; border-radius: 10px; }
  .header-actions { gap: .06rem; }
  .header-actions .icon-button, .header-actions .header-files { width: 34px; height: 35px; min-height: 35px; }
  .header-person h2 { font-size: 1rem; }
  .header-person .small { font-size: .76rem; }
  .context-bar { padding-inline: .65rem; }
  .messages { padding-inline: .65rem; }
  .composer-wrap { padding: .25rem .47rem max(.48rem, env(safe-area-inset-bottom)); }
  .composer-row .icon-button { width: 32px; }
  .composer-row { gap: .1rem; }
  .send-button { padding-inline: .52rem; font-size: .77rem; }
  .message-bubble { max-width: 86%; }
  .dialog-content { padding: .8rem .8rem 1rem; }
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
