:root {
  color-scheme: dark;
  --bg: #06060d;
  --bg-2: #101026;
  --panel: rgba(23, 18, 37, 0.66);
  --panel-strong: rgba(19, 15, 31, 0.82);
  --panel-2: rgba(255, 255, 255, 0.07);
  --line: rgba(255, 255, 255, 0.16);
  --line-strong: rgba(255, 255, 255, 0.28);
  --text: #fff3ff;
  --muted: #d4c2dc;
  --muted-2: #988aa8;
  --accent: #ffaae9;
  --accent-deep: #d676ff;
  --accent-2: #99ecff;
  --accent-3: #ff6f9b;
  --danger: #ff8ea3;
  --success: #7dffd8;
  --shadow: 0 32px 110px rgba(0, 0, 0, 0.55);
  --radius-xl: 34px;
  --radius-lg: 26px;
  --ease: cubic-bezier(.2,.8,.2,1);
}

* { box-sizing: border-box; }

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  height: 100dvh;
  overflow: hidden;
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans TC", "Noto Sans", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 18% 12%, rgba(255, 170, 233, 0.20), transparent 30rem),
    radial-gradient(circle at 86% 16%, rgba(153, 236, 255, 0.15), transparent 28rem),
    radial-gradient(circle at 62% 90%, rgba(214, 118, 255, 0.14), transparent 35rem),
    linear-gradient(135deg, #05050b 0%, #121127 50%, #070712 100%);
}

button, input, select, textarea { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }

::selection {
  background: rgba(255, 170, 233, .32);
  color: #fff;
}

/* Background atmosphere */
.ambient,
.ambient > * {
  position: fixed;
  inset: 0;
  pointer-events: none;
}

.aurora {
  width: 54vw;
  height: 54vw;
  inset: auto;
  border-radius: 999px;
  filter: blur(70px);
  opacity: .54;
  mix-blend-mode: screen;
  animation: auroraDrift 18s var(--ease) infinite alternate;
}

.aurora-a {
  left: -16vw;
  top: -18vw;
  background: radial-gradient(circle, rgba(255, 170, 233, .72), rgba(214, 118, 255, .2) 46%, transparent 68%);
}

.aurora-b {
  right: -16vw;
  bottom: -18vw;
  background: radial-gradient(circle, rgba(153, 236, 255, .66), rgba(114, 142, 255, .20) 48%, transparent 70%);
  animation-delay: -8s;
}

@keyframes auroraDrift {
  from { transform: translate3d(0,0,0) scale(1); }
  to { transform: translate3d(7vw, 4vh, 0) scale(1.12); }
}

.starfield {
  opacity: .52;
  background-image:
    radial-gradient(circle, rgba(255,255,255,.28) 1px, transparent 1.4px),
    radial-gradient(circle, rgba(153,236,255,.22) 1px, transparent 1.4px),
    linear-gradient(120deg, transparent 0 48%, rgba(255,255,255,.045) 49%, transparent 50% 100%);
  background-size: 38px 38px, 83px 83px, 180px 180px;
  background-position: 0 0, 23px 21px, 0 0;
  mask-image: linear-gradient(to bottom, black, transparent 88%);
  animation: stars 80s linear infinite;
}

@keyframes stars {
  to { background-position: 700px 380px, -420px 760px, 360px 720px; }
}

.void-ring {
  inset: auto;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,.14);
  box-shadow: inset 0 0 40px rgba(153,236,255,.08), 0 0 75px rgba(255,170,233,.08);
  opacity: .5;
  animation: ringPulse 12s ease-in-out infinite;
}

.void-ring-a { width: 330px; height: 330px; right: 10vw; top: 8vh; }
.void-ring-b { width: 520px; height: 520px; left: 20vw; bottom: -250px; animation-delay: -5s; }

@keyframes ringPulse {
  0%, 100% { transform: scale(.96) rotate(0deg); opacity: .32; }
  50% { transform: scale(1.05) rotate(12deg); opacity: .66; }
}

.ambient-bubble {
  position: absolute;
  left: var(--x);
  top: 105vh;
  width: var(--s);
  height: var(--s);
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,.36);
  background:
    radial-gradient(circle at 28% 24%, rgba(255,255,255,.72), rgba(255,255,255,.18) 20%, transparent 36%),
    radial-gradient(circle at 68% 78%, rgba(153,236,255,.22), transparent 52%),
    rgba(255,255,255,.035);
  box-shadow: inset 0 0 20px rgba(255,255,255,.12), 0 0 28px rgba(255,170,233,.10);
  opacity: var(--o);
  animation: bubbleRise var(--d) linear infinite;
  animation-delay: var(--delay);
}

@keyframes bubbleRise {
  from { transform: translate3d(0,0,0) scale(.9); }
  to { transform: translate3d(var(--drift), -125vh, 0) scale(1.12); }
}

.grain {
  opacity: .10;
  background-image:
    repeating-radial-gradient(circle at 17% 32%, rgba(255,255,255,.9) 0 1px, transparent 1px 4px),
    repeating-linear-gradient(0deg, rgba(255,255,255,.06) 0 1px, transparent 1px 3px);
  background-size: 140px 140px, 100% 3px;
  mix-blend-mode: overlay;
}

