/* ===== CSS Variables (Light theme default) ===== */
:root {
  --bg: #f5f6fa;
  --bg-card: #ffffff;
  --bg-input: #f0f1f5;
  --text: #1a1a2e;
  --text-secondary: #6b7280;
  --border: #e5e7eb;
  --primary: #4F6EF7;
  --primary-hover: #3d5ce5;
  --accent: #FF6B6B;
  --online: #22c55e;
  --offline: #ef4444;
  --msg-self: #4F6EF7;
  --msg-self-text: #ffffff;
  --msg-other: #e8eaf0;
  --msg-other-text: #1a1a2e;
  --shadow: 0 1px 3px rgba(0,0,0,0.08);
  --radius: 10px;
  --transition: 0.2s ease;
}

/* ===== Dark theme ===== */
.dark {
  --bg: #0f0f1a;
  --bg-card: #1a1a2e;
  --bg-input: #252540;
  --text: #e5e7eb;
  --text-secondary: #9ca3af;
  --border: #2d2d45;
  --msg-other: #252540;
  --msg-other-text: #e5e7eb;
  --shadow: 0 1px 3px rgba(0,0,0,0.3);
}

/* ===== Reset ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  transition: background var(--transition), color var(--transition);
}

/* ===== Views ===== */
.view { display: flex; flex-direction: column; height: 100vh; }
.view.hidden { display: none; }
.hidden { display: none; }

/* ===== Header ===== */
.header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.logo {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: -0.5px;
}
.slogan { font-size: 0.8rem; color: var(--text-secondary); flex: 1; }

/* ===== Buttons ===== */
.btn, .btn-icon, .btn-text {
  cursor: pointer; border: none; outline: none;
  transition: all var(--transition);
  font-family: inherit;
}
.btn {
  padding: 8px 20px;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 500;
  background: var(--bg-input);
  color: var(--text);
}
.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover { background: var(--primary-hover); }
.btn-icon {
  font-size: 1.2rem;
  background: none;
  padding: 4px 8px;
  border-radius: 6px;
}
.btn-icon:hover { background: var(--bg-input); }
.btn-text {
  background: none;
  color: var(--primary);
  font-size: 0.85rem;
  padding: 4px 8px;
}
.btn-text:hover { opacity: 0.8; }

/* ===== Lobby ===== */
.nickname-section {
  display: flex;
  gap: 10px;
  padding: 16px 20px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
}
.nickname-section input { flex: 1; }

/* Lobby tabs */
.lobby-tabs { display: flex; gap: 0; border-bottom: 1px solid var(--border); background: var(--bg-card); }
.lobby-tab {
  flex: 1; padding: 10px 16px; border: none; background: transparent;
  color: var(--text-secondary); font-size: 0.9rem; cursor: pointer;
  border-bottom: 2px solid transparent; transition: all 0.2s;
}
.lobby-tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }

/* Workshop game list */
.workshop-section {
  flex: 1;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
}
.workshop-section.hidden { display: none; }
.game-list { display: flex; flex-direction: column; gap: 8px; flex: 1; overflow-y: auto; }
.workshop-bottom {
  flex-shrink: 0;
  padding: 12px 0 0;
  border-top: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 6px;
}
.workshop-bottom .hint { margin: 0; padding: 0; }
.workshop-bottom .workshop-search { margin: 0; }
.workshop-search { flex-shrink: 0; }
.workshop-search input { width: 100%; padding: 8px 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-input); color: var(--text); font-size: 0.85rem; outline: none; }
.workshop-search input:focus { border-color: var(--primary); }
.game-card {
  display: flex; align-items: center; gap: 12px; padding: 10px 14px;
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  cursor: pointer; transition: border-color 0.15s;
}
.game-card:hover { border-color: var(--primary); }
.game-card .game-icon { font-size: 1.5rem; flex-shrink: 0; }
.game-card .game-info { flex: 1; min-width: 0; }
.game-card .game-title { font-weight: 600; font-size: 0.9rem; }
.game-card .game-meta { font-size: 0.75rem; color: var(--text-secondary); margin-top: 2px; }
.game-card .game-players { font-size: 0.8rem; color: var(--primary); font-weight: 600; flex-shrink: 0; }
.game-report-btn { background: none; border: none; color: var(--text-secondary); cursor: pointer; font-size: 0.75rem; padding: 2px 4px; flex-shrink: 0; opacity: 0.4; transition: opacity 0.15s; }
.game-report-btn:hover { opacity: 1; color: var(--accent); }

