/* CUBICRON DESIGN v2 — Linear-inspired */
:root {
  --bg-base: #0a0a0f;
  --bg-rail: #0d0d13;
  --bg-panel: #111118;
  --bg-card: #16161f;
  --bg-hover: #1c1c28;
  --bg-active: #23233a;
  --bg-input: #181822;

  --text-1: #e8e9ed;
  --text-2: #a1a3ad;
  --text-3: #6a6c78;
  --text-disabled: #4a4c56;

  --accent: #7c5cff;
  --accent-2: #6b4dff;
  --accent-soft: rgba(124, 92, 255, .15);
  --accent-glow: rgba(124, 92, 255, .35);

  --success: #3fb950;
  --warn: #d29922;
  --danger: #f85149;

  --border: rgba(255, 255, 255, .05);
  --border-2: rgba(255, 255, 255, .1);
  --border-3: rgba(255, 255, 255, .15);

  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-xl: 20px;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, .3);
  --shadow: 0 4px 16px rgba(0, 0, 0, .4);
  --shadow-lg: 0 20px 60px rgba(0, 0, 0, .6);
  --shadow-glow: 0 0 24px var(--accent-glow);

  --tr: 150ms cubic-bezier(.4, 0, .2, 1);
  --tr-slow: 300ms cubic-bezier(.4, 0, .2, 1);
}

[data-theme="light"] {
  --bg-base: #fafafb;
  --bg-rail: #f0f0f3;
  --bg-panel: #ffffff;
  --bg-card: #ffffff;
  --bg-hover: #f4f4f7;
  --bg-active: #ececff;
  --bg-input: #f4f4f7;

  --text-1: #0f0f14;
  --text-2: #5a5c66;
  --text-3: #8a8c96;

  --border: rgba(0, 0, 0, .06);
  --border-2: rgba(0, 0, 0, .1);
  --border-3: rgba(0, 0, 0, .15);

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, .06);
  --shadow: 0 4px 16px rgba(0, 0, 0, .08);
  --shadow-lg: 0 20px 60px rgba(0, 0, 0, .15);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', Roboto, sans-serif;
  font-size: 14px; line-height: 1.5;
  color: var(--text-1); background: var(--bg-base);
  -webkit-font-smoothing: antialiased;
  transition: background var(--tr-slow), color var(--tr-slow);
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }
button:disabled { cursor: not-allowed; opacity: .4; }
input, select { outline: none; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-3); }

/* ============ LAYOUT ============ */
#app {
  display: grid;
  grid-template-columns: 64px 300px 1fr;
  height: 100vh;
  height: 100dvh;
}

/* ============ RAIL ============ */
.rail {
  background: var(--bg-rail);
  display: flex; flex-direction: column; align-items: center;
  padding: 14px 0; gap: 6px;
  border-right: 1px solid var(--border);
}
.rail-logo {
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--accent), #9d7dff);
  border-radius: var(--r-md);
  color: #fff;
  margin-bottom: 12px;
  box-shadow: 0 4px 12px var(--accent-glow);
}
.rail-btn {
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--r-md);
  color: var(--text-3);
  transition: all var(--tr);
  position: relative;
}
.rail-btn:hover { background: var(--bg-hover); color: var(--text-1); }
.rail-btn.active { background: var(--accent-soft); color: var(--accent); }
.rail-btn.active::before {
  content: ''; position: absolute; left: -14px;
  width: 3px; height: 24px; background: var(--accent);
  border-radius: 0 3px 3px 0;
}
.rail-spacer { flex: 1; }
.rail-me { padding: 8px; }