.ambient::before,
.ambient::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.ambient::before {
  opacity: .18;
  background:
    linear-gradient(90deg, rgba(153,236,255,.10) 1px, transparent 1px),
    linear-gradient(0deg, rgba(255,170,233,.08) 1px, transparent 1px);
  background-size: 86px 86px;
  mask-image:
    radial-gradient(circle at 16% 18%, black, transparent 36%),
    radial-gradient(circle at 86% 18%, black, transparent 38%),
    linear-gradient(to bottom, black, transparent 92%);
  animation: circuitDrift 26s linear infinite;
}

.ambient::after {
  opacity: .28;
  background:
    conic-gradient(from 190deg at 50% 50%, transparent 0 14%, rgba(255,170,233,.18) 16%, transparent 19% 46%, rgba(153,236,255,.18) 48%, transparent 51% 100%);
  width: 980px;
  height: 980px;
  left: 50%;
  top: 50%;
  inset: auto;
  transform: translate(-50%, -50%);
  border-radius: 999px;
  filter: blur(.4px);
  animation: slowRotate 42s linear infinite;
}

@keyframes circuitDrift {
  to { background-position: 260px 120px, 120px 260px; }
}

@keyframes slowRotate {
  to { transform: translate(-50%, -50%) rotate(360deg); }
}

.shell {
  position: relative;
  z-index: 1;
  width: min(1440px, calc(100vw - 32px));
  margin: 0 auto;
  min-height: 100vh;
  height: 100dvh;
  min-height: 0;
  display: grid;
  grid-template-columns: 390px minmax(0, 1fr);
  gap: 18px;
  padding: 24px 0;
}

.glass-card,
.profile-panel,
.chat-panel {
  position: relative;
  border: 1px solid var(--line);
  background:
    linear-gradient(135deg, rgba(255,255,255,.10), rgba(255,255,255,.035)),
    var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(26px) saturate(140%);
  -webkit-backdrop-filter: blur(26px) saturate(140%);
  border-radius: var(--radius-xl);
}

.glass-card::before,
.profile-panel::before,
.chat-panel::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(135deg, rgba(255,255,255,.42), rgba(255,170,233,.15), rgba(153,236,255,.22), transparent 70%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
}

.panel-glow,
.chat-top-glow {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  overflow: hidden;
}

.panel-glow::after,
.chat-top-glow::after {
  content: "";
  position: absolute;
  width: 60%;
  height: 2px;
  top: 0;
  left: 12%;
  background: linear-gradient(90deg, transparent, rgba(255,170,233,.76), rgba(153,236,255,.6), transparent);
  filter: blur(.2px);
}

.profile-panel {
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  height: calc(100dvh - 48px);
  max-height: calc(100dvh - 48px);
  min-height: 0;
  overflow-y: scroll;
  overflow-x: hidden;
  overscroll-behavior-y: contain;
  touch-action: pan-y;
  scrollbar-gutter: stable;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,170,233,.45) transparent;
}

.profile-panel::-webkit-scrollbar,
.chat-log::-webkit-scrollbar,
pre::-webkit-scrollbar { width: 10px; }
.profile-panel::-webkit-scrollbar-thumb,
.chat-log::-webkit-scrollbar-thumb,
pre::-webkit-scrollbar-thumb {
  background: linear-gradient(var(--accent), var(--accent-2));
  border: 3px solid transparent;
  background-clip: padding-box;
  border-radius: 999px;
}

.avatar-card {
  position: relative;
  overflow: hidden;
  min-height: 300px;
  padding: 20px;
  border-radius: 28px;
  background:
    radial-gradient(circle at 74% 12%, rgba(255, 170, 233, 0.38), transparent 11rem),
    radial-gradient(circle at 10% 92%, rgba(153, 236, 255, 0.20), transparent 13rem),
    linear-gradient(145deg, rgba(255,255,255,.14), rgba(255,255,255,.035));
  border: 1px solid var(--line);
  isolation: isolate;
}

.avatar-card::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, transparent 0 46%, rgba(255,255,255,.06) 50%, transparent 54% 100%),
    repeating-linear-gradient(90deg, rgba(255,255,255,.04) 0 1px, transparent 1px 74px);
  opacity: .42;
  mask-image: linear-gradient(to bottom, black, transparent 92%);
  pointer-events: none;
}

.scanline {
  position: absolute;
  inset: -80% 0 auto;
  height: 80%;
  background: linear-gradient(to bottom, transparent, rgba(153,236,255,.08), transparent);
  transform: translateY(-100%);
  animation: scan 7s ease-in-out infinite;
  pointer-events: none;
}

@keyframes scan {
  0%, 45% { transform: translateY(-110%); opacity: 0; }
  52% { opacity: 1; }
  78%, 100% { transform: translateY(230%); opacity: 0; }
}

.portrait-wrap {
  position: relative;
  width: 178px;
  height: 178px;
  margin: 4px 0 24px;
  display: grid;
  place-items: center;
  filter: drop-shadow(0 24px 54px rgba(255,170,233,.24));
}

