:root {
  --bg: #05070b;
  --panel: rgba(5, 11, 19, .82);
  --panel-strong: rgba(4, 9, 16, .92);
  --border: rgba(41, 86, 126, .82);
  --border-soft: rgba(41, 86, 126, .42);
  --text: #f1f5f9;
  --muted: #c5d0df;
  --muted-2: #92a5ba;
  --accent: #ff6848;
  --accent-soft: rgba(255, 104, 72, .14);
  --good: #bdf3b6;
  --dark: #07101a;
  --shadow: 0 24px 70px rgba(0, 0, 0, .42);
  --radius: 26px;
  --maxw: 1680px;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
}

button,
textarea,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.scene {
  position: relative;
  height: 100dvh;
  min-height: 100dvh;
  overflow: hidden;
  isolation: isolate;
  background: var(--bg);
}

/* Layers */

.bg-layer,
.vfx-layer,
.scene-overlay {
  position: absolute;
  inset: 0;
}

.bg-layer {
  z-index: 0;
  background-image: url("./assets/bg/background.png");
  background-size: cover;
  background-position: center center;
  background-repeat: no-repeat;
  filter: brightness(.92) saturate(1.04);
  transform: scale(1.01);
}

.vfx-layer {
  z-index: 1;
  pointer-events: none;
}

.vfx-frame {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: .48;
  mix-blend-mode: screen;
  pointer-events: none;
}

.scene-overlay {
  z-index: 2;
  pointer-events: none;
  background:
    radial-gradient(circle at 16% 14%, rgba(122, 29, 31, .34), transparent 28%),
    radial-gradient(circle at 79% 20%, rgba(23, 76, 132, .22), transparent 25%),
    linear-gradient(90deg, rgba(3, 7, 12, .30) 0%, rgba(3, 7, 12, .12) 42%, rgba(3, 7, 12, .23) 100%),
    linear-gradient(180deg, rgba(3, 7, 12, .08) 0%, rgba(3, 7, 12, .20) 50%, rgba(3, 7, 12, .55) 100%);
}

/* Top navigation */

.topbar {
  position: absolute;
  z-index: 10;
  top: 18px;
  left: 0;
  right: 0;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 24px;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  padding: .66rem 1rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(6, 15, 26, .82);
  color: var(--text);
  text-decoration: none;
  font-weight: 850;
  line-height: 1;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .28);
}

.back-link:hover {
  border-color: rgba(122, 184, 232, .82);
}

/* Main layout */

.app-shell {
  position: relative;
  z-index: 4;
  max-width: var(--maxw);
  height: 100dvh;
  min-height: 0;
  margin: 0 auto;
  padding: 82px 24px 22px;
  display: grid;
  grid-template-columns: minmax(340px, 470px) minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  gap: 24px;
  align-items: stretch;
}

/* A/B panels: input and answer use the same slot */

.control-panel,
.response-panel {
  grid-column: 1 / 2;
  grid-row: 1 / 2;
  align-self: center;
  max-height: calc(100dvh - 112px);
  overflow: auto;
  padding: 18px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, rgba(8, 13, 22, .84), rgba(4, 9, 16, .92));
  box-shadow: var(--shadow);
  backdrop-filter: blur(13px);
  -webkit-backdrop-filter: blur(13px);
}

.control-panel.hidden,
.response-panel.hidden,
.hidden {
  display: none !important;
}

.control-panel::-webkit-scrollbar,
.response-panel::-webkit-scrollbar {
  width: 7px;
}

.control-panel::-webkit-scrollbar-thumb,
.response-panel::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(143, 214, 255, .28);
}

.eyebrow {
  margin-bottom: 12px;
  color: var(--accent);
  font-size: .88rem;
  font-weight: 950;
  letter-spacing: .15em;
  text-transform: uppercase;
}

h1 {
  margin: 0 0 .55rem;
  color: var(--text);
  font-size: clamp(2.45rem, 3.6vw, 4.6rem);
  line-height: .9;
  letter-spacing: -.055em;
}

.lead {
  max-width: 44ch;
  margin: 0 0 .92rem;
  color: var(--muted);
  font-size: .98rem;
  line-height: 1.45;
}

