:root {
  --bg: #06070a;
  --panel: #0f1219;
  --panel-soft: #121826;
  --text: #f4f7ff;
  --muted: #b8c3de;
  --particle-1: #2dd4bf;
  --particle-2: #38bdf8;
  --particle-glow: rgba(45, 212, 191, 0.45);
  --radius: 20px;
  --transition-ms: 380ms;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  color: var(--text);
  min-height: 100vh;
  background:
    radial-gradient(circle at 12% 10%, color-mix(in srgb, var(--particle-1) 20%, transparent), transparent 36%),
    radial-gradient(circle at 86% 90%, color-mix(in srgb, var(--particle-2) 22%, transparent), transparent 42%),
    linear-gradient(145deg, #05070b 0%, #090d16 52%, #06070b 100%),
    var(--bg);
  transition: background var(--transition-ms) ease, color var(--transition-ms) ease;
}

.bg-field {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  z-index: 0;
  pointer-events: none;
}

body.theme-pulse {
  animation: themePulse calc(var(--transition-ms) * 1.2) ease;
}

@keyframes themePulse {
  0% {
    filter: saturate(0.9) brightness(0.98);
  }
  50% {
    filter: saturate(1.12) brightness(1.02);
  }
  100% {
    filter: saturate(1) brightness(1);
  }
}

.layout {
  position: relative;
  z-index: 2;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.scene-wrap {
  width: min(920px, 100%);
  position: relative;
  isolation: isolate;
  padding-top: 0;
  transform: none;
}

.chat-shell,
.admin-shell {
  width: 100%;
  background: color-mix(in srgb, var(--panel) 88%, transparent);
  backdrop-filter: blur(12px);
  border-radius: var(--radius);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(181, 201, 255, 0.16);
  overflow: visible;
}

.chat-shell {
  position: relative;
  z-index: 3;
  margin-top: 130px;
  height: clamp(500px, 70vh, 760px);
  display: grid;
  grid-template-rows: 1fr auto;
  overflow: hidden;
}

.face-stage {
  position: absolute;
  inset: -112px 0 auto 0;
  height: 320px;
  pointer-events: none;
  z-index: 4;
}

.admin-header {
  border-bottom: 1px solid rgba(163, 184, 255, 0.16);
}

.reactor-panel {
  position: relative;
  height: 100%;
  overflow: visible;
  background: transparent;
}

.reactor-panel::before {
  content: '';
  position: absolute;
  left: 18%;
  right: 18%;
  top: -26px;
  height: 72px;
  border-radius: 999px;
  background: radial-gradient(circle, color-mix(in srgb, var(--particle-1) 20%, transparent), transparent 72%);
  pointer-events: none;
  filter: blur(10px);
}

.reactor-panel::after {
  content: '';
  position: absolute;
  left: 8%;
  right: 8%;
  bottom: -16px;
  height: 42px;
  border-radius: 999px;
  background: radial-gradient(circle, color-mix(in srgb, var(--particle-2) 20%, transparent), transparent 78%);
  pointer-events: none;
  filter: blur(10px);
}

.face-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  pointer-events: none;
}
.admin-header h1 {
  margin: 0;
  font-size: 1.1rem;
  letter-spacing: 0.2px;
}

.admin-header p {
  margin: 0.2rem 0 0;
  color: var(--muted);
}

.chat-log {
  min-height: 0;
  max-height: none;
  overflow-y: auto;
  padding: 1.15rem 1.2rem 1rem;
  display: grid;
  align-content: start;
  grid-auto-rows: max-content;
  gap: 0.6rem;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.01), rgba(255, 255, 255, 0));
}

.bubble {
  max-width: 84%;
  padding: 0.75rem 0.9rem;
  border-radius: 14px;
  line-height: 1.45;
  white-space: pre-wrap;
}

.bubble.user {
  justify-self: end;
  background: color-mix(in srgb, var(--particle-2) 24%, #ffffff12);
  border: 1px solid rgba(127, 214, 255, 0.25);
}

.bubble.assistant {
  justify-self: start;
  background: color-mix(in srgb, var(--particle-1) 18%, #ffffff10);
  border: 1px solid rgba(130, 250, 220, 0.2);
}

.chat-form,
.form-grid {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.6rem;
  padding: 0.9rem 1.2rem 1.2rem;
}

.chat-form {
  border-top: 1px solid rgba(163, 184, 255, 0.18);
  background:
    linear-gradient(180deg, rgba(148, 163, 184, 0.05), rgba(148, 163, 184, 0.02)),
    rgba(5, 9, 16, 0.32);
  border-bottom-left-radius: var(--radius);
  border-bottom-right-radius: var(--radius);
}

.chat-form input,
.form-grid input,
.form-grid textarea,
.form-grid select {
  border: 1px solid rgba(160, 182, 255, 0.3);
  border-radius: 12px;
  padding: 0.72rem 0.78rem;
  font-size: 0.97rem;
  color: var(--text);
  background: rgba(18, 24, 38, 0.82);
}

.chat-form input::placeholder,
.form-grid input::placeholder,
.form-grid textarea::placeholder {
  color: #8ea0c5;
}

.form-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.form-grid .full {
  grid-column: 1 / -1;
}

button,
.btn {
  border: 0;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--particle-1), var(--particle-2));
  color: #fff;
  font-weight: 600;
  padding: 0.72rem 1rem;
  cursor: pointer;
}

.toolbar {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  justify-content: space-between;
  padding: 0.8rem 1.2rem;
  border-bottom: 1px solid rgba(107, 114, 128, 0.2);
}

.pill {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  background: rgba(143, 178, 255, 0.12);
  color: var(--text);
  font-size: 0.84rem;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1rem;
}

.login-card {
  width: min(430px, 100%);
  background: color-mix(in srgb, var(--panel) 90%, transparent);
  border-radius: var(--radius);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.13);
  padding: 1.2rem;
}

.alert {
  margin: 0.8rem 0;
  background: rgba(239, 68, 68, 0.16);
  border: 1px solid rgba(239, 68, 68, 0.42);
  border-radius: 10px;
  padding: 0.6rem;
  color: #ffd8d8;
}

.success {
  background: rgba(22, 163, 74, 0.18);
  border: 1px solid rgba(34, 197, 94, 0.42);
  color: #d8ffe7;
}

@media (max-width: 760px) {
  .scene-wrap {
    padding-top: 0;
    transform: none;
  }

  .face-stage {
    height: 240px;
    inset: -74px 0 auto 0;
  }

  .chat-shell,
  .admin-shell {
    border-radius: 14px;
  }

  .chat-shell {
    margin-top: 96px;
    height: min(72vh, 640px);
  }


@media (max-width: 900px), (pointer: coarse) {
  .chat-shell,
  .admin-shell,
  .login-card {
    backdrop-filter: blur(6px);
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.34);
  }
}

@media (prefers-reduced-motion: reduce) {
  body.theme-pulse {
    animation: none;
  }
}
  .chat-form,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .bubble {
    max-width: 96%;
  }
}
