:root{
  --edge-gap: 16px;            /* unified margin from screen edges */
  --trigger-size: 46px;        /* menu button size */
  --panel-gap-under-trigger: 8px;
  --thumb-bottom-trim: 14%;    /* legacy var (unused in new list) */

  /* Navbar height is updated live by JS via ResizeObserver. */
  --navbar-height: 72px;
}

/* Scale global paddings a bit on narrower screens */
@media (max-width: 900px){
  :root{ --edge-gap: 12px; --trigger-size: 44px; }
}
@media (max-width: 560px){
  :root{ --edge-gap: 10px; --trigger-size: 42px; }
}

/* Thicker/wider scrollbar for the tab-body on mobile */
@media (max-width: 560px), (pointer: coarse) {
  /* Firefox */
  .tab-body {
    scrollbar-width: auto;                 /* wider than "thin" */
    scrollbar-color: rgba(255,255,255,0.35) transparent;
  }

  #tabScene {
    padding: 3rem;
  }

  .scene-card{
    width: 8rem;
    margin: 1rem;
    font-size: 8px;
  }

  /* WebKit (Chrome/Edge/Safari on iOS & Android) */
  .tab-body::-webkit-scrollbar {
    width: 18px;                           /* 👈 make it wider */
    height: 18px;
  }
  .tab-body::-webkit-scrollbar-track {
    background: transparent;
    border-radius: 999px;
    margin-block: 4px;                     /* small insets at top/bottom */
  }
  .tab-body::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.35);
    border-radius: 999px;
    border: 6px solid transparent;         /* increases grab area */
    background-clip: padding-box;          /* keep soft edges */
  }
  .tab-body::-webkit-scrollbar-thumb:hover {
    background: rgba(255,255,255,0.5);
  }
}

/* ---------- Base layout ---------- */
html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100svh; /* fallback when dvh not supported */
  background: #000;
  overscroll-behavior: none;
  touch-action: none;
  font-family: system-ui,-apple-system,Segoe UI,Roboto,Arial;
}
@supports (height: 100dvh){
  html, body { height: 100dvh; }
}
a-scene { position: fixed; inset: 0; }

/* ✅ Ensure canvas receives taps/clicks cleanly on touch */
a-scene canvas, .a-canvas {
  touch-action: manipulation;
  pointer-events: auto;
}

/* ---------- Boot overlay ---------- */
#bootOverlay{
  position: fixed; inset: 0;
  background: #000; color: #fff;
  z-index: 999999;
  display: grid; place-items: center;
  gap: 16px;
  font-family: system-ui, sans-serif;
  opacity: 1; visibility: visible; pointer-events: all;
  transition: opacity .35s ease, visibility .35s ease;
}
#bootOverlay.hide{ opacity: 0; visibility: hidden; pointer-events: none; }
.bootWrap{ display: grid; place-items: center; gap: 14px; }
.bootSpinner{
  width: 44px; height: 44px; border-radius: 9999px;
  border: 3px solid rgba(255,255,255,.18);
  border-top-color: rgba(255,255,255,.9);
  animation: bootspin 1s linear infinite;
}
.bootText{ font-size: 14px; opacity: .88; letter-spacing: .3px; }
@keyframes bootspin { to { transform: rotate(360deg); } }

