/* ===== CSS Custom Properties (Floating Panels Dark Theme) ===== */
:root {
  --bg-dark: #161618;
  --bg-panel: #1E1E22;
  --bg-surface: #27272B;
  --bg-input: #27272B;
  --bg-hover: #27272B;
  --bg-active: rgba(59, 130, 246, 0.12);
  --bg-modal: #1E1E22;

  --text-primary: #F4F4F5;
  --text-secondary: #D4D4D8;
  --text-muted: #71717A;
  --text-dim: #52525B;
  --text-accent: #3B82F6;

  --border-color: #2A2A2E;

  --accent: #3B82F6;
  --accent-hover: #2563EB;
  --danger: #DC2626;
  --danger-hover: #EF4444;
  --success: #10B981;

  --radius: 8px;
  --radius-lg: 16px;
  --radius-xl: 12px;

  --sidebar-width: 260px;
  --members-width: 220px;
  --gap: 12px;

  --status-online: #10B981;
  --status-away: #F59E0B;
  --status-offline: #52525B;

  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', monospace;

  --spacing-xs: 4px;
  --spacing-sm: 8px;
  --spacing-md: 16px;
  --spacing-lg: 24px;
}

/* ===== Reset & Base ===== */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  font-family: var(--font-sans);
  font-size: 14px;
  color: #E4E4E7;
  background: var(--bg-dark);
  overflow: hidden;
}

/* ===== App Layout (3-column floating panels) ===== */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr var(--members-width);
  gap: var(--gap);
  padding: var(--gap);
  height: 100dvh;
  overflow: hidden;
}

.app.members-hidden {
  grid-template-columns: var(--sidebar-width) 1fr;
}

.app.members-hidden .members-panel {
  display: none;
}

/* ===== Center Column ===== */
.center {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  min-height: 0;
}

