@import url('https://fonts.googleapis.com/css2?family=Inter:opsz,wght@14..32,400;14..32,500;14..32,600;14..32,700&display=swap');

:root {
  --bg-deep: #08090b;
  --bg-base: #0b0d10;
  --bg-elev-1: #101216;
  --bg-elev-2: #15171c;
  --bg-elev-3: #1b1e24;
  --border: rgba(255,255,255,0.06);
  --border-strong: rgba(255,255,255,0.1);
  --accent: #5865f2;
  --accent-hover: #6b76f5;
  --accent-soft: rgba(88,101,242,0.16);
  --success: #23a55a;
  --success-soft: rgba(35,165,90,0.14);
  --danger: #ed4245;
  --danger-soft: rgba(237,66,69,0.14);
  --text-hi: #f2f3f5;
  --text-mid: #b5bac5;
  --text-dim: #80868f;
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 9px;
  --shadow-soft: 0 8px 24px rgba(0,0,0,0.35);
  --shadow-strong: 0 20px 60px rgba(0,0,0,0.55);
  --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --sidebar-width: 240px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { 
  -webkit-font-smoothing: antialiased; 
  text-rendering: optimizeLegibility;
  height: 100%;
  overflow: hidden;
}
body {
  background:
    radial-gradient(1100px 620px at 18% -8%, rgba(88,101,242,0.10), transparent 60%),
    radial-gradient(900px 520px at 100% 100%, rgba(88,101,242,0.05), transparent 55%),
    var(--bg-base);
  color: var(--text-hi);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 14px;
  letter-spacing: 0.1px;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
button { 
  font-family: inherit; 
  cursor: pointer; 
  border: none; 
  background: transparent;
  touch-action: manipulation;
  -webkit-touch-callout: none;
}
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-thumb { background: #24262c; border-radius: 8px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: #303339; background-clip: padding-box; }
::-webkit-scrollbar-track { background: transparent; }

/* ----- Lobby ----- */
#lobby {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  position: relative;
  animation: fadeIn 0.5s ease;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}
.auth-card {
  background: linear-gradient(180deg, var(--bg-elev-2), var(--bg-elev-1));
  border-radius: var(--radius-lg);
  padding: 32px 24px 28px;
  width: 100%;
  max-width: 440px;
  box-shadow: var(--shadow-strong);
  border: 1px solid var(--border-strong);
  position: relative;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.auth-card::before {
  content: '';
  position: absolute;
  top: -1px;
  left: 20%;
  right: 20%;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  border-radius: 0 0 50% 50%;
}
.auth-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: center;
  margin-bottom: 16px;
}
.auth-logo-mark {
  background: linear-gradient(145deg, var(--accent-hover), var(--accent));
  width: 38px; height: 38px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 19px;
  color: #fff;
  box-shadow: 0 6px 16px rgba(88,101,242,0.35);
  animation: pulseGlow 3s ease-in-out infinite;
}
@keyframes pulseGlow {
  0%, 100% { box-shadow: 0 6px 16px rgba(88,101,242,0.35); }
  50% { box-shadow: 0 6px 24px rgba(88,101,242,0.55); }
}
.auth-logo-name {
  font-size: 19px;
  font-weight: 700;
  color: var(--text-hi);
  letter-spacing: -0.3px;
}
.auth-heading {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-hi);
  text-align: center;
  letter-spacing: -0.4px;
}
.auth-sub {
  color: var(--text-dim);
  font-size: 13px;
  text-align: center;
  margin: 6px 0 22px;
  line-height: 1.5;
}
.field-group { margin-bottom: 16px; }
.field-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-dim);
  margin-bottom: 6px;
}
.field-row { display: flex; gap: 8px; }
.field-row input[type="text"] {
  flex: 1;
  background: var(--bg-deep);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 13px 16px;
  font-size: 15px;
  color: var(--text-hi);
  outline: none;
  transition: var(--transition);
  font-family: 'Inter', monospace;
  min-height: 48px;
  -webkit-appearance: none;
  appearance: none;
}
.field-row input[type="text"]::placeholder { color: #4b4f58; }
.field-row input[type="text"]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}
.btn-secondary {
  background: var(--bg-elev-3);
  border: 1px solid var(--border-strong);
  color: var(--text-mid);
  font-weight: 500;
  padding: 0 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  transition: var(--transition);
  white-space: nowrap;
  min-height: 48px;
}
.btn-secondary:hover { background: #33363d; color: #fff; border-color: rgba(255,255,255,0.16); }
.btn-secondary:active { transform: scale(0.97); }
.btn-primary {
  width: 100%;
  background: linear-gradient(145deg, var(--accent-hover), var(--accent));
  color: #fff;
  font-weight: 600;
  font-size: 15px;
  padding: 14px;
  border-radius: var(--radius-sm);
  transition: var(--transition);
  box-shadow: 0 10px 24px rgba(88,101,242,0.28);
  position: relative;
  overflow: hidden;
  min-height: 50px;
}
.btn-primary::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.15), transparent);
  opacity: 0;
  transition: var(--transition);
}
.btn-primary:hover { 
  filter: brightness(1.06); 
  transform: translateY(-2px); 
  box-shadow: 0 14px 32px rgba(88,101,242,0.4);
}
.btn-primary:hover::after { opacity: 1; }
.btn-primary:active { transform: scale(0.98); }
.btn-primary:disabled { opacity: 0.5; cursor: default; transform: none; box-shadow: none; }
.err {
  color: #f47174;
  font-size: 13px;
  margin-top: 8px;
  min-height: 20px;
}
.waitBox {
  background: var(--bg-elev-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  margin-top: 12px;
  display: none;
  align-items: center;
  gap: 12px;
  color: var(--text-mid);
  font-size: 13.5px;
}
.spin {
  width: 15px; height: 15px;
  border: 2px solid #3a3e46;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }
.auth-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 20px 0 14px;
}
.hint {
  font-size: 12px;
  color: var(--text-dim);
  line-height: 1.6;
}
.hint b { color: #aeb3bf; font-weight: 600; }

/* ----- App Shell ----- */
#app {
  display: none;
  flex: 1;
  min-height: 0;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

/* guild rail */
.guild-rail {
  width: 56px;
  background: var(--bg-deep);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 0;
  gap: 6px;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  z-index: 10;
}
.guild-icon {
  width: 38px; height: 38px;
  border-radius: 14px;
  background: var(--bg-elev-2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  transition: var(--transition);
  color: var(--text-mid);
}
.guild-icon.active {
  background: linear-gradient(145deg, var(--accent-hover), var(--accent));
  color: #fff;
  border-radius: 12px;
  box-shadow: 0 6px 16px rgba(88,101,242,0.35);
}
.mobile-menu-btn {
  display: none !important;
  cursor: pointer;
  font-size: 20px;
  margin-top: auto;
}

/* Sidebar Overlay (mobile) */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 50;
  opacity: 0;
  transition: opacity 0.3s ease;
}
.sidebar-overlay.open {
  display: block;
  opacity: 1;
}

/* channel sidebar */
.channel-sidebar {
  width: var(--sidebar-width);
  background: var(--bg-base);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  position: relative;
  z-index: 60;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.server-header {
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 0 rgba(0,0,0,0.2);
  color: var(--text-hi);
  font-weight: 600;
  font-size: 14px;
  flex-shrink: 0;
}
.server-header span:last-child { color: var(--text-dim); font-size: 12px; }
.channel-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 6px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  -webkit-overflow-scrolling: touch;
}
.channel-category {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 8px 10px 4px;
}
.voice-channel, .text-channel {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 7px;
  color: var(--text-mid);
  font-size: 14px;
  font-weight: 500;
  transition: var(--transition);
  margin: 1px 0;
  cursor: pointer;
  min-height: 36px;
}
.voice-channel:active, .text-channel:active { transform: scale(0.97); }
.voice-channel:hover, .text-channel:hover { background: var(--bg-elev-2); color: var(--text-hi); }
.voice-channel.active, .text-channel.active {
  background: var(--bg-elev-2);
  color: var(--text-hi);
}
.voice-members {
  padding: 3px 0 8px 15px;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.voice-member {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 13px;
  color: var(--text-mid);
  transition: var(--transition);
  min-height: 32px;
}
.voice-member:active { transform: scale(0.98); }
.voice-member:hover { background: var(--bg-elev-2); }
.mini-avatar {
  width: 22px; height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10.5px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  box-shadow: 0 0 0 2px transparent;
  transition: box-shadow 0.12s;
}
.voice-member.speaking .mini-avatar { box-shadow: 0 0 0 2px var(--success); }
.voice-member.speaking { color: var(--text-hi); }

/* user panel */
.user-panel {
  height: 54px;
  background: var(--bg-deep);
  display: flex;
  align-items: center;
  padding: 0 6px 0 10px;
  gap: 4px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.user-info {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 6px;
  border-radius: 8px;
  transition: var(--transition);
}
.user-info:active { transform: scale(0.98); }
.user-info:hover { background: var(--bg-elev-2); }
.user-avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 12px;
  color: #fff;
  background: var(--accent);
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(0,0,0,0.4);
}
.user-meta { min-width: 0; }
.user-name { 
  font-size: 12.5px; 
  font-weight: 600; 
  color: var(--text-hi);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-status { 
  font-size: 10.5px; 
  color: var(--success); 
  font-weight: 500; 
  white-space: nowrap; 
  overflow: hidden; 
  text-overflow: ellipsis; 
}
.user-controls { display: flex; gap: 2px; flex-shrink: 0; }
.icon-btn {
  width: 30px; height: 30px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: var(--text-mid);
  transition: var(--transition);
}
.icon-btn:active { transform: scale(0.92); }
.icon-btn:hover { background: var(--bg-elev-2); color: #fff; }
.icon-btn.off { color: var(--danger); }
.icon-btn.danger { color: var(--danger); }
.icon-btn.danger:active { transform: scale(0.9); }
.icon-btn.danger:hover { background: var(--danger); color: #fff; }

/* main content */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg-base);
  min-width: 0;
  position: relative;
}
.call-chat-layout {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  position: relative;
}
.call-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  position: relative;
  overflow: hidden;
}
.chat-area {
  height: 0;
  display: none;
  flex-direction: column;
  background: var(--bg-elev-1);
  border-top: 1px solid var(--border);
  min-height: 0;
  flex-shrink: 0;
}
.chat-area.open {
  height: 260px;
  display: flex;
  flex-shrink: 0;
  animation: slideUp 0.25s ease;
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.resize-handle {
  display: none;
  height: 6px;
  background: transparent;
  cursor: ns-resize;
  flex-shrink: 0;
  position: relative;
  z-index: 10;
  transition: background 0.15s;
  touch-action: none;
}
.resize-handle::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 40px;
  height: 3px;
  background: #3a3e46;
  border-radius: 4px;
  transition: background 0.15s;
}
.resize-handle:hover::after,
.resize-handle.active::after { background: var(--accent); }
.resize-handle.active { background: var(--accent-soft); }
.chat-area.open ~ .resize-handle { display: block; }
.resize-handle.dragging { background: var(--accent-soft); }
.resize-handle.dragging::after {
  background: var(--accent);
  width: 60px;
}

.chat-area .chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  font-weight: 600;
  font-size: 13px;
  color: var(--text-mid);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  min-height: 40px;
}
.chat-area .chat-header button {
  color: var(--text-dim);
  font-size: 16px;
  padding: 0 8px;
  border-radius: 6px;
  transition: var(--transition);
  min-height: 32px;
  min-width: 32px;
}
.chat-area .chat-header button:active { transform: scale(0.92); }
.chat-area .chat-header button:hover { color: var(--text-hi); background: var(--bg-elev-2); }
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 6px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-height: 0;
  -webkit-overflow-scrolling: touch;
}
.chat-messages .msg {
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-mid);
  display: flex;
  gap: 6px;
  align-items: baseline;
  padding: 2px 0;
  word-break: break-word;
}
.chat-messages .msg .author { font-weight: 600; color: var(--text-hi); }
.chat-messages .msg .time { color: var(--text-dim); font-size: 10px; flex-shrink: 0; }
.chat-messages .msg.sys {
  text-align: center;
  color: var(--text-dim);
  font-size: 12px;
  padding: 6px 0;
  justify-content: center;
}
.chat-input-row {
  display: flex;
  gap: 6px;
  padding: 6px 12px 10px;
  flex-shrink: 0;
  align-items: center;
  background: var(--bg-elev-1);
  border-top: 1px solid var(--border);
}
.chat-input-row input {
  flex: 1;
  background: var(--bg-deep);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  color: var(--text-hi);
  font-size: 14px;
  outline: none;
  font-family: 'Inter', sans-serif;
  transition: var(--transition);
  min-height: 38px;
  -webkit-appearance: none;
  appearance: none;
}
.chat-input-row input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.chat-input-row button {
  background: var(--accent);
  color: #fff;
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  transition: var(--transition);
  white-space: nowrap;
  min-height: 38px;
  min-width: 44px;
}
.chat-input-row button:active { transform: scale(0.95); }
.chat-input-row button:hover { background: var(--accent-hover); }
.chat-input-row .file-btn {
  background: transparent;
  color: var(--text-mid);
  font-size: 17px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  transition: var(--transition);
  min-height: 38px;
  min-width: 38px;
}
.chat-input-row .file-btn:active { transform: scale(0.92); }
.chat-input-row .file-btn:hover { background: var(--bg-elev-2); color: #fff; }
.chat-input-row .file-input { display: none; }

.content-header {
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 0 rgba(0,0,0,0.2);
  flex-shrink: 0;
  background: var(--bg-base);
  z-index: 2;
  gap: 8px;
}
.channel-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 14px;
  color: var(--text-hi);
  min-width: 0;
  flex: 1;
}
.channel-title span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.hamburger-btn {
  display: none;
  color: var(--text-mid);
  font-size: 20px;
  padding: 4px 6px;
  border-radius: 6px;
  transition: var(--transition);
  min-width: 32px;
  min-height: 32px;
}
.hamburger-btn:active { transform: scale(0.92); }
.hamburger-btn:hover { background: var(--bg-elev-2); color: var(--text-hi); }
.status-pill {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  padding: 4px 10px 4px 8px;
  border-radius: 20px;
  color: var(--text-dim);
  flex-shrink: 0;
  white-space: nowrap;
}
.status-pill::before {
  content: '👥';
  font-size: 10px;
  filter: grayscale(1) opacity(0.7);
}
.status-pill.online {
  background: var(--success-soft);
  border-color: rgba(35,165,90,0.28);
  color: var(--success);
}
.status-pill.online::before { filter: none; }
.header-actions { 
  display: flex; 
  gap: 2px; 
  align-items: center; 
  flex-shrink: 0;
}
.h-btn {
  width: 32px; height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  color: var(--text-mid);
  transition: var(--transition);
}
.h-btn:active { transform: scale(0.92); }
.h-btn:hover { background: var(--bg-elev-2); color: var(--text-hi); }
.h-btn.active { color: var(--success); background: var(--success-soft); }

