* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: 'Google Sans', Roboto, Arial, -apple-system, BlinkMacSystemFont, sans-serif;
  background: #202124;
  color: #e8eaed;
  overflow: hidden;
}
button {
  font-family: inherit;
  cursor: pointer;
}
input {
  font-family: inherit;
}
.hidden { display: none !important; }

/* ============ LANDING ============ */
#landing {
  height: 100%;
  display: flex;
  flex-direction: column;
  background: #202124;
  overflow-y: auto;
}
.landing-header {
  padding: 20px 40px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 22px;
  color: #e8eaed;
}
.brand-icon { flex-shrink: 0; }
.landing-main {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 60px;
  flex-wrap: wrap;
  padding: 40px;
}
.landing-copy { max-width: 420px; }
.landing-copy h1 {
  font-size: 40px;
  font-weight: 400;
  line-height: 1.2;
  margin: 0 0 16px;
}
.landing-copy p {
  font-size: 16px;
  color: #9aa0a6;
  line-height: 1.5;
}
.landing-card {
  background: #292a2d;
  border-radius: 16px;
  padding: 32px;
  width: 360px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.4);
}
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 20px;
  font-size: 13px;
  color: #9aa0a6;
}
.field input, .join-row input {
  background: #202124;
  border: 1px solid #5f6368;
  border-radius: 8px;
  padding: 12px 14px;
  color: #e8eaed;
  font-size: 15px;
  outline: none;
}
.field input:focus, .join-row input:focus {
  border-color: #8ab4f8;
}
.landing-actions {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.join-row {
  display: flex;
  gap: 8px;
}
.join-row input { flex: 1; min-width: 0; }

.btn {
  border: none;
  border-radius: 20px;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background 0.15s;
}
.btn-primary {
  background: #8ab4f8;
  color: #202124;
}
.btn-primary:hover { background: #aecbfa; }
.btn-outline {
  background: transparent;
  color: #8ab4f8;
  border: 1px solid #5f6368;
}
.btn-outline:hover { background: rgba(138,180,248,0.08); }
.btn-large { width: 100%; padding: 12px; font-size: 15px; }
.btn-text {
  background: transparent;
  color: #8ab4f8;
  width: 100%;
  margin-top: 8px;
}
.btn-text:hover { background: rgba(138,180,248,0.08); }

.error-text {
  color: #f28b82;
  font-size: 13px;
  margin: 10px 0 0;
}

/* ============ PREVIEW ============ */
#preview {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 48px;
  flex-wrap: wrap;
  padding: 20px;
}
.preview-wrap {
  display: flex;
  align-items: center;
  gap: 48px;
  flex-wrap: wrap;
  justify-content: center;
}
.preview-video-box {
  position: relative;
  width: 480px;
  max-width: 90vw;
  aspect-ratio: 16/9;
  background: #3c4043;
  border-radius: 16px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
.preview-video-box video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
}
.preview-controls {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 12px;
}
.preview-info {
  text-align: center;
  min-width: 260px;
}
.preview-info h2 {
  font-weight: 400;
  margin: 0 0 8px;
}
.room-code-label {
  color: #9aa0a6;
  font-size: 14px;
  margin-bottom: 20px;
  word-break: break-all;
}

/* ============ ICON BUTTONS ============ */
.icon-btn {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: none;
  background: #3c4043;
  color: #e8eaed;
  display: flex;
  align-items: center;
  justify-content: center;
}
.icon-btn:hover { background: #4c4f52; }
.icon-btn.active-off {
  background: #ea4335;
  color: #fff;
}
.icon-btn.small {
  width: 36px;
  height: 36px;
  background: #8ab4f8;
  color: #202124;
}
.icon-btn.small:hover { background: #aecbfa; }

.avatar-fallback {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #3c4043;
  font-size: 64px;
  font-weight: 500;
  color: #e8eaed;
}
.avatar-fallback.tile-avatar {
  font-size: 40px;
  background: #5f6368;
}

/* ============ ROOM ============ */
#room {
  height: 100%;
  display: flex;
  flex-direction: column;
}
.room-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  font-size: 14px;
  color: #9aa0a6;
}
.room-title {
  display: flex;
  align-items: center;
  gap: 12px;
}
.chip-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #3c4043;
  color: #e8eaed;
  border: none;
  border-radius: 16px;
  padding: 6px 12px;
  font-size: 13px;
}
.chip-btn:hover { background: #4c4f52; }

.room-body {
  flex: 1;
  display: flex;
  min-height: 0;
  padding: 0 12px;
  gap: 8px;
}
.video-grid {
  flex: 1;
  display: grid;
  gap: 8px;
  padding: 8px 0 8px;
  min-height: 0;
  align-content: center;
  justify-content: center;
  grid-auto-rows: minmax(0, 1fr);
}
.tile {
  position: relative;
  background: #3c4043;
  border-radius: 12px;
  overflow: hidden;
  min-width: 160px;
  min-height: 90px;
  aspect-ratio: 16/9;
}
.tile.speaking {
  box-shadow: 0 0 0 3px #8ab4f8 inset;
}
.tile video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.tile video.mirrored { transform: scaleX(-1); }
.tile-label {
  position: absolute;
  left: 10px;
  bottom: 8px;
  background: rgba(0,0,0,0.55);
  padding: 3px 10px;
  border-radius: 6px;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.tile-mic-off {
  color: #f28b82;
  display: flex;
  align-items: center;
}
.tile-video-off video { display: none; }

/* ============ SIDE PANEL ============ */
.side-panel {
  width: 340px;
  flex-shrink: 0;
  background: #292a2d;
  border-radius: 12px;
  margin: 8px 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.side-panel-tabs {
  display: flex;
  align-items: center;
  border-bottom: 1px solid #3c4043;
  padding: 4px 8px;
}
.side-tab {
  background: none;
  border: none;
  color: #9aa0a6;
  padding: 14px 12px;
  font-size: 14px;
  border-bottom: 3px solid transparent;
}
.side-tab.active {
  color: #8ab4f8;
  border-bottom-color: #8ab4f8;
}
.side-panel-close {
  margin-left: auto;
  background: none;
  border: none;
  color: #9aa0a6;
  font-size: 22px;
  line-height: 1;
  padding: 6px 10px;
}
.side-panel-close:hover { color: #e8eaed; }

.panel-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.chat-msg {
  max-width: 100%;
}
.chat-msg .meta {
  font-size: 12px;
  color: #9aa0a6;
  margin-bottom: 2px;
  display: flex;
  gap: 8px;
}
.chat-msg .bubble {
  background: #3c4043;
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 14px;
  word-wrap: break-word;
  white-space: pre-wrap;
}
.chat-msg.own .bubble {
  background: #8ab4f8;
  color: #202124;
}
.chat-msg.system {
  text-align: center;
  color: #9aa0a6;
  font-size: 12px;
}
.chat-form {
  display: flex;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid #3c4043;
}
.chat-form input {
  flex: 1;
  background: #202124;
  border: 1px solid #5f6368;
  border-radius: 20px;
  padding: 10px 16px;
  color: #e8eaed;
  outline: none;
}
.chat-form input:focus { border-color: #8ab4f8; }

.people-list {
  list-style: none;
  margin: 0;
  padding: 10px;
  overflow-y: auto;
  flex: 1;
}
.people-list li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 8px;
  border-radius: 8px;
}
.people-list li:hover { background: #333436; }
.people-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #5f6368;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}
.people-name { flex: 1; font-size: 14px; }
.people-you { color: #9aa0a6; font-size: 12px; }

/* ============ CONTROL BAR ============ */
.control-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  gap: 16px;
}
.control-bar-left {
  color: #9aa0a6;
  font-size: 14px;
  min-width: 120px;
}
.control-bar-center {
  display: flex;
  gap: 14px;
  flex: 1;
  justify-content: center;
}
.control-bar-right {
  display: flex;
  gap: 10px;
  min-width: 120px;
  justify-content: flex-end;
}
.control-btn {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: none;
  background: #3c4043;
  color: #e8eaed;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}
.control-btn:hover { background: #4c4f52; }
.control-btn.active-off {
  background: #ea4335;
  color: #fff;
}
.control-btn.active-on {
  background: #8ab4f8;
  color: #202124;
}
.control-btn.hangup {
  background: #ea4335;
  color: #fff;
  width: 64px;
  border-radius: 28px;
}
.control-btn.hangup:hover { background: #f2503f; }

.badge {
  position: absolute;
  top: 2px;
  right: 2px;
  background: #ea4335;
  color: #fff;
  border-radius: 50%;
  width: 16px;
  height: 16px;
  font-size: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.toast {
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%);
  background: #3c4043;
  color: #e8eaed;
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 14px;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
}

@media (max-width: 720px) {
  .side-panel {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 90px;
    width: 100%;
    margin: 0;
    border-radius: 0;
    z-index: 50;
  }
  .room-body { padding: 0 6px; }
  .control-bar-left { display: none; }
}