/* ============ LIST PANEL ============ */
.list-panel {
  background: var(--bg-panel);
  display: flex; flex-direction: column;
  border-right: 1px solid var(--border);
  overflow: hidden;
}
.list-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 20px 12px;
}
.list-header h1 {
  font-size: 18px; font-weight: 700;
  letter-spacing: -.01em;
  background: linear-gradient(135deg, var(--text-1), var(--text-2));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.list-count {
  font-size: 12px; font-weight: 600;
  color: var(--text-3);
  background: var(--bg-card);
  padding: 2px 8px; border-radius: 10px;
}

.search-box {
  position: relative; margin: 0 16px 12px;
}
.search-box svg {
  position: absolute; left: 12px; top: 50%;
  transform: translateY(-50%);
  color: var(--text-3); pointer-events: none;
}
.search-box input {
  width: 100%; padding: 9px 12px 9px 34px;
  background: var(--bg-input);
  border: 1px solid transparent;
  border-radius: var(--r-md);
  color: var(--text-1); font-size: 13px;
  transition: all var(--tr);
}
.search-box input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.search-box input::placeholder { color: var(--text-3); }

.users {
  flex: 1; overflow-y: auto;
  padding: 4px 8px;
}
.user {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  border-radius: var(--r-md);
  cursor: pointer;
  transition: all var(--tr);
  position: relative;
}
.user:hover { background: var(--bg-hover); }
.user.active {
  background: var(--accent-soft);
}
.user.active .user-name { color: var(--accent); font-weight: 600; }

.avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #9d7dff);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 15px;
  flex-shrink: 0; position: relative;
  box-shadow: 0 2px 8px rgba(124, 92, 255, .25);
}
.avatar::after {
  content: ''; position: absolute;
  bottom: -1px; right: -1px;
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--text-3);
  border: 2px solid var(--bg-panel);
  transition: background var(--tr);
}
.user.online .avatar::after { background: var(--success); box-shadow: 0 0 8px var(--success); }
.avatar.small { width: 36px; height: 36px; font-size: 13px; }
.avatar.small::after { width: 10px; height: 10px; }
.avatar-xl {
  width: 100px; height: 100px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #9d7dff);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 42px;
  box-shadow: 0 8px 32px var(--accent-glow);
}

.user-name {
  flex: 1;
  font-weight: 500; font-size: 14px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  transition: color var(--tr);
}

/* SYS MONITOR */
.sysmon {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 8px;
  background: var(--bg-panel);
}
.sysmon-item {
  display: grid;
  grid-template-columns: 32px 1fr 42px;
  align-items: center;
  gap: 8px;
  font-size: 11px;
}
.sysmon-label {
  color: var(--text-3); font-weight: 600;
  text-transform: uppercase; letter-spacing: .04em;
}
.sysmon-bar {
  height: 4px; background: var(--bg-input);
  border-radius: 2px; overflow: hidden;
}
.sysmon-fill {
  height: 100%; width: 0;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  border-radius: 2px;
  transition: width .6s cubic-bezier(.4, 0, .2, 1);
}
.sysmon-val {
  text-align: right;
  color: var(--text-2); font-weight: 600;
  font-variant-numeric: tabular-nums;
  font-size: 11px;
}

/* LIST FOOTER */
.list-me {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  background: var(--bg-rail);
}
.me-info { flex: 1; min-width: 0; }
.me-name {
  font-weight: 600; font-size: 13px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.me-status {
  display: flex; align-items: center; gap: 4px;
  font-size: 11px; color: var(--text-3);
}
.me-status .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 6px var(--success);
}
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px;
  border-radius: var(--r-sm);
  color: var(--text-3);
  transition: all var(--tr);
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text-1); }

/* ============ CHAT PANEL ============ */
.chat-panel {
  display: flex; flex-direction: column;
  background: var(--bg-base);
  min-width: 0; min-height: 0;
  position: relative;
}

