:root {
  --gold: #e8c36a;
  --gold-2: #f3d48a;
  --end: #ff3b30;
  --ok: #30d158;
  --ink: #f7f1e6;
  --muted: rgba(247, 241, 230, 0.62);
  --glass: rgba(12, 10, 12, 0.42);
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; background: #070608; color: var(--ink); }
body {
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  overflow: hidden;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
[hidden] { display: none !important; }

.screen {
  position: relative;
  height: 100dvh;
  width: 100%;
  overflow: hidden;
}

.incoming-bg {
  position: absolute; inset: -8%;
  background-size: cover;
  background-position: center 20%;
  filter: blur(28px) saturate(1.15);
  transform: scale(1.12);
}
.incoming-shade {
  position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(8,6,8,.35), rgba(8,6,8,.78) 55%, #070608);
}
.incoming-body {
  position: relative;
  z-index: 2;
  padding: calc(72px + var(--safe-t)) 24px 0;
  text-align: center;
}
.kicker {
  letter-spacing: 0.28em;
  text-transform: uppercase;
  font-size: 11px;
  color: var(--gold);
  margin: 0 0 22px;
}
.avatar-wrap { position: relative; width: 132px; height: 132px; margin: 0 auto 22px; }
.avatar {
  width: 132px; height: 132px; object-fit: cover; object-position: center 18%;
  border-radius: 50%;
  box-shadow: 0 10px 40px rgba(0,0,0,.45);
  border: 2px solid rgba(232,195,106,.55);
}
.avatar-ring {
  position: absolute; inset: -10px; border-radius: 50%;
  border: 1px solid rgba(232,195,106,.45);
  animation: pulse 2.2s ease-out infinite;
}
@keyframes pulse {
  0% { transform: scale(.92); opacity: .8; }
  100% { transform: scale(1.18); opacity: 0; }
}
.incoming-body h1, #ended h1 {
  font-family: Palatino, "Palatino Linotype", "Iowan Old Style", Georgia, serif;
  font-weight: 500;
  font-size: 42px;
  margin: 0 0 8px;
  letter-spacing: 0.02em;
}
.sub { margin: 0; color: var(--muted); font-size: 16px; }
.incoming-actions {
  position: absolute;
  left: 0; right: 0; bottom: calc(36px + var(--safe-b));
  display: flex;
  justify-content: space-around;
  padding: 0 28px;
  z-index: 2;
}
.round {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  color: #fff;
}
.round svg {
  width: 28px; height: 28px;
  padding: 18px;
  box-sizing: content-box;
  border-radius: 50%;
}
.round span { font-size: 13px; color: var(--muted); }
.round.decline svg { background: var(--end); }
.round.accept svg { background: var(--ok); animation: bounce 1.6s ease-in-out infinite; }
@keyframes bounce {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.06); }
}

.stage { position: absolute; inset: 0; overflow: hidden; background: #1a1210; }
#stage-photo {
  width: 100%; height: 100%;
  object-fit: cover;
  object-position: center 18%;
  transform-origin: 50% 30%;
  animation: ken 22s ease-in-out infinite alternate;
  filter: saturate(1.08) contrast(1.04);
}
@keyframes ken {
  from { transform: scale(1) translate3d(0,0,0); }
  to { transform: scale(1.1) translate3d(-1.5%, -1%, 0); }
}
.stage.talking #stage-photo {
  filter: saturate(1.14) contrast(1.06) brightness(1.04);
}
.grade {
  position: absolute; inset: 0;
  background:
    linear-gradient(180deg, rgba(8,6,8,.28) 0%, transparent 22%, transparent 58%, rgba(8,6,8,.78) 100%),
    radial-gradient(120% 70% at 50% 0%, rgba(232,195,106,.12), transparent 50%);
  pointer-events: none;
}
.vignette {
  position: absolute; inset: 0;
  box-shadow: inset 0 0 120px 24px rgba(0,0,0,.45);
  pointer-events: none;
}
.grain {
  position: absolute; inset: 0; opacity: .06; pointer-events: none; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='120' height='120'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}

.topbar {
  position: absolute; top: 0; left: 0; right: 0;
  padding: calc(14px + var(--safe-t)) 16px 10px;
  display: flex; justify-content: space-between; align-items: flex-start;
  z-index: 3;
}
.who { display: flex; flex-direction: column; gap: 2px; }
.who strong {
  font-family: Palatino, Georgia, serif;
  font-size: 22px;
  font-weight: 500;
  text-shadow: 0 2px 12px rgba(0,0,0,.55);
}
#call-meta, #timer {
  font-size: 12px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--gold-2);
  text-shadow: 0 1px 8px rgba(0,0,0,.6);
}
.top-right { display: flex; align-items: center; gap: 10px; }
.ghost {
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--glass);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(255,255,255,.12);
  font-size: 12px;
}