.label {
  display: block;
  margin: 0 0 .45rem;
  color: var(--text);
  font-weight: 850;
  font-size: .98rem;
}

textarea {
  display: block;
  width: 100%;
  min-height: 108px;
  resize: vertical;
  padding: 13px 15px;
  border-radius: 18px;
  border: 1px solid rgba(57, 105, 148, .86);
  outline: none;
  background: rgba(3, 9, 16, .92);
  color: var(--text);
  line-height: 1.5;
}

textarea:focus {
  border-color: rgba(122, 184, 232, .9);
  box-shadow: 0 0 0 3px rgba(122, 184, 232, .16);
}

/* Sliders */

.slider-block {
  margin-top: 13px;
}

.slider-row + .slider-row {
  margin-top: 10px;
}

.slider-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 5px;
}

.slider-topline label {
  color: var(--text);
  font-weight: 900;
  font-size: .95rem;
}

.slider-topline span {
  color: #ffc6b8;
  font-weight: 900;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.budget-line {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 10px;
  color: var(--muted-2);
  font-size: .92rem;
}

.budget-line strong {
  color: #ffd0c4;
}

/* Buttons */

.cta-button,
.feedback-btn {
  appearance: none;
  border: 0;
  border-radius: 999px;
  font-weight: 950;
  transition: transform .16s ease, filter .16s ease, opacity .16s ease;
}

.cta-button:hover,
.feedback-btn:hover {
  transform: translateY(-1px);
  filter: brightness(1.04);
}

.cta-button:disabled,
.feedback-btn:disabled {
  opacity: .55;
  cursor: not-allowed;
  transform: none;
}

.cta-button {
  margin-top: 14px;
  padding: .88rem 1.35rem;
  min-width: 210px;
  background: var(--accent);
  color: #10141b;
}

.feedback-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

.feedback-row.feedback-hidden {
  display: none !important;
}

.feedback-btn {
  padding: .82rem 1.15rem;
}

.feedback-btn.like {
  background: #ff9d76;
  color: #11151c;
}

.feedback-btn.retry {
  background: var(--good);
  color: #10151c;
}

.feedback-btn.new-question {
  border: 1px solid rgba(98, 135, 170, .55);
  background: rgba(255, 255, 255, .08);
  color: var(--text);
}

/* Avatar stage */

.avatar-stage {
  position: relative;
  grid-column: 2 / 3;
  grid-row: 1 / 2;
  min-height: 0;
  height: 100%;
  overflow: visible;
}

.avatar-wrap {
  position: absolute;
  z-index: 6;
  right: 7vw;
  bottom: 5vh;
  width: min(29vw, 430px);
  filter: drop-shadow(0 25px 42px rgba(0, 0, 0, .35));
  animation: floaty 5.5s ease-in-out infinite;
}

.avatar-img {
  display: block;
  width: 100%;
  height: auto;
}

.status-box {
  position: absolute;
  z-index: 7;
  left: 32px;
  bottom: 28px;
  max-width: 44ch;
  padding: 12px 14px;
  border: 1px solid rgba(57, 105, 148, .78);
  border-radius: 16px;
  background: rgba(3, 10, 17, .76);
  color: var(--text);
  font-size: .96rem;
  line-height: 1.42;
  box-shadow: 0 14px 40px rgba(0, 0, 0, .32);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

/* Response panel */

.response-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.response-head h2 {
  margin: 0;
  color: var(--text);
  font-size: clamp(1.55rem, 2.3vw, 2.45rem);
  line-height: 1.05;
  letter-spacing: -.035em;
}

.score-ring {
  flex: 0 0 72px;
  width: 72px;
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 104, 72, .72);
  border-radius: 50%;
  color: #ff9d81;
  font-size: 1.16rem;
  font-weight: 950;
  background: rgba(255, 104, 72, .04);
}

.response-tag {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  margin-top: 14px;
  padding: .42rem .75rem;
  border: 1px solid rgba(98, 135, 170, .65);
  border-radius: 999px;
  background: rgba(13, 24, 38, .72);
  color: #e1ebf5;
  font-size: .88rem;
  font-weight: 850;
}

.response-body {
  margin-top: 16px;
  color: #e4ebf4;
  font-size: .98rem;
  line-height: 1.58;
}

.response-body p {
  margin: 0 0 .82rem;
}

/* Desktop compact height */

@media (min-width: 1101px) and (max-height: 850px) {
  .app-shell {
    padding-top: 72px;
    padding-bottom: 14px;
  }

  .control-panel,
  .response-panel {
    max-height: calc(100dvh - 90px);
    padding: 15px;
  }

  h1 {
    font-size: clamp(2.25rem, 3.35vw, 4rem);
  }

  .lead {
    font-size: .94rem;
    line-height: 1.38;
  }

  textarea {
    min-height: 88px;
  }

  .avatar-wrap {
    width: min(26vw, 380px);
    bottom: 4vh;
  }

  .status-box {
    bottom: 18px;
  }

  .response-body {
    line-height: 1.52;
  }
}

/* Tablet/mobile */

@media (max-width: 1100px) {
  html,
  body {
    height: auto;
    overflow-x: hidden;
    overflow-y: auto;
  }

  .scene {
    height: auto;
    min-height: 100dvh;
    overflow: visible;
  }

  .topbar {
    position: relative;
    top: auto;
    padding: 16px 14px 0;
  }

  .app-shell {
    height: auto;
    min-height: calc(100dvh - 66px);
    padding: 14px 14px 22px;
    grid-template-columns: 1fr;
    grid-template-rows: 340px auto;
    gap: 14px;
  }

  .avatar-stage {
    grid-column: 1 / -1;
    grid-row: 1 / 2;
    height: 340px;
    min-height: 340px;
  }

  .control-panel,
  .response-panel {
    grid-column: 1 / -1;
    grid-row: 2 / 3;
    align-self: start;
    width: 100%;
    max-height: none;
    overflow: visible;
  }

  .avatar-wrap {
    width: min(46vw, 280px);
    right: 4vw;
    bottom: 0;
  }

  .status-box {
    left: 0;
    right: auto;
    bottom: 14px;
    max-width: min(54vw, 360px);
    font-size: .9rem;
  }
}

@media (max-width: 760px) {
  .topbar {
    padding: 14px 12px 0;
  }

  .back-link {
    padding: .55rem .8rem;
    font-size: .86rem;
  }

  .app-shell {
    grid-template-rows: 310px auto;
    gap: 12px;
    padding: 12px 12px 18px;
  }

  .avatar-stage {
    height: 310px;
    min-height: 310px;
  }

  .avatar-wrap {
    width: min(54vw, 230px);
    right: 2vw;
    bottom: 2px;
  }

  .status-box {
    left: 0;
    bottom: 10px;
    max-width: 58vw;
    padding: 10px 11px;
    font-size: .82rem;
    line-height: 1.35;
  }

  .control-panel,
  .response-panel {
    padding: 15px;
    border-radius: 22px;
  }

  h1 {
    font-size: clamp(2.3rem, 14vw, 3.5rem);
    line-height: .92;
  }

  .lead {
    font-size: .94rem;
    line-height: 1.4;
  }

  textarea {
    min-height: 92px;
  }

  .response-head {
    gap: 12px;
  }

  .response-head h2 {
    font-size: clamp(1.45rem, 9vw, 2.15rem);
  }

  .score-ring {
    width: 64px;
    height: 64px;
    flex-basis: 64px;
    font-size: 1rem;
  }

  .response-body {
    font-size: .94rem;
    line-height: 1.55;
  }

  .feedback-row {
    gap: 8px;
  }

  .feedback-btn {
    padding: .75rem .95rem;
    font-size: .9rem;
  }
}

@media (max-width: 420px) {
  .app-shell {
    grid-template-rows: 280px auto;
  }

  .avatar-stage {
    height: 280px;
    min-height: 280px;
  }

  .avatar-wrap {
    width: min(58vw, 210px);
    right: -2vw;
  }

  .status-box {
    max-width: 56vw;
    font-size: .78rem;
  }
}

@keyframes floaty {
  0% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-9px);
  }

  100% {
    transform: translateY(0);
  }
}