.halo-ring {
  position: absolute;
  inset: 6px;
  border-radius: 50%;
  border: 1px solid rgba(153,236,255,.55);
  box-shadow: 0 0 38px rgba(153,236,255,.15), inset 0 0 34px rgba(255,170,233,.10);
  animation: spin 18s linear infinite;
}

.halo-ring::before,
.halo-ring::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 132%;
  height: 52%;
  border: 1px solid rgba(255,170,233,.35);
  border-radius: 50%;
  transform: translate(-50%, -50%) rotate(24deg);
}

.halo-ring::after { transform: translate(-50%, -50%) rotate(-24deg); border-color: rgba(153,236,255,.28); }
@keyframes spin { to { transform: rotate(360deg); } }

.portrait {
  position: relative;
  width: 132px;
  height: 146px;
}

.face {
  position: absolute;
  left: 31px;
  top: 36px;
  width: 72px;
  height: 82px;
  border-radius: 45% 45% 48% 48%;
  background: linear-gradient(180deg, #ffe6f2, #f8c9df 92%);
  box-shadow: inset 0 -9px 18px rgba(165, 91, 136,.18);
  z-index: 4;
}

.hair {
  position: absolute;
  border-radius: 999px 999px 34px 34px;
  background: linear-gradient(160deg, #ffd0ec 0%, #f6a7ff 48%, #db77f4 100%);
}

.hair-back {
  left: 9px;
  top: 11px;
  width: 114px;
  height: 132px;
  border-radius: 55% 55% 42% 42%;
  transform: rotate(-2deg);
  z-index: 1;
}

.hair-front {
  left: 23px;
  top: 18px;
  width: 86px;
  height: 54px;
  border-radius: 60% 60% 42% 42%;
  clip-path: polygon(0 0, 100% 0, 88% 65%, 68% 38%, 51% 88%, 31% 35%, 14% 73%);
  z-index: 5;
}

.eye {
  position: absolute;
  top: 34px;
  width: 10px;
  height: 12px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff, #9ceeff 18%, #7a72ff 58%, #2c2450 100%);
  box-shadow: 0 0 8px rgba(153,236,255,.65);
}
.eye.left { left: 19px; }
.eye.right { right: 19px; }
.smile {
  position: absolute;
  left: 30px;
  top: 58px;
  width: 13px;
  height: 6px;
  border-bottom: 2px solid rgba(61, 31, 62, .65);
  border-radius: 0 0 999px 999px;
}

.ribbon {
  position: absolute;
  top: 42px;
  width: 24px;
  height: 42px;
  background: linear-gradient(180deg, #1a1429, #05050b);
  border: 1px solid rgba(255,255,255,.16);
  z-index: 2;
}
.ribbon-left { left: 0; border-radius: 18px 6px 18px 6px; transform: rotate(-22deg); }
.ribbon-right { right: 0; border-radius: 6px 18px 6px 18px; transform: rotate(22deg); }
.gem {
  position: absolute;
  left: 58px;
  top: 111px;
  width: 18px;
  height: 18px;
  border-radius: 5px 5px 12px 12px;
  background: linear-gradient(135deg, #e8ffff, #69ddff 42%, #695aff);
  box-shadow: 0 0 16px rgba(153,236,255,.76);
  z-index: 6;
}

.orb {
  position: absolute;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, .38);
  background:
    radial-gradient(circle at 30% 25%, rgba(255,255,255,.70), rgba(255,255,255,.12) 44%, rgba(255,255,255,.025) 70%),
    linear-gradient(135deg, rgba(255,170,233,.11), rgba(153,236,255,.10));
  box-shadow: inset 0 0 24px rgba(255,255,255,.12), 0 0 28px rgba(255,170,233,.12);
  animation: float 7s ease-in-out infinite;
  z-index: -1;
}

.orb-a { width: 92px; height: 92px; right: 30px; top: 32px; }
.orb-b { width: 52px; height: 52px; right: 116px; top: 128px; animation-delay: -2s; }
.orb-c { width: 34px; height: 34px; right: 54px; top: 172px; animation-delay: -4s; }

@keyframes float {
  0%, 100% { transform: translateY(0) translateX(0); }
  50% { transform: translateY(-16px) translateX(7px); }
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent-2);
  text-transform: uppercase;
  letter-spacing: .12em;
  font-size: 12px;
  font-weight: 800;
}

h1, h2 { margin: 0; }
h1 {
  font-size: clamp(38px, 5vw, 54px);
  letter-spacing: .08em;
  line-height: 1;
  text-shadow: 0 0 22px rgba(255,170,233,.28);
}

h2 { font-size: 22px; letter-spacing: .02em; }
.subtitle { color: var(--muted); margin: 10px 0 0; line-height: 1.6; }
.header-subtitle { margin: 7px 0 0; color: var(--muted-2); font-size: 13px; }

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 18px;
}

.tag-row span,
.mini-badge,
.lore-status,
.status,
.quick-prompts button {
  border: 1px solid rgba(255,255,255,.16);
  background: rgba(255,255,255,.075);
  box-shadow: inset 0 1px rgba(255,255,255,.09);
}

.tag-row span,
.mini-badge {
  border-radius: 999px;
  color: #f9e8ff;
  font-size: 12px;
  font-weight: 800;
  padding: 7px 10px;
}

.mini-badge { color: var(--accent-2); }
.mini-badge.ghost { color: var(--accent); }

.lore-card,
.controls,
.glass-card-soft {
  position: relative;
  padding: 18px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  background:
    linear-gradient(135deg, rgba(255,255,255,.095), rgba(255,255,255,.028)),
    rgba(255,255,255,.045);
  overflow: hidden;
}

.lore-card::before,
.controls::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 15% 0%, rgba(255,170,233,.13), transparent 15rem);
  pointer-events: none;
}