/* ---------- Bottom navbar ---------- */
.navbar-container {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(10px + env(safe-area-inset-bottom, 0px));
  z-index: 10000;

  background: rgba(12,12,14,0.55);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 14px;                     /* ↓ slightly smaller */
  box-shadow: 0 6px 22px rgba(0,0,0,.35);

  padding: 6px 8px;                        /* ↓ tighter padding */

  /* auto width based on content instead of fixed */
  display: inline-grid;
  grid-auto-rows: 48px;                    /* ↓ shorter row height */
  align-items: center;
  justify-items: center;
  gap: 4px 6px;                            /* ↓ smaller gaps */

  /* each item takes its own space */
  grid-auto-flow: column;
  grid-auto-columns: minmax(40px, auto);   /* ↓ smaller min cell width */

  /* let it shrink/grow with content */
  width: auto;
  max-width: 94vw;  /* safety for very long navbars */
}
@media (max-width: 768px) {
  .navbar-container {
    padding: 6px 8px;                      /* ↓ tighter on tablets/phones */
    gap: 4px 6px;
    grid-template-columns: repeat(5, 1fr);
  }
}
@media (max-width: 380px) {
  .navbar-container {
    grid-template-columns: repeat(4, 1fr);
    grid-auto-rows: 44px;                  /* ↓ shorter on tiny phones */
  }
}
.navbar-btn {
  appearance: none;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 10px;                     /* ↓ a bit smaller corner */
  cursor: pointer;
  width: 100%; height: 100%;
  min-width: 40px; min-height: 40px;       /* ↓ smaller min target (still ok) */
  display: grid; place-items: center;
  transition: transform .12s ease, background .2s ease, border-color .2s ease, box-shadow .2s ease;
  touch-action: manipulation;
}
@media (max-width: 380px){
  .navbar-btn { min-width: 36px; min-height: 36px; } /* extra compact */
}
.navbar-btn:active { transform: scale(0.96); }
.navbar-btn i { font-size: 18px; color: #ECF0F1 !important; pointer-events: none; } /* ↓ icon size */
@media (max-width: 380px){
  .navbar-btn i { font-size: 16px; }
}
.navbar-btn.active-rotate{
  background: rgba(59,130,246,.22);
  border-color: rgba(59,130,246,.55);
  box-shadow: inset 0 0 0 2px rgba(59,130,246,.25);
}

.hidden { display: none; }

/* ---------- Vignette ---------- */
.vignette{
  position: fixed; inset: 0; pointer-events: none; z-index: 9998;
  background: radial-gradient(ellipse at center, rgba(0,0,0,0) 55%, rgba(0,0,0,.28) 92%);
  opacity: 0; transition: opacity .3s ease;
}
.vignette.active{ opacity: 1; }

/* ---------- Coordinates HUD ---------- */
#hoverHUD{
  position: fixed;
  right: var(--edge-gap);
  top: calc(env(safe-area-inset-top, 0px) + var(--edge-gap));
  z-index: 10000;
  font: 13px/1.35 system-ui,-apple-system,Segoe UI,Roboto,Arial;
  color: #fff; background: rgba(0,0,0,.55);
  padding: 8px 10px; border-radius: 8px; white-space: pre-line;
  pointer-events: none;
  text-align: right;
}
/* Re-enable HUD on touch devices */
@media (pointer: coarse){
  #hoverHUD { display: block !important; }
}

/* ---------- Gesture preview ---------- */
#gestureVideo {
  position: fixed;
  right: 8px;
  bottom: calc(8px + var(--navbar-height) + env(safe-area-inset-bottom, 0px));
  width: 180px; height: auto;
  opacity: .08; border-radius: 8px; border: 1px solid rgba(255,255,255,.12);
  display: none;
  z-index: 10001;
}

/* --- YouTube overlay --- */
.yt-overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(0,0,0,.6);
  z-index: 10002;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease;
}
.yt-overlay.active { opacity: 1; pointer-events: auto; }
.yt-modal {
  width: min(92vw, 960px);
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 14px 42px rgba(0,0,0,.55);
  position: relative;
}
.yt-close {
  position: absolute;
  top: 8px; right: 8px;
  background: rgba(255,255,255,.12);
  border: 1px solid rgba(255,255,255,.2);
  color: #fff;
  width: 40px; height: 40px;
  border-radius: 999px;
  cursor: pointer;
  display: grid; place-items: center;
  z-index: 2;
}
.yt-close:hover { background: rgba(255,255,255,.22); }
#ytPlayerHost, #ytPlayer { position: absolute; inset: 0; width: 100%; height: 100%; }

