/* ─────────────────────────────────────────────────────────────────────────────
   VIRTUAL NORIA — premium UI
   Refined, minimal, high-craft dark theme. Restrained gold accent, glass
   surfaces, careful type and spacing. All element ids/classes preserved.
   ───────────────────────────────────────────────────────────────────────────── */
:root {
  --bg: #070a10;
  --bg-2: #0b0f17;
  --surface: rgba(255, 255, 255, .045);
  --surface-2: rgba(255, 255, 255, .07);
  --border: rgba(255, 255, 255, .09);
  --border-strong: rgba(255, 255, 255, .16);
  --ink: #f2f5fa;
  --muted: #97a3b6;
  --faint: #6b7688;
  --gold: #e4c37b;
  --gold-2: #f6e2ad;
  --gold-deep: #b8912f;
  --ok: #45d6a4;
  --bad: #ff6b6b;
  --shadow: 0 24px 70px rgba(0, 0, 0, .55);
  --font: "Inter", ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  color: var(--ink);
  font: 15px/1.6 var(--font);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  background:
    radial-gradient(1100px 620px at 50% -8%, #16233a 0%, rgba(11, 15, 23, 0) 60%),
    radial-gradient(800px 500px at 92% 8%, rgba(228, 195, 123, .07) 0%, rgba(11, 15, 23, 0) 55%),
    var(--bg);
}

.app {
  max-width: 900px;
  margin: 0 auto;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  padding: 22px 20px 26px;
  gap: 18px;
}

/* ── Header ─────────────────────────────────────────────────────────────────── */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.brand {
  display: flex; align-items: center; gap: 10px;
  font-weight: 650; font-size: 1.02rem; letter-spacing: -.01em;
}
.brand .star {
  color: var(--gold);
  filter: drop-shadow(0 0 10px rgba(228, 195, 123, .5));
  font-size: 1.05rem;
}
.brand { gap: 9px; min-width: 0; }
.backchat { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; border-radius: 8px; color: var(--muted); border: 1px solid var(--border); background: var(--surface); text-decoration: none; flex: none; transition: color .16s, border-color .16s; }
.backchat:hover { color: var(--ink); border-color: rgba(228, 195, 123, .5); }
.backchat svg { width: 18px; height: 18px; }
.pclose { display: none; }
.app.presence .pclose { display: flex; position: fixed; top: calc(16px + env(safe-area-inset-top)); right: calc(16px + env(safe-area-inset-right)); z-index: 430; width: 44px; height: 44px; align-items: center; justify-content: center; border-radius: 50%; background: rgba(10, 12, 18, .55); border: 1px solid rgba(255, 255, 255, .28); color: #fff; -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); cursor: pointer; }
.app.presence .pclose svg { width: 22px; height: 22px; }
.brand-logo { width: 24px; height: 24px; flex: none; display: block; }
.brand span { font-weight: 600; font-size: 1.12rem; letter-spacing: -.02em; }
.status { flex: none; white-space: nowrap; }
@media (max-width: 480px) {
  .app { padding: 16px 14px 22px; }
  .brand span { font-size: 1.04rem; }
  .status { font-size: .68rem; padding: 5px 10px; }
}

/* ── Voice: subtle listening dock — Noria's face stays visible (Gemini-style) ── */
.listening {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 6; display: none;
  flex-direction: column; align-items: center; justify-content: flex-end; gap: 12px;
  padding: 40px 24px 20px; text-align: center; cursor: pointer;
  background: linear-gradient(to top, rgba(7, 10, 16, .78) 0%, rgba(7, 10, 16, .5) 45%, transparent 100%);
}
.listening.on { display: flex; }
.live-transcript { font-size: 1.08rem; line-height: 1.45; color: #fff; font-weight: 500; max-width: 92%; min-height: 1.45em; text-shadow: 0 1px 8px rgba(0,0,0,.5); }
.live-transcript:empty::before { content: "Listening…"; color: rgba(255, 255, 255, .6); font-weight: 400; }
.listen-row { display: flex; align-items: center; gap: 12px; }
.wave { display: flex; align-items: center; gap: 4px; height: 22px; }
.wave span {
  width: 4px; height: 100%; border-radius: 4px;
  background: linear-gradient(180deg, #f4d77a, var(--gold));
  animation: waveJump 1s ease-in-out infinite;
}
.wave span:nth-child(1) { animation-delay: 0s; }
.wave span:nth-child(2) { animation-delay: .15s; }
.wave span:nth-child(3) { animation-delay: .3s; }
.wave span:nth-child(4) { animation-delay: .45s; }
.wave span:nth-child(5) { animation-delay: .6s; }
@keyframes waveJump { 0%, 100% { transform: scaleY(.35); } 50% { transform: scaleY(1); } }
.listen-hint { font-size: .78rem; color: rgba(255, 255, 255, .62); letter-spacing: .02em; }
@media (prefers-reduced-motion: reduce) { .wave span { animation: none; transform: scaleY(.6); } }
.tag {
  font-weight: 500; font-size: .64rem; letter-spacing: .14em; text-transform: uppercase;
  color: var(--gold); background: rgba(228, 195, 123, .1);
  border: 1px solid rgba(228, 195, 123, .22);
  padding: 3px 10px; border-radius: 999px;
}
.status {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: .74rem; color: var(--muted); font-weight: 500;
  background: var(--surface); border: 1px solid var(--border);
  padding: 6px 12px; border-radius: 999px;
}
.status .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); box-shadow: 0 0 0 0 rgba(69, 214, 164, .5); }
.status.up .dot { background: var(--ok); animation: statusPulse 2.4s ease-in-out infinite; }
.status.down .dot { background: var(--bad); }
@keyframes statusPulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(69, 214, 164, .45); } 50% { box-shadow: 0 0 0 4px rgba(69, 214, 164, 0); } }