.card-title {
  position: relative;
  z-index: 1;
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.lore-card h2,
.controls h2 { font-size: 17px; }
.lore-card p { position: relative; z-index: 1; color: var(--muted); line-height: 1.72; margin: 0; }
.lore-card ul { position: relative; z-index: 1; list-style: none; margin: 0; padding: 0; color: var(--muted); display: grid; gap: 12px; }
.lore-card li {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  padding: 10px 0;
  border-top: 1px solid rgba(255,255,255,.08);
  line-height: 1.55;
}
.lore-card li:first-child { border-top: 0; padding-top: 0; }
.lore-card li b { color: #fff; font-size: 13px; }
.lore-card li span { color: var(--muted); }

.meter-list {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.meter-list div {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  color: var(--muted-2);
  font-size: 12px;
  font-weight: 800;
}

.meter-list i {
  height: 6px;
  border-radius: 999px;
  background: rgba(255,255,255,.10);
  overflow: hidden;
  position: relative;
}

.meter-list i::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: var(--v);
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  box-shadow: 0 0 18px rgba(255,170,233,.36);
}

.controls { display: grid; gap: 14px; }

.control-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px 12px;
}

.wide-field {
  grid-column: 1 / -1;
}

label {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 650;
}

input, select, textarea {
  width: 100%;
  color: var(--text);
  background:
    linear-gradient(180deg, rgba(0,0,0,.22), rgba(0,0,0,.10)),
    rgba(8,8,18,.38);
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 16px;
  outline: none;
  box-shadow: inset 0 1px rgba(255,255,255,.05);
  transition: border-color .2s var(--ease), box-shadow .2s var(--ease), transform .2s var(--ease), background .2s var(--ease);
}

input, select { padding: 12px 13px; }
select option { background: #171224; color: var(--text); }
textarea {
  resize: none;
  padding: 16px 56px 16px 18px;
  max-height: 190px;
  line-height: 1.65;
}

input:focus, select:focus, textarea:focus {
  border-color: rgba(255, 170, 233, .85);
  box-shadow: 0 0 0 4px rgba(255, 170, 233, .12), 0 0 32px rgba(255,170,233,.10);
}

input[type="range"] {
  appearance: none;
  height: 38px;
  padding: 0 2px;
  background: transparent;
  border: 0;
  box-shadow: none;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 8px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(255,170,233,.78), rgba(153,236,255,.78));
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.16);
}
input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 22px;
  height: 22px;
  margin-top: -7px;
  border-radius: 50%;
  background: #fff;
  border: 4px solid var(--accent);
  box-shadow: 0 0 22px rgba(255,170,233,.58);
}

.button-row { position: relative; z-index: 1; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
button,
.btn {
  cursor: pointer;
  border: 0;
  color: #170d20;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-radius: 16px;
  padding: 12px 14px;
  font-weight: 900;
  letter-spacing: .02em;
  transition: transform .18s var(--ease), box-shadow .18s var(--ease), filter .18s var(--ease), border-color .18s var(--ease);
  position: relative;
  overflow: hidden;
}

button::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(110deg, transparent 0 34%, rgba(255,255,255,.30) 48%, transparent 62% 100%);
  transform: translateX(-120%);
  transition: transform .55s var(--ease);
  pointer-events: none;
}
button:hover { transform: translateY(-2px); box-shadow: 0 16px 30px rgba(255,170,233,.16); }
button:hover::after { transform: translateX(120%); }
button:active { transform: translateY(0) scale(.99); }
button:disabled { opacity: .55; cursor: not-allowed; transform: none; }

button.secondary,
.btn.secondary {
  background: rgba(255,255,255,.09);
  color: var(--text);
  border: 1px solid rgba(255,255,255,.15);
}

.danger-soft {
  background: rgba(255,142,163,.12);
  color: #ffe4eb;
  border: 1px solid rgba(255,142,163,.25);
}

.chat-panel {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto auto;
  overflow: hidden;
  height: calc(100dvh - 48px);
  max-height: calc(100dvh - 48px);
  min-height: 0;
  background:
    radial-gradient(circle at 82% 0%, rgba(153,236,255,.12), transparent 20rem),
    linear-gradient(135deg, rgba(255,255,255,.08), rgba(255,255,255,.03)),
    var(--panel-strong);
}

.chat-panel::after {
  content: "";
  position: absolute;
  right: -40px;
  bottom: 92px;
  width: min(32vw, 360px);
  height: min(46vw, 520px);
  background: url('/assets/denia-main.webp') center bottom / contain no-repeat;
  opacity: .08;
  filter: drop-shadow(0 18px 40px rgba(255,170,233,.2));
  pointer-events: none;
  z-index: 0;
  mask-image: linear-gradient(to top, black, transparent 95%);
}