#pip {
  position: absolute;
  right: 14px;
  bottom: calc(138px + var(--safe-b));
  width: 92px;
  height: 124px;
  object-fit: cover;
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,.22);
  box-shadow: 0 8px 24px rgba(0,0,0,.4);
  z-index: 4;
  background: #111;
  transform: scaleX(-1);
}

.connecting {
  position: absolute;
  left: 50%;
  top: 46%;
  transform: translate(-50%, -50%);
  z-index: 4;
  padding: 10px 16px;
  border-radius: 999px;
  background: rgba(8,6,8,.55);
  backdrop-filter: blur(12px);
  letter-spacing: .18em;
  text-transform: uppercase;
  font-size: 11px;
  color: var(--gold-2);
  animation: pulse 1.6s ease-in-out infinite;
}

.caption-wrap {
  position: absolute;
  left: 16px; right: 16px;
  bottom: calc(118px + var(--safe-b));
  z-index: 4;
  text-align: center;
}
#caption {
  margin: 8px 0 0;
  font-size: 16px;
  line-height: 1.35;
  text-shadow: 0 2px 14px rgba(0,0,0,.8);
  min-height: 1.35em;
}
.waveform {
  display: inline-flex; gap: 4px; align-items: flex-end; height: 16px;
}
.waveform i {
  display: block; width: 3px; height: 6px; border-radius: 2px; background: var(--gold);
  animation: eq 0.7s ease-in-out infinite;
}
.waveform i:nth-child(2) { animation-delay: .1s; }
.waveform i:nth-child(3) { animation-delay: .18s; }
.waveform i:nth-child(4) { animation-delay: .08s; }
.waveform i:nth-child(5) { animation-delay: .22s; }
@keyframes eq {
  0%, 100% { height: 5px; opacity: .6; }
  50% { height: 16px; opacity: 1; }
}

.controls {
  position: absolute;
  left: 0; right: 0;
  bottom: calc(22px + var(--safe-b));
  display: flex;
  justify-content: space-evenly;
  align-items: center;
  z-index: 5;
  padding: 0 8px;
}
.ctl {
  width: 52px; height: 52px; border-radius: 50%;
  background: rgba(20,16,18,.55);
  backdrop-filter: blur(18px);
  border: 1px solid rgba(255,255,255,.14);
  color: #fff;
  display: grid; place-items: center;
}
.ctl svg { width: 22px; height: 22px; }
.ctl.mic {
  width: 72px; height: 72px;
  background: radial-gradient(circle at 30% 20%, #f3d48a, #c8963a 62%, #8a6420);
  border: 0;
  color: #2a1a08;
  box-shadow: 0 10px 30px rgba(200,150,58,.4);
}
.ctl.mic.listening {
  outline: 3px solid rgba(232,195,106,.55);
  transform: scale(1.04);
}
.ctl.end { background: var(--end); border: 0; }
.ctl.on { background: rgba(255,255,255,.18); }
.hint {
  position: absolute;
  left: 0; right: 0;
  bottom: calc(4px + var(--safe-b));
  text-align: center;
  font-size: 11px;
  color: var(--muted);
  z-index: 5;
  pointer-events: none;
}

.sheet {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: min(62dvh, 520px);
  background: rgba(12,10,12,.82);
  backdrop-filter: blur(28px);
  border-radius: 22px 22px 0 0;
  z-index: 8;
  display: flex; flex-direction: column;
  padding-bottom: var(--safe-b);
  border-top: 1px solid rgba(255,255,255,.1);
}
.sheet-handle {
  width: 42px; height: 4px; border-radius: 4px;
  background: rgba(255,255,255,.28);
  margin: 10px auto 0;
}
.sheet-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 16px 8px;
}
.messages {
  flex: 1; overflow-y: auto;
  padding: 8px 16px 12px;
  display: flex; flex-direction: column; gap: 8px;
}
.bubble {
  max-width: 82%;
  padding: 10px 12px;
  border-radius: 16px;
  font-size: 15px;
  line-height: 1.35;
  white-space: pre-wrap;
}
.bubble.user {
  align-self: flex-end;
  background: #3a2a16;
  border: 1px solid rgba(232,195,106,.25);
}
.bubble.assistant {
  align-self: flex-start;
  background: rgba(255,255,255,.1);
}
.composer {
  display: flex; gap: 8px;
  padding: 8px 12px 12px;
}
.composer input {
  flex: 1;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 999px;
  padding: 12px 16px;
  outline: none;
}
.send {
  width: 44px; height: 44px; border-radius: 50%;
  background: var(--gold);
  color: #2a1a08;
  font-size: 16px;
}
.text-btn {
  margin-top: 28px;
  background: var(--gold);
  color: #2a1a08;
  padding: 12px 22px;
  border-radius: 999px;
  font-weight: 600;
}

@media (min-width: 720px) {
  #app {
    max-width: 430px;
    margin: 0 auto;
    height: 100dvh;
    box-shadow: 0 0 80px rgba(0,0,0,.6);
    position: relative;
  }
  .screen { height: 100dvh; }
}