/* ---------- TOP-LEFT MENU (panel above navbar) ---------- */
.mega-root{
  position: fixed;
  top: calc(env(safe-area-inset-top, 0px) + var(--edge-gap));
  left: var(--edge-gap);
  z-index: 10003;
}
.menu-trigger{
  width: var(--trigger-size); height: var(--trigger-size);
  border-radius: 12px; border: 1px solid rgba(255,255,255,.18);
  background: rgba(20,20,24,.55); backdrop-filter: blur(10px);
  display: grid; place-items: center; cursor: pointer;
}
.menu-trigger i{ color: #fff; }

/* Panel fills toward bottom with extra clearance for the navbar.
   We also cap height to FORCE internal scrolling. */
.mega-panel{
  position: fixed;
  top: calc(env(safe-area-inset-top, 0px) + var(--edge-gap) + var(--trigger-size) + var(--panel-gap-under-trigger));
  bottom: calc(var(--edge-gap) + var(--navbar-height) + env(safe-area-inset-bottom, 0px));
  left: var(--edge-gap);
  width: min(540px, 92vw);
  max-height: calc(100dvh - (var(--edge-gap) + var(--trigger-size) + var(--panel-gap-under-trigger) + var(--edge-gap) + var(--navbar-height)));
  background: rgba(10,12,16,.92);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 14px;
  box-shadow: 0 16px 48px rgba(0,0,0,.5);
  backdrop-filter: blur(12px);

  /* grid columns: tabs (left) + content (right) */
  display: grid;
  grid-template-columns: 170px 1fr;

  /* Keep outer container fixed; inner columns scroll */
  overflow: hidden;

  transform: translateY(-16px);
  opacity: 0;
  pointer-events: none;
  transition: transform .18s ease, opacity .18s ease;
}
.mega-panel.show{ transform: translateY(0); opacity: 1; pointer-events: auto; }
@media (max-width: 920px){
  .mega-panel { width: min(86vw, 520px); grid-template-columns: 150px 1fr; }
}
@media (max-width: 560px){
  .mega-panel { width: 94vw; grid-template-columns: 128px 1fr; left: calc(env(safe-area-inset-left, 8px)); }
}

/* ✖️ Close button in the panel (top-right) */
.mega-close{
  position: absolute;
  top: 6px;
  right: 6px;
  z-index: 2;
  width: 36px; height: 36px;
  border: 1px solid rgba(255,255,255,.18);
  background: rgba(255,255,255,.12);
  color: #fff;
  border-radius: 10px;
  cursor: pointer;
  display: grid; place-items: center;
}
.mega-close:hover{ background: rgba(255,255,255,.2); }

/* Left column (tabs) — own vertical scroll (touch friendly) */
.mega-left{
  height: 100%;
  border-right: 1px solid rgba(255,255,255,.08);
  background: linear-gradient(180deg, rgba(255,255,255,.06), rgba(255,255,255,.02));
  display: flex;
  flex-direction: column;
  padding: 10px;
  padding-bottom: calc(12px + var(--navbar-height) + env(safe-area-inset-bottom, 0px));
  gap: 6px;

  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-gutter: stable;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y !important;
  overscroll-behavior: contain;
}
.mega-item{
  display:flex; align-items:center; gap:10px;
  padding: 10px 12px;
  color: #e7f4ff;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 10px;
  cursor: pointer;
  font: 14px/1.2 system-ui,-apple-system,Segoe UI,Roboto,Arial;
  text-align: left;
}
.mega-item i{ width: 18px; text-align: center; opacity:.9; }
.mega-item:hover{ background: rgba(255,255,255,.06); border-color: rgba(255,255,255,.12); }
.mega-item.active{ background: rgba(59,130,246,.22); border-color: rgba(59,130,246,.35); }

/* Right column scaffolding — MUST allow child scrolling */
.mega-right{
  position: relative;
  min-height: 0;
  display: flex;
  flex-direction: column;  /* header + body (or help) */
}
.mega-right-header{
  display:flex; align-items:center; justify-content:flex-start; gap: 8px;
  padding: 12px 14px;
  color:#e6f2ff;
  border-bottom: 1px solid rgba(255,255,255,.08);
  flex: 0 0 auto;
}
.mega-right-header h3{ margin:0; font: 600 16px/1.2 system-ui,-apple-system,Segoe UI,Roboto,Arial; }

/* --------- Tab body: scroll container --------- */
.tab-body{
  flex: 1 1 auto;
  min-height: 0;
  max-height: 100%;
  padding: 12px;

  overflow-y: auto !important;   /* vertical scrollbar when needed */
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-gutter: stable both-edges;
  overscroll-behavior: contain;

  position: relative;
  touch-action: pan-y !important;
}

/* Help tab should occupy the same scroll area as scenes */
#tabHelp{
  color:#eaf4ff;
  max-width: 60ch;
  flex: 1 1 auto;
  min-height: 0;
  padding: 12px;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-gutter: stable both-edges;
  touch-action: pan-y !important;
}