/* ===== Panel Base ===== */
.sidebar,
.main,
.members-panel,
.video-panel {
  background: var(--bg-panel);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

/* ===== Left Sidebar ===== */
.sidebar {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.sidebar-header {
  padding: 20px var(--spacing-md) 12px;
  border-bottom: 1px solid var(--border-color);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.sidebar-brand-icon {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, #3B82F6, #10B981);
  border-radius: var(--spacing-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: var(--spacing-md);
  color: #fff;
}

.logo {
  font-size: 17px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.3px;
}

.sidebar-search {
  padding: 0;
}

.sidebar-search-input {
  width: 100%;
  padding: var(--spacing-sm) 12px;
  background: var(--bg-surface);
  border: none;
  border-radius: var(--spacing-sm);
  color: var(--text-primary);
  font-size: 16px;
  outline: none;
}

.sidebar-search-input::placeholder {
  color: var(--text-muted);
}

.sidebar-search-input:focus {
  box-shadow: 0 0 0 1px var(--accent);
}

.sidebar-body {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

.sidebar-section {
  padding: var(--spacing-md) var(--spacing-md) var(--spacing-sm);
}

.sidebar-section:last-child {
  padding: var(--spacing-sm) var(--spacing-md) var(--spacing-md);
  flex: 1;
  min-height: 0;
}

.sidebar-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.05em;
  margin-bottom: var(--spacing-sm);
  text-transform: uppercase;
  padding: 0;
}

/* ===== Channel List ===== */
.channel-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.channel-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: var(--spacing-sm);
  font-size: 14px;
  color: #A1A1AA;
  cursor: pointer;
  transition: background 0.1s;
}

.channel-item:hover {
  background: var(--bg-hover);
}

.channel-item.active {
  background: var(--bg-active);
  color: var(--accent);
}

.channel-icon {
  font-size: 15px;
  font-weight: 500;
  opacity: 0.6;
  width: var(--spacing-md);
  text-align: center;
  flex-shrink: 0;
}

.channel-item-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ===== DM List ===== */
.dm-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.dm-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  border-radius: var(--spacing-sm);
  cursor: pointer;
  transition: background 0.1s;
}

.dm-item:hover {
  background: var(--bg-hover);
}

.dm-item.active {
  background: var(--bg-active);
  color: var(--accent);
}

.dm-item-name {
  flex: 1;
  font-size: 14px;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ===== Unread Badge ===== */
.unread-badge {
  margin-left: auto;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 10px;
  min-width: var(--spacing-md);
  text-align: center;
  flex-shrink: 0;
}

/* ===== Avatar System (gradient-based) ===== */
.avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-weight: 600;
  flex-shrink: 0;
  color: #fff;
  text-transform: uppercase;
  user-select: none;
}

.avatar-xs {
  width: 22px;
  height: 22px;
  font-size: 10px;
}

.avatar-sm {
  width: 28px;
  height: 28px;
  font-size: 12px;
}

.avatar-md {
  width: 36px;
  height: 36px;
  font-size: 14px;
  border-radius: 10px;
}

.avatar-lg {
  width: 40px;
  height: 40px;
  font-size: 15px;
  border-radius: 12px;
}

.avatar-color-0 { background: linear-gradient(135deg, #3B82F6, #6366F1); }
.avatar-color-1 { background: linear-gradient(135deg, #10B981, #059669); }
.avatar-color-2 { background: linear-gradient(135deg, #F59E0B, #EF4444); }
.avatar-color-3 { background: linear-gradient(135deg, #8B5CF6, #EC4899); }
.avatar-color-4 { background: linear-gradient(135deg, #06B6D4, #3B82F6); }
.avatar-color-5 { background: linear-gradient(135deg, #10B981, #34D399); }
.avatar-color-6 { background: linear-gradient(135deg, #A855F7, #6366F1); }
.avatar-color-7 { background: linear-gradient(135deg, #F43F5E, #FB923C); }
.avatar-color-8 { background: linear-gradient(135deg, #0EA5E9, #22D3EE); }
.avatar-color-9 { background: linear-gradient(135deg, #E11D48, #BE185D); }

/* ===== Status Dot ===== */
.avatar-wrapper {
  position: relative;
  flex-shrink: 0;
}

.status-dot {
  position: absolute;
  bottom: -1px;
  right: -1px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid var(--bg-panel);
}

.status-dot.status-online {
  background: var(--status-online);
}

.status-dot.status-away {
  background: var(--status-away);
}

.status-dot.status-offline {
  background: var(--status-offline);
}

/* DM avatars — status shown as ring */
.dm-item .avatar {
  box-shadow: 0 0 0 2px var(--bg-panel);
}

/* ===== Sidebar Footer ===== */
.sidebar-footer {
  padding: 12px var(--spacing-md);
  border-top: 1px solid var(--border-color);
  background: rgba(0, 0, 0, 0.15);
}

.user-info {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
}

.user-name {
  flex: 1;
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
}

/* ===== Main Area (chat panel) ===== */
.main {
  display: flex;
  flex-direction: column;
  flex: 1.2;
  min-height: 0;
}

/* ===== Channel Header ===== */
.channel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
  gap: 12px;
}

.channel-header-left {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 0;
}

.channel-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
}

.channel-description {
  font-size: 12px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.channel-header-actions {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-shrink: 0;
}

.btn-members-toggle {
  font-size: 12px;
  color: var(--text-muted);
  background: var(--bg-surface);
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
  border: none;
  width: auto;
  height: auto;
  transition: color 0.1s, background 0.1s;
}

.btn-members-toggle:hover {
  color: #E4E4E7;
  background: #323237;
}

.btn-call-toggle {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  background: var(--bg-surface);
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  border: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: color 0.1s, background 0.1s;
}

.btn-call-toggle:hover {
  color: #E4E4E7;
  background: #323237;
}

.btn-call-toggle.has-call {
  color: var(--text-secondary);
  border: 1px solid #10B981;
}

.btn-call-toggle.has-call:hover {
  color: var(--text-primary);
  background: rgba(16, 185, 129, 0.1);
}

.btn-call-toggle.in-call {
  color: #10B981;
  background: rgba(16, 185, 129, 0.15);
}

.btn-call-toggle.in-call:hover {
  background: rgba(16, 185, 129, 0.25);
}

.btn-call-toggle[hidden],
.btn-members-toggle[hidden] {
  display: none;
}

/* ===== Chat Area ===== */
.chat-area {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}

.messages {
  flex: 1;
  overflow-y: auto;
  padding: var(--spacing-md) 20px;
  display: flex;
  flex-direction: column;
  gap: var(--spacing-md);
  min-height: 0;
}

/* ===== Message (floating panels style) ===== */
.message {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 2px 0;
}

.message-content {
  flex: 1;
  min-width: 0;
}

.message-header {
  display: flex;
  align-items: baseline;
  gap: var(--spacing-sm);
  margin-bottom: 3px;
}

.message-author {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  flex-shrink: 0;
}

.message-time {
  font-size: 11px;
  color: var(--text-dim);
  flex-shrink: 0;
}

.message-body {
  font-size: 14px;
  color: var(--text-secondary);
  word-break: break-word;
  line-height: 1.5;
}

.bot-badge {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  font-weight: 600;
  padding: 1px 5px;
  border-radius: 3px;
  margin-left: 6px;
  vertical-align: middle;
  letter-spacing: 0.5px;
}

.mention {
  background: rgba(88, 101, 242, 0.15);
  color: var(--accent);
  padding: 0 3px;
  border-radius: 3px;
  font-weight: 500;
}

/* ===== Markdown in Messages ===== */

.message-body .md-codeblock {
  background: var(--bg-dark);
  border-radius: 6px;
  padding: 10px 12px;
  margin: 6px 0;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-secondary);
}

.message-body .md-code {
  background: var(--bg-dark);
  padding: 1px 5px;
  border-radius: 3px;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-secondary);
}

.message-body .md-blockquote {
  border-left: 3px solid var(--accent);
  padding-left: 10px;
  margin: 4px 0;
  color: var(--text-muted);
}

.message-body a {
  color: var(--accent);
  text-decoration: none;
}

.message-body a:hover {
  text-decoration: underline;
}

.message-body strong {
  color: var(--text-primary);
}

.message-system {
  color: var(--text-muted);
  font-size: 12px;
  font-style: italic;
  padding: 2px 0 2px 48px;
}

/* ===== Chat Form ===== */
.chat-form {
  display: flex;
  gap: 10px;
  padding: 12px var(--spacing-md) var(--spacing-md);
  flex-shrink: 0;
  align-items: center;
  position: relative;
}

.chat-input {
  flex: 1;
  padding: 10px 14px;
  background: var(--bg-surface);
  border: none;
  border-radius: 12px;
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 16px;
  outline: none;
}

.chat-input:focus {
  box-shadow: 0 0 0 1px var(--accent);
}

.chat-input::placeholder {
  color: var(--text-dim);
}

.btn-send {
  padding: 10px 16px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--spacing-sm);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s;
  flex-shrink: 0;
}

.btn-send:hover {
  background: var(--accent-hover);
}

/* ===== @Mention Autocomplete ===== */

.mention-menu {
  position: absolute;
  bottom: 100%;
  left: var(--spacing-md);
  right: var(--spacing-md);
  max-height: 240px;
  overflow-y: auto;
  background: var(--bg-panel);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 4px;
  margin-bottom: 4px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  z-index: 50;
}

.mention-menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 4px;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 14px;
}

.mention-menu-item:hover,
.mention-menu-item.selected {
  background: var(--bg-active);
  color: var(--text-primary);
}

.mention-menu-name {
  flex: 1;
}

/* ===== Video Panel (separate floating panel below chat) ===== */
.video-panel {
  display: flex;
  flex-direction: column;
  flex: 0.8;
}

.video-panel[hidden] {
  display: none;
}

.center.in-call .main {
  flex: none;
  height: 300px;
}

.center.in-call .video-panel {
  flex: 1;
  min-height: 0;
}

/* -- Header -- */
.video-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}

.video-header-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.video-call-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: rgba(16, 185, 129, 0.15);
  color: #10B981;
  font-size: 14px;
  flex-shrink: 0;
}

.video-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.video-header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.call-timer {
  font-size: 13px;
  font-weight: 500;
  color: #10B981;
  font-variant-numeric: tabular-nums;
}

.call-participants-count {
  font-size: 12px;
  color: var(--text-muted);
}

/* -- Tile Grid -- */
.video-tiles {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  padding: 14px var(--spacing-md);
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  align-content: start;
}

/* -- Single Tile -- */
.video-tile {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100px;
  aspect-ratio: 16 / 9;
}

.video-tile.speaking {
  box-shadow: 0 0 0 2px #10B981;
}

.video-tile-bg {
  position: absolute;
  inset: 0;
}

.video-tile-bg-1 { background: linear-gradient(135deg, #1a2744, #1E1E22); }
.video-tile-bg-2 { background: linear-gradient(135deg, #1a3a2e, #1E1E22); }
.video-tile-bg-3 { background: linear-gradient(135deg, #2d1a44, #1E1E22); }

.video-tile-avatar {
  position: relative;
  z-index: 1;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
  text-transform: uppercase;
  user-select: none;
}

.video-tile video {
  position: absolute;
  inset: 0;
  z-index: 2;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: none;
}

.video-tile video.has-stream {
  display: block;
}

/* -- Tile Info Bar -- */
.video-tile-info {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.5));
}

.video-tile-name {
  flex: 1;
  min-width: 0;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.video-tile-mic {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 8px;
  flex-shrink: 0;
}

.video-tile-mic.mic-on {
  background: rgba(16, 185, 129, 0.2);
  color: #10B981;
}

.video-tile-mic.mic-muted {
  background: rgba(220, 38, 38, 0.2);
  color: #DC2626;
}

.video-tile-cam {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 8px;
  flex-shrink: 0;
}

.video-tile-cam.cam-on {
  background: rgba(16, 185, 129, 0.2);
  color: #10B981;
}

.video-tile-cam.cam-muted {
  background: rgba(220, 38, 38, 0.2);
  color: #DC2626;
}

/* -- Controls -- */
.video-controls {
  display: flex;
  justify-content: center;
  gap: 10px;
  padding: 10px var(--spacing-md) 14px;
  border-top: 1px solid var(--border-color);
  flex-shrink: 0;
}

.ctrl-btn {
  padding: var(--spacing-sm) var(--spacing-md);
  border-radius: 10px;
  font-size: 12px;
  font-weight: 500;
  color: #A1A1AA;
  background: var(--bg-surface);
  cursor: pointer;
  border: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background 0.1s, color 0.1s;
}

.ctrl-btn:hover:not(:disabled) {
  background: #323237;
}

.ctrl-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.ctrl-btn.active {
  color: var(--text-primary);
  background: #3F3F46;
}

.ctrl-btn.ctrl-muted {
  color: var(--danger);
  background: rgba(220, 38, 38, 0.1);
}

.ctrl-btn.ctrl-muted:hover:not(:disabled) {
  background: rgba(220, 38, 38, 0.2);
}

.ctrl-btn.ctrl-end {
  background: var(--danger);
  color: #fff;
}

.ctrl-btn.ctrl-end:hover:not(:disabled) {
  background: var(--danger-hover);
}

/* ===== Maximized Video Tile ===== */
.video-tile {
  cursor: pointer;
}

.video-panel.maximized {
  position: fixed;
  inset: 0;
  z-index: 90;
  border-radius: 0;
  flex: none;
}

.video-panel.maximized .video-tiles {
  display: flex;
  align-items: stretch;
}

.video-panel.maximized .tile-maximized {
  flex: 1;
  aspect-ratio: auto;
  min-height: 0;
  border-radius: 0;
}

.video-panel.maximized .video-tile:not(.tile-maximized) {
  display: none;
}

.btn-minimize[hidden] {
  display: none;
}

/* ===== Right Sidebar: Members Panel ===== */
.members-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.members-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--spacing-md) var(--spacing-md) 12px;
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}

.members-header span:first-child {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
}

.members-count {
  font-size: 12px;
  color: var(--text-muted);
  background: var(--bg-surface);
  padding: 2px var(--spacing-sm);
  border-radius: 10px;
  font-weight: 400;
}

.members-body {
  flex: 1;
  overflow-y: auto;
}

.members-group {
  padding: 12px var(--spacing-md) var(--spacing-xs);
}

.members-group-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-dim);
  letter-spacing: 0.05em;
  margin-bottom: var(--spacing-sm);
  text-transform: uppercase;
}

.members-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.member-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px var(--spacing-sm);
  border-radius: var(--spacing-sm);
  cursor: pointer;
  color: var(--text-secondary);
  transition: background 0.1s;
}

.member-item:hover {
  background: var(--bg-hover);
}

.member-item-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.member-item-you {
  font-size: 11px;
  color: var(--text-dim);
}

.member-item-location {
  font-size: 11px;
  color: var(--text-muted);
  margin-left: 4px;
}

/* Offline members are dimmed */
.member-item-offline {
  opacity: 0.5;
}

/* ===== Buttons ===== */
.btn-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 18px;
  cursor: pointer;
  border-radius: 6px;
  transition: background 0.1s, color 0.1s;
}

.btn-icon:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.btn-menu {
  display: none;
  min-width: 44px;
  min-height: 44px;
}

.btn-edit-name {
  font-size: 14px;
  color: #71717A;
}

/* ===== Buttons (generic) ===== */
.btn {
  padding: 8px 16px;
  border: none;
  border-radius: var(--spacing-sm);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-secondary {
  background: var(--bg-surface);
  color: var(--text-primary);
}

.btn-secondary:hover {
  background: #323237;
}

/* ===== Modal ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal-overlay[hidden] {
  display: none;
}

.modal {
  background: var(--bg-modal);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 24px;
  width: 100%;
  max-width: 400px;
}

.modal-title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--text-primary);
}

.form-group {
  margin-bottom: 12px;
}

.form-group label {
  display: block;
  margin-bottom: 4px;
  font-size: 13px;
  color: var(--text-muted);
}

.form-group input[type="text"] {
  width: 100%;
  padding: 8px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--spacing-sm);
  color: var(--text-primary);
  font-size: 16px;
  outline: none;
}

.form-group input[type="text"]:focus {
  box-shadow: 0 0 0 1px var(--accent);
  border-color: transparent;
}

.input-masked {
  -webkit-text-security: disc;
}

.form-group input[type="checkbox"] {
  margin-right: 6px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
}

/* ===== Member Profile Modal ===== */
.modal-profile {
  max-width: 320px;
  padding: 0;
  overflow: hidden;
}

.profile-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 28px 24px 24px;
}

.profile-avatar {
  margin-bottom: 12px;
}

.profile-avatar .avatar.avatar-lg {
  width: 64px;
  height: 64px;
  font-size: 24px;
  border-radius: 16px;
}

.profile-name {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 4px;
  color: var(--text-primary);
}

.profile-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.profile-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.profile-status-dot.status-online { background: var(--status-online); }
.profile-status-dot.status-away { background: var(--status-away); }
.profile-status-dot.status-offline { background: var(--status-offline); }

.profile-details {
  width: 100%;
  border-top: 1px solid var(--border-color);
  padding-top: 12px;
  margin-bottom: 16px;
}

.profile-detail-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 0;
}

.profile-detail-label {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.profile-detail-value {
  font-size: 13px;
  color: var(--text-muted);
}

.profile-detail-mono {
  font-family: var(--font-mono);
  font-size: 11px;
}

.profile-actions {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.profile-btn-pm {
  width: 100%;
  text-align: center;
}

.profile-btn-block {
  width: 100%;
  text-align: center;
}

.btn-danger-outline {
  background: transparent;
  border: 1px solid var(--danger);
  color: var(--danger);
}

.btn-danger-outline:hover {
  background: var(--danger);
  color: #fff;
}

/* ===== Toast Notifications ===== */
.toast-container {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 10px 16px;
  background: var(--bg-modal);
  border: 1px solid var(--border-color);
  border-radius: var(--spacing-sm);
  color: var(--text-primary);
  font-size: 13px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  animation: toast-in 0.2s ease-out;
}

.toast-error {
  border-color: var(--danger);
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ===== Unjoined Channel ===== */
.channel-item.channel-unjoined { opacity: 0.5; }
.channel-item.channel-unjoined:hover { opacity: 0.7; }

/* ===== Channel Preview Modal ===== */
.preview-channel-info { text-align: center; margin-bottom: 16px; }
.preview-channel-info h3 { font-size: 18px; font-weight: 600; margin-bottom: 8px; color: var(--text-primary); }
.preview-channel-meta { display: flex; justify-content: center; gap: 16px; font-size: 13px; color: var(--text-muted); }

/* ===== Warning & Danger ===== */
.warning-text { font-size: 14px; color: var(--text-secondary); margin-bottom: 16px; line-height: 1.5; }
.btn-danger { background: var(--danger); color: #fff; border: none; }
.btn-danger:hover { opacity: 0.9; }

/* ===== Share Channel Button ===== */
.btn-share-channel { font-size: 14px; color: var(--text-muted); background: none; border: none; padding: 6px 10px; border-radius: 6px; cursor: pointer; display: inline-flex; align-items: center; transition: color 0.1s, background 0.1s; }
.btn-share-channel:hover { color: var(--text-primary); background: var(--bg-surface); }
.btn-share-channel[hidden] { display: none; }

/* ===== Leave Channel Button ===== */
.btn-leave-channel { font-size: 12px; color: var(--text-muted); background: none; border: none; padding: 6px 12px; border-radius: 6px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.btn-leave-channel:hover { color: var(--danger); background: rgba(220, 38, 38, 0.1); }
.btn-leave-channel[hidden] { display: none; }

/* ===== Scrollbar ===== */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: #3F3F46;
}

/* ===== Responsive ===== */
@media (max-width: 1024px) {
  .app {
    grid-template-columns: var(--sidebar-width) 1fr;
    padding: var(--spacing-sm);
    gap: var(--spacing-sm);
  }

  .members-panel {
    position: fixed;
    top: var(--spacing-sm);
    right: var(--spacing-sm);
    bottom: var(--spacing-sm);
    width: var(--members-width);
    z-index: 50;
    transform: translateX(calc(100% + var(--spacing-sm)));
    transition: transform 0.2s ease;
  }

  .app:not(.members-hidden) .members-panel {
    transform: translateX(0);
  }

  .app.members-hidden .members-panel {
    display: flex;
    transform: translateX(calc(100% + var(--spacing-sm)));
  }
}

@media (max-width: 768px) {
  .app,
  .app.members-hidden {
    grid-template-columns: 1fr;
    padding: 0;
    gap: 0;
  }

  .sidebar,
  .main,
  .members-panel,
  .video-panel {
    border-radius: 0;
  }

  .center {
    gap: 0;
  }

  .sidebar {
    position: fixed;
    inset: 0;
    z-index: 50;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    width: var(--sidebar-width);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .members-panel {
    top: 0;
    right: 0;
    bottom: 0;
    transform: translateX(100%);
  }

  .app.members-hidden .members-panel {
    transform: translateX(100%);
  }

  .btn-menu {
    display: flex;
  }

  .video-tiles {
    grid-template-columns: repeat(2, 1fr);
  }
}
