:root {
  --bg: #0f1117;
  --panel: #171a23;
  --border: #262b3a;
  --text: #e6e8ee;
  --muted: #8b90a0;
  --accent: #7c5cff;
  --danger: #f87171;
  --ok: #34d399;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.center {
  max-width: 480px;
  margin: 8vh auto;
  padding: 0 16px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.hero h1 { margin: 0 0 8px; font-size: 2rem; }
.lead { color: var(--muted); margin: 0 0 16px; }
.features { list-style: none; padding: 0; margin: 0 0 8px; }
.features li { padding: 6px 0; color: var(--muted); }
.features li::before { content: "✓ "; color: var(--ok); }

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

input[type="text"], input[type="password"] {
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 1rem;
}
input:focus { outline: 2px solid var(--accent); }

.btn {
  display: inline-block;
  padding: 10px 16px;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-size: 1rem;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
}
.btn.ghost { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn:hover { filter: brightness(1.1); }

.muted { color: var(--muted); }
.break { word-break: break-all; }
.hidden { display: none !important; }

.room {
  max-width: 760px;
  margin: 0 auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  height: 100vh;
}

.room-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}
.room-header h1 { margin: 0; font-size: 1.4rem; }
.token {
  font-family: ui-monospace, Menlo, monospace;
  font-size: 0.9rem;
  background: var(--panel);
  border: 1px solid var(--border);
  padding: 2px 8px;
  border-radius: 6px;
}
.room-actions { display: flex; gap: 8px; flex-shrink: 0; }

.qr-panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  text-align: center;
}
.qr-panel img { border-radius: 8px; background: #fff; }

#room-stream { flex: 1; display: flex; flex-direction: column; gap: 12px; min-height: 0; }

.messages {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  min-height: 0;
}

.msg { display: flex; gap: 10px; align-items: flex-start; }
.avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 18px; flex-shrink: 0;
}
.avatar.mini { width: 20px; height: 20px; font-size: 12px; }
.msg-body { min-width: 0; }
.msg-meta { color: var(--muted); font-size: 0.75rem; margin-bottom: 4px; display: flex; align-items: center; gap: 4px; }
.msg-text {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 12px;
  white-space: pre-wrap;
  word-break: break-word;
}
.msg-text pre {
  overflow-x: auto;
  background: #0d1117;
  border-radius: 8px;
  padding: 10px 12px;
  margin: 6px 0;
}
.msg-text code {
  font-family: ui-monospace, Menlo, monospace;
  font-size: .9em;
}
.file-card {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 12px;
  color: var(--text);
  text-decoration: none;
}
.file-card:hover { border-color: var(--accent); }
.file-name { word-break: break-all; }
.file-size { color: var(--muted); font-size: 0.8rem; margin-left: auto; white-space: nowrap; }

.file-card-image {
  flex-direction: column;
  align-items: stretch;
  padding: 8px;
  max-width: 300px;
}
.file-card-image img {
  width: 100%;
  border-radius: 6px;
  display: block;
}
.file-card-meta { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.file-media video {
  max-width: 100%;
  max-height: 360px;
  border-radius: 8px;
  background: #000;
  display: block;
}
.file-media audio { width: 100%; }
.file-media .file-card { margin-top: 6px; }

.empty { color: var(--muted); text-align: center; padding: 24px 0; }

.stats { display: flex; align-items: center; gap: 10px; font-size: 0.85rem; }
.meter { flex: 1; height: 6px; background: var(--bg); border-radius: 3px; overflow: hidden; }
.meter-bar { height: 100%; background: var(--accent); transition: width .3s; }

.composer { display: flex; gap: 8px; }
.composer input[type="text"] { flex: 1; }
.file-btn { padding: 8px 12px; font-size: 1rem; }

.dropzone {
  border: 2px dashed var(--border);
  border-radius: 12px;
  padding: 14px;
  text-align: center;
  color: var(--muted);
  font-size: .9rem;
  transition: border-color .2s, background .2s;
}
.dropzone.dragover {
  border-color: var(--accent);
  background: rgba(124, 92, 255, .08);
}
.dz-pick {
  color: var(--accent);
  cursor: pointer;
  text-decoration: underline;
}
.upload-queue { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; text-align: left; }
.upload-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: .85rem;
}
.upload-row { display: flex; align-items: center; gap: 8px; }
.upload-item .upload-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.upload-item .upload-size { color: var(--muted); }
.upload-item .upload-status { color: var(--muted); white-space: nowrap; }
.upload-item.done .upload-status { color: var(--ok); }
.upload-item.error .upload-status { color: var(--danger); }
.upload-bar { flex: 1; height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; }
.upload-bar-fill { height: 100%; background: var(--accent); transition: width .15s; }

.toast-error {
  background: rgba(248, 113, 113, .12);
  border: 1px solid var(--danger);
  color: var(--danger);
  border-radius: 8px;
  padding: 8px 12px;
  margin-top: 8px;
}

@media (max-width: 560px) {
  .room-header { flex-direction: column; }
  .room-actions { width: 100%; }
  .room-actions .btn { flex: 1; }
}
