:root {
  color-scheme: dark;
  --bg: #111827;
  --panel: #1f2937;
  --panel-alt: #0f172a;
  --border: #374151;
  --text: #f3f4f6;
  --muted: #9ca3af;
  --accent: #60a5fa;
  --accent-hover: #3b82f6;
  --danger: #ef4444;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Arial, sans-serif;
  background: linear-gradient(135deg, #0b1020, #111827 45%, #1f2937);
  color: var(--text);
}

.username-fancy,
.video-label,
#authStatus,
.room-entry summary,
.room-entry li,
#incomingCallText {
  font-family: 'Trebuchet MS', 'Segoe UI', Verdana, sans-serif;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-shadow: 0 0 10px rgba(96, 165, 250, 0.18);
}

.username-fancy {
  color: #93c5fd;
  text-transform: capitalize;
}

button,
input,
select {
  font: inherit;
}

input[type='range'] {
  width: 100%;
}

.app-shell {
  display: grid;
  grid-template-columns: 320px 1fr;
  min-height: 100vh;
  gap: 16px;
  padding: 16px;
}

.panel {
  background: rgba(17, 24, 39, 0.92);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.25);
}

.setup-panel,
.room-panel,
.chat-panel,
.device-panel,
.auth-panel,
.room-list-panel,
.friend-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.subtitle,
#roomMeta,
.status-box,
label {
  color: var(--muted);
}

label {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

input,
select,
button,
.file-picker-label {
  border-radius: 10px;
  border: 1px solid var(--border);
}

input,
select {
  padding: 10px 12px;
  background: var(--panel-alt);
  color: var(--text);
}

button,
.file-picker-label {
  background: var(--accent);
  color: white;
  padding: 10px 14px;
  cursor: pointer;
  border: none;
  font-weight: 600;
  text-align: center;
}

button:hover,
.file-picker-label:hover {
  background: var(--accent-hover);
}

button.active-toggle {
  background: #2563eb;
}

.button-row,
.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.status-box,
.warning-box {
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
}

.warning-box {
  border-color: #f59e0b;
  color: #fde68a;
}

#incomingCallBox {
  border-color: #22c55e;
  color: #dcfce7;
}

#incomingCallLink {
  display: inline-block;
  margin-top: 8px;
  color: #93c5fd;
}

.video-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
}

.video-card {
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

.video-card.speaking {
  border-color: #22c55e;
  box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.25);
}

.video-label {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  text-transform: uppercase;
  transition: color 120ms ease, background 120ms ease;
}

.video-card.speaking .video-label {
  color: #dcfce7;
  background: rgba(20, 83, 45, 0.55);
}

video,
.video-placeholder {
  width: 100%;
  aspect-ratio: 16 / 9;
  background: black;
}

video {
  display: block;
}

.video-placeholder {
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 4rem;
  color: #cbd5e1;
  background: radial-gradient(circle at center, #1e293b, #020617);
}

.video-card.placeholder-only .video-placeholder {
  display: flex;
}

.video-card.placeholder-only video {
  display: none;
}

.messages {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 180px;
  max-height: 280px;
  overflow-y: auto;
}

.chat-compose-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
}

/* Image attachments (room chat + DMs) */
.attach-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px 0;
}
.attach-thumb {
  position: relative;
}
.attach-thumb img {
  display: block;
  height: 56px;
  width: auto;
  max-width: 120px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--border);
}
.attach-remove {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 20px;
  height: 20px;
  padding: 0;
  border-radius: 50%;
  background: var(--danger);
  color: #fff;
  font-size: 12px;
  line-height: 1;
  border: none;
  cursor: pointer;
}
.attach-button {
  padding: 0 10px;
  font-size: 1.1rem;
  line-height: 1;
}
.drag-over {
  outline: 2px dashed var(--accent, #16a34a);
  outline-offset: -4px;
  border-radius: 10px;
}
.chat-img-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}
.chat-img {
  display: block;
  max-width: 220px;
  max-height: 220px;
  border-radius: 8px;
  border: 1px solid var(--border);
  cursor: pointer;
}

.range-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
}

.device-note {
  color: var(--muted);
  font-size: 0.92rem;
}

.message {
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(31, 41, 55, 0.9);
  border: 1px solid var(--border);
}

.message a {
  color: #93c5fd;
}

.room-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 220px;
  overflow-y: auto;
}

.room-entry {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(31, 41, 55, 0.9);
  padding: 10px 12px;
}