/* ── Stage / face ───────────────────────────────────────────────────────────── */
.stage { position: relative; display: flex; justify-content: center; }
.face-wrap {
  position: relative;
  width: min(460px, 86vw);
  aspect-ratio: 3 / 3.5;
  border-radius: 24px;
  overflow: hidden;
  background:
    radial-gradient(75% 60% at 50% 30%, #1a3050 0%, #0c1524 72%),
    var(--bg-2);
  border: 1px solid var(--border);
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, .05), inset 0 0 80px rgba(0, 0, 0, .4);
}
.face-wrap::after { /* subtle top sheen for a glassy, premium edge */
  content: ""; position: absolute; inset: 0; pointer-events: none; border-radius: inherit;
  background: linear-gradient(180deg, rgba(255, 255, 255, .06), rgba(255, 255, 255, 0) 22%);
}
#face { width: 100%; height: 100%; display: block; position: relative; z-index: 1; }
.statechip {
  position: absolute; left: 14px; bottom: 14px; z-index: 3;
  font-size: .66rem; letter-spacing: .08em; text-transform: uppercase; font-weight: 600;
  color: var(--muted); background: rgba(7, 10, 16, .66);
  border: 1px solid var(--border); padding: 5px 11px; border-radius: 999px;
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
}
#cam {
  position: absolute; right: 14px; top: 14px; z-index: 3; width: 92px;
  border-radius: 12px; border: 1px solid var(--border); transform: scaleX(-1);
}

