/* ─────────────────────────────────────────────────────────────────
   Live Interpreter Call — modern, mobile-first, responsive UI
   ───────────────────────────────────────────────────────────────── */
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
:root {
  --bg: #0b1020;
  --bg2: #0e1430;
  --glass: rgba(255,255,255,.07);
  --glass-brd: rgba(255,255,255,.12);
  --text: #eef1fb;
  --muted: #9aa6cf;
  --accent: #7c5cff;
  --accent2: #19c3ff;
  --green: #2ee6a6;
  --red: #ff5d73;
  --shadow: 0 18px 50px rgba(0,0,0,.45);
}
html, body { height: 100%; }
body {
  font-family: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
.screen { height: 100dvh; display: flex; flex-direction: column; }
.hidden { display: none !important; }
button { font-family: inherit; }

/* ── JOIN SCREEN ───────────────────────────────────────────────── */
.join {
  align-items: center; justify-content: center; position: relative;
  background: radial-gradient(1200px 600px at 50% -10%, #1a2150 0%, var(--bg) 60%);
  padding: 20px; overflow: hidden;
}
.orb { position: absolute; border-radius: 50%; filter: blur(60px); opacity: .55; z-index: 0; animation: float 14s ease-in-out infinite; }
.orb1 { width: 380px; height: 380px; background: #7c5cff; top: -90px; left: -80px; }
.orb2 { width: 320px; height: 320px; background: #19c3ff; bottom: -90px; right: -60px; animation-delay: -4s; }
.orb3 { width: 260px; height: 260px; background: #ff5d99; top: 40%; right: 20%; opacity: .35; animation-delay: -8s; }
@keyframes float { 0%,100% { transform: translateY(0) } 50% { transform: translateY(-28px) } }

.card {
  position: relative; z-index: 1;
  width: 400px; max-width: 94vw;
  background: linear-gradient(180deg, rgba(255,255,255,.10), rgba(255,255,255,.04));
  border: 1px solid var(--glass-brd);
  border-radius: 24px; padding: 30px 28px;
  box-shadow: var(--shadow); backdrop-filter: blur(18px);
  text-align: center;
}
.logo { font-size: 46px; line-height: 1; margin-bottom: 10px; filter: drop-shadow(0 6px 16px rgba(124,92,255,.5)); }
.card h1 {
  font-size: 25px; font-weight: 800; letter-spacing: -.4px;
  background: linear-gradient(90deg, #fff, #c9d2ff);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
.card .sub { color: var(--muted); font-size: 14px; margin-top: 8px; line-height: 1.5; }
.langrow { display: flex; align-items: center; justify-content: center; gap: 8px; font-size: 22px; margin: 18px 0 6px; }
.langrow .arrow { color: var(--accent2); font-size: 18px; margin-left: 2px; }
.field { text-align: left; margin-top: 16px; }
.field label { display: block; font-size: 12.5px; color: var(--muted); margin: 0 0 7px 3px; font-weight: 500; }
.field input, .select-wrap select {
  width: 100%; padding: 14px 15px; font-size: 15.5px; color: var(--text);
  background: rgba(0,0,0,.25); border: 1px solid var(--glass-brd); border-radius: 13px;
  outline: none; transition: border-color .2s, box-shadow .2s;
}
.field input:focus, .select-wrap select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(124,92,255,.25); }
.select-wrap { position: relative; }
.select-wrap select { appearance: none; -webkit-appearance: none; cursor: pointer; }
.select-wrap::after { content: '▾'; position: absolute; right: 16px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.primary {
  width: 100%; margin-top: 22px; padding: 15px; border: none; border-radius: 14px;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  color: #fff; font-size: 16px; font-weight: 700; cursor: pointer;
  box-shadow: 0 10px 26px rgba(124,92,255,.4); transition: transform .15s, filter .2s;
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
.primary:hover { filter: brightness(1.07); }
.primary:active { transform: scale(.98); }
.primary .ar { transition: transform .2s; }
.primary:hover .ar { transform: translateX(4px); }
.hint { color: var(--accent2); font-size: 12.5px; margin-top: 12px; min-height: 16px; }
.foot { position: relative; z-index: 1; color: var(--muted); font-size: 12px; margin-top: 18px; opacity: .8; }
.foot b { color: #cdd6ff; }

/* ── CALL SCREEN ───────────────────────────────────────────────── */
.call { background: var(--bg); }
.topbar {
  display: flex; align-items: center; gap: 10px;
  padding: calc(10px + env(safe-area-inset-top)) 14px 10px;
  background: rgba(10,14,30,.7); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--glass-brd); z-index: 30;
}
.brand { font-weight: 700; font-size: 15px; display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.livedot { width: 9px; height: 9px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 0 rgba(46,230,166,.6); animation: pulse 2s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(46,230,166,.5) } 70% { box-shadow: 0 0 0 8px rgba(46,230,166,0) } 100% { box-shadow: 0 0 0 0 rgba(46,230,166,0) } }
.status {
  flex: 1; text-align: center; font-size: 13px; color: var(--muted);
  background: var(--glass); border: 1px solid var(--glass-brd); border-radius: 100px;
  padding: 6px 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.status.connected { color: var(--green); border-color: rgba(46,230,166,.35); }
.top-actions { display: flex; gap: 8px; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 12px; font-size: 17px; cursor: pointer;
  background: var(--glass); border: 1px solid var(--glass-brd); color: var(--text);
  display: flex; align-items: center; justify-content: center; transition: background .2s, transform .1s;
}
.icon-btn:hover { background: rgba(255,255,255,.14); }
.icon-btn:active { transform: scale(.92); }
.icon-btn.small { width: 32px; height: 32px; font-size: 14px; }
.lang-select { height: 40px; border-radius: 12px; padding: 0 10px; font-size: 13px; font-weight: 600; cursor: pointer; background: var(--glass); border: 1px solid var(--glass-brd); color: var(--text); outline: none; }
.lang-select:focus { border-color: var(--accent); }

.middle { flex: 1; display: flex; min-height: 0; position: relative; }

/* Stage — full-bleed remote video, floating self PiP */
.stage { flex: 1; position: relative; background: #05070f; overflow: hidden; }
.remotes { position: absolute; inset: 0; display: grid; gap: 8px; padding: 8px; grid-template-columns: 1fr; }
.remotes.n2 { grid-template-columns: 1fr 1fr; }
.remotes.n3, .remotes.n4 { grid-template-columns: 1fr 1fr; grid-auto-rows: 1fr; }
.rtile { position: relative; background: #0a0e1c; border: 1px solid var(--glass-brd); border-radius: 14px; overflow: hidden; display: flex; align-items: center; justify-content: center; min-height: 0; }
.rtile video { width: 100%; height: 100%; object-fit: cover; background: #0a0e1c; }
.rtile .tag { position: absolute; left: 10px; bottom: 10px; z-index: 3; }
.rtile .ph { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; color: var(--muted); font-size: 13px; background: radial-gradient(400px 280px at 50% 40%, #141b3c 0%, #0a0e1c 70%); }
.rtile .ph .av { width: 64px; height: 64px; border-radius: 50%; font-size: 30px; display: flex; align-items: center; justify-content: center; background: linear-gradient(180deg, #232c5a, #161d3e); border: 1px solid var(--glass-brd); }
.rtile.speaking { border-color: var(--green); box-shadow: 0 0 0 2px rgba(46,230,166,.4); }
.placeholder {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 14px;
  color: var(--muted); font-size: 14.5px; text-align: center; padding: 24px;
  background: radial-gradient(600px 400px at 50% 40%, #141b3c 0%, #05070f 70%);
}
.placeholder .avatar {
  width: 92px; height: 92px; border-radius: 50%; font-size: 44px;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(180deg, #232c5a, #161d3e); border: 1px solid var(--glass-brd);
  box-shadow: var(--shadow);
}
.placeholder.small { gap: 0; font-size: 22px; background: linear-gradient(180deg, #1a2148, #0d1230); }

.tag {
  position: absolute; left: 12px; bottom: 12px; z-index: 4;
  background: rgba(0,0,0,.55); backdrop-filter: blur(6px);
  padding: 4px 11px; border-radius: 9px; font-size: 12px; font-weight: 500;
  border: 1px solid var(--glass-brd);
}

.self-pip {
  position: absolute; top: 14px; right: 14px; z-index: 10;
  width: 132px; height: 186px; border-radius: 16px; overflow: hidden;
  background: #0d1230; border: 1.5px solid var(--glass-brd);
  box-shadow: var(--shadow); transition: transform .2s;
}
.self-pip video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); background: #0d1230; }
.self-pip .tag { left: 8px; bottom: 8px; font-size: 11px; padding: 2px 8px; }
.self-pip .placeholder { font-size: 26px; }

/* Subtitle — the spoken translation, shown large */
.subtitle {
  position: absolute; left: 50%; bottom: 22px; transform: translateX(-50%);
  width: min(86%, 720px); z-index: 12;
  background: rgba(8,11,24,.82); backdrop-filter: blur(10px);
  border: 1px solid var(--glass-brd); border-radius: 16px;
  padding: 14px 20px; font-size: 19px; line-height: 1.45; text-align: center;
  box-shadow: var(--shadow); animation: rise .25s ease;
}
@keyframes rise { from { opacity: 0; transform: translate(-50%, 10px) } to { opacity: 1; transform: translate(-50%, 0) } }
.subtitle .who { color: var(--accent2); font-weight: 700; margin-right: 8px; }

/* Transcript — docked sidebar on desktop, slide-up sheet on mobile */
.transcript {
  width: 340px; flex-shrink: 0; background: var(--bg2);
  border-left: 1px solid var(--glass-brd); display: flex; flex-direction: column;
}
.transcript-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--glass-brd); font-size: 14px; font-weight: 600; }
.transcript-body { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 12px; }
.tx-empty { color: var(--muted); font-size: 13px; text-align: center; margin-top: 30px; line-height: 1.6; }
.line { font-size: 14.5px; line-height: 1.45; animation: fadein .2s ease; }
@keyframes fadein { from { opacity: 0; transform: translateY(4px) } to { opacity: 1 } }
.line .name { font-weight: 600; font-size: 11.5px; color: var(--accent2); display: block; margin-bottom: 3px; }
.line.me .name { color: var(--green); }
.line .bubble { background: var(--glass); border: 1px solid var(--glass-brd); border-radius: 12px; padding: 9px 12px; }
.line.me .bubble { background: rgba(46,230,166,.10); border-color: rgba(46,230,166,.25); }
.line .orig { color: var(--muted); font-size: 12px; font-style: italic; margin-top: 5px; }

.scrim { display: none; }

/* Controls — glass bar */
.controls {
  display: flex; justify-content: center; gap: 10px;
  padding: 12px 12px calc(12px + env(safe-area-inset-bottom));
  background: rgba(10,14,30,.78); backdrop-filter: blur(14px);
  border-top: 1px solid var(--glass-brd); z-index: 30;
}
.ctrl {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  width: 76px; padding: 10px 6px; border-radius: 16px; cursor: pointer; font-size: 22px;
  background: var(--glass); border: 1px solid var(--glass-brd); color: var(--text);
  transition: transform .12s, background .2s, border-color .2s;
}
.ctrl span { font-size: 11px; color: var(--muted); font-weight: 500; }
.ctrl:active { transform: scale(.93); }
.ctrl.on { background: linear-gradient(180deg, rgba(124,92,255,.35), rgba(25,195,255,.18)); border-color: rgba(124,92,255,.6); box-shadow: 0 6px 18px rgba(124,92,255,.25); }
.ctrl.on span { color: #e6e9ff; }
.ctrl.leave { background: rgba(255,93,115,.16); border-color: rgba(255,93,115,.5); }
.ctrl.leave span { color: #ffb3bd; }
.ctrl.leave:hover { background: rgba(255,93,115,.28); }

/* ── RESPONSIVE: tablet / phone ────────────────────────────────── */
@media (max-width: 900px) {
  .transcript {
    position: fixed; left: 0; right: 0; bottom: 0; top: auto; width: 100%;
    height: 62dvh; border-left: none; border-top: 1px solid var(--glass-brd);
    border-radius: 22px 22px 0 0; z-index: 50;
    transform: translateY(100%); transition: transform .28s cubic-bezier(.4,0,.2,1);
  }
  .transcript.open { transform: translateY(0); }
  .scrim.show { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 45; }
  .self-pip { width: 104px; height: 150px; top: 12px; right: 12px; }
  .subtitle { font-size: 17px; bottom: 16px; padding: 12px 16px; }
}
@media (max-width: 480px) {
  .brand span:not(.livedot) { display: none; }
  .ctrl { width: auto; flex: 1; max-width: 80px; }
  .self-pip { width: 88px; height: 124px; }
  .subtitle { font-size: 16px; width: 92%; }
  .card { padding: 26px 20px; }
}
@media (min-width: 901px) {
  /* desktop: transcript can be toggled off via JS class */
  .transcript.closed { display: none; }
}
