:root {
  --bg: #0c0b0f;
  --panel: #141318;
  --panel-2: #1b1a20;
  --line: #2a2830;
  --ink: #ece7e0;
  --muted: #8b8590;
  --orange: #ff8a5c;
  --cream: #f7d9a8;
  --green: #7fe0a4;
  --red: #f0685c;
  --violet: #b39ddb;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background:
    radial-gradient(1200px 600px at 15% -10%, #1a1520 0%, transparent 60%),
    radial-gradient(900px 500px at 110% 110%, #191320 0%, transparent 55%),
    var(--bg);
  color: var(--ink);
  font-family: 'Nunito', system-ui, sans-serif;
  padding: 18px;
}

.shell {
  position: relative;
  max-width: 1500px;
  margin: 0 auto;
  border: 1px solid var(--line);
  border-radius: 26px;
  padding: 22px 26px 16px;
  background: linear-gradient(180deg, rgba(255,255,255,0.02), transparent 40%);
}

.star {
  position: absolute;
  top: -12px; left: 22px;
  color: var(--cream);
  font-size: 22px;
  opacity: .85;
}

/* ---------- top bar ---------- */
.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.logo {
  margin: 0;
  font-family: 'Fredoka', system-ui, sans-serif;
  font-weight: 700;
  font-size: clamp(28px, 4vw, 44px);
  letter-spacing: -0.5px;
  line-height: 1;
}
.logo-a { color: #fdfbf7; }
.logo-b {
  background: linear-gradient(92deg, var(--orange), #ffb37a);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.tagline {
  margin: 6px 0 0 4px;
  font-family: 'Caveat', cursive;
  font-size: 17px;
  color: var(--muted);
}

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

.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
}
.pill-ico { opacity: .8; }

.dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--muted);
  box-shadow: 0 0 0 3px rgba(255,255,255,0.04);
}
.dot.live   { background: var(--green); box-shadow: 0 0 0 3px rgba(127,224,164,0.15); }
.dot.search { background: var(--cream); box-shadow: 0 0 0 3px rgba(247,217,168,0.15); }
.dot.off    { background: var(--red);   box-shadow: 0 0 0 3px rgba(240,104,92,0.15); }

/* ---------- layout ---------- */
.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 370px;
  gap: 18px;
  align-items: stretch;
}

.left { display: flex; flex-direction: column; gap: 16px; min-width: 0; }