/* ── Transcript ─────────────────────────────────────────────────────────────── */
.transcript {
  flex: 1; min-height: 84px; max-height: 32vh; overflow-y: auto;
  display: flex; flex-direction: column; gap: 10px; padding: 2px 2px 2px;
  scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, .14) transparent;
}
.transcript::-webkit-scrollbar { width: 6px; }
.transcript::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .12); border-radius: 3px; }
.bubble {
  max-width: 80%; padding: 11px 15px; border-radius: 16px; font-size: 14.5px; line-height: 1.6;
  white-space: pre-wrap; animation: rise .28s ease both;
}
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
.bubble.you {
  align-self: flex-end; color: #1a1405; border-bottom-right-radius: 5px;
  background: linear-gradient(135deg, var(--gold), var(--gold-2));
  box-shadow: 0 8px 20px rgba(228, 195, 123, .18);
}
.bubble.noria {
  align-self: flex-start; color: #dfe8f5; border-bottom-left-radius: 5px;
  background: var(--surface); border: 1px solid var(--border);
}
.bubble.noria.thinking { padding: 13px 16px; }
.typing { display: inline-flex; align-items: center; gap: 5px; height: 8px; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); opacity: .5; animation: typingdot 1.2s infinite ease-in-out; }
.typing i:nth-child(2) { animation-delay: .16s; }
.typing i:nth-child(3) { animation-delay: .32s; }
@keyframes typingdot { 0%, 62%, 100% { transform: translateY(0); opacity: .4; } 30% { transform: translateY(-5px); opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .typing i { animation: none; opacity: .7; } }
.bubble code { background: rgba(255, 255, 255, .1); padding: 1px 6px; border-radius: 6px; font-family: ui-monospace, "SF Mono", monospace; font-size: 13px; }
.bubble pre.code {
  background: #05090f; border: 1px solid var(--border); border-radius: 12px;
  padding: 12px 14px; margin: 10px 0 4px; overflow-x: auto;
  font-family: ui-monospace, "SF Mono", monospace; font-size: 13px; line-height: 1.55; white-space: pre;
}

/* ── Controls ───────────────────────────────────────────────────────────────── */
.controls { display: flex; flex-direction: column; gap: 10px; }
/* Gemini-style rounded composer pill */
.composer {
  display: flex; align-items: center; gap: 4px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 999px; padding: 6px 7px 6px 20px;
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  transition: border-color .18s, box-shadow .18s;
}
.composer:focus-within { border-color: rgba(228, 195, 123, .5); box-shadow: 0 0 0 3px rgba(228, 195, 123, .1); }
.composer input[type=text] {
  flex: 1; min-width: 0; color: var(--ink); font-size: 15.5px; font-family: inherit;
  background: transparent; border: none; padding: 11px 4px;
}
.composer input[type=text]:focus { outline: none; }
.composer input[type=text]::placeholder { color: var(--faint); }
/* clean round icon buttons inside the composer (mic + live voice) */
.cbtn {
  flex: none; width: 40px; height: 40px; padding: 0; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent; border: none; color: var(--muted);
  transition: background .16s, color .16s;
}
.cbtn:hover { background: rgba(255, 255, 255, .08); color: var(--ink); }
.cbtn:active { transform: translateY(1px); }
.cbtn svg { width: 21px; height: 21px; }
#mic.on { color: #ff8f8f; background: rgba(255, 107, 107, .14); }
#talk .ico-stop { display: none; }
#talk.on { color: #ff8f8f; background: rgba(255, 107, 107, .14); }
#talk.on .ico-wave { display: none; }
#talk.on .ico-stop { display: inline; }
/* circular gradient send */
.send {
  flex: none; width: 40px; height: 40px; padding: 0; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  color: #1a1405; border: none;
  background: linear-gradient(135deg, var(--gold), var(--gold-2));
  box-shadow: 0 6px 16px rgba(228, 195, 123, .28);
  transition: opacity .16s, transform .12s;
}
.send:hover { opacity: .92; background: linear-gradient(135deg, var(--gold), var(--gold-2)); }
.send:active { transform: translateY(1px); }
.send svg { width: 20px; height: 20px; }
.seg svg { width: 15px; height: 15px; flex: none; }
/* Noria F / M — clear segmented choice */
.variant-toggle { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 3px; gap: 2px; }
.vseg { border: 0; background: transparent; color: var(--muted); font-family: inherit; font-size: .78rem; font-weight: 600; padding: 7px 14px; border-radius: 8px; cursor: pointer; transition: background .16s, color .16s; }
.vseg.on { background: linear-gradient(135deg, var(--gold), var(--gold-2)); color: #1a1405; box-shadow: 0 2px 8px rgba(228, 195, 123, .25); }
.vseg:not(.on):hover { color: var(--ink); }

button {
  cursor: pointer; font-family: inherit; font-size: 14.5px; color: var(--ink);
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 12px; padding: 11px 15px; transition: transform .12s, background .18s, border-color .18s, opacity .18s;
}
button:hover { background: rgba(255, 255, 255, .1); }
button:active { transform: translateY(1px); }
button.primary {
  color: #1a1405; font-weight: 700; border: none;
  background: linear-gradient(135deg, var(--gold), var(--gold-2));
  box-shadow: 0 8px 22px rgba(228, 195, 123, .22);
}
button.primary:hover { opacity: .93; background: linear-gradient(135deg, var(--gold), var(--gold-2)); }
button.icon { font-size: 17px; padding: 10px 13px; }
button.icon.on { background: rgba(255, 107, 107, .16); border-color: rgba(255, 107, 107, .5); }
#talk { font-weight: 600; }
#talk.on { background: rgba(255, 107, 107, .16); border-color: rgba(255, 107, 107, .5); color: #ffd9d9; }
button:disabled { opacity: .45; cursor: default; }

.opts { display: flex; gap: 7px; width: 100%; margin-top: 2px; flex-wrap: wrap; align-items: center; }
.seg {
  font-size: .76rem; color: var(--muted); font-weight: 500;
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(255, 255, 255, .035); border: 1px solid var(--border);
  padding: 7px 12px; border-radius: 10px; cursor: pointer; text-decoration: none;
  transition: background .16s, border-color .16s, color .16s;
}
.seg:hover { background: rgba(255, 255, 255, .07); color: var(--ink); }
.seg input { accent-color: var(--gold); }
label.seg:has(input:checked) { border-color: rgba(228, 195, 123, .5); color: var(--ink); background: rgba(228, 195, 123, .08); }
.forget { margin-left: auto; }
.forget:hover { border-color: rgba(255, 107, 107, .5); color: #ffbdbd; }

/* Feedback (👍/👎) under Noria's answers */
.fb { display: flex; align-items: center; gap: 6px; margin-top: 10px; }
.fb button { background: transparent; border: 1px solid var(--border); border-radius: 9px; padding: 3px 10px; font-size: 13px; opacity: .75; }
.fb button:hover:not(:disabled) { opacity: 1; border-color: rgba(228, 195, 123, .5); }
.fb button.on { border-color: rgba(228, 195, 123, .6); background: rgba(228, 195, 123, .14); }
.fb button:disabled { cursor: default; }
.fbthx { font-size: 11.5px; color: var(--muted); }

/* ── Presence mode: life-size, immersive Noria (like a video call) ───────────── */
.caption, .presence-bar { display: none; }
/* AR: the room camera fills the screen BEHIND the transparent Noria cutout. */
#arbg { display: none; }
.app.ar #arbg {
  display: block; position: fixed; inset: 0; width: 100vw; height: 100vh; height: 100dvh;
  object-fit: cover; z-index: 390;
}
.app.ar .face-wrap { background: transparent !important; } /* let the room camera show behind Noria */

.app.presence { max-width: none; padding: 0; }
.app.presence .topbar, .app.presence .transcript, .app.presence .controls { display: none; }
.app.presence .stage { position: static; }
.app.presence .face-wrap {
  position: fixed; inset: 0; width: 100vw; height: 100vh; height: 100dvh;
  max-width: none; aspect-ratio: auto; border: 0; border-radius: 0; z-index: 400;
  background: radial-gradient(70% 70% at 50% 30%, #16324c 0%, #06111d 75%);
}
.app.presence .face-wrap::after { display: none; }
.app.presence .statechip { top: 18px; left: 18px; bottom: auto; z-index: 420; }
.app.presence .caption {
  display: block; position: fixed; left: 50%; transform: translateX(-50%); bottom: 96px;
  z-index: 420; max-width: min(880px, 92vw); text-align: center;
  font-size: clamp(16px, 2.4vw, 23px); line-height: 1.5; color: #fff; font-weight: 500;
  text-shadow: 0 2px 16px rgba(0, 0, 0, .85); background: rgba(7, 10, 16, .38);
  padding: 12px 20px; border-radius: 16px; -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
}
.app.presence .caption:empty { display: none; }
.app.presence .presence-bar {
  display: flex; gap: 12px; position: fixed; left: 50%; transform: translateX(-50%);
  bottom: 24px; z-index: 420;
}
.presence-bar .pbtn {
  background: rgba(10, 16, 24, .68); border: 1px solid var(--border-strong); color: var(--ink);
  border-radius: 999px; padding: 13px 24px; font-size: 15px; font-weight: 600; cursor: pointer;
  font-family: inherit; -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  transition: transform .12s, opacity .18s;
}
.presence-bar .pbtn:hover { opacity: .9; }
.presence-bar .pbtn:active { transform: translateY(1px); }
.presence-bar .pbtn.primary {
  background: linear-gradient(135deg, var(--gold), var(--gold-2)); color: #1a1405; border: none;
  box-shadow: 0 10px 26px rgba(228, 195, 123, .28);
}
.presence-bar .pbtn.on { background: rgba(255, 107, 107, .2); border-color: rgba(255, 107, 107, .5); color: #fff; }

@media (max-width: 560px) {
  .app { padding: 16px 14px 20px; }
  .tag { display: none; }
}
