:root {
  --brand: #1c75bc;
  --brand-dark: #14568c;
  --bg: #0f1720;
  --surface: #1a2530;
  --surface-2: #22303d;
  --text: #eef3f7;
  --text-dim: #9fb0bd;
  --danger: #e6483f;
  --radius: 14px;
}

* { box-sizing: border-box; }

.hidden { display: none !important; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  color-scheme: dark;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.4rem;
  font-weight: 600;
}
.brand.small { font-size: 1.05rem; }
.brand strong { color: var(--brand); }

/* ---------- Landing page ---------- */
body.landing {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: radial-gradient(circle at top, #16222c, #0f1720 70%);
}

.landing-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 36px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.4);
}

.tagline {
  color: var(--text-dim);
  margin: 10px 0 24px;
}

label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-dim);
  margin-bottom: 6px;
}

input[type="text"], input[type="datetime-local"] {
  width: 100%;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid #2f3f4d;
  background: var(--surface-2);
  color: var(--text);
  font-size: 1rem;
  outline: none;
}
input[type="text"]:focus, input[type="datetime-local"]:focus { border-color: var(--brand); }
input::-webkit-calendar-picker-indicator { filter: invert(1); opacity: 0.7; }

.actions { margin-top: 18px; }

.btn {
  border: none;
  border-radius: 10px;
  padding: 12px 18px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.05s ease, opacity 0.15s ease;
}
.btn:active { transform: scale(0.98); }
.btn.primary { background: var(--brand); color: white; width: 100%; }
.btn.primary:hover { background: var(--brand-dark); }
.btn.secondary { background: var(--surface-2); color: var(--text); border: 1px solid #2f3f4d; width: 100%; }
.btn.ghost { background: transparent; color: var(--text-dim); }
.btn.ghost:hover { color: var(--text); }
.btn.small { padding: 8px 12px; font-size: 0.85rem; width: auto; }

.divider {
  display: flex;
  align-items: center;
  text-align: center;
  color: var(--text-dim);
  font-size: 0.8rem;
  margin: 22px 0;
}
.divider::before, .divider::after {
  content: "";
  flex: 1;
  border-bottom: 1px solid #2f3f4d;
}
.divider span { padding: 0 10px; }

.join-row { display: flex; gap: 10px; }
.join-row input { flex: 1; }

.error-msg { color: var(--danger); font-size: 0.85rem; margin-top: 14px; min-height: 1em; }

.schedule-summary {
  background: var(--surface-2);
  border-radius: 10px;
  padding: 14px;
  font-size: 0.9rem;
  line-height: 1.6;
  word-break: break-word;
}
.schedule-summary .link-text { color: var(--brand); font-size: 0.82rem; }

/* ---------- Room page ---------- */
body.room {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.room-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 18px;
  background: var(--surface);
  border-bottom: 1px solid #22303d;
  flex-shrink: 0;
}

.meeting-banner {
  background: #16324a;
  color: #cfe6f7;
  font-size: 0.82rem;
  padding: 7px 16px;
  text-align: center;
  flex-shrink: 0;
}

.room-main {
  flex: 1;
  display: flex;
  overflow: hidden;
  min-height: 0;
}

.video-grid {
  flex: 1;
  display: grid;
  gap: 8px;
  padding: 10px;
  min-height: 0;
  min-width: 0;
}

.video-tile {
  position: relative;
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
  min-height: 0;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

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

.video-tile .name-tag {
  position: absolute;
  bottom: 8px;
  left: 10px;
  background: rgba(0,0,0,0.55);
  padding: 3px 10px;
  border-radius: 6px;
  font-size: 0.8rem;
  max-width: calc(100% - 20px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.video-tile.muted .name-tag::after { content: " 🔇"; }

.chat-panel {
  width: 300px;
  max-width: 85vw;
  background: var(--surface);
  border-left: 1px solid #22303d;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}
.chat-panel.hidden { display: none; }

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid #22303d;
  font-weight: 600;
  flex-shrink: 0;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px 14px;
  font-size: 0.88rem;
}

.chat-msg { margin-bottom: 10px; word-break: break-word; }
.chat-msg .who { color: var(--brand); font-weight: 600; margin-right: 6px; }
.chat-msg .when { color: var(--text-dim); font-size: 0.72rem; margin-left: 6px; }

/* Typing field sits above the send button, full width */
.chat-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  border-top: 1px solid #22303d;
  flex-shrink: 0;
}
.chat-form input {
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid #2f3f4d;
  background: var(--surface-2);
  color: var(--text) !important;
  caret-color: var(--text);
  font-size: 0.9rem;
}
.chat-form input::placeholder { color: var(--text-dim); }

.chat-form .btn {
  padding: 9px 14px;
  font-size: 0.85rem;
  align-self: flex-end;
  width: auto;
}

.controls-bar {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: var(--surface);
  border-top: 1px solid #22303d;
  flex-shrink: 0;
  flex-wrap: wrap;
}

.control-btn {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  border: none;
  background: var(--surface-2);
  color: var(--text);
  font-size: 1.15rem;
  cursor: pointer;
  flex-shrink: 0;
}
.control-btn:hover { background: #2c3d4c; }
.control-btn.active-off { background: var(--danger); }
.control-btn.danger { background: var(--danger); }
.control-btn.danger:hover { background: #c93a32; }

.toast {
  position: fixed;
  bottom: 90px;
  left: 50%;
  transform: translateX(-50%);
  background: #223142;
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 0.85rem;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
  max-width: 90vw;
  text-align: center;
  z-index: 20;
}
.toast.hidden { display: none; }

.ended-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 15, 20, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 30;
  padding: 20px;
}
.ended-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 30px;
  text-align: center;
  max-width: 340px;
}
.ended-card p { margin: 0 0 18px; font-size: 1rem; }

@media (max-width: 700px) {
  .landing-card { padding: 26px 22px; }
  .room-header { padding: 8px 12px; }
  .chat-panel {
    position: fixed;
    right: 0;
    top: 0;
    bottom: 0;
    width: 88vw;
    z-index: 15;
  }
  .control-btn { width: 46px; height: 46px; font-size: 1.05rem; }
  .controls-bar { gap: 8px; padding: 10px; }
  .video-grid { padding: 6px; gap: 6px; }
}
