:root {
  --bg: #e7f5f6;
  --bg-warm: #d6eff1;
  --bg-green: #cfe9ee;
  --ink: #1f2f36;
  --muted: #50636b;
  --accent: #2aa3b3;
  --accent-strong: #1f7f8b;
  --card: rgba(255, 255, 255, 0.82);
  --stroke: rgba(31, 47, 54, 0.12);
  --shadow: 0 20px 60px rgba(16, 34, 40, 0.18);
  --radius-lg: 28px;
  --radius-md: 18px;
}

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

html,
body {
  height: 100%;
}

body {
  min-height: 100dvh;
  height: 100dvh;
  font-family: "Manrope", "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: radial-gradient(circle at top, var(--bg-warm), transparent 60%),
    linear-gradient(130deg, var(--bg) 0%, #e2f1f3 40%, var(--bg-green) 100%);
  overflow: hidden;
}

.ambient {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

.glow {
  position: absolute;
  width: 320px;
  height: 320px;
  border-radius: 50%;
  filter: blur(70px);
  opacity: 0.55;
  animation: float 14s ease-in-out infinite;
}

.glow--one {
  top: 8%;
  left: 8%;
  background: #b9ecf2;
}

.glow--two {
  bottom: 15%;
  right: 10%;
  background: #b6dde7;
  animation-delay: -6s;
}

.glow--three {
  top: 40%;
  right: 30%;
  background: #a8d5de;
  animation-delay: -10s;
}

@keyframes float {
  0%,
  100% {
    transform: translate(0, 0);
  }
  50% {
    transform: translate(14px, -18px);
  }
}

.app {
  position: relative;
  z-index: 1;
  height: 100dvh;
  box-sizing: border-box;
  max-width: 100%;
  margin: 0 auto;
  padding: 16px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 10px;
}

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-text p {
  font-family: "Fraunces", "Georgia", serif;
  font-size: 20px;
}

.brand-text span {
  font-size: 13px;
  color: var(--muted);
}

.status {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  color: var(--muted);
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #f2b36b;
  box-shadow: 0 0 0 6px rgba(242, 179, 107, 0.2);
  transition: background 0.3s ease;
}

.status--live .dot {
  background: #4aa678;
  box-shadow: 0 0 0 6px rgba(74, 166, 120, 0.2);
}

.status--offline .dot {
  background: #cc6b5a;
  box-shadow: 0 0 0 6px rgba(204, 107, 90, 0.2);
}

.ghost {
  border: 1px solid var(--stroke);
  background: rgba(255, 255, 255, 0.65);
  color: var(--ink);
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 14px;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  position: relative;
}

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

.ghost--quiet {
  background: rgba(255, 255, 255, 0.4);
}

.ghost:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 24px rgba(47, 42, 36, 0.12);
}

.chat-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 18px;
  height: 18px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  display: none;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 16px rgba(31, 127, 139, 0.3);
}

.chat-badge.is-visible {
  display: inline-flex;
}

.stage {
  position: relative;
  background: var(--card);
  border-radius: var(--radius-lg);
  padding: 12px;
  box-shadow: var(--shadow);
  flex: 1;
  min-height: 0;
  display: grid;
  place-items: stretch;
  animation: rise 0.8s ease;
  overflow: hidden;
}

body.chat-open .stage {
  padding-right: 360px;
}


.stage-grid {
  position: relative;
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: 1fr;
  gap: 14px;
}

.panel {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 22px;
  overflow: hidden;
  background: #1f1d1b;
}

.panel--screen {
  background: #141312;
}

.panel-hidden {
  display: none;
}

.panel-label {
  position: absolute;
  top: 12px;
  left: 12px;
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  letter-spacing: 0.2px;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.remote {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 22px;
  overflow: hidden;
  background: #1f1d1b;
}

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

.remote-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  text-align: center;
  padding: 24px;
  color: #fef6ef;
  background: linear-gradient(180deg, rgba(31, 29, 27, 0.2), rgba(31, 29, 27, 0.7));
  transition: opacity 0.3s ease;
}

.remote-overlay h2 {
  font-family: "Fraunces", "Georgia", serif;
  font-size: 28px;
  font-weight: 600;
}

.remote-overlay p {
  font-size: 15px;
  color: rgba(254, 246, 239, 0.8);
}

.screen-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-align: center;
  padding: 24px;
  color: #fef6ef;
  background: linear-gradient(180deg, rgba(20, 19, 18, 0.2), rgba(20, 19, 18, 0.75));
  transition: opacity 0.3s ease;
}

.screen-overlay h3 {
  font-family: "Fraunces", "Georgia", serif;
  font-size: 22px;
  font-weight: 600;
}

.screen-overlay p {
  font-size: 14px;
  color: rgba(254, 246, 239, 0.8);
}

.local {
  position: absolute;
  bottom: 24px;
  right: 24px;
  width: 240px;
  height: 180px;
  border-radius: 20px;
  overflow: hidden;
  background: #2b2620;
  border: 2px solid rgba(255, 255, 255, 0.4);
  box-shadow: 0 16px 30px rgba(0, 0, 0, 0.35);
}

.local video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
}

.local-label {
  position: absolute;
  bottom: 10px;
  left: 10px;
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
}

.stage.layout-video .stage-grid {
  display: block;
}

.stage.layout-video .panel--screen {
  position: absolute;
  width: 32%;
  height: 32%;
  bottom: 24px;
  left: 24px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  box-shadow: 0 18px 30px rgba(0, 0, 0, 0.35);
}

