/* Personal Meet - all styles local, no CDN */
:root {
  --bg: #202124;
  --bg-card: #292a2d;
  --bg-tile: #3c4043;
  --text: #e8eaed;
  --text-muted: #9aa0a6;
  --primary: #8ab4f8;
  --primary-hover: #aecbfa;
  --danger: #f28b82;
  --danger-hover: #f6aea9;
  --success: #81c995;
  --border: #5f6368;
  --radius: 12px;
  --shadow: 0 2px 8px rgba(0,0,0,.3);
}

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

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

/* ----- Home ----- */
body.home {
  display: flex;
  flex-direction: column;
}

.header {
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.25rem;
  font-weight: 600;
}

.logo-icon {
  width: 32px;
  height: 32px;
  color: var(--primary);
}

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 24px;
}

.hero {
  text-align: center;
  margin-bottom: 48px;
}

.hero h1 {
  font-size: 2rem;
  font-weight: 400;
  margin-bottom: 8px;
}

.hero p {
  color: var(--text-muted);
  font-size: 1rem;
}

.actions {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
  justify-content: center;
  max-width: 640px;
}

.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 24px;
  min-width: 280px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.card h2 {
  font-size: 1.125rem;
  font-weight: 500;
  margin-bottom: 8px;
}

.card p {
  color: var(--text-muted);
  font-size: 0.875rem;
  margin-bottom: 16px;
}

.input-row {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}

.input-row input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: 1rem;
}

.input-row input:focus {
  outline: none;
  border-color: var(--primary);
}

.btn {
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  font-size: 0.9375rem;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s;
}

.btn-primary {
  background: var(--primary);
  color: var(--bg);
}

.btn-primary:hover {
  background: var(--primary-hover);
  color: var(--bg);
}

.btn-secondary {
  background: var(--bg-tile);
  color: var(--text);
}

.btn-secondary:hover {
  background: var(--border);
}

.hint {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-bottom: 0;
}

.hint.error { color: var(--danger); }
.hint.success { color: var(--success); }

.app-footer {
  flex-shrink: 0;
  text-align: center;
  padding: 20px 24px;
  color: var(--text-muted);
  font-size: 0.875rem;
  border-top: 1px solid var(--border);
}

.app-footer a {
  color: var(--primary);
  text-decoration: none;
}

.app-footer a:hover {
  color: var(--primary-hover);
  text-decoration: underline;
}

.footer-heart {
  display: inline-flex;
  align-items: center;
  vertical-align: middle;
  color: var(--danger);
}

.footer-heart svg {
  width: 1em;
  height: 1em;
  margin: 0 2px;
}

/* ----- Meeting ----- */
body.meet {
  overflow: hidden;
  height: 100vh;
  height: 100dvh;
}

.meet-layout {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 100dvh;
}

.meet-header {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
}

.meet-info {
  display: flex;
  align-items: center;
  gap: 8px;
}

.meet-code {
  font-family: ui-monospace, monospace;
  font-size: 0.9375rem;
  letter-spacing: 0.05em;
}

.btn-icon {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: 50%;
  color: var(--text-muted);
  cursor: pointer;
}

.btn-icon:hover {
  background: var(--bg-tile);
  color: var(--text);
}

.btn-icon svg {
  width: 20px;
  height: 20px;
}

.meet-title {
  font-weight: 500;
  font-size: 1rem;
}

.meet-meta {
  color: var(--text-muted);
  font-size: 0.875rem;
}

.videos-container {
  flex: 1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 16px;
  overflow: auto;
  background: var(--bg);
}

.video-tile {
  position: relative;
  background: var(--bg-tile);
  border-radius: var(--radius);
  overflow: hidden;
  min-width: 240px;
  min-height: 180px;
  max-width: min(400px, 50vw);
  aspect-ratio: 16/10;
  box-shadow: var(--shadow);
}

.video-tile video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

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

.tile-label {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 8px 12px;
  background: linear-gradient(transparent, rgba(0,0,0,.7));
  font-size: 0.8125rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

.tile-btn-fullscreen {
  position: absolute;
  right: 10px;
  bottom: 10px;
  z-index: 2;
  width: 36px;
  height: 36px;
  padding: 0;
  border: none;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.5);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s;
}

.tile-btn-fullscreen:hover {
  background: rgba(0, 0, 0, 0.7);
}

.tile-btn-fullscreen svg {
  width: 18px;
  height: 18px;
  display: block;
}

.video-tile:fullscreen,
.video-tile:-webkit-full-screen {
  max-width: none;
  width: 100%;
  height: 100%;
  aspect-ratio: auto;
  border-radius: 0;
}

.video-tile:fullscreen video,
.video-tile:-webkit-full-screen video {
  object-fit: contain;
  width: 100%;
  height: 100%;
}

.muted-badge {
  background: var(--danger);
  color: var(--bg);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.75rem;
}

.video-tile.off .tile-label .muted-badge {
  background: var(--border);
}

.meet-controls {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 16px 24px;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
}

.ctrl-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 12px 20px;
  background: var(--bg-tile);
  border: none;
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.75rem;
  cursor: pointer;
  transition: background .15s, color .15s;
}

.ctrl-btn:hover {
  background: var(--border);
}

