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

:root {
  --bg: #fafafa;
  --text: #1a1a1a;
  --text-subtle: #555555;
  --border: #cccccc;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.7;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  letter-spacing: -0.01em;
}

/* Screens */
.screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 4rem 2rem;
  text-align: center;
}

.screen.hidden {
  display: none;
}

.screen p {
  max-width: 400px;
}

.subtle {
  color: var(--text-subtle);
  font-size: 13px;
  margin-top: 2rem;
}

/* Fade animation for entering text */
.fade-text {
  animation: fade-pulse 2.5s ease-in-out infinite;
}

@keyframes fade-pulse {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}

/* The Room */
#room {
  justify-content: flex-end;
  padding: 0;
  min-height: 100vh;
}

#chat-container {
  width: 100%;
  max-width: 540px;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 4rem 2rem 4rem 2rem;
  margin: 0 auto;
}

#messages {
  flex: 1;
  overflow-y: auto;
  padding-bottom: 10rem;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

#messages::-webkit-scrollbar {
  display: none;
}

.message {
  margin-bottom: 2.5rem;
  word-wrap: break-word;
}

.message.user {
  color: var(--text);
  font-weight: 500;
  transition: text-shadow 0.4s ease-out;
}

/* Input Area */
#input-area {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 4rem);
  max-width: 508px;
  padding-top: 1rem;
  background: var(--bg);
}

#user-input {
  width: 100%;
  field-sizing: content;
  min-height: 1lh;
  max-height: 150px;
  overflow-y: auto;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  font-family: inherit;
  font-size: inherit;
  line-height: inherit;
  resize: none;
  outline: none;
  padding-bottom: 1rem;
  transition: border-color 0.2s ease;
}

#user-input:focus {
  border-color: var(--text);
}

#user-input::placeholder {
  color: var(--text-subtle);
}

#user-input:disabled {
  opacity: 0.4;
}


/* Persistent note */
#ephemeral-note {
  position: fixed;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  font-size: 11px;
  color: var(--text-subtle);
  letter-spacing: 0.02em;
  white-space: nowrap;
}

/* Loading progress bar - minimal line */
#progress-container {
  width: 200px;
  height: 1px;
  background: var(--text-subtle);
  margin-top: 2.5rem;
}

#progress-bar {
  height: 100%;
  width: 0%;
  background: var(--text);
  transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Responsive */
@media (max-width: 640px) {
  .screen {
    padding: 3rem 1.5rem;
  }

  #chat-container {
    padding: 3rem 1.5rem 1.5rem 1.5rem;
  }

  #input-area {
    width: calc(100% - 3rem);
    bottom: 1.5rem;
  }

  html, body {
    font-size: 14px;
  }
}

/* Selection */
::selection {
  background: var(--text);
  color: var(--bg);
}

/* Focus visible for accessibility */
#user-input:focus-visible {
  outline: none;
}

/* Smooth scrolling */
html {
  scroll-behavior: smooth;
}

/* Living presence - neutral breathing always, color emerges on response */
/* CSS variables set by JS: --vignette-x, --vignette-y, --mood-hue, --mood-saturation, --mood-lightness */

/* Constant neutral breathing - colorless, gentle presence */
#room::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(
    ellipse at 50% 50%,
    transparent 20%,
    hsla(0, 0%, 10%, 0.4) 100%
  );
  animation: idle-breathe 12s cubic-bezier(0.4, 0, 0.6, 1) infinite;
  z-index: 98;
}

/* Response layer - colored, directional, fades in/out smoothly */
#room::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(
    ellipse at var(--vignette-x, 50%) var(--vignette-y, 50%),
    transparent var(--vignette-spread, 35%),
    hsla(var(--mood-hue, 0), var(--mood-saturation, 35%), var(--mood-lightness, 50%), var(--vignette-darkness, 0.3)) 100%
  );
  opacity: 0;
  transition: opacity 2s cubic-bezier(0.4, 0, 0.2, 1),
              background 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 99;
}

