:root {
  color-scheme: dark;
  --bg: #050606;
  --ink: #f6f7f8;
  --muted: #9aa4ac;
  --accent: #7cffc4;
  --accent-2: #6ad9ff;
  --line: rgba(255, 255, 255, 0.1);
  --glow: rgba(124, 255, 196, 0.25);
  --font-display: "Unbounded", sans-serif;
  --font-body: "Space Grotesk", sans-serif;
  --font-mono: "Space Mono", monospace;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-body);
  background:
    radial-gradient(circle at 18% 24%, rgba(124, 255, 196, 0.16), transparent 52%),
    radial-gradient(circle at 78% 18%, rgba(106, 217, 255, 0.14), transparent 48%),
    linear-gradient(180deg, #050606 0%, #030405 60%, #020203 100%);
  color: var(--ink);
  min-height: 100vh;
  position: relative;
  line-height: 1.6;
  overflow-x: hidden;
}

.noise {
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160' viewBox='0 0 160 160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)' opacity='0.06'/%3E%3C/svg%3E");
  mix-blend-mode: screen;
  pointer-events: none;
  z-index: 0;
}

main {
  position: relative;
  z-index: 1;
}

a {
  color: inherit;
  text-decoration: none;
}

img {
  max-width: 100%;
  display: block;
}

/* Layout */

.canvas {
  min-height: 100vh;
  display: grid;
  align-items: center;
  justify-items: center;
  padding: clamp(80px, 18vh, 180px) 8vw 12vh;
}

.canvas-chat {
  width: min(820px, 90vw);
  display: grid;
  gap: 24px;
}

/* Intro / empty state */

.intro {
  text-align: center;
  padding: 0 0 16px;
}

.intro-tagline {
  font-family: var(--font-display);
  font-size: clamp(1.1rem, 2.5vw, 1.4rem);
  font-weight: 400;
  color: rgba(246, 247, 248, 0.55);
  margin-bottom: 24px;
}

.intro-prompts {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}

.prompt-chip {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.03);
  color: rgba(246, 247, 248, 0.5);
  font-family: var(--font-body);
  font-size: 0.88rem;
  padding: 8px 18px;
  border-radius: 999px;
  cursor: pointer;
  transition: border-color 180ms ease, color 180ms ease, background 180ms ease;
}

.prompt-chip:hover {
  border-color: rgba(124, 255, 196, 0.3);
  color: rgba(246, 247, 248, 0.85);
  background: rgba(124, 255, 196, 0.04);
}

body.has-messages .intro {
  display: none;
}

/* Chat thread */

.chat-thread {
  display: none;
  gap: 20px;
  max-height: clamp(240px, 50vh, 600px);
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.08) transparent;
}

body.has-messages .chat-thread {
  display: grid;
}

/* Messages */

.message {
  padding: 4px 0 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.message:last-child {
  border-bottom: none;
}

.message-label {
  display: block;
  font-size: 0.7rem;
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 6px;
}

.message.oracle {
  color: rgba(246, 247, 248, 0.92);
}

.message.oracle .message-label {
  color: var(--accent);
  opacity: 0.7;
}

.message.user {
  color: rgba(246, 247, 248, 0.6);
}

.message.user .message-label {
  color: var(--muted);
  opacity: 0.5;
}

.message[data-loading] p {
  color: var(--muted);
  animation: pulse-text 1.8s ease-in-out infinite;
}

@keyframes pulse-text {
  0%, 100% { opacity: 0.35; }
  50% { opacity: 0.85; }
}

/* Follow-up suggestion */

.follow-up {
  appearance: none;
  display: inline-block;
  margin-top: 14px;
  border: 1px solid rgba(124, 255, 196, 0.15);
  background: rgba(124, 255, 196, 0.03);
  color: rgba(246, 247, 248, 0.5);
  font-family: var(--font-body);
  font-size: 0.85rem;
  padding: 8px 16px;
  border-radius: 999px;
  cursor: pointer;
  transition: border-color 180ms ease, color 180ms ease, background 180ms ease;
}

.follow-up:hover {
  border-color: rgba(124, 255, 196, 0.4);
  color: rgba(246, 247, 248, 0.85);
  background: rgba(124, 255, 196, 0.06);
}

/* Input */

.chat-input {
  display: grid;
}

.input-shell {
  position: relative;
  display: flex;
  align-items: center;
  padding-bottom: 6px;
}

.input-shell::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 1px;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.16), rgba(124, 255, 196, 0.4), rgba(255, 255, 255, 0.08));
  opacity: 0.6;
  transition: opacity 200ms ease;
}

.input-shell:has(input:focus)::after {
  opacity: 1;
}

.chat-input input {
  width: 100%;
  padding: 12px 4px 18px;
  border: none;
  background: transparent;
  color: var(--ink);
  font-size: 1.25rem;
  font-family: var(--font-body);
  letter-spacing: 0.01em;
}

.chat-input input:focus {
  outline: none;
}

.chat-input input:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.chat-input input::placeholder {
  color: rgba(246, 247, 248, 0.18);
}

/* Pulse cursor — visible when input is empty */

.pulse-cursor {
  position: absolute;
  right: 0;
  bottom: 10px;
  width: 6px;
  height: 18px;
  border-radius: 6px;
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
  box-shadow: 0 0 14px rgba(124, 255, 196, 0.7);
  animation: breathe 2.6s ease-in-out infinite;
}

.input-shell:has(input:not(:placeholder-shown)) .pulse-cursor {
  display: none;
}

/* Submit button — visible when input has text */

.chat-submit {
  appearance: none;
  border: none;
  background: none;
  color: var(--accent);
  cursor: pointer;
  padding: 4px;
  display: none;
  align-items: center;
  position: absolute;
  right: 0;
  bottom: 10px;
  opacity: 0.6;
  transition: opacity 160ms ease, transform 160ms ease;
}

.chat-submit:hover {
  opacity: 1;
  transform: translateX(2px);
}

.input-shell:has(input:not(:placeholder-shown)) .chat-submit {
  display: flex;
}

@keyframes breathe {
  0%, 100% {
    opacity: 0.2;
    transform: scaleY(0.8);
  }
  50% {
    opacity: 0.85;
    transform: scaleY(1.15);
  }
}

/* Health indicator */

.health {
  position: fixed;
  bottom: 20px;
  right: 24px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.75rem;
  font-family: var(--font-mono);
  color: var(--muted);
  opacity: 0.45;
  transition: opacity 300ms ease;
}

.health:hover {
  opacity: 0.8;
}

.health-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 6px rgba(124, 255, 196, 0.3);
}

.health-dot.offline {
  background: #ff6b6b;
  box-shadow: 0 0 6px rgba(255, 107, 107, 0.3);
}

/* Responsive */

@media (max-width: 640px) {
  .canvas {
    padding-left: 6vw;
    padding-right: 6vw;
  }

  .chat-input input {
    font-size: 1.05rem;
  }

  .intro-prompts {
    flex-direction: column;
    align-items: center;
  }

  .chat-thread {
    max-height: clamp(200px, 40vh, 400px);
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation: none !important;
  }
}
