:root {
  --bg: #F4EFE6;
  --bg-deep: #ECE5D6;
  --ink: #14110F;
  --ink-soft: #4A453E;
  --ink-mute: rgba(20, 17, 16, 0.55);
  --paper: #FBF7EE;
  --accent: #FF4D26;
  --accent-soft: #FFE8E0;
  --line: rgba(20, 17, 16, 0.08);
  --line-strong: rgba(20, 17, 16, 0.14);
  --shadow-coral: 0 8px 24px -8px rgba(255, 77, 38, 0.5);
  --shadow-ink: 0 14px 40px -16px rgba(20, 17, 16, 0.4);
}

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

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Inter', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior: none;
}

body {
  background-image:
    radial-gradient(circle at 15% 8%, rgba(255, 77, 38, 0.05), transparent 42%),
    radial-gradient(circle at 88% 80%, rgba(20, 17, 16, 0.04), transparent 38%);
}

button { font-family: inherit; cursor: pointer; }
button:disabled { cursor: not-allowed; }
input { font-family: inherit; }

.phase-badge {
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 100;
  background: rgba(20, 17, 16, 0.85);
  color: var(--paper);
  font-family: 'JetBrains Mono', monospace;
  font-size: 9.5px;
  letter-spacing: 0.12em;
  padding: 6px 10px;
  border-radius: 6px;
  pointer-events: none;
}

.app {
  width: 100%;
  max-width: 480px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  background: var(--bg);
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.view {
  display: none;
  flex: 1;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}

.app[data-view="hero"]   .view-hero,
.app[data-view="chat"]   .view-chat,
.app[data-view="end"]    .view-end,
.app[data-view="thanks"] .view-thanks {
  display: flex;
  animation: fadeIn 0.4s ease;
}

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

/* ───── Site header (shared) ───── */
.site-header {
  padding: 20px 24px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
.logo {
  font-family: 'Fraunces', serif;
  font-weight: 700;
  font-size: 18px;
  letter-spacing: -0.02em;
}
.logo .dot { color: var(--accent); }

/* ───── HERO ───── */
.hero {
  padding: 28px 24px 32px;
  flex: 1;
  display: flex;
  flex-direction: column;
}
.hero-eyebrow {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.pulse-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(255, 77, 38, 0.55); }
  70%  { box-shadow: 0 0 0 10px rgba(255, 77, 38, 0); }
  100% { box-shadow: 0 0 0 0 rgba(255, 77, 38, 0); }
}
.hero h1 {
  font-family: 'Fraunces', serif;
  font-weight: 500;
  font-size: 32px;
  line-height: 1.04;
  letter-spacing: -0.025em;
  margin-bottom: 20px;
  font-variation-settings: "SOFT" 30;
}
.hero h1 em {
  font-style: italic;
  font-weight: 700;
  color: var(--accent);
  font-variation-settings: "SOFT" 100, "WONK" 1;
}
.hero-sub {
  font-size: 14.5px;
  line-height: 1.55;
  color: var(--ink-soft);
  margin-bottom: 28px;
}
.brains {
  font-style: italic;
  font-family: 'Fraunces', serif;
  color: var(--ink);
  font-weight: 500;
}

/* Recorder card + the robot leaning in beside it */
.hero-recorder-wrap {
  position: relative;
  margin-top: 8px;
}
.hero-robot {
  position: absolute;
  top: -62px;
  right: -10px;
  width: 118px;
  height: auto;
  z-index: 0;
  pointer-events: none;
  transform-origin: bottom left;
  transform: rotate(10deg);
  filter: drop-shadow(0 10px 18px rgba(20, 17, 16, 0.22));
  animation: hero-wave 4.5s ease-in-out infinite;
}
@keyframes hero-wave {
  0%, 100% { transform: rotate(10deg) translateY(0); }
  50%      { transform: rotate(13deg) translateY(-5px); }
}

.recorder {
  background: var(--ink);
  color: var(--paper);
  border-radius: 24px;
  padding: 26px 22px;
  position: relative;
  z-index: 1;
  overflow: hidden;
  box-shadow: var(--shadow-ink);
}
.recorder::before {
  content: '';
  position: absolute;
  top: -50px; right: -50px;
  width: 180px; height: 180px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 77, 38, 0.28), transparent 62%);
  pointer-events: none;
}
.recorder-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10.5px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(251, 247, 238, 0.55);
  margin-bottom: 16px;
  position: relative;
}
.record-btn {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  background: var(--accent);
  color: var(--paper);
  border: none;
  border-radius: 16px;
  padding: 18px 20px;
  font-weight: 600;
  font-size: 16px;
  position: relative;
  box-shadow: var(--shadow-coral);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.record-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 28px -8px rgba(255, 77, 38, 0.55);
}
.record-btn:active { transform: translateY(0); }
.mic-icon {
  width: 34px; height: 34px;
  background: rgba(251, 247, 238, 0.18);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.mic-icon svg { width: 16px; height: 16px; }
.record-btn .arrow {
  margin-left: auto;
  font-family: 'JetBrains Mono', monospace;
  font-size: 18px;
}
.record-tagline {
  margin-top: 16px;
  font-size: 12px;
  color: rgba(251, 247, 238, 0.65);
  line-height: 1.5;
  position: relative;
}
.record-tagline strong { color: var(--paper); font-weight: 600; }

/* ───── CHAT ───── */
.view-chat {
  background: var(--ink);
  color: var(--paper);
  position: relative;
}
.view-chat::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: radial-gradient(circle at 50% 0%, rgba(255, 77, 38, 0.10), transparent 50%);
  pointer-events: none;
}
.chat-header {
  padding: 18px 22px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(251, 247, 238, 0.08);
  position: relative;
  z-index: 2;
}
.chat-status {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10.5px;
  letter-spacing: 0.16em;
  color: rgba(251, 247, 238, 0.7);
}
.rec-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--accent);
  animation: blink 1.4s infinite;
}
@keyframes blink {
  0%, 49% { opacity: 1; }
  50%, 100% { opacity: 0.35; }
}
.close-x {
  background: transparent;
  border: none;
  color: rgba(251, 247, 238, 0.5);
  font-size: 18px;
  padding: 4px 8px;
}
.close-x:hover { color: var(--paper); }

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px 22px 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: relative;
  z-index: 2;
  -webkit-overflow-scrolling: touch;
}
.msg {
  max-width: 84%;
  animation: msgIn 0.35s ease;
}
@keyframes msgIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.msg.robot { align-self: flex-start; }
.msg.robot .msg-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 9.5px;
  letter-spacing: 0.18em;
  color: rgba(251, 247, 238, 0.45);
  margin-bottom: 6px;
  display: block;
}
.msg.robot .msg-body {
  font-family: 'Fraunces', serif;
  font-weight: 400;
  font-size: 19px;
  line-height: 1.32;
  letter-spacing: -0.01em;
  color: var(--paper);
  font-variation-settings: "SOFT" 30;
}
.msg.user {
  align-self: flex-end;
  background: var(--accent);
  color: var(--paper);
  border-radius: 18px 18px 6px 18px;
  padding: 12px 16px;
  font-size: 14px;
  line-height: 1.45;
  box-shadow: var(--shadow-coral);
}
.msg.user .msg-meta {
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  letter-spacing: 0.14em;
  color: rgba(251, 247, 238, 0.65);
  margin-top: 6px;
  display: flex;
  gap: 8px;
}
.typing {
  align-self: flex-start;
  display: flex;
  gap: 6px;
  padding: 8px 0;
}
.typing span {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: rgba(251, 247, 238, 0.5);
  animation: bounce 1.2s infinite;
}
.typing span:nth-child(2) { animation-delay: 0.15s; }
.typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.5; }
  40% { transform: translateY(-4px); opacity: 1; }
}