.chat-header {
  position: relative;
  z-index: 1;
  padding: 24px 26px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid rgba(255,255,255,.13);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.lore-status,
.status {
  min-height: 34px;
  padding: 8px 12px;
  border-radius: 999px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--success);
  box-shadow: 0 0 16px rgba(125,255,216,.75);
}

.status.live { color: #d9fff5; background: rgba(80,255,205,.12); border-color: rgba(125,255,216,.28); }
.status.live::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 14px rgba(125,255,216,.75);
  animation: ping 1.4s ease-in-out infinite;
}
.status.warn { color: #fff5d5; background: rgba(255,230,144,.1); border-color: rgba(255,230,144,.22); }
.status.warn { color: #fff5d5; background: rgba(255,230,144,.1); border-color: rgba(255,230,144,.22); }
.status.error { color: #ffe0e6; background: rgba(255,142,163,.12); border-color: rgba(255,142,163,.30); }
@keyframes ping { 50% { transform: scale(.72); opacity: .55; } }

.quick-prompts {
  position: relative;
  z-index: 1;
  display: flex;
  gap: 10px;
  padding: 14px 24px;
  overflow-x: auto;
  border-bottom: 1px solid rgba(255,255,255,.08);
  scrollbar-width: none;
}
.quick-prompts::-webkit-scrollbar { display: none; }
.quick-prompts button {
  flex: 0 0 auto;
  color: var(--text);
  background: rgba(255,255,255,.06);
  padding: 9px 12px;
  font-size: 13px;
  box-shadow: none;
}
.quick-prompts button:hover { border-color: rgba(255,170,233,.38); box-shadow: 0 10px 24px rgba(0,0,0,.18); }

.chat-log {
  position: relative;
  overflow: auto;
  padding: 26px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  scroll-behavior: smooth;
}

.chat-log::before {
  content: "";
  position: sticky;
  top: -26px;
  height: 30px;
  margin-bottom: -30px;
  background: linear-gradient(to bottom, rgba(15,12,28,.92), transparent);
  pointer-events: none;
  z-index: 4;
}

.message {
  display: grid;
  grid-template-columns: 46px minmax(0, min(100%, 780px));
  max-width: min(90%, 860px);
  gap: 10px;
  animation: messageIn .35s var(--ease) both;
}

.message.user {
  align-self: flex-end;
  grid-template-columns: minmax(0, min(100%, 620px)) 46px;
}

@keyframes messageIn {
  from { opacity: 0; transform: translateY(12px) scale(.985); filter: blur(3px); }
  to { opacity: 1; transform: translateY(0) scale(1); filter: blur(0); }
}

.msg-avatar {
  width: 46px;
  height: 46px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 1000;
  letter-spacing: .05em;
  color: #150b20;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 14px 24px rgba(255,170,233,.16);
  align-self: end;
}

.message.user .msg-avatar {
  grid-column: 2;
  grid-row: 1;
  background: linear-gradient(135deg, #99ecff, #fafaff);
  box-shadow: 0 14px 24px rgba(153,236,255,.14);
}

.assistant-avatar {
  padding: 0;
  overflow: hidden;
  background: linear-gradient(180deg, rgba(255,255,255,.28), rgba(255,255,255,.06));
  border: 1px solid rgba(255,255,255,.18);
}

.assistant-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center top;
  transform: scale(1.18);
}

.user-avatar {
  font-size: 14px;
}

.msg-bubble {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 15px 18px;
  line-height: 1.82;
  white-space: pre-wrap;
  background: rgba(255,255,255,.07);
  box-shadow: 0 16px 42px rgba(0,0,0,.18);
  overflow: hidden;
}

.msg-bubble::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 10% 0%, rgba(255,255,255,.12), transparent 8rem);
  pointer-events: none;
}

.message.assistant .msg-bubble {
  border-top-left-radius: 10px;
  background:
    radial-gradient(circle at 0% 0%, rgba(255,170,233,.14), transparent 12rem),
    linear-gradient(145deg, rgba(255,170,233,.12), rgba(255,255,255,.055));
}

.message.user .msg-bubble {
  grid-column: 1;
  border-top-right-radius: 10px;
  background:
    radial-gradient(circle at 100% 0%, rgba(153,236,255,.15), transparent 12rem),
    rgba(153,232,255,.11);
}

.message .name {
  display: block;
  margin-bottom: 5px;
  font-size: 11px;
  color: var(--accent-2);
  font-weight: 1000;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.message.user .name { color: #e8fbff; text-align: right; }

.typing {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  min-height: 26px;
}
.typing span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  animation: blink 1s infinite ease-in-out;
  box-shadow: 0 0 16px rgba(255,170,233,.32);
}
.typing span:nth-child(2) { animation-delay: .15s; }
.typing span:nth-child(3) { animation-delay: .3s; }
@keyframes blink { 50% { opacity: .25; transform: translateY(-4px); } }

.composer {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  padding: 18px 24px 10px;
  border-top: 1px solid rgba(255,255,255,.12);
  background: linear-gradient(to top, rgba(8,7,16,.64), rgba(8,7,16,.18));
}

.input-frame {
  position: relative;
  display: grid;
}
.input-frame::before {
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: 17px;
  background: linear-gradient(135deg, rgba(255,170,233,.32), rgba(153,236,255,.20), transparent 62%);
  opacity: 0;
  transition: opacity .2s var(--ease);
  pointer-events: none;
}
.input-frame:focus-within::before { opacity: 1; }
.input-frame textarea { position: relative; z-index: 1; }
.char-count {
  position: absolute;
  right: 14px;
  bottom: 10px;
  z-index: 2;
  color: var(--muted-2);
  font-size: 12px;
  font-weight: 800;
}

.send-btn {
  min-width: 112px;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  box-shadow: 0 18px 38px rgba(255,170,233,.18);
}
.send-btn i {
  width: 14px;
  height: 14px;
  border-radius: 999px;
  border: 1px solid rgba(23,13,32,.52);
  box-shadow: inset 0 0 7px rgba(255,255,255,.7);
  background: rgba(255,255,255,.35);
}

.hint {
  margin: 0 24px 18px;
  padding: 12px 14px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.65;
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 16px;
  background: rgba(255,255,255,.045);
}

.hint b { color: #fff; }
.hint.error-hint {
  color: #ffe3ea;
  border-color: rgba(255,142,163,.28);
  background: rgba(255,142,163,.08);
}

.burst-bubble {
  position: fixed;
  width: var(--s);
  height: var(--s);
  left: var(--x);
  top: var(--y);
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,.5);
  background: radial-gradient(circle at 28% 26%, rgba(255,255,255,.85), rgba(255,255,255,.18) 30%, rgba(255,170,233,.06) 70%);
  pointer-events: none;
  z-index: 99;
  animation: burst .9s var(--ease) forwards;
}
@keyframes burst {
  to { transform: translate3d(var(--dx), var(--dy), 0) scale(0); opacity: 0; }
}

dialog {
  width: min(960px, calc(100vw - 28px));
  border: 1px solid var(--line);
  border-radius: 28px;
  padding: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 12% 0%, rgba(255,170,233,.15), transparent 18rem),
    #121020;
  box-shadow: var(--shadow);
  overflow: hidden;
}
dialog::backdrop { background: rgba(0,0,0,.70); backdrop-filter: blur(10px); }
dialog article { max-height: min(800px, calc(100vh - 44px)); display: grid; grid-template-rows: auto minmax(0,1fr); }
dialog header { display: flex; justify-content: space-between; align-items: center; gap: 20px; padding: 18px 20px; border-bottom: 1px solid var(--line); }
#closePromptBtn { width: 42px; height: 42px; padding: 0; border-radius: 999px; }
pre { margin: 0; padding: 22px; overflow: auto; white-space: pre-wrap; line-height: 1.68; color: var(--muted); font-size: 13px; }

@media (max-width: 1080px) {
  .shell {
    width: min(100vw - 18px, 820px);
    grid-template-columns: 1fr;
    padding: 9px 0;
  }
  .profile-panel, .chat-panel { max-height: none; border-radius: 28px; }
  .profile-panel { overflow: visible; }
  .chat-panel { min-height: 78vh; }
  .avatar-card { min-height: 280px; }
  .portrait-wrap { width: 150px; height: 150px; }
  .portrait { transform: scale(.86); }
}

@media (max-width: 680px) {
  body { background-attachment: fixed; }
  .shell { width: 100%; padding: 0; gap: 10px; }
  .profile-panel, .chat-panel { border-radius: 0; border-left: 0; border-right: 0; }
  .profile-panel { padding: 12px; }
  .avatar-card { min-height: 260px; padding: 18px; border-radius: 24px; }
  .portrait-wrap { width: 130px; height: 130px; margin-bottom: 16px; }
  .portrait { transform: scale(.74); }
  h1 { font-size: 38px; }
  h2 { font-size: 19px; }
  .tag-row { gap: 6px; }
  .tag-row span { font-size: 11px; padding: 6px 9px; }
  .chat-header { align-items: flex-start; padding: 18px 16px; flex-direction: column; }
  .header-actions { justify-content: flex-start; }
  .quick-prompts { padding: 12px 16px; }
  .chat-log { padding: 18px 14px; gap: 15px; }
  .message,
  .message.user {
    grid-template-columns: 34px minmax(0, 1fr);
    max-width: 100%;
  }
  .message.user {
    grid-template-columns: minmax(0, 1fr) 34px;
  }
  .msg-avatar { width: 34px; height: 34px; border-radius: 13px; font-size: 11px; }
  .msg-bubble { padding: 12px 14px; border-radius: 20px; font-size: 15px; }
  .composer { grid-template-columns: 1fr; padding: 14px 14px 8px; }
  .send-btn { min-height: 46px; }
  .hint { padding: 0 16px 14px; }
  .button-row { grid-template-columns: 1fr; }
  .control-grid { grid-template-columns: 1fr; }
  .lore-card li { grid-template-columns: 1fr; gap: 4px; }
  .void-ring-a { right: -120px; top: 80px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: .001ms !important;
  }
  .ambient-bubble { display: none; }
}

.hero-stage {
  position: relative;
  min-height: 230px;
  display: grid;
  place-items: center;
  margin: -4px -4px 14px;
  padding: 8px 0 0;
  isolation: isolate;
}

.hero-aura {
  position: absolute;
  inset: 18px 10px 0;
  border-radius: 28px;
  background:
    radial-gradient(circle at 50% 18%, rgba(255,255,255,.22), transparent 22%),
    radial-gradient(circle at 35% 30%, rgba(255,170,233,.34), transparent 45%),
    radial-gradient(circle at 70% 60%, rgba(153,236,255,.18), transparent 35%),
    linear-gradient(180deg, rgba(255,255,255,.06), rgba(255,255,255,.02));
  border: 1px solid rgba(255,255,255,.12);
  box-shadow: inset 0 0 30px rgba(255,255,255,.06), 0 30px 60px rgba(0,0,0,.14);
}

.character-visual {
  position: relative;
  z-index: 3;
  width: min(100%, 246px);
  max-height: 250px;
  object-fit: contain;
  object-position: center top;
  filter: drop-shadow(0 28px 42px rgba(0,0,0,.34)) drop-shadow(0 0 24px rgba(255,170,233,.18));
}

.hero-bubble {
  position: absolute;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,.36);
  background:
    radial-gradient(circle at 32% 26%, rgba(255,255,255,.75), rgba(255,255,255,.13) 42%, rgba(255,255,255,.02) 70%),
    linear-gradient(135deg, rgba(255,170,233,.12), rgba(153,236,255,.14));
  box-shadow: inset 0 0 26px rgba(255,255,255,.08), 0 12px 28px rgba(255,170,233,.14);
  animation: float 7s ease-in-out infinite;
}