.stage {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.video-wrap {
  position: relative;
  aspect-ratio: 4 / 3;
  background: #000;
  border: 1px solid var(--line);
  border-radius: 18px;
  overflow: hidden;
}

video {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}
#localVideo { transform: scaleX(-1); }

.tape {
  position: absolute;
  top: 12px; left: 12px;
  z-index: 3;
  padding: 5px 14px;
  font-family: 'Caveat', cursive;
  font-size: 19px;
  font-weight: 700;
  color: #2a2118;
  background: #f4e3c6;
  border-radius: 3px;
  transform: rotate(-2.5deg);
  box-shadow: 0 3px 10px rgba(0,0,0,.4);
}
.tape-r { transform: rotate(2deg); background: #f3dcc0; }

.vid-foot {
  position: absolute;
  bottom: 10px; left: 10px;
  z-index: 3;
  display: flex; gap: 8px;
}

.chip {
  border: 1px solid rgba(255,255,255,.14);
  background: rgba(12,11,15,.72);
  color: var(--ink);
  border-radius: 10px;
  padding: 5px 9px;
  font-size: 14px;
  cursor: pointer;
  line-height: 1;
  backdrop-filter: blur(4px);
}
.chip:hover { background: rgba(12,11,15,.9); }
.chip.muted { border-color: var(--red); color: var(--red); }

.vid-placeholder {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 8px;
  color: var(--muted);
  background: repeating-linear-gradient(45deg, #101015, #101015 12px, #131319 12px, #131319 24px);
}
.vid-placeholder[hidden] { display: none; }
.ph-emoji { font-size: 34px; opacity: .75; }
.ph-text { font-family: 'Caveat', cursive; font-size: 19px; }

/* ---------- controls ---------- */
.controls {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
}

.ctrl { display: flex; flex-direction: column; align-items: center; gap: 6px; flex: 1 1 130px; }
.ctrl small { color: var(--muted); font-size: 12px; font-family: 'Caveat', cursive; font-size: 15px; }

.btn {
  width: 100%;
  padding: 14px 18px;
  border: none;
  border-radius: 14px;
  font-family: 'Fredoka', system-ui, sans-serif;
  font-size: 20px;
  font-weight: 600;
  color: #1a1512;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: transform .08s ease, filter .15s ease;
}
.btn:hover:not(:disabled) { filter: brightness(1.07); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .34; cursor: not-allowed; }
.gl { font-size: 14px; opacity: .8; }

.btn-start { background: var(--green); }
.btn-next  { background: var(--cream); }
.btn-stop  { background: var(--red); color: #2a100c; }

/* ---------- chat ---------- */
.chat {
  display: flex;
  flex-direction: column;
  min-height: 480px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
  padding: 14px;
  min-width: 0;
}

.chat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-bottom: 12px;
  border-bottom: 1px dashed var(--line);
}
.chat-head h2 {
  margin: 0;
  font-family: 'Fredoka', sans-serif;
  font-size: 20px;
  color: var(--orange);
}
.sticky-note {
  font-family: 'Caveat', cursive;
  font-size: 15px;
  line-height: 1.15;
  color: #2a2118;
  background: #f4e3c6;
  padding: 6px 10px;
  border-radius: 4px;
  transform: rotate(2deg);
  text-align: center;
}

.messages {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 9px;
  padding: 14px 4px;
  min-height: 0;
}
.messages::-webkit-scrollbar { width: 7px; }
.messages::-webkit-scrollbar-thumb { background: #2f2c37; border-radius: 4px; }

.sys {
  align-self: stretch;
  text-align: center;
  font-size: 13px;
  color: var(--muted);
  background: var(--panel-2);
  border-radius: 10px;
  padding: 9px 12px;
}

.bubble {
  max-width: 85%;
  padding: 8px 13px;
  border-radius: 14px;
  font-size: 14.5px;
  line-height: 1.4;
  word-wrap: break-word;
  overflow-wrap: anywhere;
}
.bubble .who { font-weight: 700; opacity: .75; }
.bubble.them { align-self: flex-start; background: var(--orange); color: #33170e; border-bottom-left-radius: 5px; }
.bubble.me   { align-self: flex-end;   background: var(--cream);  color: #33280e; border-bottom-right-radius: 5px; }
.stamp { display: block; font-size: 10.5px; opacity: .6; margin-top: 3px; }

.typing {
  font-size: 12.5px;
  color: var(--muted);
  padding: 2px 6px 6px;
}
.typing .d { animation: blink 1.2s infinite; margin-left: 1px; }
.typing .d:nth-child(2) { animation-delay: .2s; }
.typing .d:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%,60%,100% { opacity: .25 } 30% { opacity: 1 } }

.composer { display: flex; gap: 8px; padding-top: 10px; border-top: 1px dashed var(--line); }
#chatInput {
  flex: 1;
  min-width: 0;
  padding: 12px 15px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--ink);
  font-family: inherit;
  font-size: 14.5px;
}
#chatInput:focus { outline: none; border-color: var(--orange); }
#chatInput:disabled { opacity: .5; }
.send {
  border: none;
  border-radius: 12px;
  width: 46px;
  background: var(--orange);
  color: #33170e;
  font-size: 17px;
  cursor: pointer;
  flex: none;
}
.send:disabled { opacity: .35; cursor: not-allowed; }

/* ---------- footer ---------- */
.footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.note {
  font-family: 'Caveat', cursive;
  font-size: 16px;
  line-height: 1.2;
  padding: 9px 14px;
  border: 1px dashed #3a3742;
  border-radius: 8px;
  color: var(--muted);
}
.note-tip  { transform: rotate(-1.5deg); }
.note-made { transform: rotate(1deg); text-align: right; }
.note-made span { color: #6f6a76; font-size: 14px; }

.doodle {
  font-family: 'Caveat', cursive;
  font-size: 17px;
  color: var(--violet);
  opacity: .85;
}
.doodle span { color: var(--muted); }

/* ---------- responsive ---------- */
@media (max-width: 1080px) {
  .layout { grid-template-columns: 1fr; }
  .chat { min-height: 420px; }
}
@media (max-width: 640px) {
  body { padding: 8px; }
  .shell { padding: 16px 14px 12px; border-radius: 18px; }
  .stage { grid-template-columns: 1fr; }
  .controls { padding: 12px; gap: 10px; }
  .btn { font-size: 17px; padding: 12px 14px; }
  .footer { justify-content: center; text-align: center; }
  .note-made { text-align: center; }
}