.chat-footer {
  padding: 16px 22px 24px;
  border-top: 1px solid rgba(251, 247, 238, 0.08);
  background: rgba(20, 17, 16, 0.5);
  backdrop-filter: blur(8px);
  position: relative;
  z-index: 2;
  flex-shrink: 0;
}
.waveform-container {
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
  opacity: 0;
  transition: opacity 0.25s ease;
}
.app[data-recording="true"] .waveform-container { opacity: 1; }
.waveform {
  display: flex;
  align-items: center;
  gap: 3px;
  height: 100%;
}
.wave-bar {
  width: 3px;
  background: var(--accent);
  border-radius: 2px;
  animation: wave 1s ease-in-out infinite;
}
@keyframes wave {
  0%, 100% { transform: scaleY(0.25); }
  50% { transform: scaleY(1); }
}
.mic-btn {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  background: var(--accent);
  color: var(--paper);
  border: none;
  border-radius: 16px;
  padding: 16px 20px;
  font-weight: 600;
  font-size: 15px;
  box-shadow: var(--shadow-coral);
  transition: transform 0.15s ease, opacity 0.15s ease, background 0.2s ease;
  justify-content: center;
}
.mic-btn:disabled { opacity: 0.35; box-shadow: none; }
.mic-btn-inner {
  width: 28px; height: 28px;
  background: rgba(251, 247, 238, 0.18);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  position: relative;
}
.mic-svg { width: 14px; height: 14px; transition: opacity 0.2s ease; }
.stop-square {
  position: absolute;
  width: 10px; height: 10px;
  background: var(--paper);
  border-radius: 2px;
  opacity: 0;
  transition: opacity 0.2s ease;
}
.app[data-recording="true"] .mic-svg { opacity: 0; }
.app[data-recording="true"] .stop-square { opacity: 1; }
.chat-hint {
  margin-top: 10px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 9.5px;
  letter-spacing: 0.14em;
  text-align: center;
  color: rgba(251, 247, 238, 0.45);
  text-transform: uppercase;
}