.chat-top {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px;
  padding: 14px 24px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.peer-head { display: flex; align-items: center; gap: 12px; min-width: 0; }
.peer-meta { min-width: 0; }
.peer-name {
  font-weight: 600; font-size: 15px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.peer-status { font-size: 12px; color: var(--text-3); }
.chat-actions { display: flex; align-items: center; gap: 8px; }

.btn-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px;
  background: var(--accent);
  color: #fff;
  border-radius: 20px;
  font-size: 13px; font-weight: 600;
  transition: all var(--tr);
  box-shadow: 0 2px 8px var(--accent-glow);
}
.btn-pill:hover {
  background: var(--accent-2);
  transform: translateY(-1px);
  box-shadow: 0 4px 16px var(--accent-glow);
}
.btn-pill:active { transform: translateY(0); }
.btn-pill.ghost {
  background: var(--bg-card);
  color: var(--text-2);
  box-shadow: none;
  border: 1px solid var(--border-2);
}
.btn-pill.ghost:hover {
  background: var(--bg-hover);
  color: var(--text-1);
  box-shadow: none;
}
.mic-select {
  background: var(--bg-card);
  border: 1px solid var(--border-2);
  border-radius: 20px;
  padding: 8px 12px;
  font-size: 12px;
  color: var(--text-2);
  max-width: 160px;
  cursor: pointer;
  transition: all var(--tr);
}
.mic-select:hover { border-color: var(--accent); color: var(--text-1); }

/* MESSAGES */
.messages {
  flex: 1; overflow-y: auto;
  padding: 24px;
  display: flex; flex-direction: column; gap: 6px;
  min-height: 0;
}
.empty-chat {
  flex: 1;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 16px; padding: 40px;
  color: var(--text-3);
  animation: fadeIn .4s;
}
.empty-icon {
  width: 96px; height: 96px;
  border-radius: 50%;
  background: var(--accent-soft);
  display: flex; align-items: center; justify-content: center;
  color: var(--accent);
  animation: float 3s ease-in-out infinite;
}
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.empty-chat h2 {
  font-size: 22px; font-weight: 700;
  color: var(--text-1);
  letter-spacing: -.01em;
}
.empty-chat p { font-size: 14px; }

.msg {
  display: flex; gap: 10px;
  padding: 6px 8px;
  border-radius: var(--r-md);
  animation: msgIn .25s cubic-bezier(.4, 0, .2, 1);
  transition: background var(--tr);
}
@keyframes msgIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}
.msg:hover { background: rgba(255, 255, 255, .02); }
.msg.mine { justify-content: flex-end; }
.msg-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #9d7dff);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 13px;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(124, 92, 255, .2);
}
.msg-content { max-width: 68%; display: flex; flex-direction: column; }
.msg-author {
  font-size: 12px; font-weight: 600;
  color: var(--accent);
  margin-bottom: 3px;
  padding-left: 4px;
}
.msg.mine .msg-author { text-align: right; padding-right: 4px; padding-left: 0; }
.msg-bubble {
  padding: 9px 14px;
  border-radius: 16px;
  word-wrap: break-word;
  line-height: 1.45;
  font-size: 14px;
  transition: all var(--tr);
}
.msg.theirs .msg-bubble {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-top-left-radius: 6px;
}
.msg.mine .msg-bubble {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  border-top-right-radius: 6px;
  box-shadow: 0 2px 8px var(--accent-glow);
}
.msg-time {
  font-size: 10px; color: var(--text-3);
  margin-top: 3px;
  opacity: 0;
  transition: opacity var(--tr);
  padding: 0 4px;
}
.msg:hover .msg-time { opacity: 1; }
.msg.mine .msg-time { text-align: right; }

/* INPUT */
.chat-input {
  display: flex; gap: 10px;
  padding: 16px 24px 20px;
  flex-shrink: 0;
}
.chat-input input {
  flex: 1;
  padding: 13px 18px;
  background: var(--bg-input);
  border: 1px solid transparent;
  border-radius: 24px;
  color: var(--text-1);
  font-size: 14px;
  transition: all var(--tr);
}
.chat-input input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
  background: var(--bg-panel);
}
.chat-input input::placeholder { color: var(--text-3); }
.chat-input button {
  width: 46px; height: 46px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--tr);
  box-shadow: 0 4px 12px var(--accent-glow);
}
.chat-input button:hover:not(:disabled) {
  transform: scale(1.05);
  box-shadow: 0 6px 20px var(--accent-glow);
}
.chat-input button:active:not(:disabled) { transform: scale(.95); }