/* Upload form */
/* Publish modal */
.publish-overlay { position: fixed; inset: 0; z-index: 200; background: rgba(0,0,0,0.5); display: flex; align-items: center; justify-content: center; }
.publish-overlay.hidden { display: none; }
.publish-modal { background: var(--bg-card); border-radius: var(--radius); padding: 20px 24px; width: 380px; max-height: 90vh; overflow-y: auto; box-shadow: 0 8px 30px rgba(0,0,0,0.3); display: flex; flex-direction: column; gap: 10px; }
.publish-modal input, .publish-modal textarea { width: 100%; padding: 8px 12px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg-input); color: var(--text); font-size: 0.85rem; font-family: inherit; outline: none; }
.publish-modal input:focus, .publish-modal textarea:focus { border-color: var(--primary); }

.upload-form { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; padding: 12px; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); }
.upload-form.hidden { display: none; }
.upload-form input, .upload-form textarea { width: 100%; box-sizing: border-box; }
.upload-actions { display: flex; gap: 8px; }
.upload-mode-tabs { display: flex; gap: 4px; }
.upload-mode-tab { flex:1; padding: 6px 0; background: var(--bg-input); color: var(--text-secondary); border: 1px solid var(--border); border-radius: 6px; cursor: pointer; font-size: 0.82rem; transition: all 0.15s; }
.upload-mode-tab.active { background: var(--primary); color: #fff; border-color: var(--primary); }
#uploadStatus.success { color: var(--online); }
#uploadStatus.error { color: var(--offline); }

/* Game waiting screen */
.game-waiting { flex: 1; display: flex; align-items: center; justify-content: center; }
.game-waiting.hidden { display: none; }
.game-waiting-card { text-align: center; padding: 32px; max-width: 360px; width: 100%; }
.game-waiting-card h2 { font-size: 1.3rem; margin-bottom: 16px; }
.game-waiting-card .member-list { text-align: left; margin-bottom: 12px; }
.game-waiting-card .hint { margin: 8px 0; }
#startGameBtn { margin-top: 12px; }
#startGameBtn.hidden { display: none; }

/* Game container (full-area iframe) */
#gameIframe { width: 100%; height: 100%; border: none; }
#gameIframe.loading { visibility: hidden; }

/* Game bar (between header and chat) */
.game-bar { display: flex; align-items: center; gap: 10px; padding: 8px 16px; background: var(--bg-card); border-bottom: 1px solid var(--border); font-size: 0.9rem; }
.game-bar.hidden { display: none; }
#gameBarTitle { flex: 1; }
#gameBarRemove { color: var(--text-secondary); }

/* Game countdown overlay */
.game-countdown { position: absolute; inset: 0; z-index: 60; background: rgba(0,0,0,0.85); display: flex; align-items: center; justify-content: center; }
.game-countdown.hidden { display: none; }
.countdown-content { text-align: center; color: #fff; }
.countdown-number { font-size: 4rem; font-weight: 700; animation: pulse 1s infinite; }
.countdown-content p { margin-top: 12px; font-size: 1rem; color: #ccc; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }

input[type="text"], textarea {
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-input);
  color: var(--text);
  font-size: 0.9rem;
  font-family: inherit;
  outline: none;
  transition: border var(--transition);
}
input[type="text"]:focus, textarea:focus {
  border-color: var(--primary);
}

.room-list-section {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
}
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.section-header h2, .section-header h3 {
  font-size: 1rem;
  font-weight: 600;
}

.room-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.empty-hint {
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.85rem;
  padding: 30px 0;
}

.room-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all var(--transition);
}
.room-card:hover { border-color: var(--primary); }
.room-card .room-name { font-weight: 600; font-size: 0.95rem; }
.room-card .room-meta {
  font-size: 0.8rem;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 8px;
}
.room-card .room-meta .count { color: var(--online); font-weight: 600; }

.action-section {
  padding: 16px 20px;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.action-section.hidden { display: none; }
.hint {
  font-size: 0.75rem;
  color: var(--text-secondary);
}
.room-create-row { display: flex; gap: 8px; }
.room-create-row input { flex: 1; }
.room-type-row { display: flex; gap: 8px; align-items: center; }
.room-type-select { flex: 1; padding: 6px 8px; border-radius: 8px; border: 1px solid var(--border); background: var(--bg-input); color: var(--text); font-size: 0.8rem; }
.room-password { width: 140px; padding: 6px 8px; border-radius: 8px; border: 1px solid var(--border); background: var(--bg-input); color: var(--text); font-size: 0.8rem; }
.room-type-btn {
  padding: 6px 12px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--bg-input); color: var(--text); font-size: 0.85rem;
  cursor: pointer; white-space: nowrap;
}
.room-type-btn:hover { border-color: var(--primary); }

/* Room type modal */
.room-type-overlay {
  position: fixed; inset: 0; z-index: 1001;
  background: rgba(0,0,0,0.5); display: flex; align-items: center; justify-content: center;
  animation: fadeIn 0.15s;
}
.room-type-overlay.hidden { display: none; }
.room-type-modal {
  background: var(--bg-card); border-radius: 14px; padding: 24px;
  max-width: 360px; width: 90vw; box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}
.room-type-modal h3 { margin-bottom: 4px; font-size: 1rem; text-align: center; }
.modal-sub { font-size: 0.8rem; color: var(--text-secondary); text-align: center; margin-bottom: 14px; }
.type-cards { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.type-card {
  display: flex; align-items: center; gap: 10px; padding: 10px 14px;
  border-radius: 10px; border: 2px solid var(--border); cursor: pointer;
  transition: all 0.15s;
}
.type-card:hover { border-color: var(--primary); background: var(--bg-input); }
.type-card.selected { border-color: var(--primary); background: rgba(79,110,247,0.08); }
.type-icon { font-size: 1.3rem; }
.type-label { font-weight: 600; font-size: 0.9rem; }
.type-desc { font-size: 0.75rem; color: var(--text-secondary); flex: 1; text-align: right; }

/* ===== Footer ===== */
.footer {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 20px;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  font-size: 0.75rem;
  color: var(--text-secondary);
}
.footer a { color: var(--text-secondary); text-decoration: none; }
.footer a:hover { color: var(--primary); }
.dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  display: inline-block;
}
.dot.connected { background: var(--online); }
.dot.disconnected { background: var(--offline); }
.sep { color: var(--border); }

/* ===== Room View ===== */
.room-header { gap: 8px; }
.room-info { flex: 1; }
.room-info h2 { font-size: 1.1rem; }
.room-info span { font-size: 0.75rem; color: var(--text-secondary); }
.latency-inline { font-size: 0.7rem; color: var(--text-secondary); white-space: nowrap; }

/* Connecting overlay — shown while testing room connection */
.connect-overlay {
  position: absolute; inset: 0; z-index: 100;
  background: var(--bg);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 16px;
}
.connect-overlay.hidden { display: none; }
.connect-overlay p { font-size: 0.95rem; color: var(--text-secondary); }
.connect-spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.room-body {
  flex: 1;
  display: flex;
  overflow: hidden;
  position: relative;
}
.room-body.has-game { flex-direction: row; }

/* Chat area */
.chat-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.has-game .chat-area { flex: 1; min-width: 280px; }

/* Game panel (split right) */
.game-panel { flex: 1; min-width: 300px; background: #000; display: flex; position: relative; }
.game-panel.hidden { display: none; }
#gameIframe { width: 100%; height: 100%; border: none; }
.game-fullscreen-btn {
  position: absolute; top: 4px; left: 4px; z-index: 5;
  width: 28px; height: 28px; border-radius: 4px;
  background: rgba(0,0,0,0.45); color: #fff; border: none;
  cursor: pointer; font-size: 1rem; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity 0.2s;
}
.game-panel:hover .game-fullscreen-btn,
.game-panel:fullscreen .game-fullscreen-btn { opacity: 1; }
/* Touch devices: always show fullscreen button */
@media (hover: none) { .game-fullscreen-btn { opacity: 1; } }

/* Narrow: stack vertically */
@media (max-width: 700px) {
  .room-body.has-game { flex-direction: column; }
  .has-game .chat-area { flex: none; height: 45%; }
  .game-panel { flex: 1; }
  /* Sidebar stops above game panel + input area */
  .has-game .sidebar { bottom: calc(55% + 100px); }
}
.message-list {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.message {
  max-width: 75%;
  padding: 8px 14px;
  border-radius: 14px;
  font-size: 0.9rem;
  line-height: 1.5;
  word-break: break-word;
  animation: fadeIn 0.2s ease;
}
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
.message.self {
  align-self: flex-end;
  background: var(--msg-self);
  color: var(--msg-self-text);
  border-bottom-right-radius: 4px;
}
.message.other {
  align-self: flex-start;
  background: var(--msg-other);
  color: var(--msg-other-text);
  border-bottom-left-radius: 4px;
}
.message.ephemeral {
  border: 1px dashed rgba(239,68,68,0.35);
}
.message .img-wrapper { position: relative; margin-top: 4px; border-radius: 8px; overflow: hidden; display: inline-block; cursor: pointer; min-width: 80px; min-height: 60px; background: var(--bg-input); }
.message .img-wrapper img { display: block; width: auto; height: auto; max-width: 400px; max-height: 300px; border-radius: 8px; }
/* Image loading spinner */
.img-spinner {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  background: var(--bg-input); z-index: 1;
}
.img-spinner::after {
  content: ''; width: 24px; height: 24px; border: 3px solid var(--border);
  border-top-color: var(--primary); border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
.img-spinner.hidden, .img-wrapper.loaded .img-spinner { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.message .img-wrapper.ephemeral-img { position: relative; cursor: pointer; overflow: hidden; border-radius: 8px; }
.message .img-wrapper.ephemeral-img img { filter: blur(24px) brightness(0.6); transition: filter 0.8s; user-select: none; -webkit-user-drag: none; }
.message .img-wrapper.ephemeral-img::before {
  content: ''; position: absolute; inset: 0; z-index: 1; background: rgba(0,0,0,0.35);
  pointer-events: none;
}
.message .img-wrapper.ephemeral-img::after {
  content: '点击查看'; position: absolute; inset: 0; z-index: 2; display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 0.85rem; font-weight: 600; pointer-events: none;
}
/* Sweep reveal: curtain slides down from top */
.message .img-wrapper.ephemeral-img.revealing::before {
  animation: sweepDown 1.5s ease-in forwards;
}
@keyframes sweepDown {
  0%   { clip-path: inset(0 0 0 0); }
  100% { clip-path: inset(0 0 100% 0); }
}
.message .img-wrapper.ephemeral-img.revealing::after { content: ''; }
.message .img-wrapper.ephemeral-img.revealing img { filter: blur(0) brightness(1); }
/* Fully clear, fade out */
.message .img-wrapper.ephemeral-img.clear {
  transition: opacity 2s 0.5s;
  opacity: 0;
}

.message.system {
  align-self: center;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.75rem;
  max-width: 90%;
}
.message .msg-sender {
  font-size: 0.75rem;
  font-weight: 600;
  opacity: 0.85;
}
.message.self .msg-sender { display: none; }
.message .msg-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 4px;
  gap: 12px;
}
.message .msg-time {
  font-size: 0.65rem;
  opacity: 0.5;
  white-space: nowrap;
  flex-shrink: 0;
}
.message.self .msg-header { justify-content: flex-end; }
.message .msg-body {
  font-size: 0.9rem;
  line-height: 1.45;
}
.message.failed {
  border: 1px solid var(--offline);
}
.message.failed::after {
  content: " ⚠️";
  font-size: 0.7rem;
  color: var(--offline);
}

/* File message */
.file-msg {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}
.file-msg .file-icon { font-size: 1.2rem; }
.file-msg .file-name {
  font-weight: 500;
  word-break: break-all;
}
.file-msg .file-name[href] { color: var(--primary); text-decoration: underline; cursor: pointer; }
.file-msg .file-size { font-size: 0.7rem; opacity: 0.6; }
.file-msg .file-done { font-size: 0.9rem; }
.file-progress {
  width: 100%;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin-top: 4px;
  flex-basis: 100%;
}
.file-bar {
  height: 100%;
  background: var(--primary);
  border-radius: 2px;
  transition: width 0.2s ease;
  min-width: 0;
}

/* Recipient picker */
.recipient-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 10px 0;
  max-height: 200px;
  overflow-y: auto;
}
.recipient-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
}
.recipient-item:hover { background: var(--bg-input); }
.recipient-item input { accent-color: var(--primary); }
.btn-sm { padding: 4px 12px; font-size: 0.8rem; }

/* Call bar */
.call-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 16px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
  flex-shrink: 0;
}
.call-bar.hidden { display: none; }
.call-bar .call-icon { font-size: 1.1rem; }
.call-bar #callStatus { flex: 1; }

/* Input area — sits above sidebar in z-order so sidebar bottom doesn't cover it */
.input-area {
  padding: 10px 16px;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: relative;
  z-index: 20;
}
.input-area textarea {
  resize: none;
  min-height: 40px;
  max-height: 120px;
  width: 100%;
  scrollbar-width: none;       /* Firefox */
  -ms-overflow-style: none;    /* IE/Edge */
}
.input-area textarea::-webkit-scrollbar { display: none; }
.input-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.toolbar-left { display: flex; gap: 4px; }
.toolbar-right { display: flex; gap: 6px; align-items: center; }
.btn-ephemeral {
  font-size: 0.75rem; padding: 4px 10px; border: 1px solid var(--border);
  border-radius: 14px; background: transparent; color: var(--text-secondary);
  cursor: pointer; white-space: nowrap; transition: all 0.2s;
}
.btn-ephemeral.active {
  background: rgba(239,68,68,0.12); border-color: rgba(239,68,68,0.4);
  color: #ef4444; font-weight: 600;
}
.input-actions { display: flex; gap: 6px; }

/* Sidebar — overlays chat area */
.sidebar {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 88px; /* stop above input area */
  width: 200px;
  max-width: 80vw;
  background: var(--bg-card);
  border-left: 1px solid var(--border);
  padding: 12px;
  overflow-y: auto;
  z-index: 10;
  box-shadow: -2px 0 12px rgba(0,0,0,0.10);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.sidebar.hidden {
  transform: translateX(100%);
  box-shadow: none;
}
.member-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 8px;
}
.member-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  border-radius: 6px;
  font-size: 0.85rem;
}
.member-item .role-icon { font-size: 0.9rem; }
.member-item .member-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.member-item .is-you { color: var(--primary); font-size: 0.65rem; font-weight: 600; }
.member-item .ready-badge { color: var(--online); font-weight: 700; margin-left: 2px; }
.member-item .call-badge { font-size: 0.75rem; flex-shrink: 0; }
.member-item .latency { color: var(--muted); font-size: 0.65rem; margin-left: 4px; }
.member-item.in-call { background: rgba(34,197,94,0.08); }
.member-item.speaking { background: var(--bg-input); }

