:root {
  --bg: #0c0a13;
  --panel: #161320;
  --panel-2: #1e1a2c;
  --panel-3: #241f36;
  --border: #322a48;
  --text: #ece9f7;
  --muted: #9791ac;
  --accent: #9b5cff;
  --accent-2: #7c3aed;
  --accent-glow: rgba(155, 92, 255, 0.45);
  --danger: #ff5c6c;
  --ok: #3ddc84;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

a { color: var(--accent); }

::selection { background: var(--accent-glow); }

/* ---- Home page / hero ---- */

.hero-page {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 24px 48px;
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(60% 50% at 50% 0%, rgba(124, 58, 237, 0.28), transparent 70%),
    var(--bg);
}

.drip-bar {
  width: 100%;
  max-width: 720px;
  height: 8px;
  margin: 56px auto 0;
  border-radius: 5px;
  background: linear-gradient(90deg, #6d28d9, var(--accent), #6d28d9);
  box-shadow: 0 4px 24px var(--accent-glow);
  flex-shrink: 0;
}

.drip-row {
  width: 100%;
  max-width: 720px;
  margin: -1px auto 0;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  gap: clamp(6px, 2vw, 16px);
  flex-shrink: 0;
}

.drip {
  display: block;
  background: linear-gradient(180deg, var(--accent), #5b21b6);
  border-radius: 0 0 50% 50% / 0 0 100% 100%;
  box-shadow: 0 6px 14px rgba(124, 58, 237, 0.35);
}

.brand-mark {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  margin-top: 4px;
}

.brand-mark .drop-icon {
  width: 46px;
  height: 46px;
  margin-bottom: 14px;
  filter: drop-shadow(0 2px 10px var(--accent-glow));
}

.brand-mark h1 {
  font-size: 44px;
  margin: 0;
  font-weight: 800;
  letter-spacing: -0.5px;
  background: linear-gradient(180deg, #f2eaff, var(--accent) 140%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.brand-mark h1 .thin {
  font-weight: 400;
  opacity: 0.85;
}

.brand-mark p.tagline {
  color: var(--muted);
  font-size: 15.5px;
  max-width: 460px;
  margin: 14px 0 0;
  line-height: 1.55;
}

.hero-content {
  width: 100%;
  display: flex;
  justify-content: center;
  margin-top: 34px;
}

/* ---- Cards / forms ---- */

.card {
  background: linear-gradient(180deg, var(--panel-3), var(--panel));
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.45), 0 0 0 1px rgba(155,92,255,0.05);
}

.center-page {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(60% 50% at 50% 0%, rgba(124, 58, 237, 0.22), transparent 70%),
    var(--bg);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 24px;
}

.brand .drop-icon {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
}

.brand h1 {
  font-size: 20px;
  margin: 0;
  font-weight: 700;
}

label {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin: 16px 0 6px;
}

input[type="text"], input[type="password"] {
  width: 100%;
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 15px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}

input[type="text"]:focus, input[type="password"]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

button {
  cursor: pointer;
  border: none;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  padding: 12px 18px;
  transition: filter .15s, opacity .15s, transform .1s;
}

button:disabled { opacity: .5; cursor: not-allowed; }
button:active:not(:disabled) { transform: scale(0.98); }

.btn-primary {
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
  color: white;
  width: 100%;
  margin-top: 22px;
  box-shadow: 0 8px 24px var(--accent-glow);
}

.btn-primary:hover:not(:disabled) { filter: brightness(1.08); }

.error-box {
  margin-top: 14px;
  background: rgba(255,92,108,0.12);
  border: 1px solid rgba(255,92,108,0.4);
  color: var(--danger);
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13px;
  display: none;
}
.error-box.show { display: block; }

.hint { font-size: 12px; color: var(--muted); margin-top: 10px; text-align: center; }

.foot-note {
  margin-top: 32px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.foot-note .domain-tag {
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.02em;
}

.foot-note .powered-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 16px;
  border-radius: 999px;
  background: linear-gradient(180deg, var(--panel-3), var(--panel));
  border: 1px solid var(--border);
  box-shadow: 0 4px 16px rgba(124, 58, 237, 0.12);
  font-size: 12.5px;
  color: var(--muted);
}

.foot-note .powered-badge svg {
  width: 13px;
  height: 13px;
  flex-shrink: 0;
}

.foot-note .powered-badge strong {
  color: var(--text);
  font-weight: 700;
  background: linear-gradient(90deg, #d9c4ff, var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* ---- Room layout ---- */

.room-shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
  flex-wrap: wrap;
  gap: 10px;
}

.topbar .left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.topbar .brand-sm {
  display: flex;
  align-items: center;
  gap: 7px;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
}

.topbar .brand-sm .drop-icon { width: 18px; height: 18px; }

.topbar .room-id {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
  color: var(--muted);
  background: var(--panel-2);
  padding: 4px 8px;
  border-radius: 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 220px;
}

.topbar .actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.btn-sm {
  padding: 8px 12px;
  font-size: 13px;
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-sm:hover:not(:disabled) { border-color: var(--accent); }

select.btn-sm {
  cursor: pointer;
  appearance: auto;
}
select.btn-sm:disabled {
  opacity: .5;
  cursor: not-allowed;
}

.btn-share {
  background: var(--accent);
  color: white;
}
.btn-share.sharing {
  background: var(--danger);
}

.main-area {
  flex: 1;
  display: flex;
  min-height: 0;
}

.stage {
  flex: 1;
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  justify-content: center;
  gap: 12px;
  padding: 16px;
  overflow-y: auto;
  position: relative;
  background:
    radial-gradient(50% 40% at 50% 0%, rgba(124,58,237,0.10), transparent 70%),
    #08070d;
}

.stage.single-tile {
  align-content: stretch;
  align-items: stretch;
  justify-content: stretch;
  padding: 0;
  gap: 0;
}

.stage:not(.single-tile) .tile {
  cursor: pointer;
  transition: border-color .15s;
}
.stage:not(.single-tile) .tile:hover {
  border-color: var(--accent);
}

.stage.has-focus {
  padding: 0;
  gap: 0;
  align-content: stretch;
  overflow: hidden;
}

.stage.has-focus > .tile.is-focused {
  width: 100%;
  height: 100%;
  border: none;
  border-radius: 0;
  cursor: zoom-out;
}

.stage.has-focus > .tile.is-focused video {
  aspect-ratio: auto;
}

.stage.has-focus > .tile.is-hidden {
  display: none;
}

.tile {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  width: 380px;
  max-width: 100%;
  position: relative;
}

.tile video {
  width: 100%;
  height: 100%;
  display: block;
  background: #000;
  aspect-ratio: 16/9;
  object-fit: contain;
}

.tile .fullscreen-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  display: none;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  background: rgba(15, 10, 25, 0.72);
  backdrop-filter: blur(4px);
  border: 1px solid rgba(155,92,255,0.35);
  border-radius: 8px;
  color: var(--text);
  padding: 0;
}
.tile .fullscreen-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.tile .fullscreen-btn svg {
  width: 16px;
  height: 16px;
}

.stage.single-tile .tile .fullscreen-btn,
.stage.has-focus .tile.is-focused .fullscreen-btn {
  display: flex;
}

.stage.single-tile .tile {
  width: 100%;
  height: 100%;
  border: none;
  border-radius: 0;
}

.stage.single-tile .tile video {
  aspect-ratio: auto;
}

.tile .tile-label {
  position: absolute;
  bottom: 10px;
  left: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(15, 10, 25, 0.72);
  backdrop-filter: blur(4px);
  color: white;
  font-size: 12.5px;
  padding: 5px 10px 5px 8px;
  border-radius: 8px;
  border: 1px solid rgba(155,92,255,0.35);
}

.tile .tile-label .cam-icon {
  width: 14px;
  height: 14px;
  color: var(--accent);
  flex-shrink: 0;
}

.tile .vol-row {
  position: absolute;
  bottom: 10px;
  right: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(15, 10, 25, 0.72);
  backdrop-filter: blur(4px);
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid rgba(155,92,255,0.35);
  cursor: default;
}

.tile .vol-row .vol-icon {
  width: 14px;
  height: 14px;
  color: var(--muted);
  flex-shrink: 0;
}

.tile .vol-row input[type="range"] {
  width: 70px;
  accent-color: var(--accent);
  cursor: pointer;
}

.empty-stage {
  margin: auto;
  text-align: center;
  color: var(--muted);
  max-width: 320px;
}

.sidebar {
  width: 320px;
  min-width: 260px;
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  background: var(--panel);
}

.sidebar-section-header {
  padding: 12px 14px 8px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  flex-shrink: 0;
}

#participants-list {
  overflow-y: auto;
  padding: 0 8px;
  flex-shrink: 0;
  max-height: 340px;
  border-bottom: 1px solid var(--border);
}

.participant-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 8px;
  border-radius: 8px;
  font-size: 14px;
  margin-bottom: 2px;
}
.participant-row:hover { background: var(--panel-2); }

.participant-row.is-sharing {
  background: rgba(155, 92, 255, 0.12);
  border: 1px solid rgba(155, 92, 255, 0.35);
  cursor: pointer;
}
.participant-row.is-sharing:hover { background: rgba(155, 92, 255, 0.18); }
.participant-row.is-sharing.is-focused-row {
  border-color: var(--accent);
  background: rgba(155, 92, 255, 0.22);
}

.participant-row .avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--accent-2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
}
.participant-row .nick-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.participant-row .you-tag {
  font-size: 11px;
  color: var(--muted);
  flex-shrink: 0;
}
.participant-row .cam-badge {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--accent);
  color: white;
  border-radius: 999px;
  padding: 3px 8px 3px 6px;
  font-size: 10.5px;
  font-weight: 700;
  flex-shrink: 0;
}
.participant-row .cam-badge svg {
  width: 12px;
  height: 12px;
}

.chat-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

#chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.msg { max-width: 92%; }
.msg .meta {
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 2px;
}
.msg .bubble {
  background: var(--panel-2);
  padding: 8px 11px;
  border-radius: 10px;
  font-size: 14px;
  word-break: break-word;
  white-space: pre-wrap;
}
.msg.self .bubble { background: linear-gradient(135deg, var(--accent-2), var(--accent)); }
.msg.system { align-self: center; }
.msg.system .bubble {
  background: transparent;
  color: var(--muted);
  font-size: 12px;
}

.chat-input-row {
  display: flex;
  gap: 8px;
  padding: 10px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.chat-input-row input {
  flex: 1;
}

.chat-input-row button {
  background: var(--accent);
  color: white;
  padding: 10px 14px;
}

.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 13px;
  z-index: 50;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s;
}
.toast.show { opacity: 1; }

@media (max-width: 760px) {
  .main-area { flex-direction: column; }
  .sidebar { width: 100%; border-left: none; border-top: 1px solid var(--border); height: 48vh; }
  #participants-list { max-height: 160px; }
  .tile { width: 100%; }
  .brand-mark h1 { font-size: 32px; }
}
