@import url('https://fonts.googleapis.com/css2?family=Bricolage+Grotesque:opsz,wght@12..96,600;12..96,800&family=Plus+Jakarta+Sans:wght@400;500;600&display=swap');

/* ─── Design tokens ─── */
:root {
  --bg:        #07090D;
  --surface:   #0D1117;
  --surface-2: #13191F;
  --surface-3: #1A2229;
  --border:    rgba(255, 255, 255, 0.07);

  --accent:        #38BDF8;
  --accent-fg:     #07090D;
  --accent-dim:    rgba(56, 189, 248, 0.09);
  --accent-glow:   rgba(56, 189, 248, 0.22);
  --accent-border: rgba(56, 189, 248, 0.2);

  --danger:      #FF5454;
  --danger-fg:   #fff;
  --danger-dim:  rgba(255, 84, 84, 0.09);
  --danger-glow: rgba(255, 84, 84, 0.22);

  --text-1: #EBF0F5;
  --text-2: #7A8FA0;
  --text-3: #425060;

  --ff-display: 'Bricolage Grotesque', sans-serif;
  --ff-ui:      'Plus Jakarta Sans', sans-serif;

  --r-xs:   6px;
  --r-sm:   10px;
  --r-md:   14px;
  --r-lg:   20px;
  --r-xl:   28px;
  --r-full: 9999px;

  --accent-hover: rgba(56, 189, 248, 0.18);
  --signal-high: #4ade80;
  --signal-mid: #facc15;
  --signal-low: #f87171;
  --signal-inactive: #374151;
  --border-hover: rgba(255, 255, 255, 0.12);
  --overlay: rgba(0, 0, 0, 0.55);
  --warning: #FFBE5C;

  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --t: 0.18s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html { height: 100%; }

body {
  font-family: var(--ff-ui);
  background: var(--bg);
  color: var(--text-1);
  min-height: 100vh;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  line-height: 1.5;
}

/* ════════════════════════════════════
   HOME PAGE
════════════════════════════════════ */
.home-layout {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  position: relative;
  overflow: hidden;
}

.home-layout::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(
    ellipse 70% 55% at 50% 35%,
    rgba(56, 189, 248, 0.05) 0%,
    transparent 65%
  );
  pointer-events: none;
}

.home-inner {
  width: 100%;
  max-width: 380px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: relative;
}

.home-inner > * {
  animation: fade-up 0.4s var(--ease) both;
}
.home-inner > *:nth-child(2) { animation-delay: 0.07s; }
.home-inner > *:nth-child(3) { animation-delay: 0.14s; }

/* Brand */
.brand {
  text-align: center;
  padding: 8px 0 16px;
}

.brand-icon {
  color: var(--accent);
  display: flex;
  justify-content: center;
  margin-bottom: 14px;
}

.brand-name {
  font-family: var(--ff-display);
  font-size: 44px;
  font-weight: 800;
  letter-spacing: -1.5px;
  color: var(--text-1);
  line-height: 1;
  margin-bottom: 10px;
}

.brand-tagline {
  font-size: 14px;
  color: var(--text-3);
  letter-spacing: 0.02em;
}

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 20px;
}

.card-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.09em;
  margin-bottom: 14px;
}

/* Inputs */
.input-stack {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}

.input {
  width: 100%;
  padding: 12px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--text-1);
  font-family: var(--ff-ui);
  font-size: 15px;
  outline: none;
  transition: border-color var(--t), background var(--t);
  -webkit-appearance: none;
}

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

.input:focus {
  border-color: var(--accent-border);
  background: var(--surface-3);
}

.input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.input:-webkit-autofill,
.input:-webkit-autofill:hover,
.input:-webkit-autofill:focus {
  -webkit-box-shadow: 0 0 0 1000px var(--surface-2) inset;
  -webkit-text-fill-color: var(--text-1);
  caret-color: var(--text-1);
  border-color: var(--border);
  transition: background-color 9999s ease;
}

.input-code,
#nickname {
  text-align: center;
}