/* Gentle idle breathing - natural rhythm */
@keyframes idle-breathe {
  0%, 100% { opacity: 0.15; }
  50% { opacity: 0.75; }
}

/* When responding - color layer fades in */
#room.responding::after {
  opacity: 1;
  transition: opacity 0.8s cubic-bezier(0.0, 0, 0.2, 1),
              background 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Message acknowledgment - shadow dissolve with mood color */
/* CSS variables set by JS: --shadow-blur, --shadow-opacity, --shadow-y, --mood-hue, --mood-saturation, --mood-lightness */

.message.user.acknowledged {
  text-shadow: 0 var(--shadow-y, 4px) var(--shadow-blur, 20px) hsla(var(--mood-hue, 0), var(--mood-saturation, 10%), var(--mood-lightness, 30%), var(--shadow-opacity, 0.3));
}

/* Landing page */
#landing-content {
  max-width: 320px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
}

.landing-intro {
  font-size: 1.1rem;
  font-weight: 500;
  color: var(--text);
  letter-spacing: 0.03em;
  margin-bottom: 3rem;
  animation: fade-up 0.8s ease-out both;
  animation-delay: 0.1s;
}

.landing-details {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 2.5rem;
}

.landing-details p {
  font-size: 0.9rem;
  color: var(--text-subtle);
  margin: 0;
  letter-spacing: 0.01em;
}

.landing-ephemeral {
  font-size: 0.85rem;
  color: var(--text-subtle);
  opacity: 0.7;
  margin-bottom: 4rem;
  font-style: italic;
}

.landing-question {
  font-size: 1.8rem;
  font-weight: 300;
  color: var(--text);
  letter-spacing: -0.02em;
  margin-bottom: 2rem;
}

#enter-btn {
  margin-top: 0.5rem;
  background: transparent;
  border: none;
  color: var(--text-subtle);
  font-family: inherit;
  font-size: 0.85rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  padding: 0.75rem 2rem;
  cursor: pointer;
  transition: all 0.3s ease;
  position: relative;
}

#enter-btn::after {
  content: '';
  position: absolute;
  bottom: 0.5rem;
  left: 50%;
  transform: translateX(-50%);
  width: 2rem;
  height: 1px;
  background: var(--border);
  transition: all 0.3s ease;
}

#enter-btn:hover {
  color: var(--text);
}

#enter-btn:hover::after {
  width: 100%;
  background: var(--text);
}

/* About button */
#about-btn {
  position: fixed;
  top: 1.5rem;
  right: 1.5rem;
  background: transparent;
  border: none;
  color: var(--text-subtle);
  font-size: 18px;
  cursor: pointer;
  transition: color 0.2s ease;
  z-index: 10;
  padding: 0;
}

#about-btn.hidden {
  display: none;
}

#about-btn:hover {
  color: var(--text);
}

/* About overlay */
#about-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 2rem;
  z-index: 100;
  animation: fade-in 0.3s ease;
}

#about-overlay.hidden {
  display: none;
}

#about-content p {
  margin-bottom: 1.5rem;
  color: var(--text-subtle);
}

#about-content p:first-child {
  color: var(--text);
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Landing page entrance animations */
@keyframes fade-up {
  from { 
    opacity: 0;
    transform: translateY(12px);
  }
  to { 
    opacity: 1;
    transform: translateY(0);
  }
}

.landing-details {
  animation: fade-up 0.8s ease-out both;
  animation-delay: 0.3s;
}

.landing-ephemeral {
  animation: fade-up 0.8s ease-out both;
  animation-delay: 0.5s;
}

.landing-question {
  animation: fade-up 0.8s ease-out both;
  animation-delay: 0.7s;
}

#enter-btn {
  animation: fade-up 0.8s ease-out both;
  animation-delay: 0.9s;
}