.hero-bubble-a { width: 72px; height: 72px; right: 10px; top: 8px; }
.hero-bubble-b { width: 38px; height: 38px; right: 94px; top: 118px; animation-delay: -2s; }
.hero-bubble-c { width: 28px; height: 28px; left: 14px; top: 72px; animation-delay: -4s; }

.hero-shadow {
  position: absolute;
  z-index: 1;
  left: 50%;
  bottom: 6px;
  width: 58%;
  height: 22px;
  transform: translateX(-50%);
  border-radius: 999px;
  background: radial-gradient(circle, rgba(0,0,0,.28), transparent 72%);
}

.hero-copy { position: relative; z-index: 2; }

.identity-grid {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 16px;
}

.identity-grid div {
  padding: 10px 12px;
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,.09);
  background: rgba(255,255,255,.04);
}

.identity-grid small {
  display: block;
  margin-bottom: 4px;
  color: var(--muted-2);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .05em;
}

.identity-grid b {
  color: #fff;
  font-size: 12px;
  line-height: 1.45;
}

.message-text {
  display: block;
  text-wrap: pretty;
}

@media (max-width: 1080px) {
  .chat-panel::after { opacity: .06; width: 240px; height: 340px; }
}

@media (max-width: 680px) {
  .hero-stage { min-height: 208px; margin-bottom: 10px; }
  .character-visual { width: min(100%, 210px); max-height: 218px; }
  .hero-aura { inset: 12px 4px 0; }
  .identity-grid { grid-template-columns: 1fr; }
  .chat-panel::after { display: none; }
}