.input-code {
  font-family: var(--ff-display);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

/* Buttons */
.btn {
  width: 100%;
  padding: 13px 20px;
  border: none;
  border-radius: var(--r-sm);
  font-family: var(--ff-ui);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  outline: none;
  transition: transform var(--t), box-shadow var(--t), background var(--t);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.btn:active { transform: scale(0.97); }

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

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 28px var(--accent-glow);
}

.btn-secondary {
  background: var(--surface-2);
  color: var(--text-1);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--surface-3);
  transform: translateY(-1px);
}

#joinBtn {
  background: rgba(56, 189, 248, 0.1);
  border-color: var(--accent-border);
  color: var(--accent);
}

#joinBtn:hover {
  background: var(--accent-hover);
  box-shadow: 0 4px 20px var(--accent-glow);
  transform: translateY(-1px);
}

/* ════════════════════════════════════
   ROOM PAGE
════════════════════════════════════ */
.room-layout {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Top bar */
.room-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  height: 60px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 10;
}

.room-code-badge {
  display: flex;
  align-items: center;
  gap: 10px;
}

.badge-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.09em;
}

#shareCode {
  font-family: var(--ff-display);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--accent);
  cursor: pointer;
  padding: 4px 10px;
  border-radius: var(--r-xs);
  transition: background var(--t), transform var(--t);
  user-select: all;
}

#shareCode:hover  { background: var(--accent-dim); }
#shareCode:active { transform: scale(0.95); }

#shareCode.copied {
  background: var(--accent-hover);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Icon button */
.icon-btn {
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: var(--r-xs);
  background: var(--surface);
  color: var(--text-2);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--t), color var(--t), border-color var(--t);
  outline: none;
}

.icon-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.icon-btn:hover {
  background: var(--surface-2);
  color: var(--text-1);
  border-color: var(--border-hover);
}

.icon-btn svg { width: 18px; height: 18px; }

/* Room scroll area */
.room-main {
  flex: 1;
  overflow-y: auto;
  padding: 24px 16px;
  padding-bottom: 110px;
}

.section-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.09em;
  margin-bottom: 14px;
}

/* Participant cards */
#participantList {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

#participantList li {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 16px 12px 14px;
  flex: 1 1 130px;
  max-width: 180px;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  animation: card-in 0.24s var(--ease) both;
  transition: border-color var(--t);
}

#participantList li:hover {
  border-color: var(--border-hover);
}

#participantList li.participant-self {
  border-color: var(--accent-border);
}

.participant-row {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: 100%;
}

.avatar {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  flex-shrink: 0;
  position: relative;
}

@keyframes speaking-pulse {
  0%, 100% { transform: scale(1); opacity: 0.7; }
  50%       { transform: scale(1.12); opacity: 1; }
}

.avatar.speaking::after {
  content: "";
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  border: 2px solid var(--accent);
  box-shadow: 0 0 12px var(--accent-glow);
  animation: speaking-pulse 1.3s ease-in-out infinite;
  will-change: transform, opacity;
  pointer-events: none;
}

.nickname {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-1);
  text-align: center;
  max-width: 120px;
  word-break: break-word;
}

.you-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  opacity: 0.7;
}

.signal-bars {
  display: inline-flex;
  align-items: flex-end;
  gap: 1.5px;
  height: 14px;
  margin-left: 4px;
  vertical-align: middle;
}

.signal-bars svg {
  width: 16px;
  height: 14px;
}

.signal-bar {
  transition: fill 0.3s ease;
}

.signal-high .signal-bar.bar-1,
.signal-high .signal-bar.bar-2,
.signal-high .signal-bar.bar-3 {
  fill: var(--signal-high);
}

.signal-mid .signal-bar.bar-1,
.signal-mid .signal-bar.bar-2 {
  fill: var(--signal-mid);
}

.signal-mid .signal-bar.bar-3 {
  fill: var(--signal-inactive);
}

.signal-low .signal-bar.bar-1 {
  fill: var(--signal-low);
}

.signal-low .signal-bar.bar-2,
.signal-low .signal-bar.bar-3 {
  fill: var(--signal-inactive);
}

