:root {
  --color-bg: #050705;
  --color-bg-soft: #0a0f08;
  --color-panel: rgba(7, 12, 6, 0.72);
  --color-panel-strong: rgba(13, 22, 10, 0.92);
  --color-text: #b4ca9a;
  --color-text-bright: #d6edb8;
  --color-glow: #9db77b;
  --color-muted: rgba(180, 202, 154, 0.48);
  --color-border: rgba(180, 202, 154, 0.24);
  --color-border-strong: rgba(180, 202, 154, 0.42);
  --font-terminal: "VT323", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--color-bg);
}

body {
  font-family: var(--font-terminal);
  color: var(--color-text);
}

button,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.stage {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: clamp(1rem, 4vw, 4rem);
  background:
    radial-gradient(circle at 50% 45%, rgba(157, 183, 123, 0.08), transparent 34rem),
    radial-gradient(circle at 18% 20%, rgba(180, 202, 154, 0.05), transparent 26rem),
    radial-gradient(circle at 82% 72%, rgba(157, 183, 123, 0.045), transparent 24rem),
    linear-gradient(180deg, var(--color-bg-soft), var(--color-bg));
}

.stage::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    repeating-linear-gradient(
      180deg,
      rgba(180, 202, 154, 0.025) 0,
      rgba(180, 202, 154, 0.025) 1px,
      transparent 1px,
      transparent 4px
    );
  opacity: 0.42;
}

.stage::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at center, transparent 38%, rgba(0, 0, 0, 0.38) 100%);
}

.chat-shell {
  position: relative;
  z-index: 2;
  width: min(980px, 94vw);
  max-height: min(820px, 92vh);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  gap: 1rem;
  padding: clamp(1rem, 2.6vw, 2rem);
  border: 1px solid var(--color-border);
  border-radius: 28px;
  background:
    linear-gradient(180deg, rgba(12, 19, 10, 0.78), rgba(5, 7, 5, 0.72)),
    var(--color-panel);
  box-shadow:
    0 0 28px rgba(157, 183, 123, 0.08),
    inset 0 0 46px rgba(157, 183, 123, 0.045);
  backdrop-filter: blur(8px);
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-bottom: 0.85rem;
  border-bottom: 1px solid rgba(180, 202, 154, 0.16);
}

.eyebrow {
  margin: 0 0 0.1rem;
  font-size: clamp(1.05rem, 2vw, 1.35rem);
  letter-spacing: 0.18em;
  color: var(--color-muted);
}

h1 {
  margin: 0;
  font-size: clamp(2.4rem, 6vw, 5.4rem);
  line-height: 0.8;
  letter-spacing: 0.12em;
  color: var(--color-text-bright);
  text-shadow:
    0 0 8px rgba(180, 202, 154, 0.52),
    0 0 28px rgba(157, 183, 123, 0.24);
}

.status-light {
  width: 1.1rem;
  height: 1.1rem;
  flex: 0 0 auto;
  border-radius: 999px;
  background: var(--color-text-bright);
  box-shadow:
    0 0 8px rgba(214, 237, 184, 0.75),
    0 0 22px rgba(157, 183, 123, 0.55);
  animation: statusPulse 1.8s ease-in-out infinite;
}

.bubble-stack {
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 0.95rem;
  overflow-y: auto;
  padding: 0.25rem 0.15rem 0.5rem;
  scrollbar-color: rgba(180, 202, 154, 0.28) transparent;
}

.bubble-row {
  display: flex;
  align-items: flex-end;
  gap: 0.7rem;
  opacity: 1;
  transform: translateY(0);
  transition:
    opacity 160ms ease,
    transform 160ms ease;
}

.bubble-row.hidden {
  display: none;
}

.assistant-row {
  justify-content: flex-start;
}

.user-row {
  justify-content: flex-end;
}

.avatar {
  width: clamp(2.2rem, 4.8vw, 3.4rem);
  height: clamp(2.2rem, 4.8vw, 3.4rem);
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  background: rgba(180, 202, 154, 0.05);
  color: var(--color-text-bright);
  font-size: clamp(1.5rem, 3.6vw, 2.5rem);
  line-height: 1;
  text-shadow:
    0 0 8px rgba(180, 202, 154, 0.58),
    0 0 20px rgba(157, 183, 123, 0.24);
}

.bubble {
  max-width: min(760px, 82%);
  padding: clamp(0.85rem, 2.1vw, 1.2rem) clamp(1rem, 2.6vw, 1.5rem);
  border: 1px solid var(--color-border);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: clamp(1.35rem, 3vw, 2.05rem);
  line-height: 1.08;
  letter-spacing: 0.028em;
  text-shadow:
    0 0 8px rgba(180, 202, 154, 0.28),
    0 0 24px rgba(157, 183, 123, 0.12);
}

