* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #0f0f0f;
  color: #e0e0e0;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.container {
  max-width: 480px;
  width: 100%;
  padding: 2rem;
}

.container.room {
  max-width: 900px;
}

.home {
  text-align: center;
}

h1 {
  font-size: 2rem;
  margin-bottom: 0.5rem;
}

p {
  color: #888;
  margin-bottom: 1.5rem;
}

.btn {
  display: inline-block;
  padding: 0.75rem 1.5rem;
  background: #6c5ce7;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.2s;
}

.btn:hover {
  background: #5a4bd1;
}

.btn-small {
  padding: 0.4rem 0.8rem;
  font-size: 0.85rem;
}

.btn-danger {
  background: #e74c3c;
}

.btn-danger:hover {
  background: #c0392b;
}

.divider {
  color: #555;
  margin: 1.5rem 0;
  font-size: 0.9rem;
}

.join-form {
  display: flex;
  gap: 0.5rem;
}

.join-form input {
  flex: 1;
  padding: 0.75rem;
  background: #1a1a1a;
  border: 1px solid #333;
  border-radius: 8px;
  color: #e0e0e0;
  font-size: 1rem;
  outline: none;
}

.join-form input:focus {
  border-color: #6c5ce7;
}

#join-screen {
  text-align: center;
}

#name-input {
  display: block;
  width: 100%;
  padding: 0.75rem;
  margin-bottom: 1rem;
  background: #1a1a1a;
  border: 1px solid #333;
  border-radius: 8px;
  color: #e0e0e0;
  font-size: 1rem;
  outline: none;
}

#name-input:focus {
  border-color: #6c5ce7;
}

.current-room-info {
  color: #888;
  margin-bottom: 1.5rem;
  font-size: 0.95rem;
}

.home-link {
  margin-top: 1rem;
  color: #888;
  font-size: 0.9rem;
}

.home-link a {
  color: #6c5ce7;
  text-decoration: none;
}

.home-link a:hover {
  text-decoration: underline;
}

header {
  margin-bottom: 1.5rem;
}

.header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.header-top h2 {
  font-size: 1.25rem;
}

.room-info {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.room-code {
  background: #1a1a1a;
  border: 1px solid #333;
  border-radius: 6px;
  padding: 0.25rem 0.6rem;
  font-family: monospace;
  font-size: 1rem;
  letter-spacing: 0.1em;
  color: #6c5ce7;
  user-select: all;
}

.btn-ghost {
  background: transparent;
  border: 1px solid #333;
  color: #aaa;
}

.btn-ghost:hover {
  background: #1a1a1a;
  border-color: #6c5ce7;
  color: #e0e0e0;
}

.peer-tile video {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  background: #1a1a1a;
  border-radius: 8px;
  display: block;
}

.peer-local video {
  transform: scaleX(-1);
}

#screen-share-container {
  margin-bottom: 1rem;
  border-radius: 8px;
  overflow: hidden;
  background: #000;
}

#screen-video {
  width: 100%;
  display: block;
  border-radius: 8px;
}

#peers {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

#peers.grid-2 {
  grid-template-columns: 1fr 1fr;
}

#peers.grid-3 {
  grid-template-columns: 1fr 1fr;
}

#peers.grid-4 {
  grid-template-columns: 1fr 1fr;
}

#peers.grid-many {
  grid-template-columns: 1fr 1fr 1fr;
}

.peer-tile {
  position: relative;
  background: #1e1e1e;
  border: 1px solid #2a2a2a;
  border-radius: 8px;
  overflow: hidden;
  min-height: 3rem;
}

.peer-overlay {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.75rem;
  font-weight: 500;
  font-size: 0.9rem;
}

.peer-tile:has(video) .peer-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.7));
  padding: 1.5rem 0.75rem 0.4rem;
}

.empty {
  color: #555;
  font-size: 0.9rem;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem;
  background: #141414;
  border: 1px solid #222;
  border-radius: 12px;
  flex-wrap: wrap;
}

.btn-toolbar {
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
  border-radius: 20px;
}

.btn-toolbar-secondary {
  background: transparent;
  border: 1px solid #333;
  color: #aaa;
}

.btn-toolbar-secondary:hover {
  background: #1a1a1a;
  border-color: #6c5ce7;
  color: #e0e0e0;
}

#status {
  margin-top: 1rem;
  color: #888;
  font-size: 0.85rem;
  text-align: center;
}

.media-preview {
  margin-bottom: 1.5rem;
  padding: 1.25rem;
  background: #1a1a1a;
  border: 1px solid #333;
  border-radius: 8px;
  text-align: center;
}

.preview-video {
  width: 100%;
  max-width: 320px;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  background: #000;
  border-radius: 8px;
  margin-bottom: 1rem;
  transform: scaleX(-1);
}

.media-preview-controls {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  margin-bottom: 0.75rem;
}

.media-preview-status {
  color: #e74c3c;
  font-size: 0.85rem;
  margin-bottom: 0;
}

.mic-level {
  height: 6px;
  background: #2ecc71;
  border-radius: 3px;
  margin-bottom: 1rem;
  width: 0%;
  transition: width 0.05s linear;
}

.mic-notification {
  margin-top: 1.5rem;
  padding: 1.25rem;
  background: #1a1a1a;
  border: 1px solid #333;
  border-radius: 8px;
  text-align: center;
}

.mic-notification-msg {
  color: #e0e0e0;
  margin-bottom: 1rem;
  font-size: 0.95rem;
}

.mic-allow-btn {
  display: inline-block;
}

.mic-indicator {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  color: #555;
  line-height: 0;
}

.mic-indicator .mic-off { display: none; }

.mic-indicator[data-state="talking"] {
  color: #2ecc71;
  filter: drop-shadow(0 0 4px #2ecc71);
}

.mic-indicator[data-state="silent"] {
  color: #555;
}

.mic-indicator[data-state="muted"] {
  color: #e74c3c;
}

.mic-indicator[data-state="muted"] .mic-on { display: none; }
.mic-indicator[data-state="muted"] .mic-off { display: inline; }

.mic-indicator[data-state="no-mic"] {
  color: #333;
  opacity: 0.5;
}

.webview-warning {
  max-width: 480px;
  width: 100%;
  margin: 0 auto 1.5rem;
  padding: 1.25rem;
  background: #2d1a00;
  border: 1px solid #e67e22;
  border-radius: 8px;
  text-align: center;
}

.webview-warning-msg {
  color: #f0c27a;
  margin-bottom: 1rem;
  font-size: 0.95rem;
}

.webview-open-browser {
  display: inline-block;
}