:root {
  --night: #070b24; --night-2: #141c4a; --ink: #f4efe4; --muted: #b7bdd4; --gold: #ffd36b; --gold-ink: #241a05;
  --teal: #5fe3d0; --rose: #ff7aa8; --violet: #a98bff; --ok: #6fd39a; --warn: #ffb35c;
  --line: rgba(255, 255, 255, .14); --glass: rgba(9, 13, 36, .72); --glass-2: rgba(255, 255, 255, .06);
  --serif: "Fraunces", Georgia, serif; --sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --gap: 16px; --top: 64px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body { background: radial-gradient(120% 90% at 50% 0%, var(--night-2), var(--night) 60%, #03050f); color: var(--ink);
  font: 15px/1.5 var(--sans); }
button, input { font: inherit; color: inherit; }
button:focus-visible, input:focus-visible, a:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
a { color: var(--gold); }

.stage { position: fixed; inset: 0; }
.stage canvas { display: block; width: 100%; height: 100%; touch-action: none; }

.top { position: fixed; top: 0; left: 0; right: 0; height: var(--top); display: flex; align-items: center;
  justify-content: space-between; gap: 12px; padding: 0 var(--gap); z-index: 5;
  background: linear-gradient(180deg, rgba(5, 8, 26, .85), rgba(5, 8, 26, 0)); }
.brand { font: 700 1.25rem var(--serif); display: flex; align-items: center; gap: 10px; white-space: nowrap; }
.mark { color: var(--gold); }
.tools { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.chip { font: 600 .68rem var(--sans); letter-spacing: .08em; text-transform: uppercase; padding: 4px 9px;
  border-radius: 999px; border: 1px solid var(--line); background: var(--glass-2); color: var(--muted); }
.chip.live { color: #06291d; background: var(--ok); border-color: transparent; }
.chip.sample { color: #2b1700; background: var(--warn); border-color: transparent; }
.pill { padding: 8px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--glass); cursor: pointer;
  backdrop-filter: blur(8px); font-weight: 500; font-size: .9rem; }
.pill:hover:not(:disabled) { border-color: var(--gold); }
.pill:disabled { opacity: .45; cursor: default; }
#vr-slot button { position: static !important; width: auto !important; padding: 8px 14px !important;
  border-radius: 999px !important; font: 600 .9rem var(--sans) !important; background: var(--gold) !important;
  color: var(--gold-ink) !important; border: 0 !important; opacity: 1 !important; }

/* Chat */
.chat { position: fixed; left: var(--gap); top: calc(var(--top) + 4px); bottom: 34px; width: 380px; z-index: 4;
  display: flex; flex-direction: column; gap: 10px; padding: 12px; border-radius: 22px; background: var(--glass);
  border: 1px solid var(--line); backdrop-filter: blur(10px); }
.log { list-style: none; margin: 0; padding: 4px; overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 92%; padding: 9px 12px; border-radius: 16px; line-height: 1.45; }
.msg.user { align-self: flex-end; background: rgba(255, 211, 107, .16); border: 1px solid rgba(255, 211, 107, .35); }
.msg.genie { align-self: flex-start; background: var(--glass-2); border: 1px solid var(--line); }
.msg.genie .who { display: block; font: 600 .66rem var(--sans); letter-spacing: .1em; text-transform: uppercase;
  color: var(--gold); margin-bottom: 3px; }
.msg.note { align-self: center; color: var(--muted); font-size: .85rem; font-style: italic; background: none; }
.claims { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.claims li { font-size: .8rem; color: var(--muted); }
.claims .ok { color: var(--ok); font-weight: 600; }
.claims .warn { color: var(--warn); font-weight: 600; }
.meta { display: block; margin-top: 6px; font-size: .72rem; color: var(--muted); }
.suggest { display: flex; gap: 6px; flex-wrap: wrap; }
.suggest button { font-size: .8rem; padding: 6px 10px; border-radius: 999px; border: 1px dashed rgba(255, 211, 107, .5);
  background: transparent; cursor: pointer; color: var(--ink); text-align: left; }
.suggest button:hover { background: rgba(255, 211, 107, .12); }
.ask { display: flex; gap: 8px; }
.ask input { flex: 1; min-width: 0; padding: 11px 14px; border-radius: 999px; border: 1px solid var(--line);
  background: rgba(0, 0, 0, .3); }
.ask .send { padding: 0 16px; border-radius: 999px; border: 0; background: var(--gold); color: var(--gold-ink);
  font-weight: 700; cursor: pointer; }
.ask .send:disabled { opacity: .5; }
.mic { width: 42px; flex: none; border-radius: 50%; border: 1px solid var(--line); background: var(--glass-2); cursor: pointer; }
.mic.on { background: var(--rose); border-color: transparent; animation: pulse 1s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 8px rgba(255, 122, 168, .25); } }

/* Evidence rail */
.rail { position: fixed; right: var(--gap); top: calc(var(--top) + 4px); bottom: 34px; width: 340px; z-index: 4;
  overflow-y: auto; display: flex; flex-direction: column; gap: 12px; padding-right: 2px; }
.rail:empty::before { content: "Qloo evidence appears here as the genie works."; color: var(--muted); font-size: .85rem;
  padding: 14px; border: 1px dashed var(--line); border-radius: 18px; text-align: center; }
.card { padding: 14px; border-radius: 18px; background: var(--glass); border: 1px solid var(--line); backdrop-filter: blur(10px); }
.card h3 { margin: 0 0 4px; font: 600 1.02rem var(--serif); }
.card .kicker { font: 600 .66rem var(--sans); letter-spacing: .1em; text-transform: uppercase; color: var(--teal); }
.card h4 { margin: 10px 0 4px; font: 600 .74rem var(--sans); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.ents { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.ents li { display: grid; grid-template-columns: 1fr 64px; gap: 8px; align-items: center; font-size: .86rem; }
.ents li.pick { cursor: pointer; border-radius: 6px; }
.ents li.pick:hover, .ents li.pick:focus-visible { background: rgba(255, 211, 107, .12); outline: none; }
.ents .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ents .sub { color: var(--muted); font-size: .74rem; }
.bar { height: 6px; border-radius: 999px; background: rgba(255, 255, 255, .1); overflow: hidden; }
.bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--teal), var(--gold)); border-radius: 999px; }
.tags { display: flex; flex-wrap: wrap; gap: 5px; margin: 0; padding: 0; list-style: none; }
.tags li { font-size: .78rem; padding: 3px 8px; border-radius: 999px; background: var(--glass-2); border: 1px solid var(--line); }
.age { display: grid; grid-template-columns: 90px 1fr; gap: 4px 8px; align-items: center; font-size: .78rem; }
.age .track { position: relative; height: 8px; background: rgba(255, 255, 255, .08); border-radius: 4px; }
.age .track i { position: absolute; top: 0; bottom: 0; border-radius: 4px; }
.age .track::after { content: ""; position: absolute; left: 50%; top: -2px; bottom: -2px; width: 1px; background: var(--muted); }
.card .sample-note { margin: 8px 0 0; font-size: .72rem; color: var(--warn); }

/* What the genie is saying, by the genie */
.bubble { position: fixed; left: 50%; bottom: 46px; transform: translateX(-50%); max-width: min(560px, calc(100vw - 800px));
  min-width: 260px; margin: 0; padding: 12px 16px; border-radius: 18px; background: rgba(9, 13, 36, .82);
  border: 1px solid rgba(255, 211, 107, .45); font: 500 1rem/1.45 var(--serif); z-index: 4; backdrop-filter: blur(8px);
  /* three lines at most, scrolling along with the voice, so it never climbs over the genie */
  max-height: calc(1.45em * 3 + 24px); overflow: hidden; scroll-behavior: smooth; }
.bubble .w.now { background: var(--gold); color: var(--gold-ink); border-radius: 4px; }
.back { position: fixed; left: 50%; top: calc(var(--top) + 6px); transform: translateX(-50%); z-index: 5; }
.reset { position: fixed; right: calc(340px + 2 * var(--gap)); bottom: 40px; z-index: 5; }
.painting { position: fixed; left: 50%; top: 45%; transform: translate(-50%, -50%); z-index: 6; padding: 14px 20px;
  border-radius: 18px; background: rgba(9, 13, 36, .88); border: 1px solid var(--gold); display: flex; gap: 12px; align-items: center; }
.spinner { width: 20px; height: 20px; border-radius: 50%; border: 3px solid rgba(255, 211, 107, .25);
  border-top-color: var(--gold); animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Chats and From Qloo: floating windows beside the chat (never over it); drag them by the header. */
.drawer { position: fixed; right: var(--gap); top: calc(var(--top) + 4px); width: min(420px, calc(100vw - 2 * var(--gap)));
  max-height: calc(100vh - var(--top) - 50px); z-index: 8; overflow-y: auto; padding: 0 18px 18px; border-radius: 20px;
  background: rgba(7, 10, 30, .96); border: 1px solid var(--line); box-shadow: 0 18px 50px rgba(0, 0, 0, .5); }
.drawer header { position: sticky; top: 0; z-index: 1; padding: 14px 0 10px; background: rgba(7, 10, 30, .98);
  cursor: grab; touch-action: none; user-select: none; }
.drawer header::before { content: "⠿"; color: var(--muted); margin-right: 4px; }
.drawer.dragging header { cursor: grabbing; }
.drawer.chats { right: calc(var(--gap) + 36px); top: calc(var(--top) + 40px); } /* both open: offset, not stacked */
@media (min-width: 1280px) { /* room for both beside the chat: side by side */
  .drawer { width: 400px; }
  .drawer.chats { right: calc(2 * var(--gap) + 400px); top: calc(var(--top) + 4px); }
}
/* The chat's world button: Create the world -> Painting… % (the fill) -> Step inside */
.world-action { width: 100%; padding: 12px 16px; border: 1px solid var(--gold); border-radius: 999px; cursor: pointer;
  background: var(--gold); color: var(--gold-ink); font: 700 1rem var(--sans, inherit);
  box-shadow: 0 0 0 0 rgba(255, 211, 107, .6); animation: beckon 1.8s ease-out infinite; }
.world-action:disabled { cursor: default; animation: none; color: var(--gold);
  background: linear-gradient(90deg, rgba(255, 211, 107, .35) var(--pct, 0%), rgba(9, 13, 36, .9) var(--pct, 0%)); }
@keyframes beckon { 70% { box-shadow: 0 0 0 16px rgba(255, 211, 107, 0); } 100% { box-shadow: 0 0 0 0 rgba(255, 211, 107, 0); } }
.msg.hint { font-size: .92em; opacity: .9; }
.drawer header, .dialog header { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.drawer h2, .dialog h2 { font: 600 1.25rem var(--serif); margin: 0; }
.note { color: var(--muted); font-size: .85rem; }
.turn { margin: 14px 0; padding: 12px; border-radius: 14px; background: var(--glass-2); border: 1px solid var(--line); }
.turn h3 { margin: 0 0 6px; font-size: .9rem; }
.call { font: 12px/1.45 ui-monospace, SFMono-Regular, Menlo, monospace; margin: 6px 0; padding: 8px;
  border-radius: 10px; background: rgba(0, 0, 0, .35); overflow-wrap: anywhere; }
.call b { color: var(--teal); }
.call .src { float: right; color: var(--muted); }
.dialog { width: min(760px, calc(100vw - 32px)); max-height: 86vh; overflow: auto; padding: 18px; border-radius: 20px;
  border: 1px solid var(--line); background: #090d26; color: var(--ink); }
.dialog::backdrop { background: rgba(0, 0, 0, .6); }
.cmp { width: 100%; border-collapse: collapse; font-size: .86rem; margin-top: 10px; }
.cmp th, .cmp td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.cmp td.y { color: var(--ok); } .cmp td.n { color: var(--warn); }
.score { font: 700 1.6rem var(--serif); color: var(--gold); }

.foot { position: fixed; left: 0; right: 0; bottom: 8px; text-align: center; font-size: .74rem; color: var(--muted); z-index: 3; }

@media (max-width: 1300px) { /* keep the chat column clear of the genie on mid-size screens */
  .chat { width: 330px; }
}
@media (max-width: 1100px) {
  .chat { width: 330px; }
  .rail { width: 290px; }
  .bubble { max-width: calc(100vw - 680px); }
}
@media (max-width: 1240px) {
  .tools .lbl { display: none; }
}
@media (max-width: 860px) {
  :root { --top: 56px; }
  .tools { flex-wrap: nowrap; }
  .tools .pill { padding: 6px 10px; }
  .brand { font-size: 1.05rem; }
  .stage { bottom: auto; height: 44vh; }
  .chat { left: 8px; right: 8px; width: auto; top: auto; bottom: 8px; height: 40vh; border-radius: 18px; }
  .rail { left: 8px; right: 8px; width: auto; top: auto; bottom: calc(40vh + 14px); height: 15vh;
    flex-direction: row; overflow-x: auto; overflow-y: hidden; }
  .rail .card { min-width: 260px; overflow-y: auto; padding: 10px; }
  .rail:empty { display: none; }
  .bubble { display: none; }
  .foot { display: none; }
  .drawer, .drawer.chats { left: 8px; right: 8px; width: auto; top: calc(var(--top) + 4px); max-height: calc(60vh - var(--top) - 22px); }
}

/* In the headset the 3D menu and bubbles take over; the page behind isn't visible, so don't spend time painting it */
body.xr .chat, body.xr .rail, body.xr .bubble, body.xr .foot, body.xr .drawer, body.xr .painting, body.xr .tools > :not(#vr-slot) { display: none !important; }

/* Saved chats */
.chats .new { margin: 4px 0 10px; background: var(--gold); color: var(--gold-ink); }
.chat-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.chat-list li { display: flex; gap: 6px; align-items: stretch; }
.chat-list .open { flex: 1; text-align: left; display: grid; gap: 2px; padding: 8px 10px; border-radius: 12px;
  border: 1px solid rgba(255,255,255,.12); background: rgba(255,255,255,.05); color: inherit; font: inherit; cursor: pointer; }
.chat-list .open:hover, .chat-list .open:focus-visible { background: rgba(95,227,208,.12); }
.chat-list li.current .open { border-color: var(--gold); background: rgba(255,211,107,.1); }
.chat-list .note { font-size: .72rem; }
.call details { margin-top: 2px; font-size: .72rem; color: var(--muted); }
.call details summary { cursor: pointer; }

/* The launch journey, under the header */
.journey { position: fixed; top: calc(var(--top) + 4px); left: calc(380px + 2 * var(--gap)); right: calc(340px + 2 * var(--gap));
  z-index: 4; display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; pointer-events: none; }
.journey .step { pointer-events: auto; display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px 4px 4px;
  border-radius: 999px; border: 1px solid rgba(255,255,255,.18); background: rgba(9,13,36,.7); color: var(--muted);
  font: 500 .78rem var(--sans, inherit); cursor: pointer; backdrop-filter: blur(6px); }
.journey .step .dot { width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center;
  background: rgba(255,255,255,.12); font-size: .7rem; }
.journey .step.done { color: var(--ink, #f4efe4); }
.journey .step.done .dot { background: var(--teal); color: #052b26; }
.journey .step.now { border-color: var(--gold); color: var(--ink, #f4efe4); box-shadow: 0 0 0 2px rgba(255,211,107,.25); }
.journey .step.now .dot { background: var(--gold); color: var(--gold-ink); }
.journey .step:disabled { cursor: default; opacity: .75; }
.back { top: calc(var(--top) + 44px); }
.card .why { margin: 4px 0 0; }
.vs { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 1300px) { .journey { left: calc(330px + 2 * var(--gap)); } }
@media (max-width: 1100px) { .journey { right: calc(290px + 2 * var(--gap)); } .journey .step { font-size: .7rem; } }
@media (max-width: 860px) { .journey { display: none; } }
body.xr .journey { display: none !important; }

/* Luna's lines get her own caption, so it's clear she (not the genie) is talking */
.bubble.luna { border-color: rgba(95, 227, 208, .7); }
.bubble.luna .who { color: var(--teal); font-family: var(--sans, inherit); font-size: .85rem; }

/* The chat: what the genie is doing (with a progress bar while a world paints), and reply buttons */
.msg.activity { background: none; border: 0; padding: 2px 6px; font-size: .82rem; color: var(--muted); }
.msg.activity .now { color: var(--teal); }
.msg.activity .bar { height: 8px; border-radius: 4px; background: rgba(255,255,255,.12); margin: 6px 0 2px; overflow: hidden; }
.msg.activity .bar i { display: block; height: 100%; background: var(--gold); transition: width .5s linear; }
.msg.activity .bar.ok i { background: var(--teal); }
.msg.activity .bar.warn i { background: #ffb347; }
.msg.activity .bar-text { font-size: .74rem; }
#log .choices { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; margin: 2px 0 6px; }
#log .choices button { border: 1px solid var(--gold); background: rgba(255,211,107,.12); color: inherit; font: inherit;
  font-size: .85rem; padding: 6px 12px; border-radius: 999px; cursor: pointer; }
#log .choices button:hover, #log .choices button:focus-visible { background: var(--gold); color: var(--gold-ink); }
.card .create-world { margin-top: 10px; background: var(--gold); color: var(--gold-ink); }

.pill.soon { opacity: .75; }
/* "Tap to hear me": only when the browser blocks sound until a tap; a small pill floating over the genie's head. */
.tapme { position: fixed; z-index: 7; transform: translate(-50%, -100%); padding: 7px 14px; border: 0;
  border-radius: 999px; background: var(--gold); color: var(--gold-ink); font: 600 .9rem var(--sans, inherit);
  cursor: pointer; white-space: nowrap; box-shadow: 0 0 0 0 rgba(255, 211, 107, .6); animation: beckon 1.8s ease-out infinite; }
.tapme[hidden] { display: none; }
body.xr .tapme { display: none !important; }
@keyframes beckon { 70% { box-shadow: 0 0 0 14px rgba(255, 211, 107, 0); } 100% { box-shadow: 0 0 0 0 rgba(255, 211, 107, 0); } }
/* No caption box under the genie: what he says is already in the chat (the element stays for the word timing). */
#bubble { display: none !important; }
.brand .tagline { margin-left: 10px; font: 500 .8rem var(--sans, inherit); color: var(--muted, #b7bdd4); letter-spacing: .01em; }
@media (max-width: 1240px) { .brand .tagline { display: none; } } /* narrow screens: the name alone */
/* Evidence an answer reused (no new Qloo calls): the cards behind it glow gold for a moment. */
.card.lit { animation: lit 1.6s ease-out 3; border-color: var(--gold) !important; }
@keyframes lit { 0% { box-shadow: 0 0 0 0 rgba(255, 211, 107, .75); } 100% { box-shadow: 0 0 0 14px rgba(255, 211, 107, 0); } }
/* The journey stays on one line between the chat and the evidence panel (it used to wrap "6 Plan" underneath). */
.journey { flex-wrap: nowrap; gap: 5px; }
.journey .step { white-space: nowrap; padding: 3px 9px 3px 3px; }