/* ============ CALL MODAL ============ */
.call-modal {
  position: absolute;
  inset: 0;
  background: var(--bg-base);
  display: flex; flex-direction: column;
  z-index: 50;
  animation: callIn .3s cubic-bezier(.4, 0, .2, 1);
}
@keyframes callIn {
  from { opacity: 0; transform: scale(.98); }
  to { opacity: 1; transform: scale(1); }
}
.call-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  padding: 16px 24px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap; gap: 12px;
}
.call-meta { display: flex; flex-direction: column; gap: 4px; }
.call-peer-name { font-weight: 700; font-size: 16px; }
.call-meta-line { display: flex; align-items: center; gap: 12px; }
.call-timer {
  font-variant-numeric: tabular-nums;
  font-size: 13px;
  color: var(--text-3);
}
.call-status-badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 11px; font-weight: 700;
  background: var(--warn); color: #000;
  animation: pulseStatus 1.6s ease-in-out infinite;
}
.call-status-badge.connected {
  background: var(--success); color: #fff; animation: none;
}
.call-status-badge.failed {
  background: var(--danger); color: #fff; animation: none;
}
@keyframes pulseStatus {
  0%, 100% { opacity: 1; }
  50% { opacity: .55; }
}

.call-stats { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 6px 12px;
  border-radius: 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-2);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  transition: all var(--tr);
}
.chip.good { color: var(--success); border-color: rgba(63, 185, 80, .3); }
.chip.warn { color: var(--warn); border-color: rgba(210, 153, 34, .3); }
.chip.bad { color: var(--danger); border-color: rgba(248, 81, 73, .3); }

.call-content {
  flex: 1; display: flex; min-height: 0; overflow: hidden;
}
.video-grid {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  padding: 18px;
  min-width: 0; min-height: 0;
}
.tile {
  position: relative;
  background: var(--bg-card);
  border-radius: var(--r-lg);
  overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid transparent;
  transition: all .2s;
  cursor: zoom-in;
  box-shadow: var(--shadow-sm);
}
.tile.speaking {
  border-color: var(--success);
  box-shadow: 0 0 0 4px rgba(63, 185, 80, .15), 0 0 32px rgba(63, 185, 80, .3);
}
.tile-content {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
}
.tile-content video {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: contain;
  background: #000;
  display: none;
}
.tile-content video.visible { display: block; }
.tile-content video:fullscreen { cursor: zoom-out; }
.tile-label {
  position: absolute; bottom: 12px; left: 12px;
  display: flex; align-items: center; gap: 6px;
  padding: 5px 12px;
  border-radius: 16px;
  background: rgba(0, 0, 0, .65);
  backdrop-filter: blur(12px);
  font-size: 12px; color: #fff;
  font-weight: 500;
}
.speaking-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--text-3);
  transition: all .15s;
}
.tile.speaking .speaking-dot {
  background: var(--success);
  box-shadow: 0 0 10px var(--success);
}

/* CALL SIDEBAR */
.call-sidebar {
  width: 280px; flex-shrink: 0;
  background: var(--bg-panel);
  border-left: 1px solid var(--border);
  overflow-y: auto;
  padding: 16px;
  display: flex; flex-direction: column; gap: 14px;
}
.side-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 12px 14px;
}
.side-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-3);
  margin-bottom: 8px;
}
.side-row {
  display: flex; justify-content: space-between;
  font-size: 12px; padding: 3px 0;
  color: var(--text-2);
}
.side-row b {
  color: var(--text-1);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}
.side-section input[type="range"] {
  width: 100%;
  -webkit-appearance: none; appearance: none;
  height: 4px;
  background: var(--bg-input);
  border-radius: 2px;
  outline: none; cursor: pointer;
  margin-top: 8px;
}
.side-section input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 14px; height: 14px;
  background: var(--accent);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 0 8px var(--accent-glow);
  transition: transform .15s;
}
.side-section input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

/* CALL CONTROLS */
.call-controls {
  display: flex; align-items: center; justify-content: center;
  gap: 14px;
  padding: 18px;
  background: var(--bg-panel);
  border-top: 1px solid var(--border);
}
.ctl {
  width: 56px; height: 56px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 1px solid var(--border-2);
  color: var(--text-1);
  display: flex; align-items: center; justify-content: center;
  transition: all .2s cubic-bezier(.4, 0, .2, 1);
}
.ctl:hover {
  background: var(--bg-hover);
  transform: translateY(-3px);
  box-shadow: var(--shadow);
}
.ctl:active { transform: translateY(0) scale(.95); }
.ctl.active {
  background: var(--danger);
  color: #fff;
  border-color: transparent;
}
.ctl.danger {
  background: var(--danger);
  color: #fff;
  border-color: transparent;
}
.ctl.danger:hover {
  background: #d8322a;
  box-shadow: 0 0 24px rgba(248, 81, 73, .5);
}