.room-entry summary {
  cursor: pointer;
  font-weight: 600;
}

.room-entry ul {
  margin: 8px 0 0;
  padding-left: 18px;
  color: var(--muted);
}

.room-entry button {
  margin-top: 10px;
  width: 100%;
  text-align: left;
  background: rgba(55, 65, 81, 0.95);
  border: 1px solid var(--border);
}

.room-entry button:hover {
  background: rgba(75, 85, 99, 0.95);
}

.file-picker-label input {
  display: none;
}

.hidden {
  display: none !important;
}

/* Friends: clickable row + dropdown menu + unread badge */
.friend-entry {
  margin-bottom: 6px;
}
.friend-head {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  text-align: left;
  background: var(--panel-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  color: var(--text);
  cursor: pointer;
}
.friend-head:hover {
  background: rgba(75, 85, 99, 0.55);
}
.presence-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex: 0 0 auto;
  background: #6b7280;
}
.presence-dot.active {
  background: #22c55e;
  box-shadow: 0 0 6px rgba(34, 197, 94, 0.7);
}
.presence-dot.away {
  background: #eab308;
  box-shadow: 0 0 6px rgba(234, 179, 8, 0.7);
}
.presence-dot.offline {
  background: #ef4444;
}
.dm-badge {
  margin-left: auto;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  background: var(--danger);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.friend-menu {
  display: flex;
  gap: 6px;
  padding: 6px 0 2px;
}
.friend-menu button {
  flex: 1;
  padding: 7px 8px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
  font-size: 13px;
}
.friend-menu button:hover {
  background: rgba(75, 85, 99, 0.95);
}

/* DM modal */
.dm-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.dm-window {
  width: min(540px, 92vw);
  height: min(620px, 88vh);
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}
.dm-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}
.dm-close {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 18px;
  cursor: pointer;
}
.dm-close:hover {
  color: var(--text);
}
.dm-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.dm-msg {
  display: flex;
  max-width: 80%;
}
.dm-msg-me {
  align-self: flex-end;
}
.dm-msg-them {
  align-self: flex-start;
}
.dm-msg-text {
  padding: 8px 11px;
  border-radius: 12px;
  background: var(--panel-alt);
  border: 1px solid var(--border);
  word-break: break-word;
}
.dm-msg-me .dm-msg-text {
  background: #16a34a;
  border-color: #15803d;
  color: #f0fdf4;
}
.dm-compose-row {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--border);
}
.dm-compose-row input {
  flex: 1;
}

/* Avatars (square user icons) */
.avatar-img {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  object-fit: cover;
  flex: 0 0 auto;
  background: var(--panel-alt);
  border: 1px solid var(--border);
}
.avatar-fallback {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  color: var(--muted);
  text-transform: uppercase;
}
.avatar-lg {
  width: 48px;
  height: 48px;
  border-radius: 8px;
}
.avatar-xl {
  width: 84px;
  height: 84px;
  border-radius: 12px;
}
.avatar-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 8px 0;
}
.video-label {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Shared-screen viewing controls (pop-out / fullscreen) */
.video-card {
  position: relative;
}
.video-controls {
  position: absolute;
  top: 8px;
  right: 8px;
  display: flex;
  gap: 6px;
  opacity: 0;
  transition: opacity 120ms ease;
  z-index: 5;
}
.video-card:hover .video-controls {
  opacity: 1;
}
.video-ctrl-btn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: rgba(15, 23, 42, 0.85);
  color: var(--text);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
}
.video-ctrl-btn:hover {
  background: rgba(37, 99, 235, 0.85);
}