/* ===== Responsive ===== */
@media (max-width: 640px) {
  .slogan { display: none; }
  .header { padding: 10px 12px; gap: 8px; }
  .logo { font-size: 1.1rem; }

  /* Lobby */
  .nickname-section { padding: 10px 12px; gap: 6px; }
  .room-list-section { padding: 10px 12px; }
  .room-list-section.hidden { display: none; }
  .workshop-section.hidden { display: none; }
  .room-card { padding: 10px 12px; }
  .action-section { padding: 10px 12px; gap: 6px; }
  .room-create-row { gap: 6px; }
  .room-type-row { flex-wrap: wrap; gap: 4px; }
  .room-type-select { font-size: 0.75rem; padding: 5px 6px; }
  .room-password { width: 120px; font-size: 0.75rem; }
  .hint { font-size: 0.7rem; }

  /* Room view */
  .room-header { padding: 8px 10px; gap: 6px; }
  .room-header h2 { font-size: 1rem; }
  .chat-area { padding: 0; }
  .message { max-width: 88%; font-size: 0.85rem; }
  .message .msg-header { font-size: 0.7rem; }

  /* Toolbar */
  .input-toolbar { flex-wrap: wrap; gap: 4px; }
  .toolbar-left { gap: 2px; }
  .toolbar-right { gap: 4px; }
  .btn-icon { font-size: 1rem; padding: 3px 6px; }
  .btn-ephemeral { font-size: 0.7rem; padding: 3px 8px; }
  .btn { padding: 6px 14px; font-size: 0.8rem; }
  textarea { font-size: 0.85rem; padding: 8px 10px; }

  /* Sidebar */
  .sidebar { width: 180px; max-width: 75vw; padding: 8px; bottom: 110px; }
  .member-item { padding: 4px 6px; font-size: 0.78rem; }

  /* Call bar */
  .call-bar { padding: 6px 10px; font-size: 0.8rem; gap: 6px; flex-wrap: wrap; }

  /* Images */
}