/* ============ OVERLAYS ============ */
.overlay {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, .75);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(12px);
  animation: fadeIn .2s;
}
.call-card, .modal {
  background: var(--bg-panel);
  padding: 36px 44px;
  border-radius: var(--r-xl);
  min-width: 340px;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border-2);
  animation: scaleIn .25s cubic-bezier(.4, 0, .2, 1);
}
@keyframes scaleIn {
  from { opacity: 0; transform: scale(.92); }
  to { opacity: 1; transform: scale(1); }
}
.call-card { text-align: center; }
.call-card h2 { font-size: 22px; margin-bottom: 6px; letter-spacing: -.01em; }
.call-card p { color: var(--text-2); font-size: 14px; margin-bottom: 26px; }

.call-avatar {
  width: 96px; height: 96px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #9d7dff);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 22px;
  box-shadow: 0 8px 32px var(--accent-glow);
}
.call-avatar.pulsing { animation: pulse 1.4s infinite; }
@keyframes pulse {
  0%, 100% { box-shadow: 0 8px 32px var(--accent-glow), 0 0 0 0 rgba(124, 92, 255, .5); }
  50% { box-shadow: 0 8px 32px var(--accent-glow), 0 0 0 24px rgba(124, 92, 255, 0); }
}

.call-card-actions {
  display: flex; gap: 12px; justify-content: center;
}
.call-card-actions button, .modal-actions button {
  padding: 12px 24px;
  border-radius: var(--r-md);
  font-weight: 600;
  font-size: 14px;
  color: #fff;
  transition: all var(--tr);
}
.btn-success {
  background: var(--success);
  box-shadow: 0 4px 12px rgba(63, 185, 80, .3);
}
.btn-success:hover { filter: brightness(1.1); transform: translateY(-1px); }
.btn-danger {
  background: var(--danger);
  box-shadow: 0 4px 12px rgba(248, 81, 73, .3);
}
.btn-danger:hover { background: #d8322a; transform: translateY(-1px); }
.btn-accent {
  background: var(--accent);
  box-shadow: 0 4px 12px var(--accent-glow);
}
.btn-accent:hover { background: var(--accent-2); transform: translateY(-1px); }
.btn-ghost {
  background: var(--bg-card);
  color: var(--text-1);
  border: 1px solid var(--border-2);
}
.btn-ghost:hover { background: var(--bg-hover); }

.modal h2 {
  font-size: 18px; margin-bottom: 20px;
  letter-spacing: -.01em;
}
.modal label {
  display: block;
  font-size: 12px; font-weight: 600;
  color: var(--text-2);
  margin: 14px 0 6px;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.modal select {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border-2);
  border-radius: var(--r-md);
  color: var(--text-1);
  font-size: 14px;
  cursor: pointer;
  transition: all var(--tr);
}
.modal select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.modal .chk {
  display: flex; align-items: center; gap: 8px;
  text-transform: none; letter-spacing: 0;
  font-weight: 500;
  color: var(--text-1);
  cursor: pointer;
  margin-top: 16px;
}
.modal .chk input[type="checkbox"] {
  width: 16px; height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
}
.modal-actions {
  display: flex; gap: 10px; justify-content: flex-end;
  margin-top: 26px;
}
.modal-actions button {
  padding: 10px 20px;
  font-size: 14px;
}

/* ============ RESPONSIVE ============ */
@media (max-width: 1100px) {
  #app { grid-template-columns: 64px 260px 1fr; }
  .call-sidebar { width: 240px; }
}
@media (max-width: 800px) {
  #app { grid-template-columns: 64px 1fr; }
  .list-panel { position: absolute; left: 64px; top: 0; bottom: 0; width: 280px; z-index: 100; transform: translateX(-100%); transition: transform .3s; }
  .call-sidebar { display: none; }
  .video-grid { grid-template-columns: 1fr; grid-template-rows: 1fr 1fr; }
}

/* ========================================================================
   CALL MODAL — COMPACT (не на весь экран)
   ======================================================================== */
.call-modal {
  position: relative !important; /* НЕ absolute поверх — встроен в поток */
  inset: auto !important;
  height: 55vh;
  min-height: 260px;
  max-height: 75vh;
  border-bottom: 1px solid var(--border);
  background: var(--bg-panel);
  z-index: auto !important;
  animation: slideDown .3s cubic-bezier(.4, 0, .2, 1);
}
@keyframes slideDown {
  from { opacity: 0; transform: translateY(-16px); max-height: 0; }
  to { opacity: 1; transform: translateY(0); max-height: 75vh; }
}

.call-header {
  padding: 10px 18px !important;
  background: var(--bg-card) !important;
  border-bottom: 1px solid var(--border);
}
.call-peer-name { font-size: 14px !important; }
.call-meta-line { gap: 8px !important; }
.call-timer { font-size: 12px !important; }
.call-status-badge { padding: 3px 10px !important; font-size: 10px !important; }

.call-stats { gap: 6px !important; }
.chip { padding: 4px 10px !important; font-size: 11px !important; }

/* Видео сетка — компактнее */
.video-grid {
  padding: 10px !important;
  gap: 10px !important;
}

/* Сайдбар звонка — уже */
.call-sidebar {
  width: 240px !important;
  padding: 10px !important;
  gap: 8px !important;
}
.side-section { padding: 8px 10px !important; }
.side-row { padding: 2px 0 !important; font-size: 11px !important; }
.side-title { margin-bottom: 6px !important; }

/* Кнопки компактнее */
.call-controls { padding: 10px !important; gap: 10px !important; }
.ctl { width: 46px !important; height: 46px !important; }

/* Аватар в тайле меньше */
.avatar-xl { width: 72px !important; height: 72px !important; font-size: 30px !important; }

/* Resizer для изменения высоты call-modal */
.call-modal::after {
  content: '';
  position: absolute;
  bottom: -3px; left: 0; right: 0;
  height: 6px;
  cursor: ns-resize;
  z-index: 20;
}
.call-modal::after:hover {
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
}

/* Респонсив */
@media (max-width: 1100px) {
  .call-sidebar { width: 200px !important; }
}
@media (max-width: 800px) {
  .call-modal { height: 60vh; }
  .call-sidebar { display: none; }
  .video-grid { grid-template-columns: 1fr; grid-template-rows: 1fr 1fr; }
}

/* ========================================================================
   NEW PALETTE — teal/cyan (не Discord)
   ======================================================================== */
:root {
  --accent: #06b6d4 !important;
  --accent-2: #0891b2 !important;
  --accent-soft: rgba(6, 182, 212, .15) !important;
  --accent-glow: rgba(6, 182, 212, .35) !important;

  --bg-base: #0b1114 !important;
  --bg-rail: #0d1418 !important;
  --bg-panel: #10171c !important;
  --bg-card: #161f26 !important;
  --bg-hover: #1c272f !important;
  --bg-active: #22343e !important;
  --bg-input: #182329 !important;

  --text-1: #e6edf0 !important;
  --text-2: #9aa8b0 !important;
  --text-3: #5c6a72 !important;

  --success: #10b981 !important;
  --warn: #f59e0b !important;
  --danger: #ef4444 !important;
}
[data-theme="light"] {
  --accent: #0891b2 !important;
  --accent-2: #0e7490 !important;
  --bg-base: #f8fafb !important;
  --bg-rail: #eef2f4 !important;
  --bg-panel: #ffffff !important;
  --bg-card: #ffffff !important;
  --bg-hover: #eef2f4 !important;
  --bg-active: #d9f5fb !important;
  --bg-input: #eef2f4 !important;
  --text-1: #0f1a1f !important;
  --text-2: #546069 !important;
  --text-3: #8b949e !important;
}

/* Логотип — тоже teal */
.rail-logo {
  background: linear-gradient(135deg, #06b6d4, #22d3ee) !important;
  box-shadow: 0 4px 12px rgba(6, 182, 212, .4) !important;
}
.avatar, .avatar-xl {
  background: linear-gradient(135deg, #06b6d4, #22d3ee) !important;
  box-shadow: 0 2px 8px rgba(6, 182, 212, .3) !important;
}
.msg.mine .msg-bubble {
  background: linear-gradient(135deg, #06b6d4, #0891b2) !important;
  box-shadow: 0 2px 8px rgba(6, 182, 212, .3) !important;
}
.msg-avatar {
  background: linear-gradient(135deg, #06b6d4, #22d3ee) !important;
  box-shadow: 0 2px 6px rgba(6, 182, 212, .2) !important;
}
.btn-pill {
  background: linear-gradient(135deg, #06b6d4, #0891b2) !important;
  box-shadow: 0 2px 8px rgba(6, 182, 212, .3) !important;
}
.btn-pill:hover {
  background: linear-gradient(135deg, #0891b2, #0e7490) !important;
  box-shadow: 0 4px 16px rgba(6, 182, 212, .4) !important;
}
.chat-input button {
  background: linear-gradient(135deg, #06b6d4, #0891b2) !important;
  box-shadow: 0 4px 12px rgba(6, 182, 212, .4) !important;
}
.call-avatar {
  background: linear-gradient(135deg, #06b6d4, #22d3ee) !important;
  box-shadow: 0 8px 32px rgba(6, 182, 212, .4) !important;
}
.call-avatar.pulsing { animation: pulse 1.4s infinite; }
@keyframes pulse {
  0%, 100% { box-shadow: 0 8px 32px rgba(6, 182, 212, .4), 0 0 0 0 rgba(6, 182, 212, .5); }
  50% { box-shadow: 0 8px 32px rgba(6, 182, 212, .4), 0 0 0 24px rgba(6, 182, 212, 0); }
}
.btn-accent {
  background: linear-gradient(135deg, #06b6d4, #0891b2) !important;
  box-shadow: 0 4px 12px rgba(6, 182, 212, .3) !important;
}
.side-section input[type="range"]::-webkit-slider-thumb {
  background: #06b6d4 !important;
  box-shadow: 0 0 8px rgba(6, 182, 212, .5) !important;
}
.sysmon-fill {
  background: linear-gradient(90deg, #06b6d4, #22d3ee) !important;
}
.rail-btn.active {
  background: rgba(6, 182, 212, .15) !important;
  color: #06b6d4 !important;
}
.rail-btn.active::before {
  background: #06b6d4 !important;
}
.user.active {
  background: rgba(6, 182, 212, .12) !important;
}
.user.active .user-name {
  color: #06b6d4 !important;
}
.user.active::before {
  background: #06b6d4 !important;
}

/* ========================================================================
   USER STATUSES
   ======================================================================== */
.user.away .avatar::after { background: #f59e0b; box-shadow: 0 0 8px #f59e0b; }
.user.dnd .avatar::after { background: #ef4444; box-shadow: 0 0 8px #ef4444; }
.user.online .avatar::after { background: #10b981; box-shadow: 0 0 8px #10b981; }

.my-status-select {
  background: transparent;
  border: none;
  color: var(--text-3);
  font-size: 11px;
  padding: 0;
  cursor: pointer;
  width: 100%;
  outline: none;
}
.my-status-select:hover { color: var(--text-1); }
.my-status-select option { background: var(--bg-card); color: var(--text-1); }

/* ========================================================================
   ANIMATIONS v2 — живые и красивые
   ======================================================================== */

/* 1. Плавное появление контента */
@keyframes slideUpFade {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes slideDownFade {
  from { opacity: 0; transform: translateY(-12px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes scaleIn {
  from { opacity: 0; transform: scale(.92); }
  to { opacity: 1; transform: scale(1); }
}

/* 2. Мягкое дыхание (пульсация) */
@keyframes breathe {
  0%, 100% { transform: scale(1); box-shadow: 0 4px 12px var(--accent-glow); }
  50% { transform: scale(1.03); box-shadow: 0 6px 20px var(--accent-glow); }
}

/* 3. Волнистое появление сообщений */
@keyframes msgPop {
  0% { opacity: 0; transform: translateY(8px) scale(.98); }
  60% { opacity: 1; transform: translateY(-2px) scale(1.01); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

/* 4. Ripple при клике */
@keyframes ripple {
  from { transform: scale(0); opacity: .6; }
  to { transform: scale(2.5); opacity: 0; }
}

/* 5. Плавное свечение для speaking */
@keyframes speakGlow {
  0%, 100% { box-shadow: 0 0 0 4px rgba(16, 185, 129, .15), 0 0 32px rgba(16, 185, 129, .3); }
  50% { box-shadow: 0 0 0 8px rgba(16, 185, 129, .25), 0 0 48px rgba(16, 185, 129, .5); }
}

/* 6. Мягкое покачивание аватара при speaking */
@keyframes swaySpeaking {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

/* 7. Shimmer загрузка */
@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

/* === Применяем === */

/* Сообщения — pop */
.msg { animation: msgPop .3s cubic-bezier(.34, 1.56, .64, 1) both; }

/* Тайлы — speaking пульсирует красиво */
.tile.speaking { animation: speakGlow 2s ease-in-out infinite; }
.tile.speaking .avatar-xl { animation: swaySpeaking 1.5s ease-in-out infinite; }

/* Кнопки — ripple при клике */
.btn-pill, .ctl, .icon-btn, .chat-input button, .btn-accent, .btn-success, .btn-danger, .btn-ghost {
  position: relative;
  overflow: hidden;
}
.btn-pill::after, .ctl::after, .icon-btn::after, .chat-input button::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle, rgba(255,255,255,.4) 0%, transparent 70%);
  opacity: 0;
  pointer-events: none;
  transform: scale(0);
}
.btn-pill:active::after, .ctl:active::after, .icon-btn:active::after, .chat-input button:active::after {
  animation: ripple .4s ease-out;
}

/* Плавное появление модалок */
.overlay { animation: fadeIn .25s ease-out; }
.call-card, .modal { animation: scaleIn .3s cubic-bezier(.34, 1.56, .64, 1); }

/* Чат-хедер — плавное появление */
.chat-header { animation: slideDownFade .3s ease-out; }
.chat-input { animation: slideUpFade .3s ease-out; }

/* Звонок — красивое появление */
.call-modal { animation: slideDownFade .4s cubic-bezier(.34, 1.56, .64, 1); }

/* Пустой чат — мягкое появление иконки */
.empty-chat { animation: slideUpFade .5s ease-out; }
.empty-icon { animation: breathe 3s ease-in-out infinite; }

/* Аватар пользователя — плавный hover */
.user:hover .avatar { transform: scale(1.08); transition: transform .25s cubic-bezier(.34, 1.56, .64, 1); }
.avatar { transition: transform .25s cubic-bezier(.34, 1.56, .64, 1), box-shadow .25s; }

/* Кнопки — плавное свечение при hover */
.btn-pill:hover { animation: breathe 2s ease-in-out infinite; }

/* Чипы статистики — плавное появление */
.chip { animation: scaleIn .3s ease-out both; }
.chip:nth-child(1) { animation-delay: 0s; }
.chip:nth-child(2) { animation-delay: .05s; }
.chip:nth-child(3) { animation-delay: .1s; }

/* Side sections — плавно */
.side-section { animation: slideUpFade .35s ease-out both; }
.side-section:nth-child(1) { animation-delay: .05s; }
.side-section:nth-child(2) { animation-delay: .1s; }
.side-section:nth-child(3) { animation-delay: .15s; }
.side-section:nth-child(4) { animation-delay: .2s; }
.side-section:nth-child(5) { animation-delay: .25s; }

/* Общий transition на всё интерактивное */
button, .user, .tile, .chip, .side-section, input, select {
  transition: background .15s, color .15s, border-color .15s, transform .15s, box-shadow .15s;
}

/* Активная вкладка rail — пульсирующая точка */
.rail-btn.active::after {
  content: '';
  position: absolute;
  bottom: 4px;
  left: 50%;
  transform: translateX(-50%);
  width: 4px;
  height: 4px;
  background: var(--accent);
  border-radius: 50%;
  animation: breathe 2s ease-in-out infinite;
}

/* Sysmon — плавный прогресс */
.sysmon-fill {
  transition: width .8s cubic-bezier(.4, 0, .2, 1), background .3s;
}

/* Статус-бейдж — плавное появление */
.call-status-badge { animation: slideDownFade .4s ease-out; }

/* Инпут сообщения — glow при фокусе */
.chat-input input:focus {
  animation: breathe 2s ease-in-out infinite;
}

/* Уведомление "печатает" (задел) */
@keyframes dotBounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-4px); }
}