/* Volume control - always visible */
.volume-control {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.volume-control input[type="range"] {
  flex: 1;
  height: 3px;
  border-radius: 2px;
  appearance: none;
  -webkit-appearance: none;
  background: var(--surface-3);
  accent-color: var(--accent);
  outline: none;
  cursor: pointer;
  margin: 0;
  padding: 0;
  border: none;
}

.volume-control input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  transition: transform 0.1s;
}

.volume-control input[type="range"]:active::-webkit-slider-thumb {
  transform: scale(1.25);
}

.volume-control input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  border: none;
  cursor: pointer;
}

.volume-value {
  font-size: 10px;
  font-weight: 500;
  color: var(--text-3);
  min-width: 28px;
  text-align: right;
}

/* Bottom dock */
.bottom-dock {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 14px 16px;
  padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  background: linear-gradient(to top, var(--bg) 65%, transparent);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  z-index: 20;
}

.dock-btn {
  border: none;
  cursor: pointer;
  border-radius: var(--r-full);
  font-family: var(--ff-ui);
  font-weight: 600;
  outline: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  white-space: nowrap;
  transition: transform var(--t), box-shadow var(--t), background var(--t), color var(--t);
  min-height: 52px;
}

.dock-btn:active { transform: scale(0.95); }

.dock-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.dock-btn-mute {
  background: var(--accent);
  color: var(--accent-fg);
  padding: 14px 44px;
  font-size: 15px;
}

.dock-btn-mute:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 30px var(--accent-glow);
}

.dock-btn-mute.muted {
  background: var(--danger);
  color: var(--danger-fg);
}

.dock-btn-mute.muted:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 30px var(--danger-glow);
}

.dock-btn-leave {
  background: var(--surface-2);
  color: var(--text-2);
  border: 1px solid var(--border);
  padding: 14px 22px;
  font-size: 14px;
}

.dock-btn-leave:hover {
  background: var(--surface-3);
  color: var(--text-1);
  transform: translateY(-1px);
}

/* Status toast */
.status {
  position: fixed;
  top: 68px;
  left: 50%;
  transform: translateX(-50%) translateY(-8px);
  padding: 9px 18px;
  border-radius: var(--r-full);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s var(--ease), transform 0.2s var(--ease), visibility 0.2s;
  z-index: 100;
  pointer-events: none;
  border: 1px solid var(--border);
  max-width: calc(100vw - 32px);
  overflow: hidden;
  text-overflow: ellipsis;
}

.status.error {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
  background: rgba(255, 84, 84, 0.1);
  border-color: var(--danger-glow);
  color: #FF8080;
}

.status.success {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
  background: var(--accent-dim);
  border-color: var(--accent-border);
  color: var(--accent);
}

/* Accessibility */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* ════════════════════════════════════
   SETTINGS MODAL
════════════════════════════════════ */
.settings-modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--overlay);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.22s var(--ease), visibility 0.22s;
}

.settings-modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.settings-modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  width: 100%;
  max-width: 480px;
  max-height: 85vh;
  overflow-y: auto;
  overscroll-behavior: contain;
  box-shadow: 0 -12px 60px rgba(0, 0, 0, 0.5);
  transform: translateY(16px);
  transition: transform 0.22s var(--ease);
}

.settings-modal-overlay.active .settings-modal {
  transform: translateY(0);
}

/* Drag handle (mobile only) */
.settings-modal::before {
  content: '';
  display: block;
  width: 32px;
  height: 3px;
  background: var(--surface-3);
  border-radius: 2px;
  margin: 10px auto 0;
}

.settings-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
}

.settings-modal-header h2 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-1);
  margin: 0;
}

.settings-close-btn {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-2);
  width: 28px;
  height: 28px;
  border-radius: var(--r-xs);
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  transition: color var(--t), background var(--t);
  outline: none;
  padding: 0;
}

.settings-close-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.settings-close-btn:hover {
  background: var(--surface-3);
  color: var(--text-1);
}

.settings-modal-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* Groups */
.settings-group {
  display: flex;
  flex-direction: column;
}