.assistant-bubble {
  border-radius: 22px 22px 22px 6px;
  background:
    linear-gradient(180deg, rgba(180, 202, 154, 0.08), rgba(180, 202, 154, 0.035)),
    rgba(8, 13, 7, 0.9);
  color: var(--color-text);
}

.user-bubble {
  border-radius: 22px 22px 6px 22px;
  background:
    linear-gradient(180deg, rgba(214, 237, 184, 0.14), rgba(157, 183, 123, 0.065)),
    rgba(11, 18, 9, 0.94);
  color: var(--color-text-bright);
  border-color: var(--color-border-strong);
}

.thinking {
  color: var(--color-muted);
  animation: waitingPulse 1.2s ease-in-out infinite;
}

.composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.75rem;
  padding-top: 0.7rem;
  border-top: 1px solid rgba(180, 202, 154, 0.16);
}

#question-input {
  width: 100%;
  min-height: 3.4rem;
  max-height: 9.5rem;
  resize: none;
  overflow-y: auto;
  padding: 0.72rem 1rem;
  border: 1px solid var(--color-border);
  border-radius: 16px;
  outline: none;
  background: rgba(4, 7, 4, 0.72);
  color: var(--color-text-bright);
  caret-color: var(--color-text-bright);
  font-size: clamp(1.35rem, 2.8vw, 1.8rem);
  line-height: 1.08;
  box-shadow: inset 0 0 20px rgba(157, 183, 123, 0.04);
}

#question-input::placeholder {
  color: rgba(180, 202, 154, 0.34);
}

#question-input:focus {
  border-color: var(--color-border-strong);
  box-shadow:
    0 0 16px rgba(157, 183, 123, 0.09),
    inset 0 0 20px rgba(157, 183, 123, 0.06);
}

.send-button,
.utility-button {
  min-height: 3.4rem;
  border: 1px solid var(--color-border);
  border-radius: 16px;
  background: rgba(180, 202, 154, 0.075);
  color: var(--color-text-bright);
  font-size: clamp(1.2rem, 2.5vw, 1.55rem);
  letter-spacing: 0.08em;
  text-shadow: 0 0 8px rgba(180, 202, 154, 0.36);
  transition:
    border-color 140ms ease,
    background 140ms ease,
    transform 140ms ease,
    opacity 140ms ease;
}

.send-button {
  min-width: 5.4rem;
  padding: 0.4rem 1rem;
}

.send-button:hover,
.utility-button:hover {
  border-color: var(--color-border-strong);
  background: rgba(180, 202, 154, 0.12);
}

.send-button:active,
.utility-button:active {
  transform: translateY(1px);
}

.send-button:disabled,
.utility-button:disabled {
  cursor: not-allowed;
  opacity: 0.46;
}

.tool-buttons {
  grid-column: 1 / -1;
  display: flex;
  justify-content: flex-end;
  gap: 0.55rem;
}

.utility-button {
  min-height: 2.55rem;
  padding: 0.25rem 0.95rem;
  border-radius: 999px;
  font-size: clamp(1.05rem, 2.3vw, 1.35rem);
}

.reset-button {
  width: 2.8rem;
  padding: 0;
  font-size: 1.55rem;
  line-height: 1;
}

.hidden {
  display: none !important;
}

.hint {
  margin: -0.3rem 0 0;
  text-align: right;
  color: rgba(180, 202, 154, 0.34);
  font-size: clamp(1rem, 2vw, 1.25rem);
  letter-spacing: 0.04em;
}

.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;
}

@keyframes statusPulse {
  0%,
  100% {
    opacity: 0.48;
    transform: scale(0.86);
  }

  50% {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes waitingPulse {
  0%,
  100% {
    opacity: 0.42;
  }

  50% {
    opacity: 0.82;
  }
}

@media (max-width: 700px) {
  html,
  body {
    overflow: auto;
  }

  .stage {
    position: relative;
    min-height: 100svh;
    padding: 0.8rem;
  }

  .chat-shell {
    width: 100%;
    min-height: calc(100svh - 1.6rem);
    max-height: none;
    border-radius: 22px;
  }

  .bubble {
    max-width: 88%;
  }

  .composer {
    grid-template-columns: minmax(0, 1fr);
  }

  .send-button {
    width: 100%;
  }

  .tool-buttons,
  .hint {
    justify-content: center;
    text-align: center;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
