:root {
  color-scheme: dark;
  --bg: #08040a;
  --panel: rgba(28, 10, 22, 0.92);
  --panel-strong: rgba(36, 12, 28, 0.98);
  --panel-soft: rgba(255, 255, 255, 0.04);
  --line: rgba(255, 180, 210, 0.12);
  --line-strong: rgba(255, 120, 180, 0.38);
  --text: #fff5fa;
  --muted: #c9a8b8;
  --rose: #ff4d9a;
  --rose-2: #ffb0d4;
  --rose-hot: #ff2d7a;
  --gold: #f6c98a;
  --violet: #c084fc;
  --cyan: #67e8f9;
  --green: #6ee7b7;
  --danger: #fb7185;
  --shadow: 0 32px 100px rgba(0, 0, 0, 0.55);
  --glow-rose: 0 0 40px rgba(255, 45, 122, 0.22);
  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 14px;
  --font: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  color: var(--text);
  font-family: var(--font);
  background:
    radial-gradient(ellipse 80% 50% at 15% 0%, rgba(255, 40, 120, 0.18), transparent 50%),
    radial-gradient(ellipse 60% 40% at 90% 100%, rgba(140, 40, 180, 0.16), transparent 45%),
    radial-gradient(circle at 50% 50%, rgba(60, 10, 40, 0.4), transparent 70%),
    linear-gradient(160deg, #060208 0%, #140810 45%, #0a050c 100%);
}
button, input, textarea, select { font: inherit; }
button { color: inherit; }
button, select, input[type="range"] { cursor: pointer; }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible {
  outline: 2px solid var(--rose-2);
  outline-offset: 3px;
}
[hidden] { display: none !important; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Ambient lights */
.ambient {
  position: fixed;
  pointer-events: none;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.28;
  animation: breathe 9s ease-in-out infinite;
}
.ambient-one { width: 32rem; height: 32rem; top: -14rem; right: -10rem; background: #ff2d7a; }
.ambient-two { width: 26rem; height: 26rem; bottom: -14rem; left: -9rem; background: #7c3aed; animation-delay: -3s; }
.ambient-three { width: 18rem; height: 18rem; top: 40%; left: 40%; background: #be185d; opacity: 0.12; animation-delay: -5s; }
@keyframes breathe {
  0%, 100% { transform: scale(1); opacity: 0.22; }
  50% { transform: scale(1.08); opacity: 0.32; }
}

.spark-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background-image:
    radial-gradient(1.5px 1.5px at 12% 22%, rgba(255, 180, 210, 0.35), transparent),
    radial-gradient(1px 1px at 78% 18%, rgba(255, 120, 180, 0.4), transparent),
    radial-gradient(1.5px 1.5px at 45% 70%, rgba(200, 140, 255, 0.3), transparent),
    radial-gradient(1px 1px at 88% 62%, rgba(255, 200, 220, 0.28), transparent),
    radial-gradient(1px 1px at 30% 88%, rgba(255, 100, 160, 0.25), transparent);
  opacity: 0.7;
}

.app-shell {
  position: relative;
  z-index: 1;
  width: min(1460px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 22px;
  display: grid;
  place-items: center;
}
.app-card {
  width: 100%;
  min-height: min(920px, calc(100vh - 44px));
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background:
    linear-gradient(155deg, rgba(42, 14, 32, 0.95), rgba(12, 6, 16, 0.98));
  box-shadow: var(--shadow), var(--glow-rose), inset 0 1px 0 rgba(255, 180, 210, 0.08);
  backdrop-filter: blur(28px);
}
.app-header {
  height: 74px;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(20, 6, 16, 0.75), rgba(10, 4, 12, 0.4));
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
}
.brand > span:last-child { display: grid; gap: 2px; }
.brand strong { font-size: 0.98rem; letter-spacing: 0.1em; text-transform: uppercase; }
.brand small { color: var(--rose-2); font-size: 0.72rem; letter-spacing: 0.04em; }
.brand-orbit {
  position: relative;
  width: 40px;
  height: 40px;
  border: 1px solid rgba(255, 120, 180, 0.5);
  border-radius: 50%;
  box-shadow: inset 0 0 24px rgba(255, 45, 122, 0.3), 0 0 28px rgba(255, 45, 122, 0.25);
  animation: pulse-orbit 3.2s ease-in-out infinite;
}
@keyframes pulse-orbit {
  0%, 100% { box-shadow: inset 0 0 24px rgba(255, 45, 122, 0.25), 0 0 20px rgba(255, 45, 122, 0.2); }
  50% { box-shadow: inset 0 0 28px rgba(255, 45, 122, 0.4), 0 0 36px rgba(255, 45, 122, 0.35); }
}
.brand-orbit::before,
.brand-orbit::after {
  content: "";
  position: absolute;
  inset: 7px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.2);
  transform: rotate(38deg) scaleX(1.5);
}
.brand-orbit::after { transform: rotate(-38deg) scaleX(1.5); }
.brand-orbit i {
  position: absolute;
  width: 9px;
  height: 9px;
  left: 14px;
  top: 14px;
  border-radius: 50%;
  background: var(--rose-2);
  box-shadow: 0 0 16px var(--rose);
}

.header-actions { display: flex; align-items: center; gap: 10px; }
.heat-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid rgba(255, 77, 154, 0.35);
  border-radius: 999px;
  color: var(--rose-2);
  background: linear-gradient(135deg, rgba(255, 45, 122, 0.18), rgba(120, 20, 80, 0.2));
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.heat-pill i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--rose);
  box-shadow: 0 0 12px var(--rose);
  animation: heat-dot 1.6s ease-in-out infinite;
}
@keyframes heat-dot {
  0%, 100% { opacity: 0.7; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.25); }
}
.status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(255,255,255,0.035);
  font-size: 0.74rem;
}
.status i { width: 7px; height: 7px; border-radius: 50%; background: #c4a0b5; box-shadow: 0 0 0 4px rgba(196,160,181,0.08); }
.status[data-state="ready"] { color: #d8fff2; border-color: rgba(127,240,198,0.25); }
.status[data-state="ready"] i { background: var(--green); box-shadow: 0 0 13px rgba(127,240,198,0.75); }
.status[data-state="warning"] { color: #ffe3b8; border-color: rgba(247,213,154,0.25); }
.status[data-state="warning"] i { background: var(--gold); }
.status[data-state="error"] { color: #ffd2dc; border-color: rgba(255,141,166,0.3); }
.status[data-state="error"] i { background: var(--danger); }
.icon-button {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255,255,255,0.04);
  transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
}
.icon-button:hover {
  background: rgba(255, 77, 154, 0.12);
  border-color: var(--line-strong);
  box-shadow: 0 0 18px rgba(255, 45, 122, 0.15);
}
.icon-button svg { width: 18px; fill: currentColor; }

.app-grid {
  min-height: calc(min(920px, calc(100vh - 44px)) - 74px);
  display: grid;
  grid-template-columns: minmax(400px, 0.94fr) minmax(500px, 1.06fr);
}
.avatar-column {
  padding: 18px;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto auto;
  gap: 12px;
  border-right: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255, 40, 100, 0.04), transparent 40%);
}
.avatar-stage {
  position: relative;
  min-height: 560px;
  overflow: hidden;
  border: 1px solid rgba(255, 120, 180, 0.18);
  border-radius: 22px;
  background:
    radial-gradient(ellipse 70% 50% at 50% 28%, rgba(255, 60, 140, 0.22), transparent 55%),
    radial-gradient(circle at 50% 90%, rgba(80, 10, 50, 0.5), transparent 40%),
    linear-gradient(180deg, #2a1022 0%, #100810 55%, #08060a 100%);
  isolation: isolate;
  box-shadow: inset 0 0 80px rgba(255, 30, 100, 0.08);
}
#avatarCanvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; z-index: 2; touch-action: none; }
.stage-glow {
  position: absolute;
  z-index: 1;
  width: 75%;
  aspect-ratio: 1;
  left: 12.5%;
  top: 10%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 70, 150, 0.28), transparent 68%);
  filter: blur(14px);
  animation: stage-pulse 5s ease-in-out infinite;
}
.stage-vignette {
  position: absolute;
  z-index: 3;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse 70% 80% at 50% 40%, transparent 40%, rgba(5, 2, 8, 0.55) 100%);
}
@keyframes stage-pulse {
  0%, 100% { opacity: 0.7; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.05); }
}
.stage-topline,
.stage-label { position: absolute; z-index: 5; left: 18px; right: 18px; display: flex; align-items: center; justify-content: space-between; pointer-events: none; }
.stage-topline { top: 18px; color: #e8c4d4; font-size: 0.66rem; letter-spacing: 0.14em; }
.scene-hud {
  position: absolute;
  top: 62px;
  right: 16px;
  z-index: 6;
  width: min(240px, 58vw);
  padding: 11px;
  border-radius: 12px;
  border: 1px solid rgba(255, 140, 190, 0.28);
  background: rgba(14, 8, 16, 0.72);
  backdrop-filter: blur(12px);
  pointer-events: auto;
  display: grid;
  gap: 8px;
}
.scene-hud label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: #f2ccdc;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.scene-hud label b {
  color: #ffd8ea;
  font-size: 0.74rem;
}
.scene-hud input[type="range"] {
  width: 100%;
}
.scene-hud select {
  width: 100%;
  min-height: 32px;
  border: 1px solid rgba(255, 150, 196, 0.26);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  color: #ffd9e8;
  padding: 0 8px;
}
.romance-meter {
  width: 100%;
  height: 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
}
.romance-meter span {
  display: block;
  width: 75%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #ff6aa8, #ff3d8d);
  box-shadow: 0 0 16px rgba(255, 61, 141, 0.42);
  transition: width 0.22s ease;
}
.live-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 11px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(10, 4, 12, 0.65);
  backdrop-filter: blur(12px);
}
.live-pill i { width: 6px; height: 6px; border-radius: 50%; background: var(--green); box-shadow: 0 0 12px rgba(127,240,198,0.8); }
.stage-label { bottom: 18px; align-items: flex-end; }
.stage-label > span {
  color: #fff;
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-shadow: 0 0 20px rgba(255, 80, 150, 0.5);
}
.stage-label small { max-width: 55%; color: #d4b0c4; text-align: right; font-size: 0.72rem; line-height: 1.4; }
.stage-loader {
  position: absolute;
  z-index: 8;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 14px;
  background: rgba(8, 3, 10, 0.88);
  transition: opacity 0.45s ease, visibility 0.45s ease;
}
.stage-loader.is-hidden { opacity: 0; visibility: hidden; }
.stage-loader span {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.1);
  border-top-color: var(--rose);
  border-right-color: var(--rose-2);
  animation: spin 0.85s linear infinite;
}
.stage-loader p { margin: 0; color: var(--muted); font-size: 0.8rem; }
@keyframes spin { to { transform: rotate(360deg); } }

