:root {
  --bg: #0a0a0a;
  --bg-elevated: #141414;
  --text: #e8e0d8;
  --text-muted: #888078;
  --accent: #d4a574;
  --accent-dim: #b8956a;
  --user-bg: #1a1612;
  --border: #2a2520;
  --font-serif: 'Lora', Georgia, serif;
  --font-sans: 'Inter', -apple-system, sans-serif;
}

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

html, body {
  height: 100%;
  height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-serif);
  -webkit-font-smoothing: antialiased;
}

/* Views */
.view {
  display: none;
  height: 100%;
  height: 100dvh;
}

.view.active {
  display: flex;
  animation: viewFadeIn 0.4s ease;
}

@keyframes viewFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ===== LANDING PAGE ===== */
#landing {
  flex-direction: column;
}

.landing-scroll {
  flex: 1;
  overflow-y: auto;
  scroll-behavior: smooth;
}

/* Nav */
.landing-nav {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem 2rem;
  z-index: 10;
}

.nav-logo {
  font-family: var(--font-serif);
  font-size: 0.9375rem;
  color: var(--text-muted);
  letter-spacing: 0.03em;
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.nav-user {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.nav-user-name {
  font-family: var(--font-sans);
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.btn-text {
  font-family: var(--font-sans);
  font-size: 0.8125rem;
  color: var(--accent);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.25rem 0;
  transition: opacity 0.2s;
}

.btn-text:hover {
  opacity: 0.7;
}

/* Session save prompt (ended view) */
.ended-save {
  margin-bottom: 2rem;
}

.ended-save-text {
  font-family: var(--font-sans);
  font-size: 0.9375rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
  line-height: 1.5;
}

.ended-save-confirmed {
  color: var(--accent);
}

/* Hero */
.landing-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-height: 100dvh;
  padding: 4rem 2rem;
}

.landing-title {
  font-family: var(--font-serif);
  font-size: 3.5rem;
  font-weight: 400;
  letter-spacing: 0.04em;
  color: var(--text);
  margin-bottom: 1.5rem;
}

.landing-tagline {
  font-family: var(--font-serif);
  font-size: 1.3rem;
  font-style: italic;
  color: var(--text-muted);
  line-height: 1.7;
  margin-bottom: 1rem;
}

.landing-desc {
  font-family: var(--font-sans);
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-bottom: 2.5rem;
}

.btn-begin {
  font-family: var(--font-sans);
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--bg);
  background: var(--accent);
  border: none;
  padding: 0.875rem 2rem;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-begin:hover {
  background: var(--accent-dim);
}

/* Landing sections */
.landing-section {
  max-width: 580px;
  margin: 0 auto;
  padding: 5rem 2rem;
}

.section-heading {
  font-family: var(--font-serif);
  font-size: 1.75rem;
  font-weight: 400;
  margin-bottom: 1.75rem;
  color: var(--text);
}

.section-text {
  font-family: var(--font-serif);
  font-size: 1.0625rem;
  line-height: 1.8;
  color: var(--text);
  margin-bottom: 1.25rem;
}

.section-text-muted {
  color: var(--accent);
  font-style: italic;
}

/* Steps */
.steps {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.step {
  display: flex;
  gap: 1.25rem;
  align-items: flex-start;
}

.step-number {
  font-family: var(--font-sans);
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--accent);
  background: rgba(212, 165, 116, 0.1);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
}

.step-title {
  font-family: var(--font-serif);
  font-size: 1.0625rem;
  font-weight: 500;
  margin-bottom: 0.375rem;
}

.step-desc {
  font-family: var(--font-serif);
  font-size: 0.9375rem;
  line-height: 1.7;
  color: var(--text-muted);
}

/* Differentiation grid */
.diff-grid {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.diff-item {
  padding-left: 1.25rem;
  border-left: 2px solid var(--border);
}

.diff-label {
  font-family: var(--font-sans);
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 0.5rem;
}

.diff-text {
  font-family: var(--font-serif);
  font-size: 1rem;
  line-height: 1.7;
  color: var(--text-muted);
}

/* Final CTA */
.landing-cta {
  text-align: center;
  padding: 5rem 2rem;
}

.cta-text {
  font-family: var(--font-serif);
  font-size: 1.0625rem;
  line-height: 1.7;
  color: var(--text-muted);
  margin-bottom: 2rem;
  max-width: 440px;
  margin-left: auto;
  margin-right: auto;
}

/* Footer */
.landing-footer {
  text-align: center;
  padding: 2rem;
  border-top: 1px solid var(--border);
}

.landing-footer p {
  font-family: var(--font-sans);
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ===== SESSION ===== */
#session {
  flex-direction: column;
}

.session-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.session-title {
  font-family: var(--font-serif);
  font-size: 1rem;
  font-weight: 500;
  color: var(--text-muted);
  letter-spacing: 0.03em;
}

.btn-end {
  font-family: var(--font-sans);
  font-size: 0.8125rem;
  color: var(--text-muted);
  background: none;
  border: 1px solid var(--border);
  padding: 0.375rem 0.875rem;
  border-radius: 4px;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
}

.btn-end:hover {
  color: var(--text);
  border-color: var(--text-muted);
}

/* Messages */
.session-messages {
  flex: 1;
  overflow-y: auto;
  padding: 2rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.message {
  max-width: 640px;
  width: 100%;
  margin: 0 auto;
  line-height: 1.7;
  font-size: 1.0625rem;
  white-space: pre-wrap;
  animation: fadeIn 0.3s ease;
}

.message.assistant {
  color: var(--text);
}

.message.user {
  color: var(--accent);
  padding-left: 1.5rem;
  border-left: 2px solid var(--border);
}

.message.system {
  color: var(--text-muted);
  font-family: var(--font-sans);
  font-size: 0.875rem;
  text-align: center;
  max-width: 400px;
}

.message.thinking {
  color: var(--text-muted);
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes pulse {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 0.7; }
}

/* Input area */
.session-input-area {
  padding: 1rem 1.5rem 1.5rem;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.input-container {
  max-width: 640px;
  margin: 0 auto;
  display: flex;
  align-items: flex-end;
  gap: 0.75rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem 1rem;
}

textarea {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text);
  font-family: var(--font-serif);
  font-size: 1rem;
  line-height: 1.6;
  resize: none;
  max-height: 150px;
  overflow-y: auto;
}

textarea::placeholder {
  color: var(--text-muted);
  font-style: italic;
}

.btn-send {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  padding: 4px;
  flex-shrink: 0;
  opacity: 0.7;
  transition: opacity 0.2s;
}

.btn-send:hover {
  opacity: 1;
}

.btn-send:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

/* ===== ENDED VIEW ===== */
#ended {
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 2rem;
}

.ended-content {
  max-width: 480px;
}

.ended-title {
  font-family: var(--font-serif);
  font-size: 1.75rem;
  font-weight: 400;
  margin-bottom: 1rem;
}

.ended-text {
  color: var(--text-muted);
  font-size: 1.0625rem;
  margin-bottom: 2rem;
  line-height: 1.6;
}

.ended-actions {
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
}

.btn-secondary {
  font-family: var(--font-sans);
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--text-muted);
  background: none;
  border: 1px solid var(--border);
  padding: 0.875rem 2rem;
  border-radius: 6px;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
}

.btn-secondary:hover {
  color: var(--text);
  border-color: var(--text-muted);
}

/* ===== SUBSCRIBE VIEW ===== */
#subscribe {
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 2rem;
}

.subscribe-price {
  font-family: var(--font-sans);
  font-size: 2rem;
  font-weight: 500;
  color: var(--accent);
  margin-bottom: 0.5rem;
}

.subscribe-detail {
  font-family: var(--font-sans);
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-bottom: 2rem;
}

/* ===== HISTORY VIEW ===== */
#history {
  flex-direction: column;
}