.call-stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 16px 16px 88px;
  overflow: hidden;
  position: relative;
  min-height: 0;
  background:
    radial-gradient(800px 400px at 50% 0%, rgba(88,101,242,0.05), transparent 60%);
}
.avatar-grid, .video-grid {
  flex: 1;
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  align-content: center;
  min-height: 0;
}
.avatar-grid { display: grid; }
.video-grid { display: none; }
.video-grid.show { display: grid; }

.voice-tile {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(165deg, var(--bg-elev-2), var(--bg-elev-1));
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  min-height: 100px;
  transition: border-color 0.15s, box-shadow 0.15s;
  overflow: hidden;
  aspect-ratio: 1 / 1;
  max-height: 200px;
}
.voice-tile::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(140px 100px at 50% 38%, rgba(255,255,255,0.035), transparent 70%);
  pointer-events: none;
}
.voice-tile.speaking {
  border-color: var(--success);
  box-shadow: 0 0 0 1px var(--success), 0 0 20px rgba(35,165,90,0.18);
}
.big-avatar {
  width: 72px; height: 72px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  font-weight: 700;
  color: #fff;
  transition: var(--transition);
  box-shadow: 0 6px 20px rgba(0,0,0,0.4), 0 0 0 3px rgba(255,255,255,0.04);
}
.name-row {
  position: absolute;
  left: 10px; bottom: 10px;
  font-weight: 600;
  font-size: 11px;
  color: var(--text-hi);
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  padding: 4px 10px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  gap: 4px;
}
.video-wrap {
  position: relative;
  background: var(--bg-deep);
  border-radius: var(--radius-lg);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1.5px solid var(--border);
  min-height: 100px;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
  aspect-ratio: 16 / 9;
  max-height: 200px;
}
.video-wrap.speaking {
  border-color: var(--success);
  box-shadow: 0 0 0 1px var(--success), 0 0 20px rgba(35,165,90,0.18);
}
.video-wrap.fullscreen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  border-radius: 0;
  z-index: 9999;
  background: #000;
  border: none;
  aspect-ratio: auto;
  max-height: none;
}
.video-wrap.fullscreen .tag {
  font-size: 15px;
  padding: 6px 16px;
}
video {
  width: 100%; height: 100%;
  object-fit: contain;
  background: var(--bg-deep);
}
.video-wrap .tag {
  position: absolute;
  left: 10px; bottom: 10px;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-hi);
}
.sharing-banner {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--success-soft);
  border: 1px solid rgba(35,165,90,0.3);
  color: var(--success);
  padding: 6px 8px 6px 14px;
  border-radius: 40px;
  font-weight: 600;
  font-size: 12px;
  display: none;
  align-items: center;
  gap: 10px;
  z-index: 5;
  box-shadow: var(--shadow-soft);
  animation: fadeIn 0.3s ease;
  white-space: nowrap;
  max-width: 90%;
}
.sharing-banner button {
  background: rgba(255,255,255,0.08);
  color: var(--text-hi);
  padding: 3px 12px;
  border-radius: 30px;
  font-size: 11px;
  font-weight: 600;
  transition: var(--transition);
  min-height: 28px;
}
.sharing-banner button:active { transform: scale(0.95); }
.sharing-banner button:hover { background: rgba(255,255,255,0.16); }