/* ==============================
   SCENES TAB — LIST WITH THUMBS
   ============================== */

#tabScenes {
  height: 100%;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* The list itself (vertical) */
.scenes-grid{
  flex: 1 1 auto;
  min-height: 0;

  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 4px 2px 12px 2px;
  box-sizing: border-box;

  /* Do NOT scroll here; the parent .tab-body handles it cleanly */
  overflow: visible;
}

/* Each scene row (thumb + title) */
.scene-card{
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;

  padding: 8px 10px;
  background: rgba(255,255,255,.05);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 10px;

  /* Only the image looks clickable; the card is inert */
  cursor: default;

  transition: background .18s ease, transform .12s ease, border-color .18s ease;
}
.scene-card:hover{
  background: rgba(255,255,255,.10);
  border-color: rgba(255,255,255,.18);
  transform: translateX(2px);
}
.scene-card:active{ transform: translateX(1px) scale(.995); }

/* Thumbnail preview (clickable) — crop bottom by a % */
.scene-thumb{
  width: 100%;
  /* keep a consistent frame so cropping is visible */
  aspect-ratio: 16 / 9;        /* change if you prefer another shape */
  object-fit: cover;
  object-position: top;        /* keep the top; cut the bottom */
  border-radius: 6px;
  flex-shrink: 0;
  background: #111;
  box-shadow: 0 2px 8px rgba(0,0,0,.25);
  cursor: pointer;
  position: relative;

  /* 👇 hard-cut the bottom by the CSS var */
  clip-path: inset(0 0 var(--thumb-bottom-trim) 0 round 6px);
}

/* Optional: tweak how much to cut globally */
:root{
  --thumb-bottom-trim: 14%;
}

/* Glow effect around the image on hover/focus/touch */
.scene-thumb::after{
  content: "";
  position: absolute;
  inset: -3px;                 /* slight outside halo */
  border-radius: inherit;
  box-shadow:
    0 0 0 0 rgba(59,130,246,.0),
    0 0 18px rgba(59,130,246,.0) inset;
  opacity: 0;
  transition: box-shadow .18s ease, opacity .18s ease;
  pointer-events: none;
}

/* Hover (mouse), focus (keyboard), and touch (JS toggles .touching on card) */
.scene-card:hover .scene-thumb::after,
.scene-thumb:focus-visible::after,
.scene-card.touching .scene-thumb::after{
  opacity: 1;
  box-shadow:
    0 0 0 3px rgba(59,130,246,.45),
    0 0 18px rgba(59,130,246,.35) inset;
}

/* Ensure thumb can be keyboard focused if JS enables it */
.scene-thumb[tabindex="0"]{ outline: none; }

/* Scene title text */
.scene-title{
  flex: 1;
  color: #f0f6ff;
  font: 600 14px/1.25 system-ui,-apple-system,Segoe UI,Roboto,Arial;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  letter-spacing: .2px;
}

/* Optional right-side meta (count, tag, etc.) */
.scene-meta{
  margin-left: 6px;
  font: 12px/1.2 system-ui,-apple-system,Segoe UI,Roboto,Arial;
  color: #bed8ff;
  opacity: .9;
}

/* ---------- Scrollbar styling ---------- */
/* Firefox (default) */
.mega-left,
.tab-body,
#tabHelp {
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.10) transparent;
}

/* WebKit (default) */
.mega-left::-webkit-scrollbar,
.tab-body::-webkit-scrollbar,
#tabHelp::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
.mega-left::-webkit-scrollbar-track,
.tab-body::-webkit-scrollbar-track,
#tabHelp::-webkit-scrollbar-track {
  background: transparent;
  border-radius: 999px;
}
.mega-left::-webkit-scrollbar-thumb,
.tab-body::-webkit-scrollbar-thumb,
#tabHelp::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.10);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
.mega-left::-webkit-scrollbar-thumb:hover,
.tab-body::-webkit-scrollbar-thumb:hover,
#tabHelp::-webkit-scrollbar-thumb:hover {
  background: rgba(255,255,255,0.16);
}