/* Admin panel */
.admin-window {
  width: min(820px, 95vw);
  height: min(82vh, 760px);
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}
.admin-login {
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.admin-hint {
  color: var(--muted);
  font-size: 13px;
}
.admin-chat {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.admin-warn {
  background: #7f1d1d;
  color: #fff;
  font-size: 12px;
  padding: 7px 12px;
}
.admin-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.admin-msg {
  white-space: pre-wrap;
  word-break: break-word;
  padding: 9px 12px;
  border-radius: 10px;
  font-size: 13px;
  line-height: 1.4;
}
.admin-user {
  align-self: flex-end;
  max-width: 85%;
  background: #1d4ed8;
  color: #fff;
}
.admin-claude {
  align-self: flex-start;
  background: var(--panel-alt);
  border: 1px solid var(--border);
  font-family: 'Cascadia Code', 'Consolas', monospace;
}
.admin-compose {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--border);
}
.admin-attachments {
  flex-basis: 100%;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.admin-attachment {
  position: relative;
}
.admin-attachment img {
  display: block;
  height: 56px;
  width: auto;
  max-width: 120px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--border);
}
.admin-attachment-remove {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 20px;
  height: 20px;
  padding: 0;
  border-radius: 50%;
  background: var(--danger);
  color: #fff;
  font-size: 12px;
  line-height: 1;
  border: none;
  cursor: pointer;
}
.admin-msg-img {
  display: block;
  margin-top: 6px;
  max-width: 100%;
  max-height: 240px;
  border-radius: 8px;
  border: 1px solid var(--border);
}
.admin-compose textarea {
  flex: 1;
  resize: none;
  height: 64px;
  font-family: inherit;
}
.admin-compose-buttons {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* Update status pill: green dot = up to date, red (pulsing) = update available */
.update-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}
.update-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 6px rgba(34, 197, 94, 0.7);
}
.update-pill.update-available {
  background: #7f1d1d;
  border-color: #ef4444;
  color: #fff;
}
.update-pill.update-available .update-dot {
  background: #ef4444;
  box-shadow: 0 0 7px rgba(239, 68, 68, 0.9);
  animation: updatePulse 1.2s ease-in-out infinite;
}
@keyframes updatePulse {
  50% {
    opacity: 0.35;
  }
}

/* Detachable panels: each panel can pop into a floating, movable, resizable window */
.auth-panel,
.friend-panel,
.room-list-panel,
.device-panel,
.room-panel,
.chat-panel {
  position: relative;
  resize: both;
  overflow: auto;
  min-width: 200px;
  min-height: 90px;
}
/* Room + Chat: shrink content to fit on resize (no panel scrollbars) */
.room-panel,
.chat-panel {
  overflow: hidden;
}
.room-panel .video-grid {
  min-height: 0;
  overflow: hidden;
}
.room-panel .video-card,
.room-panel .chat-panel {
  min-height: 0;
}
.chat-panel .messages {
  min-height: 0;
  max-height: none;
  flex: 1;
}
.detach-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  z-index: 6;
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: rgba(15, 23, 42, 0.8);
  color: var(--muted);
  cursor: pointer;
  opacity: 0.55;
  transition: opacity 120ms ease;
}
.detach-btn:hover {
  opacity: 1;
  color: var(--text);
}
.detached {
  cursor: move;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.55);
  outline: 1px solid var(--accent);
}
.docked {
  box-shadow: 0 6px 22px rgba(0, 0, 0, 0.4);
  outline: 1px solid var(--border);
}
.docked .detach-btn {
  opacity: 0.85;
}
.detached .detach-btn {
  opacity: 1;
  background: var(--accent);
  color: #04122b;
  border-color: var(--accent);
}

/* Remote-control banner (fixed top, role-colored) */
.control-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 2000;
  text-align: center;
  padding: 8px 14px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #fff;
}
.control-banner-host {
  background: #b91c1c;
}
.control-banner-ctrl {
  background: #15803d;
}

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 1fr;
  }
}