.stage.layout-share .stage-grid {
  display: block;
}

.stage.layout-share .panel--video {
  position: absolute;
  width: 28%;
  height: 28%;
  bottom: 24px;
  right: 24px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  box-shadow: 0 18px 30px rgba(0, 0, 0, 0.35);
  z-index: 2;
}

.stage.layout-share .local {
  top: 24px;
  right: 24px;
  bottom: auto;
}

.stage.layout-split .stage-grid {
  grid-template-columns: 1.1fr 1fr;
  grid-template-rows: 1fr;
}

.stage.layout-split .local {
  width: 200px;
  height: 150px;
}

.chat {
  position: absolute;
  top: 92px;
  right: 24px;
  height: calc(100dvh - 140px);
  width: 320px;
  background: rgba(235, 248, 250, 0.92);
  backdrop-filter: blur(14px);
  border: 1px solid rgba(47, 42, 36, 0.12);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: 0 26px 60px rgba(35, 28, 20, 0.2);
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: 320px;
  animation: rise 0.9s ease;
  transform: translateX(380px) scale(0.98);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.35s ease, opacity 0.35s ease;
  overflow: hidden;
}

.chat-open .chat {
  transform: translateX(0) scale(1);
  opacity: 1;
  pointer-events: auto;
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(47, 42, 36, 0.08);
}

.chat-header h3 {
  font-family: "Fraunces", "Georgia", serif;
  font-size: 20px;
}

#roomName {
  font-size: 12px;
  color: var(--muted);
  background: rgba(31, 127, 139, 0.12);
  padding: 6px 10px;
  border-radius: 999px;
}

.chat-log {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
  padding: 4px 6px 2px 2px;
}

.chat-message {
  padding: 10px 12px;
  border-radius: 16px;
  max-width: 80%;
  font-size: 14px;
  line-height: 1.4;
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid rgba(31, 127, 139, 0.1);
  box-shadow: 0 6px 12px rgba(24, 72, 82, 0.08);
}

.chat-message--self {
  align-self: flex-end;
  background: rgba(42, 163, 179, 0.18);
  border-color: rgba(42, 163, 179, 0.4);
}

.chat-message time {
  display: block;
  margin-top: 6px;
  font-size: 11px;
  color: var(--muted);
}

.chat-message .status {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  margin-top: 6px;
  font-size: 11px;
  color: var(--muted);
}

.chat-message .status-icon {
  font-size: 12px;
  color: rgba(31, 127, 139, 0.7);
}

.chat-form {
  display: flex;
  gap: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(47, 42, 36, 0.08);
}

.chat-form input {
  flex: 1;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid rgba(47, 42, 36, 0.16);
  background: rgba(255, 255, 255, 0.95);
  font-size: 14px;
  outline: none;
  transition: border 0.2s ease, box-shadow 0.2s ease;
}

.chat-form input:focus {
  border-color: rgba(42, 163, 179, 0.7);
  box-shadow: 0 0 0 3px rgba(42, 163, 179, 0.18);
}

.chat-form button {
  border: none;
  border-radius: 14px;
  padding: 12px 16px;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 10px 20px rgba(42, 163, 179, 0.25);
}

.typing-indicator {
  display: none;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
}

.typing-indicator.is-visible {
  display: flex;
}

.typing-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(42, 163, 179, 0.8);
  animation: typingPulse 1.1s infinite ease-in-out;
}

.typing-dot:nth-child(2) {
  animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typingPulse {
  0%,
  100% {
    transform: translateY(0);
    opacity: 0.5;
  }
  50% {
    transform: translateY(-4px);
    opacity: 1;
  }
}

.controls-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(31, 47, 54, 0.12);
  border-radius: 18px;
  box-shadow: 0 10px 30px rgba(16, 34, 40, 0.12);
}

.pill {
  border: 1px solid rgba(47, 42, 36, 0.18);
  background: #fff;
  color: var(--ink);
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.pill:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.pill:hover {
  transform: translateY(-1px);
}

.pill--accent {
  background: var(--accent);
  border-color: transparent;
  color: #fff;
}

.pill.is-off {
  background: rgba(47, 42, 36, 0.08);
  color: var(--muted);
}

.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: rgba(47, 42, 36, 0.85);
  color: #fff;
  padding: 12px 18px;
  border-radius: 999px;
  font-size: 13px;
  opacity: 0;
  transform: translateY(8px);
  transition: all 0.3s ease;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 980px) {
  .stage {
    min-height: 380px;
  }

  .local {
    width: 190px;
    height: 140px;
  }

  .chat {
    top: 84px;
    width: 280px;
  }

  body.chat-open .stage {
    padding-right: 320px;
  }

  .stage.layout-video .panel--screen,
  .stage.layout-share .panel--video {
    width: 40%;
    height: 32%;
  }
}

@media (max-width: 640px) {
  .top {
    flex-direction: column;
    align-items: flex-start;
  }

  .local {
    position: static;
    width: 100%;
    height: 220px;
    margin-top: 14px;
  }

  .stage {
    padding: 14px;
  }


  .chat {
    position: fixed;
    top: auto;
    bottom: 24px;
    right: 24px;
    left: 24px;
    width: auto;
    height: 40dvh;
    transform: translateY(60dvh);
  }

  .chat-open .chat {
    transform: translateY(0);
  }

  .stage.layout-video .panel--screen,
  .stage.layout-share .panel--video {
    width: 48%;
    height: 34%;
    bottom: 18px;
  }
}