/* 📱 Thicker, easier-to-grab scrollbars on touch screens */
@media (pointer: coarse){
  .mega-left,
  .tab-body,
  #tabHelp {
    scrollbar-width: auto; /* Firefox wider track */
  }
  .mega-left::-webkit-scrollbar,
  .tab-body::-webkit-scrollbar,
  #tabHelp::-webkit-scrollbar {
    width: 16px;
    height: 16px;
  }
  .mega-left::-webkit-scrollbar-thumb,
  .tab-body::-webkit-scrollbar-thumb,
  #tabHelp::-webkit-scrollbar-thumb {
    border-width: 4px; /* thicker grab area */
  }
}

/* ---------- Top-center Scene Toast ---------- */
.scene-toast{
  position: fixed;
  top: calc(env(safe-area-inset-top, 0px) + var(--edge-gap));
  left: 50%;
  transform: translate(-50%, -6px);
  z-index: 10002;
  min-width: min(80vw, 560px);
  max-width: min(90vw, 720px);
  background: rgba(18,20,26,.75);
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 12px;
  box-shadow: 0 10px 28px rgba(0,0,0,.45);
  backdrop-filter: blur(10px);
  color: #eaf4ff;
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s ease, transform .18s ease, max-height .18s ease;
  overflow: hidden;
}
/* Narrower toast on mobile */
@media (max-width: 560px){
  .scene-toast{
    min-width: 0;              /* override desktop min-width */
    width: 64vw;               /* tighter than before */
    max-width: 64vw;
    border-radius: 10px;
    transform: translate(-50%, -4px);
    margin-left: 2.3rem;
  }
}

/* Extra-small phones */
@media (max-width: 380px){
  .scene-toast{
    width: 58vw;               /* even narrower on tiny screens */
    max-width: 58vw;
    margin-left: 2.5rem;
  }
}
.scene-toast.show{ opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.scene-toast-btn{
  width: 100%;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 10px;
  background: transparent;
  border: 0;
  color: inherit;
  padding: 10px 12px;
  cursor: pointer;
  text-align: left;
  font: 600 14px/1.2 system-ui,-apple-system,Segoe UI,Roboto,Arial;
}
.scene-toast-btn i{ transition: transform .18s ease; opacity: .9; }
.scene-toast.expanded .scene-toast-btn i{ transform: rotate(180deg); }
.scene-toast-desc{
  padding: 0 12px 12px 12px;
  font: 13px/1.35 system-ui,-apple-system,Segoe UI,Roboto,Arial;
  color: #cfe7ff;
  display: none;
}
.scene-toast.expanded .scene-toast-desc{ display: block; }

/* Accessibility & focus styles */
.menu-trigger:focus, .mega-item:focus, .navbar-btn:focus, .scene-card:focus {
  outline: 3px solid rgba(59,130,246,0.18);
  outline-offset: 2px;
  border-color: rgba(59,130,246,0.35);
}

/* ===========================
   CHAT (built dynamically)
   =========================== */
#chatToggle {
  bottom: calc(10px + var(--navbar-height) + env(safe-area-inset-bottom, 0px)) !important;
  right: calc(var(--edge-gap) + 10px) !important;
}
#chatFloat {
  bottom: calc(120px + var(--navbar-height) + env(safe-area-inset-bottom, 0px)) !important;
  right: calc(35px + var(--edge-gap)) !important;
}
#chatToggle{
  position: fixed;
  width: 58px; height: 58px;
  border-radius: 9999px; border: none;
  background: #0ea5e9; color: #fff;
  box-shadow: 0 14px 34px rgba(0,0,0,.25);
  cursor: pointer; z-index: 10004;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 2.3rem;
}
#chatToggle svg{ width: 26px; height: 26px; }