.settings-group-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.09em;
  margin-bottom: 4px;
  padding: 0 2px;
}

/* Rows */
.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 52px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.settings-row:last-child {
  border-bottom: none;
}

.settings-row-label {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-1);
  flex-shrink: 0;
}

.settings-row-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.settings-row-column {
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
  min-height: auto;
  padding: 14px 0;
}

.settings-row-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.settings-row-value {
  font-size: 13px;
  color: var(--text-2);
  font-weight: 500;
}

.settings-select {
  padding: 8px 28px 8px 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--text-1);
  font-family: var(--ff-ui);
  font-size: 13px;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%237C907C' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  outline: none;
  transition: border-color var(--t);
  max-width: 180px;
}

.settings-select:focus {
  border-color: var(--accent-border);
}

.settings-select option {
  background: var(--surface-2);
  color: var(--text-1);
}

.settings-warning {
  background: var(--danger-dim);
  border: 1px solid rgba(255, 84, 84, 0.2);
  border-radius: var(--r-sm);
  padding: 12px;
  font-size: 13px;
  color: var(--danger);
}

/* Toggle switch */
.settings-toggle {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}

.settings-toggle input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.settings-toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}

.settings-toggle-slider::before {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  left: 2px;
  top: 2px;
  background: var(--text-2);
  border-radius: 50%;
  transition: transform 0.2s, background 0.2s;
}

.settings-toggle input:checked + .settings-toggle-slider {
  background: var(--accent-dim);
  border-color: var(--accent-border);
}

.settings-toggle input:checked + .settings-toggle-slider::before {
  transform: translateX(20px);
  background: var(--accent);
}

/* Slider */
.settings-slider {
  width: 100%;
  height: 4px;
  border-radius: 2px;
  background: var(--surface-3);
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  outline: none;
  accent-color: var(--accent);
}

.settings-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  transition: transform 0.1s;
}

.settings-slider::-webkit-slider-thumb:hover {
  transform: scale(1.15);
}

.settings-slider::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: none;
}

/* Mic permission */
.settings-mic-perm-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-2);
}

.settings-mic-perm-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--surface-3);
  flex-shrink: 0;
}

.settings-mic-perm-dot.granted { background: var(--accent); }
.settings-mic-perm-dot.denied  { background: var(--danger); }
.settings-mic-perm-dot.prompt  { background: var(--text-3); }

.settings-mic-perm-btn {
  padding: 6px 12px;
  font-size: 12px;
  background: var(--surface-2);
  color: var(--text-1);
  border: 1px solid var(--border);
  border-radius: var(--r-xs);
  cursor: pointer;
  font-family: var(--ff-ui);
  font-weight: 500;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background var(--t);
  outline: none;
}

.settings-mic-perm-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.settings-mic-perm-btn:hover {
  background: var(--surface-3);
}

.settings-mic-perm-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Ping */
.settings-ping-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 11px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
}

.settings-ping-label {
  font-size: 13px;
  color: var(--text-2);
  font-weight: 500;
}

.settings-ping-value {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-3);
  font-family: var(--ff-display);
}

.settings-ping-value.good { color: var(--accent); }
.settings-ping-value.ok   { color: var(--warning); }
.settings-ping-value.bad  { color: var(--danger); }

/* ════════════════════════════════════
   CHAT PANEL
════════════════════════════════════ */
.chat-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 320px;
  background: var(--surface);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 50;
  transform: translateX(100%);
  transition: transform 0.25s var(--ease);
}

.chat-panel.open {
  transform: translateX(0);
}

.chat-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  height: 60px;
}

.chat-panel-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-1);
}

.chat-close-btn {
  width: 28px;
  height: 28px;
  border-radius: var(--r-xs);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  transition: color var(--t), background var(--t);
  outline: none;
  padding: 0;
}

.chat-close-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.chat-close-btn:hover {
  background: var(--surface-3);
  color: var(--text-1);
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  position: relative;
}

.chat-msg {
  display: flex;
  gap: 10px;
  padding: 2px 0;
}

.chat-msg-grouped {
  padding-left: 46px;
}

.chat-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  color: #fff;
  margin-top: 2px;
}