/* ===== Custom Alert Modal ===== */
.alert-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.15s ease;
}
.alert-overlay.hidden { display: none; }

/* Announcement popup */
.announce-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex; align-items: center; justify-content: center;
  z-index: 2000; animation: fadeIn 0.2s ease;
}
.announce-overlay.hidden { display: none; }
.announce-modal {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 24px 28px;
  max-width: 420px; width: 90%; text-align: center;
}
.announce-header { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.announce-header h2 { font-size: 1.1rem; flex: 1; margin: 0; text-align: center; }
.announce-time { font-size: 0.7rem; color: var(--text-secondary); white-space: nowrap; }
.announce-modal p { font-size: 0.9rem; color: var(--text-secondary); margin-bottom: 16px; white-space: pre-wrap; line-height: 1.5; }
.announce-arrow {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--bg-input); color: var(--text); border: 1px solid var(--border);
  cursor: pointer; font-size: 0.9rem; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s;
}
.announce-arrow:hover { background: var(--primary); color: #fff; border-color: var(--primary); }
.announce-arrow.hidden { visibility: hidden; }
.announce-footer { display: flex; align-items: center; justify-content: center; gap: 12px; }
.announce-page { font-size: 0.75rem; color: var(--text-secondary); }

/* Help modal */
.help-modal {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 24px 28px;
  max-width: 560px; width: 92%; max-height: 80vh; overflow-y: auto;
}
.help-modal h2 { font-size: 1.1rem; margin-bottom: 12px; text-align: center; }
.help-body { text-align: left; font-size: 0.85rem; line-height: 1.6; }
.help-body h3 { font-size: 0.95rem; margin: 14px 0 6px; color: var(--primary); }
.help-body h4 { font-size: 0.85rem; margin: 10px 0 4px; color: var(--text); }
.help-body p { margin-bottom: 6px; color: var(--text-secondary); }
.help-body ul { margin: 4px 0 8px 18px; color: var(--text-secondary); }
.help-body ol { margin: 4px 0 8px 18px; color: var(--text-secondary); }
.help-body li { margin-bottom: 2px; }
.help-body code { background: var(--bg-input); padding: 1px 5px; border-radius: 3px; font-size: 0.8rem; }
.help-body pre { background: var(--bg-input); padding: 8px 12px; border-radius: 6px; font-size: 0.75rem; overflow-x: auto; margin: 4px 0; }
.help-body a { color: var(--primary); }
.help-body table th { color: var(--text); font-weight: 600; }
.help-body table td { color: var(--text-secondary); }
.help-body table tr:hover td { background: var(--bg-input); }
.help-modal .btn { margin-top: 14px; }

/* Custom audio player */
.custom-player { max-width: 260px; }
.custom-player.compact { max-width: 200px; }
.cp-row {
  display: flex; align-items: center; gap: 6px;
  padding: 4px 8px;
  background: var(--bg-input);
  border-radius: 20px;
}
.custom-player.compact .cp-row { background: transparent; padding: 0; }
.cp-btn {
  width: 28px; height: 28px;
  border: none; border-radius: 50%;
  background: var(--primary); color: #fff;
  font-size: 0.7rem; cursor: pointer; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  padding: 0;
}
.custom-player.compact .cp-btn { width: 24px; height: 24px; font-size: 0.6rem; }
.cp-progress {
  flex: 1; height: 4px;
  background: var(--border); border-radius: 2px;
  cursor: pointer; position: relative;
}
.cp-bar {
  height: 100%; background: var(--primary);
  border-radius: 2px; transition: width 0.15s linear; width: 0%;
}
.cp-time {
  font-size: 0.65rem; opacity: 0.6; white-space: nowrap; flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}
.custom-player:not(.compact) .cp-btn {
  margin-right: 6px;
}
.custom-player:not(.compact) .cp-progress {
  display: inline-block; width: calc(100% - 90px); vertical-align: middle; margin: 0 8px;
}
.custom-player:not(.compact) .cp-time {
  display: inline-block; vertical-align: middle;
}
.message.self .cp-row { background: rgba(255,255,255,0.15); }
.message.self .cp-btn { background: rgba(255,255,255,0.3); }
.message.self .cp-bar { background: rgba(255,255,255,0.6); }
.message.self .cp-time { color: rgba(255,255,255,0.7); }

.alert-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 28px;
  min-width: 280px;
  max-width: 90vw;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
  text-align: center;
  animation: slideUp 0.2s ease;
}

.alert-box p {
  font-size: 0.95rem;
  line-height: 1.6;
  margin-bottom: 20px;
  color: var(--text);
}

.alert-box .btn { min-width: 80px; }

@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ===== Fullscreen Image Viewer ===== */
.image-viewer-overlay {
  position: fixed; inset: 0; z-index: 2000;
  background: rgba(0,0,0,0.92);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  animation: fadeIn 0.2s ease;
}
.image-viewer-overlay img {
  max-width: 95vw; max-height: 95vh;
  width: auto; height: auto;
  object-fit: contain;
  border-radius: 4px;
  box-shadow: 0 4px 32px rgba(0,0,0,0.5);
}
