:root {
  color-scheme: dark;
  --bg: #0b1020;
  --card: rgba(255,255,255,.08);
  --line: rgba(255,255,255,.14);
  --text: #f6f7fb;
  --muted: #a9b1c7;
  --accent: #7c5cff;
  --danger: #ff4d6d;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, Segoe UI, sans-serif;
  background: radial-gradient(circle at top left, #26346d, transparent 36rem), var(--bg);
  color: var(--text);
}
.app { width: min(1100px, calc(100% - 32px)); margin: 32px auto; display: grid; gap: 18px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 22px; padding: 22px; backdrop-filter: blur(16px); box-shadow: 0 18px 60px rgba(0,0,0,.28); }
.eyebrow { color: #9ad7ff; text-transform: uppercase; letter-spacing: .14em; font-size: .75rem; font-weight: 700; }
h1 { margin: .1rem 0 .5rem; font-size: clamp(2rem, 5vw, 4rem); }
p { color: var(--muted); line-height: 1.5; }
.join { display: grid; gap: 10px; margin-top: 18px; }
label { font-weight: 700; }
.row { display: flex; gap: 10px; }
input, button { border: 0; border-radius: 14px; padding: 13px 15px; font: inherit; }
input { min-width: 0; flex: 1; background: rgba(255,255,255,.1); color: var(--text); outline: 1px solid var(--line); }
button { cursor: pointer; color: var(--text); background: rgba(255,255,255,.14); border: 1px solid var(--line); font-weight: 750; }
button:hover:not(:disabled) { transform: translateY(-1px); filter: brightness(1.08); }
button:disabled { cursor: not-allowed; opacity: .45; }
.primary { background: linear-gradient(135deg, var(--accent), #00b8ff); }
.danger { background: linear-gradient(135deg, var(--danger), #ff8a4d); }
.status { min-height: 1.5em; margin-bottom: 0; }
.stage { display: grid; grid-template-columns: 1fr 280px; gap: 18px; align-items: end; }
.videoBox { position: relative; overflow: hidden; border-radius: 24px; background: #050711; border: 1px solid var(--line); min-height: 220px; }
.videoBox.remote { aspect-ratio: 16/9; }
.videoBox.local { aspect-ratio: 4/3; }
video { width: 100%; height: 100%; object-fit: cover; display: block; background: #050711; }
.videoBox span { position: absolute; left: 12px; bottom: 12px; padding: 7px 10px; border-radius: 999px; background: rgba(0,0,0,.5); color: white; font-size: .85rem; }
.controls { display: grid; gap: 12px; }
.call-status { display: none; margin: 0; color: #dbeafe; font-size: .95rem; }
.control-buttons { display: flex; flex-wrap: wrap; gap: 10px; }
.control-buttons button { flex: 1 1 150px; }

body.in-call { background: #050711; }
body.in-call .app { width: min(1180px, calc(100% - 24px)); margin: 12px auto; min-height: calc(100vh - 24px); grid-template-rows: 1fr auto; }
body.in-call .intro { display: none; }
body.in-call .stage { align-items: stretch; }
body.in-call .controls { position: sticky; bottom: 10px; z-index: 5; }
body.in-call .call-status { display: block; }

@media (max-width: 760px) {
  .app { width: min(100% - 20px, 760px); margin: 14px auto; gap: 12px; }
  .card { padding: 16px; border-radius: 18px; }
  .row { flex-direction: column; }
  .stage { grid-template-columns: 1fr; gap: 12px; }
  .videoBox { border-radius: 18px; min-height: 0; }
  .videoBox.remote { aspect-ratio: 4 / 5; }
  .videoBox.local { aspect-ratio: 16 / 9; width: 100%; justify-self: stretch; margin-top: 0; }
  .control-buttons { display: grid; grid-template-columns: 1fr; }

  body.in-call .app { width: 100%; margin: 0; min-height: 100vh; padding: 8px; gap: 8px; }
  body.in-call .stage { grid-template-rows: minmax(0, 1fr) auto; min-height: 0; }
  body.in-call .videoBox.remote { aspect-ratio: auto; min-height: 58vh; }
  body.in-call .videoBox.local { aspect-ratio: 16 / 9; max-height: 28vh; }
  body.in-call .controls { bottom: 8px; border-radius: 18px; padding: 12px; }
  body.in-call .control-buttons { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  body.in-call .control-buttons button { padding: 11px 8px; font-size: 13px; }
  body.in-call .call-status { font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
}

/* iPhone/Safari call-screen safe-area fixes */
@supports (height: 100dvh) {
  body.in-call .app {
    min-height: 100dvh;
  }
}

@media (max-width: 760px) {
  body {
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
  }

  body.in-call {
    overflow: hidden;
  }

  body.in-call .app {
    min-height: 100dvh;
    max-height: 100dvh;
    padding: calc(env(safe-area-inset-top) + 10px) 8px calc(env(safe-area-inset-bottom) + 104px);
    grid-template-rows: minmax(0, 1fr);
    overflow: hidden;
  }

  body.in-call .stage {
    height: 100%;
    min-height: 0;
    overflow: hidden;
    grid-template-rows: minmax(0, 1fr) minmax(118px, 24vh);
  }

  body.in-call .videoBox.remote {
    min-height: 0;
    height: 100%;
  }

  body.in-call .videoBox.local {
    width: 100%;
    max-height: none;
    height: 100%;
    margin: 0;
  }

  body.in-call .controls {
    position: fixed;
    left: 8px;
    right: 8px;
    bottom: calc(env(safe-area-inset-bottom) + 14px);
    padding: 10px;
    max-height: 96px;
    overflow: hidden;
  }

  body.in-call .control-buttons button {
    min-height: 42px;
  }
}