.ctrl-btn svg {
  width: 24px;
  height: 24px;
}

.ctrl-btn.mic-off .icon-mic,
.ctrl-btn.cam-off .icon-cam {
  color: var(--danger);
}

.ctrl-btn.screen-on {
  background: var(--primary);
  color: var(--bg);
}

.ctrl-btn.screen-on:hover {
  background: var(--primary-hover);
}

.ctrl-btn.danger {
  background: var(--danger);
  color: var(--bg);
}

.ctrl-btn.danger:hover {
  background: var(--danger-hover);
}

/* ----- Chat panel (Google Meet style, default closed) ----- */
.meet-chat-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0);
  z-index: 99;
  pointer-events: none;
  visibility: hidden;
  transition: visibility 0.25s ease, background 0.25s ease;
}

.meet-chat-backdrop.visible {
  visibility: visible;
  pointer-events: auto;
  background: rgba(0, 0, 0, 0.5);
}

.meet-chat-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 360px;
  max-width: 100%;
  background: var(--bg-card);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transform: translateX(100%);
  visibility: hidden;
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1), visibility 0.25s ease;
  box-shadow: -4px 0 16px rgba(0, 0, 0, 0.2);
}

.meet-chat-panel.open {
  transform: translateX(0);
  visibility: visible;
}

.meet-chat-header {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.meet-chat-title {
  font-size: 1rem;
  font-weight: 500;
  margin: 0;
}

.meet-chat-close {
  flex-shrink: 0;
}

.meet-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
  -webkit-overflow-scrolling: touch;
}

.meet-chat-msg {
  font-size: 0.9375rem;
  word-break: break-word;
}

.meet-chat-msg .meet-chat-sender {
  font-weight: 500;
  color: var(--primary);
  margin-bottom: 2px;
}

.meet-chat-msg .meet-chat-body {
  color: var(--text);
}

.meet-chat-msg.own .meet-chat-sender {
  color: var(--text-muted);
}

.meet-chat-form {
  flex-shrink: 0;
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  background: var(--bg);
}

.meet-chat-input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-card);
  color: var(--text);
  font-size: 0.9375rem;
}

.meet-chat-input:focus {
  outline: none;
  border-color: var(--primary);
}

.meet-chat-send {
  flex-shrink: 0;
  padding: 10px 16px;
}

/* ----- Chat: mobile-first responsive UX ----- */
@media (max-width: 600px) {
  .meet-chat-backdrop.visible {
    background: rgba(0, 0, 0, 0.55);
  }

  .meet-chat-panel {
    width: 100%;
    max-width: 100%;
    left: 0;
    right: 0;
    transform: translateX(100%);
    border-left: none;
    border-radius: 0;
    box-shadow: -8px 0 32px rgba(0, 0, 0, 0.35);
    padding-top: env(safe-area-inset-top, 0);
    padding-bottom: env(safe-area-inset-bottom, 0);
  }

  .meet-chat-panel.open {
    transform: translateX(0);
  }

  .meet-chat-header {
    padding: 16px 20px;
    padding-top: max(16px, env(safe-area-inset-top));
    min-height: 52px;
    align-items: center;
  }

  .meet-chat-title {
    font-size: 1.125rem;
  }

  .meet-chat-close {
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    border-radius: 50%;
    background: var(--bg-tile);
    color: var(--text);
  }

  .meet-chat-close:hover {
    background: var(--border);
  }

  .meet-chat-close svg {
    width: 22px;
    height: 22px;
  }

  .meet-chat-messages {
    padding: 16px 20px;
    gap: 16px;
  }

  .meet-chat-msg {
    font-size: 1rem;
  }

  .meet-chat-form {
    padding: 12px 20px 16px;
    padding-bottom: max(16px, env(safe-area-inset-bottom));
    gap: 10px;
  }

  .meet-chat-input {
    padding: 14px 16px;
    font-size: 16px; /* avoids iOS zoom on focus */
    border-radius: 24px;
    min-height: 48px;
  }

  .meet-chat-send {
    padding: 14px 20px;
    min-height: 48px;
    border-radius: 24px;
    font-weight: 500;
  }
}

/* Desktop: larger video tiles (Google Meet style) */
@media (min-width: 769px) {
  .videos-container {
    gap: 20px;
    padding: 24px;
  }
  .video-tile {
    min-width: 480px;
    min-height: 320px;
    max-width: min(720px, 55vw);
    aspect-ratio: 16/10;
  }
}

/* Mobile */
@media (max-width: 600px) {
  .actions { flex-direction: column; align-items: stretch; }
  .card { min-width: auto; }
  .meet-header { flex-wrap: wrap; gap: 8px; }
  .video-tile { max-width: 100%; }

  .meet-controls {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    padding: 12px 12px calc(12px + env(safe-area-inset-bottom, 0px)) 12px;
    min-height: 72px;
  }

  .videos-container {
    padding-bottom: 100px;
  }

  .ctrl-btn {
    flex: 1 1 0;
    min-width: 0;
    padding: 10px 6px;
    font-size: 0.65rem;
    gap: 2px;
  }

  .ctrl-btn svg {
    width: 22px;
    height: 22px;
  }
}