.chat-msg-body {
  flex: 1;
  min-width: 0;
}

.chat-msg-header {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.chat-msg-nick {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.375;
}

.chat-msg-time {
  font-size: 11px;
  color: var(--text-3);
  line-height: 1.375;
}

.chat-msg-text {
  font-size: 14px;
  color: var(--text-1);
  word-break: break-word;
  line-height: 1.375;
}

.chat-msg-text code {
  background: var(--surface-3);
  padding: 2px 6px;
  border-radius: var(--r-xs);
  font-size: 13px;
  font-family: var(--ff-mono, monospace);
}

.chat-msg-text a {
  color: var(--accent);
  text-decoration: none;
}

.chat-msg-text a:hover {
  text-decoration: underline;
}

.chat-system-msg {
  text-align: center;
  padding: 4px 0;
}

.chat-system-msg span {
  font-size: 12px;
  color: var(--text-3);
  background: var(--surface-2);
  padding: 3px 12px;
  border-radius: var(--r-full);
}

.chat-date-separator {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
}

.chat-date-separator::before,
.chat-date-separator::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.chat-date-separator span {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-3);
  white-space: nowrap;
}

.chat-scroll-bottom {
  position: absolute;
  bottom: 60px;
  right: 16px;
  width: 36px;
  height: 36px;
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: 50%;
  display: none;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  z-index: 1;
  transition: background var(--t);
}

.chat-scroll-bottom:hover {
  background: var(--surface-2);
}

.chat-scroll-bottom.visible {
  display: flex;
}

.chat-scroll-bottom svg {
  color: var(--text-2);
}

.chat-input-area {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.chat-input {
  flex: 1;
  padding: 10px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--text-1);
  font-family: var(--ff-ui);
  font-size: 13px;
  outline: none;
  transition: border-color var(--t), background var(--t);
  -webkit-appearance: none;
}

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

.chat-input:focus {
  border-color: var(--accent-border);
  background: var(--surface-3);
}

.chat-send-btn {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: var(--r-sm);
  background: var(--accent);
  color: var(--accent-fg);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform var(--t), box-shadow var(--t);
  outline: none;
}

.chat-send-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.chat-send-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px var(--accent-glow);
}

.chat-send-btn:active {
  transform: scale(0.95);
}

/* Chat button in dock */
.dock-btn-chat {
  background: var(--surface-2);
  color: var(--text-2);
  border: 1px solid var(--border);
  padding: 14px 22px;
  font-size: 14px;
  position: relative;
}

.dock-btn-chat:hover {
  background: var(--surface-3);
  color: var(--text-1);
  transform: translateY(-1px);
}

.dock-btn-chat.active {
  background: var(--accent-dim);
  border-color: var(--accent-border);
  color: var(--accent);
}

/* Unread badge */
.chat-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--danger);
  color: var(--danger-fg);
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  pointer-events: none;
}

/* Chat responsive */
@media (max-width: 639px) {
  .chat-panel {
    width: 100%;
  }
}

/* ════════════════════════════════════
   ANIMATIONS
════════════════════════════════════ */
@keyframes fade-up {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes card-in {
  from { opacity: 0; transform: scale(0.92) translateY(8px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ════════════════════════════════════
   RESPONSIVE
════════════════════════════════════ */
@media (min-width: 480px) {
  .settings-modal-overlay {
    align-items: center;
  }

  .settings-modal {
    border-bottom: 1px solid var(--border);
    border-radius: var(--r-xl);
    transform: scale(0.95) translateY(8px);
  }

  .settings-modal::before {
    display: none;
  }

  .settings-modal-overlay.active .settings-modal {
    transform: scale(1) translateY(0);
  }
}

@media (min-width: 640px) {
  .room-topbar  { padding: 0 24px; }
  .room-main    { padding: 28px 24px; padding-bottom: 110px; }
  .bottom-dock  { padding: 20px 24px; padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px)); }

  #participantList li {
    flex: 1 1 130px;
    max-width: 180px;
  }

  .dock-btn-chat {
    padding: 14px 30px;
  }
}