/* ---- Login / register gate (full-screen when logged out) ---- */
.auth-gate {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: radial-gradient(circle at 50% 28%, #0b1224, #05070d 80%);
}
.auth-gate.hidden { display: none; }
.auth-card {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
}
.auth-hero {
  position: relative;
  height: 190px;
  background: linear-gradient(180deg, #0a1b3a 0%, #0b2a4a 45%, #0d3a55 100%);
  border-top: 3px solid var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.auth-hero-stars {
  position: absolute;
  inset: 0;
  opacity: 0.85;
  background-image:
    radial-gradient(1px 1px at 20% 30%, #fff, transparent),
    radial-gradient(1px 1px at 70% 20%, #cfe3ff, transparent),
    radial-gradient(1.5px 1.5px at 40% 70%, #fff, transparent),
    radial-gradient(1px 1px at 85% 55%, #bcd4ff, transparent),
    radial-gradient(1px 1px at 55% 45%, #fff, transparent),
    radial-gradient(1px 1px at 10% 80%, #e6efff, transparent),
    radial-gradient(1.5px 1.5px at 90% 15%, #fff, transparent),
    radial-gradient(1px 1px at 30% 50%, #dbe7ff, transparent);
}
.auth-brand { position: relative; display: flex; align-items: center; gap: 12px; }
.auth-logo { width: 54px; height: 54px; filter: drop-shadow(0 0 12px rgba(120, 224, 208, 0.55)); }
.auth-wordmark { font-size: 34px; font-weight: 300; color: #fff; letter-spacing: 0.5px; }
.auth-wordmark strong { font-weight: 800; }
.auth-body { padding: 22px 28px 28px; display: flex; flex-direction: column; gap: 14px; }
.auth-tabs { display: flex; gap: 4px; margin-bottom: 2px; }
.auth-tab {
  flex: 1;
  padding: 8px;
  background: transparent;
  color: var(--muted);
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  font-weight: 600;
}
.auth-tab.active { color: var(--text); border-bottom-color: var(--accent); }
.auth-field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.auth-field input {
  padding: 12px;
  background: var(--panel-alt);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  outline: none;
}
.auth-field input:focus { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(96, 165, 250, 0.25); }
.auth-pass-wrap { position: relative; display: flex; }
.auth-pass-wrap input { flex: 1; padding-right: 40px; }
.auth-eye {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 16px;
}
.auth-note { display: flex; gap: 8px; align-items: center; font-size: 12px; color: var(--muted); }
.auth-note-icon {
  flex: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--border);
  color: var(--text);
  display: grid;
  place-items: center;
  font-style: italic;
  font-size: 12px;
}
.auth-error { min-height: 16px; font-size: 13px; color: var(--danger); }
.auth-submit {
  margin-top: 4px;
  padding: 13px;
  background: var(--accent-hover);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
}
.auth-submit:hover { background: var(--accent); }
.auth-submit:disabled { opacity: 0.6; cursor: default; }

/* Update pill download progress bar */
.update-pill { position: relative; overflow: hidden; }
.update-pill.updating {
  background: #1e3a5f;
  border-color: var(--accent);
  color: #fff;
}
.update-progress {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
  background: rgba(255, 255, 255, 0.18);
  display: none;
}
.update-pill.updating .update-progress { display: block; }
#updateProgressFill {
  display: block;
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width 0.2s ease;
}

/* Floating, resizable shared-screen pop-out (drag by the title bar) */
.video-card.video-floating {
  position: fixed;
  z-index: 80;
  display: flex;
  flex-direction: column;
  width: 480px;
  height: 320px;
  min-width: 240px;
  min-height: 160px;
  resize: both;
  overflow: hidden;
  border-color: var(--accent);
  box-shadow: 0 14px 48px rgba(0, 0, 0, 0.6);
}
.video-card.video-floating .video-label {
  cursor: move;
  flex: 0 0 auto;
}
.video-card.video-floating video,
.video-card.video-floating .video-placeholder {
  flex: 1 1 auto;
  width: 100%;
  height: auto;
  min-height: 0;
  aspect-ratio: auto;
  object-fit: contain;
}

/* Account & Settings drawer (hamburger) */
.settings-fab {
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 90;
  width: 40px;
  height: 40px;
  font-size: 20px;
  line-height: 1;
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  cursor: pointer;
}
.settings-fab:hover { border-color: var(--accent); color: #fff; }
.settings-window {
  width: min(440px, 100%);
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
}
.settings-body {
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.settings-section {
  background: var(--panel-alt);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
}
.settings-section h3 { margin: 0 0 10px; font-size: 15px; }
.settings-section > label { display: block; margin-bottom: 10px; }
/* neutralize the moved .panel styling/resize inside the drawer */
.settings-section .panel { resize: none; background: transparent; border: none; padding: 0; min-width: 0; min-height: 0; overflow: visible; }

.stop-share-btn { background: #7f1d1d; border-color: #ef4444; color: #fff; }
.stop-share-btn:hover { background: #991b1b; }

.video-close-btn { display: none; }
.video-card.video-floating .video-close-btn { display: inline-flex; color: #fca5a5; }
.video-shortcuts { display: none; }
.video-card.video-floating .video-shortcuts {
  display: block;
  flex: 0 0 auto;
  padding: 5px 8px;
  font-size: 11px;
  color: var(--muted);
  background: var(--panel-alt);
  border-top: 1px solid var(--border);
  text-align: center;
}

.video-card.video-maximized {
  position: fixed;
  inset: 0;
  z-index: 200;
  width: 100vw;
  height: 100vh;
  border-radius: 0;
  display: flex;
  flex-direction: column;
}
.video-card.video-maximized video,
.video-card.video-maximized .video-placeholder {
  flex: 1 1 auto;
  width: 100%;
  height: auto;
  min-height: 0;
  aspect-ratio: auto;
  object-fit: contain;
  background: #000;
}

/* ── Gray AI voice chat ──────────────────────────────────────── */
.gray-fab {
  right: 60px; /* offset left of the settings button */
}

.gray-window {
  width: min(480px, 100%);
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border-radius: 12px;
  overflow: hidden;
}

.gray-messages {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 120px;
  max-height: 340px;
}

.gray-msg {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-width: 85%;
}
.gray-msg--user { align-self: flex-end; align-items: flex-end; }
.gray-msg--gray { align-self: flex-start; align-items: flex-start; }

.gray-msg-label {
  font-size: 0.7rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.gray-msg-body {
  padding: 8px 12px;
  border-radius: 14px;
  font-size: 0.9rem;
  line-height: 1.4;
  word-break: break-word;
}
.gray-msg--user .gray-msg-body {
  background: var(--accent);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.gray-msg--gray .gray-msg-body {
  background: var(--panel-alt);
  color: var(--text);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}

.gray-status {
  padding: 6px 14px;
  font-size: 0.78rem;
  color: var(--muted);
  border-top: 1px solid var(--border);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.gray-compose {
  padding: 10px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.gray-talk-btn {
  width: 100%;
  padding: 14px;
  font-size: 1rem;
  font-weight: 600;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  border: 2px solid transparent;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  user-select: none;
  -webkit-user-select: none;
}
.gray-talk-btn:hover:not(:disabled) { background: var(--accent-hover); }
.gray-talk-btn.gray-talk-active {
  background: var(--danger);
  transform: scale(0.98);
  box-shadow: 0 0 12px rgba(239,68,68,0.5);
}
.gray-talk-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.gray-text-row {
  display: flex;
  gap: 6px;
}
.gray-text-row input {
  flex: 1 1 auto;
  padding: 6px 10px;
  border-radius: 8px;
  background: var(--panel-alt);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 0.85rem;
}
.gray-text-row input:focus {
  outline: none;
  border-color: var(--accent);
}
.gray-text-row button {
  padding: 6px 12px;
  border-radius: 8px;
  background: var(--panel-alt);
  color: var(--muted);
  border: 1px solid var(--border);
  cursor: pointer;
  font-size: 0.85rem;
}
.gray-text-row button:hover { border-color: var(--accent); color: var(--text); }

.gray-stop {
  padding: 4px 10px;
  border-radius: 6px;
  background: var(--danger);
  color: #fff;
  border: none;
  cursor: pointer;
  font-size: 0.78rem;
  margin-right: auto;
}
.gray-stop:hover { opacity: 0.85; }

/* ── Gray speech bubble & wake word ────────────────────── */
.gray-bubble {
  position: fixed;
  top: 58px;
  right: 60px;
  max-width: 260px;
  background: var(--panel);
  border: 1px solid var(--accent);
  border-radius: 12px 12px 4px 12px;
  padding: 8px 12px;
  font-size: 0.82rem;
  color: var(--text);
  line-height: 1.4;
  z-index: 91;
  opacity: 0;
  transform: translateY(-4px) scale(0.95);
  transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: none;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
}
.gray-bubble--show {
  opacity: 1;
  transform: translateY(0) scale(1);
}
.gray-bubble::after {
  content: '';
  position: absolute;
  bottom: -7px;
  right: 14px;
  width: 12px;
  height: 12px;
  background: var(--panel);
  border-right: 1px solid var(--accent);
  border-bottom: 1px solid var(--accent);
  transform: rotate(45deg);
}

/* Paw button pulsing when wake word is active */
@keyframes gray-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(96,165,250,0.5); }
  50%       { box-shadow: 0 0 0 6px rgba(96,165,250,0); }
}
.gray-fab--listening {
  border-color: var(--accent) !important;
  animation: gray-pulse 1.6s ease infinite;
}

/* Wake word toggle button */
.gray-wake-toggle {
  padding: 4px 10px;
  border-radius: 6px;
  background: var(--panel-alt);
  color: var(--muted);
  border: 1px solid var(--border);
  cursor: pointer;
  font-size: 0.75rem;
  margin-right: auto;
  white-space: nowrap;
}
.gray-wake-toggle:hover { border-color: var(--accent); color: var(--text); }