/* Extra polish: HUD corners, stronger Denia atmosphere, reliable nested scroll */
.profile-panel::after,
.chat-panel::before {
  box-shadow:
    inset 0 0 0 1px rgba(255,255,255,.025),
    inset 0 0 60px rgba(255,170,233,.035);
}

.avatar-card {
  box-shadow:
    inset 0 1px rgba(255,255,255,.12),
    inset 0 -26px 90px rgba(0,0,0,.20),
    0 22px 60px rgba(0,0,0,.18);
}

.avatar-card::before {
  content: "";
  position: absolute;
  inset: 12px;
  border-radius: 22px;
  border: 1px solid rgba(153,236,255,.14);
  pointer-events: none;
  z-index: 5;
}

.hero-stage {
  position: relative;
  min-height: 230px;
  display: grid;
  place-items: center;
  margin: -4px -4px 14px;
  padding: 8px 0 0;
  isolation: isolate;
}

.hero-aura {
  position: absolute;
  inset: 18px 10px 0;
  border-radius: 28px;
  background:
    radial-gradient(circle at 50% 18%, rgba(255,255,255,.22), transparent 22%),
    radial-gradient(circle at 35% 30%, rgba(255,170,233,.34), transparent 45%),
    radial-gradient(circle at 70% 60%, rgba(153,236,255,.18), transparent 35%),
    linear-gradient(180deg, rgba(255,255,255,.06), rgba(255,255,255,.02));
  border: 1px solid rgba(255,255,255,.12);
  box-shadow: inset 0 0 30px rgba(255,255,255,.06), 0 30px 60px rgba(0,0,0,.14);
}

.hero-stage::before,
.hero-stage::after {
  content: "";
  position: absolute;
  border-radius: 999px;
  pointer-events: none;
}