/* Chat window (reopen-safe + animated) */
#chatFloat{
  position: fixed;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(16px, env(safe-area-inset-bottom));
  width: 360px;
  height: 460px;
  display: flex;                 /* keep flex always */
  flex-direction: column;
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 18px 40px rgba(0,0,0,.25);
  overflow: hidden;
  z-index: 10004;

  /* animated hide/show (don’t toggle display) */
  transform: translateY(8px);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: transform .18s ease, opacity .18s ease, visibility 0s linear .18s;
}

#chatFloat.open{
  transform: translateY(0);
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition: transform .18s ease, opacity .18s ease, visibility 0s;
}

/* Mobile tweaks */
@media (max-width: 768px){
  #chatFloat{
    right: max(8px, env(safe-area-inset-right));
    bottom: max(8px, env(safe-area-inset-bottom));
    width: min(92vw, 380px);
    height: min(70vh, 560px);
    border-radius: 12px;
    bottom: calc(20px + var(--navbar-height) + env(safe-area-inset-bottom, 0px)) !important;
    right: var(--edge-gap) !important;
  }
}

/* Very small screens */
@media (max-width: 420px){
  #chatFloat{
    width: 94vw;
    height: 68vh;
  }
}

#chatHeader{
  background:#0ea5e9; color:#fff; font-weight:700;
  padding:10px 12px; display:flex; align-items:center; gap:8px;
}
#chatHeader .title{ flex: 1; }
#chatCloseBtn{
  background: transparent; border: none; color: #fff;
  cursor: pointer; font-size: 18px; padding: 4px 8px;
}
#chatLang{
  appearance: none; border: none; border-radius: 8px; padding: 6px 8px;
  background: rgba(255,255,255,.18); color:#fff; font-weight:600;
  outline: none; cursor: pointer; max-width: 56%;
}
#chatLang option{ color: #111; }

#chatSuggestions{
  display:flex; gap:8px; padding:8px 10px; flex-wrap:wrap;
  border-bottom:1px solid #e5e7eb; background:#f8fafc;
  max-height: 78px; overflow-y: auto;
}
.chip{
  background:#eef2ff; color:#1e293b;
  border:1px solid #e5e7eb; padding:6px 10px;
  border-radius:9999px; font-size:12px;
  cursor:pointer; user-select:none;
}

#chatbotMessages{
  flex:1; overflow-y:auto; padding:10px 12px;
  display:flex; flex-direction:column; gap:8px; background:#fff;
}
.msg{
  padding:10px 12px; border-radius:10px; max-width:85%;
  white-space:pre-wrap; line-height:1.35;
}
.msg.user{ align-self:flex-end; background:#111827; color:#fff; }
.msg.bot{ align-self:flex-start; background:#f3f4f6; color:#111827; }

#chatInputBar{
  display:flex; gap:8px; padding:10px;
  border-top:1px solid #e5e7eb; background:#fff;
}
#chatInputBar input{
  flex:1; padding:10px 12px; border:1px solid #e5e7eb; border-radius:10px;
}
#chatInputBar button{
  padding:10px 12px; border:none; border-radius:10px;
  background:#111827; color:#fff; font-weight:600; cursor:pointer;
}

@media (max-width: 480px){
  #chatFloat{ right: 12px; width: calc(100vw - 24px); }
  #chatToggle{ right: 12px; }
}

/* Tiny scene transition progress (top-center) */
.scene-progress{
  position: fixed;
  top: calc(env(safe-area-inset-top, 0px) + 10px);
  left: 50%;
  transform: translateX(-50%);
  width: min(240px, 60vw);
  height: 6px;
  background: rgba(255,255,255,.16);
  border: 1px solid rgba(255,255,255,.25);
  border-radius: 999px;
  overflow: hidden;
  z-index: 10005;
  opacity: 0;
  transition: opacity .15s ease;
  pointer-events: none;
}
.scene-progress.show { opacity: 1; }
.scene-progress .fill{
  height: 100%; width: 0%;
  transition: width .18s ease;
  background: linear-gradient(90deg, #22d3ee, #3b82f6);
}

/* optional failure flash */
.scene-progress.fail .fill{ background: linear-gradient(90deg, #ef4444, #f59e0b); }
