:root {
  color-scheme: dark;
  --accent: #3ff4df;
  --accent-soft: rgba(63, 244, 223, 0.12);
  --accent-glow: rgba(63, 244, 223, 0.28);
  --bg: #080d0f;
  --panel: rgba(16, 24, 27, 0.86);
  --panel-solid: #10181b;
  --panel-raised: #151f22;
  --line: rgba(255, 255, 255, 0.075);
  --muted: #7f9196;
  --text: #edf8f7;
  --danger: #ff7784;
  --radius: 22px;
  --ease: cubic-bezier(.2, .8, .2, 1);
  font-family: Inter, "SF Pro Display", "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); }
body { overflow: hidden; }
button, input, select { font: inherit; }
button { color: inherit; }

.ambient { position: fixed; border-radius: 50%; filter: blur(110px); pointer-events: none; opacity: .14; }
.ambient-one { width: 440px; height: 440px; background: var(--accent); top: -250px; right: 8%; }
.ambient-two { width: 280px; height: 280px; background: #25756e; bottom: -180px; left: 30%; }

.app-shell { display: grid; grid-template-columns: 340px 1fr; height: 100dvh; position: relative; z-index: 1; }
.sidebar { display: flex; flex-direction: column; min-width: 0; background: rgba(9, 15, 17, .94); border-right: 1px solid var(--line); backdrop-filter: blur(24px); }
.brand-row { height: 86px; padding: 20px 22px; display: flex; align-items: center; gap: 12px; }
.brand-mark { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 13px; background: var(--accent); box-shadow: 0 10px 34px rgba(63,244,223,.18); }
.brand-mark svg { width: 23px; fill: #061210; }
.eyebrow, .section-kicker { font-size: 10px; font-weight: 800; letter-spacing: .18em; color: var(--accent); }
.brand-title { font-size: 17px; font-weight: 680; margin-top: 2px; }
.icon-button { border: 0; background: transparent; width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; cursor: pointer; transition: .2s var(--ease); }
.icon-button:hover { background: rgba(255,255,255,.06); }
.mobile-close { display: none; margin-left: auto; font-size: 25px; color: var(--muted); }
.menu-button { display: none; }
.icon-button svg { width: 21px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }

.search-wrap { margin: 4px 18px 14px; height: 46px; display: flex; align-items: center; gap: 10px; padding: 0 12px; border: 1px solid var(--line); background: rgba(255,255,255,.025); border-radius: 14px; transition: .2s var(--ease); }
.search-wrap:focus-within { border-color: rgba(63,244,223,.36); box-shadow: 0 0 0 4px rgba(63,244,223,.05); }
.search-wrap svg { width: 18px; fill: none; stroke: var(--muted); stroke-width: 1.7; }
.search-wrap input { min-width: 0; flex: 1; border: 0; outline: 0; background: transparent; color: var(--text); }
.search-wrap input::placeholder { color: #637277; }
.count-pill { font-size: 11px; font-weight: 700; color: var(--muted); background: rgba(255,255,255,.05); padding: 3px 7px; border-radius: 20px; }
.filter-row { display: flex; gap: 5px; padding: 0 18px 14px; }
.filter { border: 0; background: transparent; color: var(--muted); padding: 7px 11px; border-radius: 9px; font-size: 12px; cursor: pointer; transition: .2s var(--ease); }
.filter.active { color: var(--text); background: rgba(255,255,255,.065); }

.chat-list { flex: 1; min-height: 0; overflow-y: auto; padding: 0 10px 16px; scrollbar-width: thin; scrollbar-color: #263336 transparent; }
.empty-list { padding: 36px 12px; color: var(--muted); font-size: 12px; text-align: center; }
.chat-item { width: 100%; border: 0; text-align: left; color: inherit; background: transparent; padding: 12px; display: grid; grid-template-columns: 42px 1fr auto; gap: 11px; align-items: center; border-radius: 15px; cursor: pointer; transition: transform .18s var(--ease), background .18s var(--ease); animation: itemIn .34s both var(--ease); }
.chat-item:hover { background: rgba(255,255,255,.038); transform: translateX(2px); }
.chat-item.active { background: var(--accent-soft); }
.chat-item.active .chat-name { color: var(--accent); }
.chat-avatar, .avatar { display: grid; place-items: center; border-radius: 13px; color: #b9cbc8; background: linear-gradient(145deg, #263438, #182124); font-weight: 750; }
.chat-avatar img, .avatar img { width: 100%; height: 100%; display: block; border-radius: inherit; object-fit: cover; }
.chat-avatar { width: 42px; height: 42px; font-size: 13px; }
.chat-item.active .chat-avatar { background: var(--accent); color: #061210; }
.chat-copy { min-width: 0; }
.chat-name { font-size: 13px; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; transition: color .2s; }
.chat-sub { font-size: 11px; color: var(--muted); margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mapping-dot { width: 7px; height: 7px; border-radius: 50%; background: #4f5d60; box-shadow: 0 0 0 4px rgba(255,255,255,.025); }
.mapping-dot.ready { background: var(--accent); box-shadow: 0 0 12px var(--accent-glow); }
.profile-row { height: 76px; border-top: 1px solid var(--line); padding: 14px 20px; display: flex; align-items: center; gap: 10px; }
.avatar.small { width: 34px; height: 34px; border-radius: 11px; font-size: 11px; }
.profile-copy { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.profile-copy strong { font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.profile-copy span { color: var(--muted); font-size: 10px; }
.online-dot { margin-left: auto; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 10px var(--accent); }

.workspace { min-width: 0; height: 100dvh; display: flex; flex-direction: column; position: relative; }
.topbar { height: 86px; display: flex; align-items: center; gap: 14px; padding: 0 32px; border-bottom: 1px solid var(--line); background: rgba(8,13,15,.58); backdrop-filter: blur(18px); z-index: 4; }
.chat-identity { display: flex; align-items: center; gap: 13px; min-width: 0; }
.avatar { width: 45px; height: 45px; flex: 0 0 auto; }
.title-line { display: flex; align-items: center; gap: 9px; }
h1, h2, p { margin: 0; }
.title-line h1 { font-size: 17px; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-identity p { color: var(--muted); font-size: 11px; margin-top: 4px; }
.status-dot { width: 6px; height: 6px; border-radius: 50%; background: #536064; }
.status-dot.active { background: var(--accent); box-shadow: 0 0 9px var(--accent); }
.save-state { margin-left: auto; color: var(--muted); font-size: 11px; opacity: 0; transition: opacity .2s; }
.save-state.visible { opacity: 1; }

.empty-state { margin: auto; text-align: center; color: var(--muted); animation: fadeIn .5s var(--ease); }
.empty-state h2 { color: #c7d5d3; font-size: 18px; margin-top: 24px; }
.empty-state p { font-size: 12px; margin-top: 7px; }
.empty-orbit { width: 62px; height: 62px; margin: auto; border: 1px solid rgba(63,244,223,.18); border-radius: 50%; display: grid; place-items: center; animation: orbit 6s linear infinite; }
.empty-orbit::after { content: ""; position: absolute; width: 8px; height: 8px; margin-top: -61px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 14px var(--accent); }
.empty-orbit span { width: 24px; height: 24px; border: 1px solid rgba(63,244,223,.35); border-radius: 8px; transform: rotate(45deg); }

.content { flex: 1; overflow-y: auto; padding: 28px 32px 120px; scrollbar-width: thin; scrollbar-color: #263336 transparent; }
.config-card { max-width: 1100px; margin: 0 auto; border: 1px solid var(--line); border-radius: var(--radius); background: linear-gradient(145deg, rgba(22,32,35,.9), rgba(13,20,22,.9)); padding: 24px; box-shadow: 0 24px 80px rgba(0,0,0,.18); }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.section-head h2 { font-size: 16px; margin-top: 5px; }
.security-badge { border: 1px solid rgba(63,244,223,.16); background: rgba(63,244,223,.06); color: #9eb9b5; padding: 7px 10px; border-radius: 20px; font-size: 10px; display: flex; align-items: center; gap: 6px; }
.security-badge i { width: 5px; height: 5px; border-radius: 50%; background: var(--accent); }
.config-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 24px; }
.field { min-width: 0; }
.field > span, .field legend { display: block; color: var(--muted); font-size: 10px; font-weight: 650; margin: 0 0 8px 2px; }
.field { border: 0; padding: 0; margin: 0; }
.select-shell { height: 48px; position: relative; }
.select-shell select { width: 100%; height: 100%; appearance: none; border: 1px solid var(--line); border-radius: 13px; background: rgba(5,10,12,.46); color: var(--text); outline: 0; padding: 0 38px 0 14px; cursor: pointer; transition: .2s var(--ease); }
.select-shell select:focus { border-color: rgba(63,244,223,.4); box-shadow: 0 0 0 4px rgba(63,244,223,.05); }
.select-shell select:disabled { color: #718085; cursor: default; opacity: .72; }
.select-shell svg { pointer-events: none; position: absolute; width: 18px; right: 12px; top: 15px; fill: none; stroke: var(--muted); stroke-width: 1.7; }
.segmented { height: 48px; padding: 4px; border: 1px solid var(--line); background: rgba(5,10,12,.46); border-radius: 13px; display: grid; grid-template-columns: 1fr 1fr; position: relative; }
.segmented button { border: 0; background: transparent; color: var(--muted); font-size: 11px; font-weight: 750; z-index: 1; cursor: pointer; transition: color .2s; }
.segmented button.active { color: #071311; }
.segment-glow { position: absolute; top: 4px; bottom: 4px; width: calc(50% - 4px); left: 4px; border-radius: 9px; background: var(--accent); box-shadow: 0 7px 22px rgba(63,244,223,.12); transition: transform .28s var(--ease); }
.segmented[data-locale="ru"] .segment-glow { transform: translateX(100%); }

.participants-section { max-width: 1100px; margin: 28px auto 0; }
.participants-head { padding: 0 3px 14px; }
.participants-head h2 span { color: var(--muted); font-size: 12px; margin-left: 5px; }
.legend { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 10px; }
.legend span { width: 5px; height: 5px; border-radius: 50%; margin-left: 7px; }
.partner-key { background: var(--accent); }
.team-key { background: #8fa5ff; }
.participants-list { display: grid; gap: 8px; }
.participant { display: grid; grid-template-columns: 42px minmax(130px, 1fr) auto auto; align-items: center; gap: 13px; min-height: 66px; padding: 10px 13px; border: 1px solid var(--line); border-radius: 16px; background: rgba(15,23,25,.65); transition: border-color .2s, transform .2s var(--ease), background .2s; animation: itemIn .35s both var(--ease); }
.participant:hover { border-color: rgba(255,255,255,.12); transform: translateY(-1px); background: rgba(18,27,30,.82); }
.participant .avatar { width: 40px; height: 40px; border-radius: 12px; font-size: 11px; }
.person-name { font-size: 13px; font-weight: 650; }
.person-handle { color: var(--muted); font-size: 10px; margin-top: 4px; }
.role-control { display: flex; gap: 4px; padding: 3px; border-radius: 11px; background: rgba(0,0,0,.2); }
.role-control button { border: 0; background: transparent; color: var(--muted); padding: 7px 10px; border-radius: 8px; font-size: 10px; font-weight: 700; cursor: pointer; transition: .2s var(--ease); }
.role-control button.active[data-side="partner"] { color: #061210; background: var(--accent); }
.role-control button.active[data-side="team"] { color: #091020; background: #8fa5ff; }
.role-control button.active[data-side="bot"] { color: #151008; background: #e7b76a; }
.tag-toggle { width: 36px; height: 36px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 11px; background: transparent; color: #5f7074; cursor: pointer; transition: .2s var(--ease); }
.tag-toggle svg { width: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.tag-toggle.active { color: var(--accent); border-color: rgba(63,244,223,.28); background: var(--accent-soft); }
.role-control button:disabled, .tag-toggle:disabled, .segmented button:disabled { cursor: default; }

.action-dock { position: absolute; z-index: 8; left: 50%; bottom: max(22px, env(safe-area-inset-bottom)); transform: translate(-50%, 20px); width: min(620px, calc(100% - 48px)); min-height: 62px; padding: 9px 10px 9px 18px; display: flex; align-items: center; gap: 9px; border: 1px solid rgba(255,255,255,.1); border-radius: 18px; background: rgba(19,28,31,.94); backdrop-filter: blur(22px); box-shadow: 0 22px 70px rgba(0,0,0,.42); opacity: 0; transition: .3s var(--ease); }
.action-dock.visible { opacity: 1; transform: translate(-50%, 0); }
.action-dock > span { margin-right: auto; color: #b5c5c3; font-size: 11px; display: flex; align-items: center; gap: 8px; }
.action-dock > span i { width: 6px; height: 6px; border-radius: 50%; background: #e7b76a; }
.ghost-button, .primary-button { height: 42px; border-radius: 12px; padding: 0 15px; border: 0; cursor: pointer; font-size: 11px; font-weight: 720; transition: .2s var(--ease); }
.ghost-button { color: var(--muted); background: transparent; }
.ghost-button:hover { background: rgba(255,255,255,.05); color: var(--text); }
.primary-button { min-width: 138px; display: flex; align-items: center; justify-content: center; gap: 6px; background: var(--accent); color: #061210; box-shadow: 0 9px 28px rgba(63,244,223,.14); }
.primary-button:hover { transform: translateY(-1px); box-shadow: 0 12px 34px rgba(63,244,223,.22); }
.primary-button:disabled { opacity: .5; cursor: wait; }
.primary-button svg { width: 18px; fill: none; stroke: currentColor; stroke-width: 2; }

.toast { position: fixed; z-index: 30; top: 20px; left: 50%; transform: translate(-50%, -20px); opacity: 0; pointer-events: none; padding: 11px 15px; border: 1px solid rgba(63,244,223,.25); border-radius: 12px; color: #dffbf7; background: #142321; font-size: 11px; box-shadow: 0 16px 45px rgba(0,0,0,.35); transition: .3s var(--ease); }
.toast.visible { opacity: 1; transform: translate(-50%, 0); }
.auth-error { position: fixed; inset: 0; z-index: 50; display: grid; place-content: center; text-align: center; background: var(--bg); }
.auth-error[hidden] { display: none; }
.auth-error h1 { margin-top: 20px; font-size: 21px; }
.auth-error p { color: var(--muted); font-size: 12px; margin-top: 8px; }
.lock-icon { width: 54px; height: 54px; margin: auto; border-radius: 17px; background: var(--accent-soft); display: grid; place-items: center; }
.lock-icon span { width: 17px; height: 15px; border: 2px solid var(--accent); border-radius: 4px; position: relative; }
.lock-icon span::before { content: ""; position: absolute; width: 9px; height: 9px; border: 2px solid var(--accent); border-bottom: 0; border-radius: 8px 8px 0 0; top: -10px; left: 2px; }

.skeleton { overflow: hidden; position: relative; background: rgba(255,255,255,.035); min-height: 62px; border-radius: 15px; margin: 8px; }
.skeleton::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(90deg, transparent, rgba(255,255,255,.045), transparent); animation: shimmer 1.4s infinite; }
.reveal { animation: riseIn .42s both var(--ease); }
.delay-one { animation-delay: .08s; }

@keyframes itemIn { from { opacity: 0; transform: translateY(7px); } }
@keyframes riseIn { from { opacity: 0; transform: translateY(12px); } }
@keyframes fadeIn { from { opacity: 0; } }
@keyframes shimmer { to { transform: translateX(100%); } }
@keyframes orbit { to { transform: rotate(360deg); } }

@media (max-width: 850px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 14% 0 0; z-index: 20; transform: translateX(-105%); box-shadow: 20px 0 70px rgba(0,0,0,.45); transition: transform .32s var(--ease); }
  .sidebar.open { transform: translateX(0); }
  .mobile-close, .menu-button { display: grid; }
  .topbar { padding: 0 18px; }
  .content { padding: 20px 16px 112px; }
  .config-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 560px) {
  .topbar { height: 76px; gap: 7px; }
  .topbar .avatar { width: 39px; height: 39px; }
  .title-line h1 { font-size: 15px; max-width: 190px; }
  .save-state { display: none; }
  .config-card { padding: 18px; border-radius: 18px; }
  .config-grid { grid-template-columns: 1fr; }
  .participant { grid-template-columns: 39px 1fr auto; gap: 10px; }
  .role-control { grid-column: 2 / 4; justify-content: stretch; }
  .role-control button { flex: 1; }
  .tag-toggle { grid-column: 3; grid-row: 1; }
  .legend { display: none; }
  .action-dock { width: calc(100% - 24px); padding-left: 12px; }
  .action-dock > span { display: none; }
  .ghost-button { margin-left: auto; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