/* ───── END (form) ───── */
.end-content {
  padding: 28px 24px;
  flex: 1;
  overflow-y: auto;
  position: relative;
}
.robot-peek {
  position: absolute;
  top: 4px;
  right: -14px;
  width: 132px;
  height: auto;
  z-index: 1;
  pointer-events: none;
  transform-origin: bottom left;
  transform: rotate(-10deg);
  filter: drop-shadow(0 6px 14px rgba(20, 17, 16, 0.18));
  animation: peek-bob 4.5s ease-in-out infinite;
}
@keyframes peek-bob {
  0%, 100% { transform: rotate(-10deg) translateY(0); }
  50%      { transform: rotate(-8deg)  translateY(-4px); }
}
.end-eyebrow {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  position: relative;
  z-index: 2;
}
.check-circle {
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--paper);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
}
.end-content h2 {
  font-family: 'Fraunces', serif;
  font-weight: 500;
  font-size: 28px;
  line-height: 1.08;
  letter-spacing: -0.022em;
  margin-bottom: 10px;
  font-variation-settings: "SOFT" 40;
  position: relative;
  z-index: 2;
  padding-right: 100px;
}
.end-content h2 em {
  font-style: italic;
  color: var(--accent);
  font-variation-settings: "SOFT" 100, "WONK" 1;
}
.end-sub {
  font-size: 13.5px;
  color: var(--ink-soft);
  line-height: 1.55;
  margin-bottom: 28px;
  position: relative;
  z-index: 2;
}
.field-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin-bottom: 6px;
  display: block;
}
.field {
  width: 100%;
  background: transparent;
  border: none;
  border-bottom: 1.5px solid var(--ink);
  padding: 10px 0;
  font-size: 16px;
  color: var(--ink);
  margin-bottom: 22px;
  outline: none;
  transition: border-color 0.2s ease;
}
.field:focus { border-color: var(--accent); }
.submit-btn {
  background: var(--ink);
  color: var(--paper);
  border: none;
  border-radius: 14px;
  padding: 17px 20px;
  font-weight: 600;
  font-size: 15px;
  width: 100%;
  margin-top: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: transform 0.15s ease;
}
.submit-btn:hover { transform: translateY(-1px); }
.submit-btn .arrow { font-family: 'JetBrains Mono', monospace; }
.expectation {
  margin-top: 20px;
  font-size: 12px;
  color: var(--ink-soft);
  text-align: center;
  line-height: 1.5;
}
.expectation strong { color: var(--ink); font-weight: 600; }

/* ───── THANKS ───── */
.view-thanks { align-items: center; justify-content: center; }
.thanks-content {
  padding: 40px 28px;
  text-align: center;
  max-width: 400px;
}
.thanks-robot {
  width: 200px;
  height: auto;
  margin: 0 auto 24px;
  display: block;
  filter: drop-shadow(0 12px 28px rgba(20, 17, 16, 0.2));
  animation: trophy-arrive 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes trophy-arrive {
  0%   { opacity: 0; transform: scale(0.6) rotate(-8deg); }
  60%  { opacity: 1; transform: scale(1.05) rotate(2deg); }
  100% { opacity: 1; transform: scale(1) rotate(0); }
}
.thanks-content h2 {
  font-family: 'Fraunces', serif;
  font-weight: 500;
  font-size: 32px;
  margin-bottom: 12px;
  letter-spacing: -0.022em;
  font-variation-settings: "SOFT" 40;
}
.thanks-sub { font-size: 15px; color: var(--ink-soft); margin-bottom: 24px; }
.thanks-sub strong { color: var(--ink); }
.thanks-micro {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  line-height: 1.6;
  color: var(--ink-mute);
  background: var(--bg-deep);
  padding: 14px 16px;
  border-radius: 10px;
  margin-bottom: 28px;
  text-align: left;
}
.restart-btn {
  background: var(--ink);
  color: var(--paper);
  border: none;
  border-radius: 12px;
  padding: 14px 22px;
  font-weight: 600;
  font-size: 14px;
}

/* ───── Desktop tweak ───── */
@media (min-width: 768px) {
  body { padding: 24px 0; }
  .app {
    min-height: calc(100vh - 48px);
    border-radius: 28px;
    box-shadow: 0 30px 80px -30px rgba(20, 17, 16, 0.25);
    overflow: hidden;
  }
  .view { min-height: calc(100vh - 48px); }
  .hero h1 { font-size: 36px; }
  .hero-robot { width: 138px; top: -72px; right: -6px; }
  .robot-peek { width: 150px; right: -10px; top: 0; }
  .end-content h2 { padding-right: 120px; }
}