.hero-stage::before {
  width: 240px;
  height: 240px;
  border: 1px solid rgba(153,236,255,.22);
  box-shadow: inset 0 0 50px rgba(153,236,255,.08), 0 0 44px rgba(255,170,233,.09);
  transform: rotate(-18deg);
  animation: slowRotate 38s linear infinite;
}

.hero-stage::after {
  width: 300px;
  height: 92px;
  border: 1px solid rgba(255,170,233,.20);
  transform: rotate(20deg);
  animation: heroOrbit 12s ease-in-out infinite alternate;
}

@keyframes heroOrbit {
  from { transform: rotate(13deg) scale(.96); opacity: .42; }
  to { transform: rotate(26deg) scale(1.04); opacity: .82; }
}

.character-visual {
  position: relative;
  z-index: 3;
  width: min(100%, 246px);
  max-height: 250px;
  object-fit: contain;
  object-position: center top;
  filter: drop-shadow(0 28px 42px rgba(0,0,0,.34)) drop-shadow(0 0 24px rgba(255,170,233,.18));
  transition: transform .42s var(--ease), filter .42s var(--ease);
}

.avatar-card:hover .character-visual {
  transform: translateY(-5px) scale(1.03);
  filter: drop-shadow(0 34px 48px rgba(0,0,0,.40)) drop-shadow(0 0 34px rgba(255,170,233,.30));
}

.hero-bubble {
  position: absolute;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,.36);
  background:
    radial-gradient(circle at 32% 26%, rgba(255,255,255,.75), rgba(255,255,255,.13) 42%, rgba(255,255,255,.02) 70%),
    linear-gradient(135deg, rgba(255,170,233,.12), rgba(153,236,255,.14));
  box-shadow: inset 0 0 26px rgba(255,255,255,.08), 0 12px 28px rgba(255,170,233,.14);
  animation: float 7s ease-in-out infinite;
}

.hero-bubble-a { width: 72px; height: 72px; right: 10px; top: 8px; }
.hero-bubble-b { width: 38px; height: 38px; right: 94px; top: 118px; animation-delay: -2s; }
.hero-bubble-c { width: 28px; height: 28px; left: 14px; top: 72px; animation-delay: -4s; }

.hero-shadow {
  position: absolute;
  z-index: 1;
  left: 50%;
  bottom: 6px;
  width: 58%;
  height: 22px;
  transform: translateX(-50%);
  border-radius: 999px;
  background: radial-gradient(circle, rgba(0,0,0,.28), transparent 72%);
}

.hero-copy { position: relative; z-index: 2; }

.identity-grid {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 16px;
}

.identity-grid div {
  padding: 10px 12px;
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,.09);
  background: rgba(255,255,255,.04);
}

.identity-grid small {
  display: block;
  margin-bottom: 4px;
  color: var(--muted-2);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .05em;
}

.identity-grid b {
  color: #fff;
  font-size: 12px;
  line-height: 1.45;
}

.message-text {
  display: block;
  text-wrap: pretty;
}

.single-action { grid-template-columns: 1fr; }

.chat-header h2 {
  text-shadow: 0 0 20px rgba(255,170,233,.26), 0 0 44px rgba(153,236,255,.10);
}

.quick-prompts button,
.btn,
.send-btn {
  isolation: isolate;
}

.quick-prompts button::before,
.btn::before,
.send-btn::before {
  content: "";
  position: absolute;
  inset: 1px;
  border-radius: inherit;
  background: linear-gradient(135deg, rgba(255,255,255,.14), transparent 58%);
  pointer-events: none;
  z-index: -1;
}

.msg-bubble {
  backdrop-filter: blur(14px) saturate(130%);
  -webkit-backdrop-filter: blur(14px) saturate(130%);
}

.message.assistant .msg-bubble {
  box-shadow:
    0 18px 44px rgba(0,0,0,.22),
    inset 0 1px rgba(255,255,255,.08),
    0 0 0 1px rgba(255,170,233,.045);
}

.message.user .msg-bubble {
  box-shadow:
    0 18px 40px rgba(0,0,0,.18),
    inset 0 1px rgba(255,255,255,.09),
    0 0 0 1px rgba(153,236,255,.045);
}

.profile-panel,
.chat-log {
  -webkit-overflow-scrolling: touch;
}

@media (min-width: 1081px) {
  .profile-panel {
    padding-bottom: 26px;
  }

  .chat-log {
    min-height: 0;
  }
}

@media (max-width: 1080px) {
  body {
    height: auto;
    min-height: 100dvh;
    overflow-x: hidden;
    overflow-y: auto;
  }

  .shell {
    height: auto;
    min-height: 100dvh;
  }

  .profile-panel {
    height: auto;
    max-height: none;
    min-height: 0;
    overflow: visible;
    scrollbar-gutter: auto;
  }

  .chat-panel {
    height: auto;
    max-height: none;
    min-height: 78vh;
  }

  .chat-panel::after { opacity: .06; width: 240px; height: 340px; }
}

@media (max-width: 680px) {
  .hero-stage { min-height: 208px; margin-bottom: 10px; }
  .character-visual { width: min(100%, 210px); max-height: 218px; }
  .hero-aura { inset: 12px 4px 0; }
  .identity-grid { grid-template-columns: 1fr; }
  .chat-panel::after { display: none; }
}