.webgl-fallback { position: absolute; z-index: 4; inset: 0; display: grid; place-content: center; justify-items: center; text-align: center; }
.webgl-fallback p { margin: 18px 0 0; font-weight: 700; }
.webgl-fallback small { display: block; margin-top: 6px; color: var(--muted); font-weight: 400; }
.fallback-silhouette { position: relative; display: grid; place-items: center; }
.fallback-hair {
  width: 170px;
  height: 190px;
  border-radius: 48% 48% 42% 42%;
  background: linear-gradient(160deg, #3a1528, #100810);
  box-shadow: 0 0 60px rgba(255, 45, 122, 0.28);
}
.fallback-face {
  position: absolute;
  width: 118px;
  height: 145px;
  margin-top: -25px;
  border-radius: 50% 50% 46% 46%;
  background: linear-gradient(180deg, #e8a898, #c47870);
}
.fallback-face i { position: absolute; top: 61px; width: 15px; height: 7px; border-radius: 50%; background: #27161e; }
.fallback-face i:first-child { left: 28px; }
.fallback-face i:nth-child(2) { right: 28px; }
.fallback-face b { position: absolute; left: 43px; bottom: 28px; width: 32px; height: 8px; border-radius: 0 0 20px 20px; background: #b83d6a; }
.fallback-body {
  width: 210px;
  height: 165px;
  margin-top: -22px;
  border-radius: 55% 55% 18px 18px;
  background: linear-gradient(180deg, #c42a6a, #2a1020);
  box-shadow: 0 20px 50px rgba(255, 40, 100, 0.2);
}

.avatar-controls { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.control-button {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: rgba(255,255,255,0.03);
  color: var(--muted);
  font-size: 0.73rem;
  transition: all 0.2s ease;
}
.control-button:hover, .control-button.is-active {
  color: white;
  border-color: rgba(255, 77, 154, 0.45);
  background: rgba(255, 45, 122, 0.14);
  box-shadow: 0 0 20px rgba(255, 45, 122, 0.12);
}
.control-button.is-listening {
  color: white;
  border-color: rgba(103, 232, 249, 0.5);
  background: rgba(103, 232, 249, 0.12);
  box-shadow: inset 0 0 20px rgba(103, 232, 249, 0.08);
}
.control-button svg { width: 17px; fill: currentColor; }
.look-switcher { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.look-switcher button {
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: rgba(255,255,255,0.026);
  color: var(--muted);
  font-size: 0.73rem;
  transition: all 0.2s ease;
}
.look-switcher button.is-active {
  color: white;
  border-color: var(--line-strong);
  background: rgba(255, 77, 154, 0.12);
  box-shadow: 0 0 18px rgba(255, 45, 122, 0.1);
}
.look-switcher i { width: 14px; height: 14px; border-radius: 50%; box-shadow: 0 0 12px currentColor; }
.look-rose { color: #ff4d9a; background: #ff4d9a; }
.look-noir { color: #e7b7db; background: #6d365d; }
.look-neon { color: #67e8f9; background: #67e8f9; }

.companion-gui {
  padding: 11px;
  border: 1px solid rgba(255, 125, 182, 0.22);
  border-radius: 14px;
  background: rgba(22, 10, 20, 0.72);
  display: grid;
  gap: 9px;
}
.companion-gui-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.companion-gui-head h3 {
  margin: 0;
  font-size: 0.84rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #ffd9e8;
}
.companion-gui-head span {
  font-size: 0.68rem;
  color: #ffb9d6;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.companion-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.companion-stats div {
  padding: 7px 8px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  display: grid;
  gap: 3px;
}
.companion-stats small {
  font-size: 0.62rem;
  color: #cda9b8;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.companion-stats strong {
  font-size: 0.92rem;
  color: #ffe3ef;
}
.meter-wrap,
.xp-wrap {
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
}
.meter-wrap span,
.xp-wrap span {
  display: block;
  height: 100%;
  border-radius: inherit;
  width: 0;
  transition: width 0.24s ease;
}
.meter-wrap span {
  background: linear-gradient(90deg, #ff6aa8, #ff3b89);
  box-shadow: 0 0 14px rgba(255, 59, 137, 0.4);
}
.xp-wrap span {
  background: linear-gradient(90deg, #7c9bff, #5f6cff);
  box-shadow: 0 0 14px rgba(95, 108, 255, 0.36);
}
.xp-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: #d4b0be;
  font-size: 0.66rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.xp-label b {
  font-size: 0.66rem;
  color: #e8d8ff;
}
.companion-actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 7px;
}
.companion-actions button {
  min-height: 33px;
  border: 1px solid rgba(255, 143, 193, 0.24);
  border-radius: 10px;
  background: rgba(255, 45, 122, 0.08);
  color: #ffd7e7;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}
.companion-actions button:hover {
  border-color: rgba(255, 143, 193, 0.5);
  background: rgba(255, 45, 122, 0.16);
}

/* Chat column */
.chat-column {
  min-width: 0;
  padding: 26px;
  display: grid;
  grid-template-rows: auto auto auto minmax(240px, 1fr) auto auto auto;
  gap: 12px;
  background: linear-gradient(180deg, rgba(255, 30, 90, 0.03), transparent 30%);
}
.chat-intro { display: flex; align-items: end; justify-content: space-between; gap: 24px; }
.chat-intro h1 {
  margin: 6px 0 0;
  font-size: clamp(1.55rem, 2.8vw, 2.35rem);
  line-height: 1.08;
  letter-spacing: -0.04em;
}
.chat-intro h1 em {
  font-style: normal;
  background: linear-gradient(120deg, var(--rose-2), var(--rose), var(--violet));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.chat-intro p { max-width: 300px; margin: 0; color: var(--muted); font-size: 0.82rem; line-height: 1.5; text-align: right; }
.eyebrow {
  color: var(--rose-2);
  font-size: 0.64rem;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-shadow: 0 0 18px rgba(255, 120, 180, 0.4);
}

.mood-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.mood-chip {
  min-height: 36px;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255,255,255,0.03);
  color: #d4b8c8;
  font-size: 0.74rem;
  font-weight: 600;
  transition: all 0.2s ease;
}
.mood-chip:hover {
  border-color: rgba(255, 77, 154, 0.4);
  color: white;
  background: rgba(255, 45, 122, 0.1);
}
.mood-chip.is-active {
  color: white;
  border-color: rgba(255, 77, 154, 0.55);
  background: linear-gradient(135deg, rgba(255, 45, 122, 0.28), rgba(140, 40, 160, 0.22));
  box-shadow: 0 0 22px rgba(255, 45, 122, 0.2);
}
.mood-chip span { font-size: 0.85rem; }

.quick-prompts { display: flex; flex-wrap: wrap; gap: 8px; }
.quick-prompts button {
  min-height: 34px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255,255,255,0.025);
  color: #d7c0ce;
  font-size: 0.72rem;
  transition: all 0.18s ease;
}
.quick-prompts button:hover {
  border-color: rgba(255, 77, 154, 0.45);
  color: white;
  background: rgba(255, 45, 122, 0.12);
  box-shadow: 0 0 16px rgba(255, 45, 122, 0.12);
}

.transcript {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 14px 6px 14px 2px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 100, 160, 0.25) transparent;
}
.message {
  display: flex;
  align-items: flex-end;
  gap: 9px;
  max-width: min(88%, 720px);
  animation: messageIn 0.3s ease both;
}
@keyframes messageIn {
  from { opacity: 0; transform: translateY(8px); }
}
.message > div {
  padding: 13px 15px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.04);
  box-shadow: 0 8px 24px rgba(0,0,0,0.15);
}
.message p { margin: 0; white-space: pre-wrap; line-height: 1.58; font-size: 0.9rem; }
.message small { display: block; margin-top: 7px; color: #a88a9a; font-size: 0.64rem; }
.message-avatar {
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: linear-gradient(145deg, var(--rose), #6b1a48);
  color: white;
  font-size: 0.72rem;
  font-weight: 900;
  box-shadow: 0 0 24px rgba(255, 45, 122, 0.35);
}
.message-assistant > div {
  border-color: rgba(255, 100, 160, 0.18);
  background: linear-gradient(145deg, rgba(80, 20, 50, 0.45), rgba(30, 10, 28, 0.55));
}
.message-user { align-self: flex-end; flex-direction: row-reverse; }
.message-user > div {
  border-color: rgba(180, 140, 255, 0.25);
  background: linear-gradient(145deg, rgba(90, 50, 140, 0.4), rgba(40, 20, 70, 0.5));
}
.message-user .message-avatar {
  background: linear-gradient(145deg, #a78bfa, #3b2a6e);
  box-shadow: 0 0 20px rgba(167, 139, 250, 0.3);
}
.message-typing > div { display: flex; gap: 5px; padding: 16px 18px; }
.message-typing i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #f0a0c0;
  animation: typing 1.1s infinite ease-in-out;
}
.message-typing i:nth-child(2) { animation-delay: .15s; }
.message-typing i:nth-child(3) { animation-delay: .3s; }
@keyframes typing {
  0%, 65%, 100% { transform: translateY(0); opacity: .45; }
  30% { transform: translateY(-4px); opacity: 1; }
}

.memory-strip { display: flex; align-items: flex-start; gap: 10px; color: var(--muted); font-size: 0.67rem; }
.memory-strip > span {
  padding-top: 6px;
  color: var(--rose-2);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 800;
}
#memoryChips { display: flex; flex-wrap: wrap; gap: 6px; }
#memoryChips i {
  padding: 5px 9px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 45, 122, 0.06);
  font-style: normal;
}

.chat-form {
  min-height: 58px;
  padding: 7px 7px 7px 16px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 46px;
  align-items: end;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(8, 3, 10, 0.55);
  box-shadow: inset 0 1px 0 rgba(255, 180, 210, 0.05);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.chat-form:focus-within {
  border-color: rgba(255, 77, 154, 0.5);
  box-shadow: 0 0 0 4px rgba(255, 45, 122, 0.08), 0 0 30px rgba(255, 45, 122, 0.1);
}
.chat-form textarea {
  width: 100%;
  height: 42px;
  max-height: 112px;
  resize: none;
  overflow-y: auto;
  padding: 10px 0 8px;
  border: 0;
  outline: 0;
  color: white;
  background: transparent;
  line-height: 1.4;
}
.chat-form textarea::placeholder { color: #8a6a78; }
.send-button {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 14px;
  background: linear-gradient(145deg, #ff5aa8, #c2185b);
  box-shadow: 0 10px 28px rgba(194, 24, 91, 0.4);
  transition: filter 0.15s, transform 0.15s;
}
.send-button:hover { filter: brightness(1.1); transform: translateY(-1px); }
.send-button:disabled { opacity: .45; cursor: default; transform: none; }
.send-button svg { width: 20px; fill: white; }

.chat-footer {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  color: #7a6270;
  font-size: 0.62rem;
}
.chat-footer span:nth-child(2) { color: rgba(255, 140, 180, 0.55); }
.model-credit { color: rgba(241, 200, 220, 0.4); font-size: 0.62rem; }

/* Settings */
.settings-backdrop {
  position: fixed;
  z-index: 30;
  inset: 0;
  background: rgba(0, 0, 0, 0.68);
  backdrop-filter: blur(10px);
}
.settings-panel {
  position: fixed;
  z-index: 31;
  top: 18px;
  right: 18px;
  bottom: 18px;
  width: min(520px, calc(100vw - 36px));
  overflow: hidden;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  border: 1px solid var(--line-strong);
  border-radius: 24px;
  background: rgba(22, 8, 18, 0.98);
  box-shadow: -30px 0 90px rgba(0,0,0,0.55), 0 0 60px rgba(255, 45, 122, 0.08);
  backdrop-filter: blur(28px);
  animation: panelIn .25s ease both;
}
@keyframes panelIn { from { opacity: 0; transform: translateX(18px); } }
.settings-panel > header, .settings-panel > footer {
  padding: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}
.settings-panel > footer {
  border-top: 1px solid var(--line);
  border-bottom: 0;
  justify-content: flex-end;
}
.settings-panel h2 { margin: 5px 0 0; font-size: 1.5rem; }
.settings-body { padding: 20px; overflow-y: auto; display: grid; gap: 16px; }
.settings-section {
  padding: 16px;
  display: grid;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 17px;
  background: rgba(255,255,255,0.025);
}
.settings-section h3 {
  margin: 0 0 2px;
  color: #f8dcec;
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: .12em;
}
.heat-legend {
  margin: -6px 0 0;
  color: var(--muted);
  font-size: 0.68rem;
  line-height: 1.4;
}
.field-row, .setting-row, .switch-row { display: grid; gap: 10px; }
.field-row { grid-template-columns: minmax(0, 1fr) 180px; align-items: center; }
.field-row-wide { grid-template-columns: 1fr; }
.field-row > span, .setting-row > span, .switch-row > span { display: grid; gap: 4px; }
.field-row strong, .setting-row strong, .switch-row strong { font-size: .81rem; }
.field-row small, .setting-row small, .switch-row small { color: var(--muted); font-size: .67rem; line-height: 1.35; }
.field-row input, .field-row textarea, .field-row select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 11px;
  color: white;
  background: rgba(0,0,0,0.25);
  outline: 0;
}
.field-row input:focus, .field-row textarea:focus, .field-row select:focus {
  border-color: rgba(255, 77, 154, 0.45);
}
.field-row input, .field-row select { height: 40px; padding: 0 10px; }
.field-row textarea { padding: 10px; resize: vertical; line-height: 1.45; }
.setting-row input[type="range"] { width: 100%; accent-color: var(--rose); }
.switch-row { grid-template-columns: 1fr auto; align-items: center; }
.switch-row input { width: 44px; height: 23px; accent-color: var(--rose); }
.primary-button, .secondary-button, .danger-button {
  min-height: 42px;
  padding: 0 17px;
  border-radius: 12px;
  font-weight: 800;
  font-size: .76rem;
}
.primary-button {
  border: 0;
  background: linear-gradient(145deg, #ff5aa8, #c2185b);
  color: white;
  box-shadow: 0 8px 24px rgba(194, 24, 91, 0.3);
}
.secondary-button { border: 1px solid var(--line); background: rgba(255,255,255,0.04); color: white; }
.danger-zone { border-color: rgba(255,141,166,0.18); }
.danger-button { border: 1px solid rgba(255,141,166,0.28); background: rgba(255,141,166,0.06); color: #ffc9d5; }
.full-width { width: 100%; }

body.settings-open { overflow: hidden; }
body.is-busy .quick-prompts, body.is-busy .look-switcher, body.is-busy .mood-bar { pointer-events: none; opacity: .6; }

@media (max-width: 1040px) {
  .app-shell { padding: 12px; }
  .app-card { min-height: calc(100vh - 24px); }
  .app-grid { grid-template-columns: 0.9fr 1.1fr; }
  .avatar-stage { min-height: 500px; }
  .chat-column { padding: 20px; }
  .chat-intro { display: grid; }
  .chat-intro p { max-width: none; text-align: left; }
}
@media (max-width: 820px) {
  .app-shell { display: block; padding: 0; }
  .app-card { min-height: 100vh; border: 0; border-radius: 0; }
  .app-header { position: sticky; top: 0; z-index: 20; height: 66px; padding: 0 15px; backdrop-filter: blur(18px); }
  .app-grid { display: block; }
  .avatar-column { padding: 12px; border-right: 0; border-bottom: 1px solid var(--line); }
  .avatar-stage { min-height: min(66vh, 590px); }
  .chat-column { min-height: 680px; padding: 18px 14px 28px; }
  .chat-intro h1 { font-size: 1.75rem; }
  .status > span { display: none; }
  .status { width: 34px; padding: 0; justify-content: center; }
  .heat-pill span { display: none; }
  .heat-pill { width: 34px; padding: 0; justify-content: center; }
}
@media (max-width: 520px) {
  .brand small { display: none; }
  .avatar-stage { min-height: 485px; border-radius: 18px; }
  .scene-hud {
    left: 12px;
    right: 12px;
    width: auto;
  }
  .avatar-controls { grid-template-columns: repeat(2, 1fr); }
  .stage-label small { max-width: 58%; }
  .look-switcher span { display: none; }
  .chat-column { min-height: 660px; }
  .quick-prompts, .mood-bar { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 3px; }
  .quick-prompts button, .mood-chip { flex: 0 0 auto; }
  .chat-footer { display: block; }
  .chat-footer span:last-child { display: none; }
  .message { max-width: 94%; }
  .settings-panel { inset: 0; width: 100%; border-radius: 0; }
  .field-row { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
  }
}

/* v6 rebuild: dedicated Alba health and five-button control row */
.avatar-controls { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.voice-health {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255,255,255,0.026);
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.voice-health i { width: 8px; height: 8px; border-radius: 50%; background: #f3b84b; box-shadow: 0 0 14px currentColor; }
.voice-health[data-state="ready"] { color: #8ff0c4; border-color: rgba(92,220,158,.3); }
.voice-health[data-state="ready"] i { background: #5cdc9e; }
.voice-health[data-state="error"] { color: #ff9aae; border-color: rgba(255,111,142,.35); }
.voice-health[data-state="error"] i { background: #ff6f8e; }
@media (max-width: 620px) {
  .avatar-controls { grid-template-columns: repeat(2, 1fr); }
  .avatar-controls .control-button:last-child { grid-column: span 2; }
}

/* fixed portrait stage + professional scrolling chat */
.app-card,
.app-grid,
.avatar-column,
.chat-column,
.chat-history,
.transcript {
  min-width: 0;
  min-height: 0;
}

.chat-history {
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(255, 140, 190, 0.13);
  border-radius: 20px;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.026), rgba(6,3,9,0.38)),
    rgba(7, 3, 10, 0.34);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.035);
}

.chat-history::before {
  content: "";
  position: absolute;
  z-index: 2;
  pointer-events: none;
  inset: 0 0 auto;
  height: 26px;
  background: linear-gradient(180deg, rgba(17, 7, 15, 0.82), transparent);
}

.transcript {
  height: 100%;
  padding: 22px 14px 24px 12px;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-gutter: stable;
  scroll-behavior: smooth;
}

.message > div {
  max-width: 100%;
  overflow-wrap: anywhere;
}

.jump-latest {
  position: absolute;
  z-index: 5;
  right: 16px;
  bottom: 14px;
  min-height: 34px;
  padding: 0 12px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid rgba(255, 120, 180, 0.35);
  border-radius: 999px;
  color: white;
  background: rgba(30, 10, 25, 0.92);
  box-shadow: 0 10px 30px rgba(0,0,0,0.32), 0 0 22px rgba(255,45,122,0.12);
  backdrop-filter: blur(12px);
  font-size: 0.72rem;
  font-weight: 700;
}

.jump-latest:hover {
  border-color: rgba(255, 120, 180, 0.62);
  background: rgba(70, 18, 50, 0.95);
}

.chat-form {
  align-items: end;
}

.chat-form textarea {
  height: 42px;
  min-height: 42px;
  max-height: 132px;
  overflow-y: hidden;
  resize: none;
}

.chat-form[aria-busy="true"] .send-button {
  opacity: 0.62;
}

@media (min-width: 821px) {
  body {
    overflow: hidden;
  }

  .app-shell {
    height: 100dvh;
    min-height: 720px;
    overflow: hidden;
  }

  .app-card {
    height: min(920px, calc(100dvh - 44px));
    min-height: 676px;
    display: grid;
    grid-template-rows: 74px minmax(0, 1fr);
  }

  .app-grid {
    height: auto;
    min-height: 0;
    overflow: hidden;
  }

  .avatar-column {
    grid-template-rows: minmax(0, 1fr) auto auto auto;
    overflow: hidden;
  }

  .avatar-stage {
    height: 100%;
    min-height: 0;
  }

  .chat-column {
    height: 100%;
    overflow: hidden;
    grid-template-rows: auto auto auto minmax(0, 1fr) auto auto auto;
  }
}

@media (max-width: 820px) {
  body {
    overflow-y: auto;
  }

  .avatar-stage {
    height: min(64vh, 590px);
    min-height: 470px;
  }

  .chat-column {
    min-height: 0;
    grid-template-rows: auto auto auto auto auto auto auto;
  }

  .chat-history {
    height: min(58vh, 560px);
    min-height: 360px;
  }
}

@media (max-width: 520px) {
  .avatar-stage {
    height: 500px;
    min-height: 440px;
  }

  .chat-history {
    height: min(62vh, 520px);
    min-height: 340px;
    border-radius: 17px;
  }

  .transcript {
    padding-inline: 10px;
  }
}

/* v32: level chat geometry and stable independent scrolling */
.chat-column,
.chat-history,
.transcript,
.chat-form {
  transform: none !important;
  rotate: 0deg;
  scale: 1;
}

.chat-column {
  align-content: stretch;
}

.chat-history {
  isolation: isolate;
  contain: layout paint;
}

.transcript {
  scroll-padding-block: 24px;
  overflow-anchor: auto;
}

.message {
  align-self: flex-start;
}

.message > div {
  border-radius: 17px 17px 17px 7px;
}

.message-user {
  align-self: flex-end;
}

.message-user > div {
  border-radius: 17px 17px 7px 17px;
}

.chat-form {
  width: 100%;
  box-sizing: border-box;
}

.chat-form textarea {
  box-sizing: border-box;
}

/* v33: polished love meter module */
.companion-gui {
  --love-accent: #ff5ca8;
  --love-accent-2: #ff2f78;
  --love-soft: rgba(255, 92, 168, 0.15);
  --love-progress: 35%;
  position: relative;
  overflow: hidden;
  padding: 13px;
  gap: 10px;
  border-color: color-mix(in srgb, var(--love-accent) 34%, transparent);
  background:
    radial-gradient(circle at 12% 0%, var(--love-soft), transparent 42%),
    linear-gradient(145deg, rgba(31, 13, 28, 0.94), rgba(13, 7, 16, 0.96));
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.05), 0 14px 34px rgba(0,0,0,0.18);
  transition: border-color .25s ease, box-shadow .25s ease;
}
.companion-gui::before {
  content: "";
  position: absolute;
  inset: 0 auto auto 0;
  width: var(--love-progress);
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--love-accent), var(--love-accent-2));
  box-shadow: 0 0 18px var(--love-accent);
  transition: width .35s ease;
}
.companion-gui[data-love-tier="spark"] {
  --love-accent: #c9a5ff;
  --love-accent-2: #8f6cff;
  --love-soft: rgba(143, 108, 255, 0.13);
}
.companion-gui[data-love-tier="warm"] {
  --love-accent: #ff83bc;
  --love-accent-2: #ff4c99;
  --love-soft: rgba(255, 76, 153, 0.14);
}
.companion-gui[data-love-tier="close"] {
  --love-accent: #ff699d;
  --love-accent-2: #ff315f;
  --love-soft: rgba(255, 49, 95, 0.16);
}
.companion-gui[data-love-tier="devoted"] {
  --love-accent: #ff7f72;
  --love-accent-2: #ff3b69;
  --love-soft: rgba(255, 88, 105, 0.18);
}
.companion-gui[data-love-tier="soulmate"] {
  --love-accent: #ffd37c;
  --love-accent-2: #ff5f9f;
  --love-soft: rgba(255, 186, 100, 0.18);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.07), 0 0 28px rgba(255, 95, 159, 0.13);
}
.companion-gui.is-pulsing {
  animation: companion-panel-pulse .55s ease;
}
@keyframes companion-panel-pulse {
  0%, 100% { transform: translateZ(0) scale(1); }
  45% { transform: translateZ(0) scale(1.012); box-shadow: 0 0 30px var(--love-soft); }
}
.companion-gui-head > div {
  display: grid;
  gap: 2px;
}
.companion-gui-head .companion-kicker {
  color: var(--love-accent);
  font-size: .56rem;
  font-weight: 900;
  letter-spacing: .18em;
}
.companion-gui-head h3 {
  font-size: .88rem;
  letter-spacing: .06em;
}
.companion-gui-head .rank-badge {
  min-height: 26px;
  display: inline-flex;
  align-items: center;
  padding: 0 10px;
  border: 1px solid color-mix(in srgb, var(--love-accent) 34%, transparent);
  border-radius: 999px;
  color: var(--love-accent) !important;
  background: var(--love-soft);
  font-weight: 900;
}
.companion-love-card {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) auto;
  align-items: center;
  gap: 11px;
  padding: 10px;
  border: 1px solid rgba(255,255,255,0.075);
  border-radius: 13px;
  background: linear-gradient(135deg, rgba(255,255,255,0.055), rgba(255,255,255,0.018));
}
.love-orb {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border: 1px solid color-mix(in srgb, var(--love-accent) 45%, transparent);
  border-radius: 50%;
  color: white;
  background: radial-gradient(circle at 35% 28%, #fff4, transparent 28%), linear-gradient(145deg, var(--love-accent), var(--love-accent-2));
  box-shadow: 0 0 20px var(--love-soft), inset 0 1px 0 rgba(255,255,255,.35);
}
.love-orb i {
  font-style: normal;
  font-size: 1.15rem;
  filter: drop-shadow(0 2px 5px rgba(80,0,35,.35));
  animation: love-heartbeat 2.3s ease-in-out infinite;
}
@keyframes love-heartbeat {
  0%, 72%, 100% { transform: scale(1); }
  78% { transform: scale(1.18); }
  84% { transform: scale(.98); }
  90% { transform: scale(1.10); }
}
.love-copy {
  min-width: 0;
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: baseline;
  column-gap: 8px;
}
.love-copy small {
  color: #d8b5c6;
  font-size: .58rem;
  letter-spacing: .1em;
  text-transform: uppercase;
}
.love-copy strong {
  color: #fff1f7;
  font-size: 1.05rem;
}
.love-copy > span {
  grid-column: 1 / -1;
  color: var(--love-accent);
  font-size: .66rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.level-chip {
  min-width: 52px;
  padding: 7px 9px;
  display: grid;
  justify-items: center;
  gap: 1px;
  border-left: 1px solid rgba(255,255,255,.09);
}
.level-chip small {
  color: #bd98aa;
  font-size: .55rem;
  letter-spacing: .1em;
  text-transform: uppercase;
}
.level-chip strong {
  color: white;
  font-size: 1.12rem;
}
.meter-wrap.love-meter {
  position: relative;
  height: 11px;
  overflow: visible;
  border: 1px solid rgba(255,255,255,.07);
  background: rgba(0,0,0,.28);
  box-shadow: inset 0 2px 5px rgba(0,0,0,.32);
}
.meter-wrap.love-meter > span {
  background: linear-gradient(90deg, color-mix(in srgb, var(--love-accent) 70%, #7c4dff), var(--love-accent), var(--love-accent-2));
  box-shadow: 0 0 18px var(--love-soft);
  transition: width .4s cubic-bezier(.2,.8,.2,1);
}
.love-spark {
  position: absolute;
  top: 50%;
  left: clamp(1px, calc(var(--love-progress) - 6px), calc(100% - 11px));
  width: 11px;
  height: 11px;
  border: 2px solid rgba(255,255,255,.86);
  border-radius: 50%;
  background: var(--love-accent-2);
  box-shadow: 0 0 9px var(--love-accent), 0 0 18px var(--love-accent);
  transform: translateY(-50%);
  transition: left .4s cubic-bezier(.2,.8,.2,1);
}
.xp-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: #c6a6b7;
  font-size: .61rem;
  font-weight: 800;
  letter-spacing: .09em;
  text-transform: uppercase;
}
.xp-header b {
  color: #dcd7ff;
  font-size: .62rem;
}
.xp-wrap {
  height: 7px;
  background: rgba(0,0,0,.28);
}
.companion-actions button {
  min-height: 40px;
  display: grid;
  place-content: center;
  gap: 1px;
  background: linear-gradient(145deg, var(--love-soft), rgba(255,255,255,.025));
  border-color: color-mix(in srgb, var(--love-accent) 28%, transparent);
  transition: transform .16s ease, border-color .16s ease, background .16s ease;
}
.companion-actions button span {
  color: #fff0f7;
  font-weight: 800;
}
.companion-actions button small {
  color: #caa5b8;
  font-size: .53rem;
  font-weight: 600;
}
.companion-actions button:hover {
  transform: translateY(-1px);
  border-color: color-mix(in srgb, var(--love-accent) 60%, transparent);
  background: var(--love-soft);
}
.companion-actions button.is-rewarded {
  transform: scale(.97);
  border-color: var(--love-accent);
}
.companion-actions button:disabled {
  cursor: default;
  opacity: .88;
}
.companion-toast {
  position: absolute;
  z-index: 5;
  right: 13px;
  top: 49px;
  max-width: calc(100% - 26px);
  padding: 7px 10px;
  border: 1px solid color-mix(in srgb, var(--love-accent) 48%, transparent);
  border-radius: 999px;
  color: #fff;
  background: rgba(20, 8, 18, .94);
  box-shadow: 0 10px 26px rgba(0,0,0,.3), 0 0 20px var(--love-soft);
  font-size: .62rem;
  font-weight: 800;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-5px) scale(.96);
  transition: opacity .18s ease, transform .18s ease;
}
.companion-toast.is-visible {
  opacity: 1;
  transform: translateY(0) scale(1);
}
.companion-toast.is-level-up {
  color: #2a1320;
  background: linear-gradient(135deg, #ffe9a8, #ff8fbd);
  border-color: rgba(255,255,255,.7);
}
@media (max-width: 520px) {
  .companion-love-card { grid-template-columns: 42px minmax(0, 1fr) auto; gap: 8px; }
  .love-orb { width: 40px; height: 40px; }
  .companion-actions button { min-height: 38px; }
  .companion-actions button small { display: none; }
}


/* v34: stable upper-body viewport and scroll-safe companion layout */
:root {
  --avatar-stage-desktop: clamp(520px, 61vh, 650px);
}

.app-grid {
  grid-template-columns: minmax(470px, 1fr) minmax(520px, 1fr);
}

.avatar-column {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 112, 176, .35) transparent;
}

.avatar-column > * {
  flex: 0 0 auto;
  min-width: 0;
}

.avatar-stage {
  width: 100%;
  height: var(--avatar-stage-desktop);
  min-height: 520px;
  flex-basis: var(--avatar-stage-desktop);
  contain: layout paint;
  background:
    radial-gradient(ellipse 68% 48% at 50% 26%, rgba(107, 121, 255, .18), transparent 60%),
    radial-gradient(ellipse 74% 48% at 50% 92%, rgba(255, 52, 132, .16), transparent 62%),
    linear-gradient(180deg, #151125 0%, #0c0912 62%, #070509 100%);
}

#avatarCanvas {
  inline-size: 100%;
  block-size: 100%;
  min-width: 100%;
  min-height: 100%;
}

.stage-vignette {
  background:
    linear-gradient(180deg, rgba(6,4,10,.14), transparent 22%, transparent 72%, rgba(5,3,8,.38)),
    radial-gradient(ellipse 76% 88% at 50% 41%, transparent 48%, rgba(5,2,8,.43) 100%);
}

.scene-hud {
  top: 58px;
  right: 14px;
  width: 184px;
  padding: 9px 10px;
  gap: 6px;
  background: rgba(10, 8, 17, .70);
}

.scene-hud label {
  font-size: .61rem;
}

.scene-hud input[type="range"] {
  height: 18px;
}

.scene-hud select {
  min-height: 29px;
  font-size: .68rem;
}

.stage-label {
  bottom: 14px;
}

.avatar-controls,
.voice-health,
.look-switcher,
.companion-gui {
  position: relative;
  z-index: 2;
}

@media (min-width: 821px) {
  .avatar-column {
    grid-template-rows: none;
    padding-bottom: 24px;
  }

  .avatar-stage {
    height: var(--avatar-stage-desktop);
    min-height: 520px;
  }
}

@media (max-width: 1120px) and (min-width: 821px) {
  .app-grid {
    grid-template-columns: minmax(360px, .92fr) minmax(420px, 1.08fr);
  }
  :root { --avatar-stage-desktop: clamp(500px, 58vh, 590px); }
  .avatar-stage { min-height: 500px; }
}

@media (max-width: 820px) {
  .app-grid { display: block; }
  .avatar-column { overflow: visible; }
  .avatar-stage {
    height: clamp(520px, 72svh, 660px);
    min-height: 520px;
    flex-basis: auto;
  }
}

@media (max-width: 520px) {
  .avatar-stage {
    height: clamp(500px, 69svh, 610px);
    min-height: 500px;
  }
  .scene-hud {
    top: 54px;
    left: auto;
    right: 10px;
    width: 164px;
  }
  .stage-topline,
  .stage-label {
    left: 12px;
    right: 12px;
  }
}

/* v36: full-viewport composition, portrait camera HUD, and automatic connection meter */
:root {
  --v36-shell-gap: 12px;
  --v36-shell-total: 24px;
}

.scene-hud {
  width: 210px;
  padding: 11px 12px;
  gap: 8px;
  border-color: rgba(255, 145, 195, .22);
  background: linear-gradient(155deg, rgba(18, 10, 22, .86), rgba(10, 7, 15, .74));
  box-shadow: 0 14px 34px rgba(0,0,0,.28), inset 0 1px 0 rgba(255,255,255,.045);
}
.scene-hud-status,
.scene-hud-love {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.scene-hud-status span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #ddb9ca;
  font-size: .57rem;
  font-weight: 900;
  letter-spacing: .12em;
  text-transform: uppercase;
}
.scene-hud-status span i,
.auto-connection-note i {
  width: 7px;
  height: 7px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--love-accent, #ff5ca8);
  box-shadow: 0 0 12px var(--love-accent, #ff5ca8);
  animation: heat-dot 1.8s ease-in-out infinite;
}
.scene-hud-status b {
  max-width: 102px;
  color: #ffb9d6;
  font-size: .59rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.scene-hud-love strong {
  color: #fff3f9;
  font-size: 1.05rem;
  line-height: 1;
}
.scene-hud-love .romance-meter {
  flex: 1 1 auto;
  height: 8px;
}
.scene-hud > small {
  color: #9f8191;
  font-size: .54rem;
  line-height: 1.35;
}

.companion-gui {
  padding: 11px 12px;
  gap: 8px;
  border-radius: 15px;
}
.companion-love-row {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid rgba(255,255,255,.072);
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(255,255,255,.052), rgba(255,255,255,.015));
}
.companion-love-row .love-orb {
  width: 40px;
  height: 40px;
}
.companion-love-row .love-copy strong {
  font-size: 1rem;
}
.connection-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
}
.connection-stats > div {
  min-width: 0;
  padding: 7px 8px;
  display: grid;
  gap: 2px;
  border: 1px solid rgba(255,255,255,.065);
  border-radius: 10px;
  background: rgba(255,255,255,.026);
}
.connection-stats strong {
  color: #fff1f7;
  font-size: .72rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.connection-stats small {
  color: #a98999;
  font-size: .49rem;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.auto-connection-note {
  display: flex;
  align-items: center;
  gap: 7px;
  color: #b999aa;
  font-size: .56rem;
  line-height: 1.3;
}
.xp-wrap {
  height: 6px;
}
.companion-toast {
  top: 42px;
}

@media (min-width: 821px) {
  body {
    overflow: hidden;
  }
  .app-shell {
    width: 100vw;
    max-width: none;
    height: 100dvh;
    min-height: 680px;
    padding: var(--v36-shell-gap);
    display: block;
  }
  .app-card {
    width: 100%;
    height: calc(100dvh - var(--v36-shell-total));
    min-height: 656px;
    max-height: none;
    border-radius: 22px;
  }
  .app-grid {
    height: calc(100% - 74px);
    min-height: 0;
    grid-template-columns: minmax(540px, 46%) minmax(0, 54%);
  }
  .avatar-column {
    min-height: 0;
    padding: 14px;
    gap: 10px;
    overflow: hidden;
  }
  .avatar-column > * {
    flex: 0 0 auto;
  }
  .avatar-column > .avatar-stage {
    flex: 1 1 520px;
    height: auto;
    min-height: 430px;
    flex-basis: auto;
    border-radius: 20px;
  }
  .chat-column {
    height: 100%;
    padding: clamp(18px, 1.45vw, 28px);
    gap: 11px;
  }
  .chat-intro h1 {
    font-size: clamp(1.8rem, 2.25vw, 2.7rem);
  }
  .chat-history {
    min-height: 0;
  }
}

@media (min-width: 1500px) {
  .app-grid {
    grid-template-columns: minmax(650px, 45%) minmax(0, 55%);
  }
  .app-header {
    padding-inline: 28px;
  }
  .avatar-column {
    padding: 16px;
  }
  .avatar-column > .avatar-stage {
    min-height: 500px;
  }
  .message {
    max-width: min(82%, 820px);
  }
}

@media (min-width: 821px) and (max-height: 850px) {
  :root { --v36-shell-gap: 8px; --v36-shell-total: 16px; }
  .app-card {
    min-height: 0;
  }
  .app-header {
    height: 64px;
  }
  .app-grid {
    height: calc(100% - 64px);
  }
  .avatar-column,
  .chat-column {
    padding: 10px;
    gap: 8px;
  }
  .avatar-column > .avatar-stage {
    min-height: 340px;
  }
  .look-switcher button {
    min-height: 36px;
  }
  .voice-health {
    min-height: 30px;
  }
  .control-button {
    min-height: 38px;
  }
  .companion-gui {
    padding: 9px 10px;
    gap: 6px;
  }
  .companion-love-row {
    padding: 6px 8px;
  }
  .companion-love-row .love-orb {
    width: 34px;
    height: 34px;
  }
  .auto-connection-note {
    display: none;
  }
  .chat-intro p {
    display: none;
  }
  .mood-chip,
  .quick-prompts button {
    min-height: 30px;
  }
}

@media (max-width: 820px) {
  .app-shell {
    width: 100%;
  }
  .avatar-stage {
    height: clamp(540px, 72svh, 700px);
    min-height: 520px;
  }
  .scene-hud {
    width: 190px;
  }
}

@media (max-width: 520px) {
  .scene-hud {
    top: 52px;
    left: auto;
    right: 9px;
    width: 172px;
    padding: 9px;
  }
  .scene-hud > small {
    display: none;
  }
  .companion-love-row {
    grid-template-columns: 38px minmax(0, 1fr) auto;
  }
  .connection-stats {
    gap: 5px;
  }
  .connection-stats > div {
    padding: 6px;
  }
  .auto-connection-note {
    font-size: .53rem;
  }
}

/* v44: true viewport fill, 1080p desktop tuning, and compact production layout */
html,
body {
  width: 100%;
  height: 100%;
}

@media (min-width: 821px) {
  body {
    min-height: 0;
    height: 100dvh;
    overflow: hidden;
  }

  .app-shell {
    position: fixed;
    inset: 0;
    width: 100%;
    max-width: none;
    height: 100dvh;
    min-height: 0;
    margin: 0;
    padding: 8px;
    display: block;
    place-items: initial;
    overflow: hidden;
  }

  .app-card {
    width: 100%;
    height: 100%;
    min-height: 0;
    max-height: none;
    display: grid;
    grid-template-rows: 64px minmax(0, 1fr);
    border-radius: 18px;
  }

  .app-header {
    height: 64px;
    padding: 0 18px;
  }

  .app-grid {
    width: 100%;
    height: 100%;
    min-height: 0;
    grid-template-columns: minmax(420px, 43%) minmax(0, 57%);
  }

  .avatar-column {
    min-width: 0;
    min-height: 0;
    padding: 10px;
    gap: 8px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  .avatar-column > * {
    min-width: 0;
    flex: 0 0 auto;
  }

  .avatar-column > .avatar-stage {
    width: 100%;
    height: auto;
    min-height: 300px;
    flex: 1 1 0;
    flex-basis: 0;
    border-radius: 18px;
  }

  .avatar-controls {
    gap: 6px;
  }

  .control-button {
    min-height: 38px;
    padding-inline: 8px;
  }

  .voice-health {
    min-height: 29px;
  }

  .look-switcher {
    gap: 6px;
  }

  .look-switcher button {
    min-height: 31px;
    padding-inline: 8px;
  }

  .companion-gui {
    padding: 9px 10px;
    gap: 6px;
  }

  .companion-gui-head h3 {
    font-size: .88rem;
  }

  .companion-love-row {
    padding: 6px 8px;
  }

  .connection-stats > div {
    padding: 6px 7px;
  }

  .chat-column {
    width: 100%;
    height: 100%;
    min-width: 0;
    min-height: 0;
    padding: 16px 18px;
    gap: 8px;
    grid-template-rows: auto auto auto minmax(0, 1fr) auto auto auto;
    overflow: hidden;
  }

  .chat-intro {
    gap: 18px;
  }

  .chat-intro h1 {
    font-size: clamp(1.65rem, 2.05vw, 2.45rem);
  }

  .chat-intro p {
    max-width: 270px;
    font-size: .75rem;
  }

  .mood-bar,
  .quick-prompts {
    gap: 6px;
  }

  .mood-chip,
  .quick-prompts button {
    min-height: 30px;
    padding-inline: 10px;
  }

  .chat-history {
    min-height: 0;
    height: auto;
  }

  .transcript {
    min-height: 0;
    height: 100%;
  }
}

@media (min-width: 821px) and (max-width: 1500px) {
  .app-grid {
    grid-template-columns: minmax(390px, 45%) minmax(0, 55%);
  }

  .brand strong {
    font-size: .9rem;
  }

  .chat-intro h1 {
    font-size: clamp(1.5rem, 2vw, 2rem);
  }

  .chat-intro p {
    max-width: 230px;
    font-size: .7rem;
  }

  .message p {
    font-size: .84rem;
  }

  .scene-hud {
    width: 178px;
  }
}

@media (min-width: 821px) and (max-width: 1220px) {
  .app-grid {
    grid-template-columns: minmax(365px, 46%) minmax(0, 54%);
  }

  .app-header {
    padding-inline: 14px;
  }

  .chat-column {
    padding: 13px 14px;
  }

  .chat-intro {
    display: block;
  }

  .chat-intro p {
    display: none;
  }

  .quick-prompts button:nth-last-child(-n + 2) {
    display: none;
  }

  .look-switcher span {
    font-size: .62rem;
  }
}

@media (min-width: 821px) and (max-height: 820px) {
  .app-shell {
    padding: 5px;
  }

  .app-card {
    grid-template-rows: 58px minmax(0, 1fr);
    border-radius: 14px;
  }

  .app-header {
    height: 58px;
  }

  .avatar-column,
  .chat-column {
    padding: 7px;
    gap: 6px;
  }

  .avatar-column > .avatar-stage {
    min-height: 250px;
  }

  .control-button {
    min-height: 34px;
    font-size: .62rem;
  }

  .voice-health,
  .look-switcher button {
    min-height: 27px;
  }

  .companion-gui {
    padding: 7px 8px;
    gap: 5px;
  }

  .companion-love-row {
    padding: 5px 7px;
  }

  .companion-love-row .love-orb {
    width: 31px;
    height: 31px;
  }

  .connection-stats > div {
    padding: 4px 6px;
  }

  .auto-connection-note {
    display: none;
  }

  .chat-intro h1 {
    font-size: 1.45rem;
  }

  .mood-chip,
  .quick-prompts button {
    min-height: 27px;
    font-size: .65rem;
  }

  .chat-footer {
    font-size: .55rem;
  }
}

@media (max-width: 820px) {
  body {
    height: auto;
    overflow-y: auto;
  }

  .app-shell {
    position: relative;
    inset: auto;
    width: 100%;
    height: auto;
    min-height: 100svh;
  }

  .app-card {
    height: auto;
  }

  .avatar-stage {
    width: 100%;
    height: clamp(500px, 68svh, 650px);
    min-height: 480px;
  }
}