.history-container {
  flex: 1;
  max-width: 640px;
  width: 100%;
  margin: 0 auto;
  padding: 2rem 1.5rem;
  overflow-y: auto;
}

.history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.history-title {
  font-family: var(--font-serif);
  font-size: 1.5rem;
  font-weight: 400;
}

.history-actions {
  display: flex;
  gap: 0.75rem;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.history-item {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  text-align: left;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem 1.25rem;
  cursor: pointer;
  transition: border-color 0.2s;
  width: 100%;
}

.history-item:hover {
  border-color: var(--accent-dim);
}

.history-date {
  font-family: var(--font-sans);
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.history-preview {
  font-family: var(--font-serif);
  font-size: 0.9375rem;
  color: var(--text);
  line-height: 1.5;
}

.history-meta {
  font-family: var(--font-sans);
  font-size: 0.75rem;
  color: var(--text-muted);
}

.history-loading,
.history-empty {
  font-family: var(--font-serif);
  font-size: 1rem;
  color: var(--text-muted);
  text-align: center;
  padding: 3rem 0;
}

/* ===== REPLAY VIEW ===== */
#replay {
  flex-direction: column;
}

/* Scrollbar */
.session-messages::-webkit-scrollbar,
.landing-scroll::-webkit-scrollbar {
  width: 4px;
}

.session-messages::-webkit-scrollbar-track,
.landing-scroll::-webkit-scrollbar-track {
  background: transparent;
}

.session-messages::-webkit-scrollbar-thumb,
.landing-scroll::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}

/* ===== TOAST ===== */
.toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(1rem);
  font-family: var(--font-sans);
  font-size: 0.875rem;
  color: var(--text);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  padding: 0.75rem 1.5rem;
  border-radius: 6px;
  opacity: 0;
  transition: opacity 0.3s, transform 0.3s;
  z-index: 100;
}

.toast-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ===== RESPONSIVE ===== */
@media (max-width: 600px) {
  .landing-title {
    font-size: 2.5rem;
  }

  .landing-tagline {
    font-size: 1.0625rem;
  }

  .landing-section {
    padding: 3.5rem 1.5rem;
  }

  .section-heading {
    font-size: 1.5rem;
  }

  .session-messages {
    padding: 1.5rem 1rem;
  }

  .message {
    font-size: 1rem;
  }

  .session-input-area {
    padding: 0.75rem 1rem calc(0.75rem + env(safe-area-inset-bottom, 0px));
  }

  .session-header {
    padding-top: calc(0.75rem + env(safe-area-inset-top, 0px));
  }

  #ended, #subscribe {
    padding: calc(2rem + env(safe-area-inset-top, 0px)) 1.5rem calc(2rem + env(safe-area-inset-bottom, 0px));
  }
}