/* Mobile participants count */
.mobile-participants {
  display: none;
  text-align: center;
  color: var(--text-dim);
  font-size: 12px;
  padding: 4px 0;
}

/* Controls */
.controls {
  position: absolute;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px;
  flex-shrink: 0;
  background: rgba(21,23,28,0.88);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-strong);
  border-radius: 28px;
  box-shadow: var(--shadow-strong);
  z-index: 6;
  padding-bottom: calc(8px + var(--safe-bottom));
}
.ctrl-btn {
  width: 42px; height: 42px;
  border-radius: 50%;
  background: var(--bg-elev-3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  color: var(--text-mid);
  transition: var(--transition);
  touch-action: manipulation;
}
.ctrl-btn:active { transform: scale(0.92); }
.ctrl-btn:hover { background: #33363d; color: #fff; transform: translateY(-2px); }
.ctrl-btn.active { background: var(--success-soft); color: var(--success); }
.ctrl-btn.off { background: var(--danger-soft); color: var(--danger); }
.ctrl-btn.hangup { 
  background: var(--danger); 
  color: #fff; 
  width: 42px; 
  margin-left: 4px;
  box-shadow: 0 4px 12px rgba(237,66,69,0.3);
}
.ctrl-btn.hangup:active { transform: scale(0.9); }
.ctrl-btn.hangup:hover { background: #ff4d4f; transform: translateY(-2px); }

.close-fullscreen {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 10000;
  background: rgba(0,0,0,0.6);
  border: 1px solid rgba(255,255,255,0.12);
  color: #fff;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  font-size: 18px;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  touch-action: manipulation;
}
.close-fullscreen:active { transform: scale(0.92); }
.close-fullscreen:hover {
  background: rgba(255,255,255,0.16);
  transform: scale(1.05);
}
.close-fullscreen.visible { display: flex; }

/* ========== RESPONSIVE ========== */

/* Tablets e telas médias */
@media (max-width: 900px) {
  .guild-rail { width: 48px; }
  .guild-icon { width: 34px; height: 34px; font-size: 16px; }
  .channel-sidebar { width: 200px; }
  .content-header { height: 44px; padding: 0 10px; }
  .channel-title { font-size: 13px; }
  .call-stage { padding: 12px 12px 80px; }
  .avatar-grid, .video-grid { gap: 10px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
  .big-avatar { width: 64px; height: 64px; font-size: 24px; }
  .controls { padding: 6px; gap: 5px; bottom: 12px; }
  .ctrl-btn { width: 38px; height: 38px; font-size: 15px; }
  .ctrl-btn.hangup { width: 38px; }
  .chat-area.open { height: 220px; }
}

/* Mobile */
@media (max-width: 600px) {
  .guild-rail { 
    width: 44px; 
    padding: 8px 0;
    border-right: none;
    background: var(--bg-base);
  }
  .guild-icon { 
    width: 30px; 
    height: 30px; 
    font-size: 14px;
    border-radius: 10px;
  }
  .mobile-menu-btn {
    display: flex !important;
    margin-top: auto;
    font-size: 18px;
    color: var(--text-mid);
  }
  .mobile-menu-btn:active { transform: scale(0.9); }

  .channel-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 280px;
    max-width: 80vw;
    transform: translateX(-100%);
    border-right: 1px solid var(--border-strong);
    box-shadow: var(--shadow-strong);
    z-index: 60;
    background: var(--bg-base);
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  .channel-sidebar.open {
    transform: translateX(0);
  }

  .hamburger-btn {
    display: flex !important;
  }

  .content-header {
    height: 44px;
    padding: 0 8px;
  }
  .channel-title { 
    font-size: 13px; 
    gap: 4px;
    min-width: 0;
  }
  .channel-title span:not(:first-child) {
    font-size: 11px;
  }
  .status-pill {
    font-size: 10px;
    padding: 3px 8px 3px 6px;
  }
  .status-pill::before { font-size: 9px; }
  .header-actions { gap: 0; }
  .h-btn { width: 30px; height: 30px; font-size: 15px; }

  .call-stage {
    padding: 10px 8px 74px;
  }
  .avatar-grid, .video-grid {
    gap: 8px;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
  }
  .voice-tile {
    min-height: 80px;
    max-height: 140px;
    aspect-ratio: 1 / 1;
  }
  .big-avatar {
    width: 52px;
    height: 52px;
    font-size: 20px;
  }
  .video-wrap {
    min-height: 80px;
    max-height: 140px;
    aspect-ratio: 16 / 9;
  }
  .name-row {
    font-size: 10px;
    padding: 3px 8px;
    left: 8px;
    bottom: 8px;
  }
  .video-wrap .tag {
    font-size: 10px;
    padding: 3px 8px;
    left: 8px;
    bottom: 8px;
  }

  .controls {
    padding: 6px;
    gap: 4px;
    bottom: 10px;
    border-radius: 24px;
    padding-bottom: calc(6px + var(--safe-bottom));
  }
  .ctrl-btn {
    width: 36px;
    height: 36px;
    font-size: 14px;
  }
  .ctrl-btn.hangup { width: 36px; }

  .chat-area.open { height: 180px; }
  .chat-area .chat-header {
    padding: 6px 12px;
    font-size: 12px;
    min-height: 34px;
  }
  .chat-messages { padding: 4px 10px; }
  .chat-messages .msg { font-size: 12.5px; }
  .chat-input-row {
    padding: 4px 10px 8px;
    gap: 4px;
  }
  .chat-input-row input {
    font-size: 13px;
    padding: 6px 10px;
    min-height: 34px;
  }
  .chat-input-row button {
    font-size: 12px;
    padding: 6px 12px;
    min-height: 34px;
    min-width: 38px;
  }
  .chat-input-row .file-btn {
    font-size: 15px;
    padding: 4px 6px;
    min-height: 34px;
    min-width: 34px;
  }

  .resize-handle { height: 4px; }
  .resize-handle::after { width: 30px; height: 2px; }

  .mobile-participants {
    display: block;
  }

  .sidebar-overlay.open {
    display: block;
  }

  .auth-card {
    padding: 24px 18px 20px;
    border-radius: var(--radius-md);
  }
  .auth-heading { font-size: 20px; }
  .auth-sub { font-size: 12.5px; margin: 4px 0 16px; }
  .field-row input[type="text"] {
    font-size: 14px;
    padding: 11px 14px;
    min-height: 44px;
  }
  .btn-secondary { min-height: 44px; font-size: 12.5px; padding: 0 14px; }
  .btn-primary { min-height: 44px; font-size: 14px; padding: 12px; }

  .close-fullscreen {
    width: 36px;
    height: 36px;
    font-size: 16px;
    top: 12px;
    right: 12px;
  }
}

/* Mobile muito pequeno */
@media (max-width: 380px) {
  .avatar-grid, .video-grid {
    grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
    gap: 6px;
  }
  .voice-tile { min-height: 70px; max-height: 110px; }
  .big-avatar { width: 44px; height: 44px; font-size: 17px; }
  .video-wrap { min-height: 70px; max-height: 110px; }
  .ctrl-btn { width: 32px; height: 32px; font-size: 12px; }
  .ctrl-btn.hangup { width: 32px; }
  .controls { gap: 3px; padding: 4px; border-radius: 20px; }
  .chat-area.open { height: 150px; }
  .channel-sidebar { width: 240px; max-width: 75vw; }
}

/* Landscape phone */
@media (max-height: 500px) and (orientation: landscape) {
  .call-stage { padding: 8px 12px 64px; }
  .avatar-grid, .video-grid {
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 6px;
  }
  .voice-tile { min-height: 70px; max-height: 120px; }
  .big-avatar { width: 48px; height: 48px; font-size: 18px; }
  .video-wrap { min-height: 70px; max-height: 120px; }
  .controls { bottom: 8px; padding: 4px 6px; gap: 4px; }
  .ctrl-btn { width: 32px; height: 32px; font-size: 13px; }
  .ctrl-btn.hangup { width: 32px; }
  .chat-area.open { height: 120px; }
  .content-header { height: 38px; padding: 0 8px; }
  .channel-title { font-size: 12px; }
  .user-panel { height: 44px; padding: 0 4px; }
  .user-avatar { width: 24px; height: 24px; font-size: 10px; }
}

/* Suporte para notch e safe areas */
@supports (padding: max(0px)) {
  .controls {
    padding-bottom: max(8px, env(safe-area-inset-bottom));
  }
  .channel-sidebar {
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
}

/* Dark mode scrollbar fix para Firefox */
* {
  scrollbar-color: #24262c transparent;
  scrollbar-width: thin;
}