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

:root {
  --bg: #0a0a0b;
  --bg-elevated: #141416;
  --bg-card: #1a1a1e;
  --border: #2a2a2e;
  --text: #e8e8ed;
  --text-muted: #8a8a95;
  --accent: #6366f1;
  --accent-hover: #818cf8;
  --accent-glow: rgba(99, 102, 241, 0.15);
  --success: #22c55e;
  --error: #ef4444;
  --radius: 12px;
  --radius-sm: 8px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: "SF Mono", SFMono-Regular, ui-monospace, Menlo, Consolas, monospace;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}

/* Hero */
#hero {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  padding: 2rem 1.5rem;
  text-align: center;
}

.hero-content {
  max-width: 640px;
}

.eyebrow {
  font-size: clamp(0.95rem, 2vw, 1.1rem);
  color: var(--text-muted);
  margin-bottom: 1.25rem;
  font-weight: 400;
}

/* Role ticker */
.role-word {
  display: inline-block;
  color: var(--accent);
  font-weight: 600;
  animation: none;
}

.role-word.fade-out {
  animation: fadeOut 0.3s ease forwards;
}

.role-word.fade-in {
  animation: fadeIn 0.3s ease forwards;
}

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

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

#hero h1 {
  font-size: clamp(1.75rem, 5vw, 3rem);
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.02em;
  margin-bottom: 1rem;
}

#hero h1 em {
  font-style: normal;
  color: var(--accent);
  text-transform: uppercase;
  font-weight: 800;
}

.subhead {
  font-size: clamp(1.1rem, 2.5vw, 1.35rem);
  color: var(--text-muted);
  margin-bottom: 2.5rem;
  line-height: 1.5;
}

.btn-primary {
  display: inline-block;
  padding: 0.875rem 2.5rem;
  background: var(--accent);
  color: #fff;
  font-size: 1.1rem;
  font-weight: 600;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}

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

.btn-primary:active {
  transform: scale(0.97);
}

/* Chat Section */
#chat-section {
  display: none;
  min-height: 100dvh;
  padding: 1rem;
  padding-bottom: env(safe-area-inset-bottom, 1rem);
}

#chat-section.active {
  display: flex;
  flex-direction: column;
  align-items: center;
}

#chat-container {
  width: 100%;
  max-width: 680px;
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

#messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 0;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* Message Bubbles */
.message {
  max-width: 85%;
  padding: 0.875rem 1.125rem;
  border-radius: var(--radius);
  font-size: 0.95rem;
  line-height: 1.6;
  word-wrap: break-word;
}

.message.user {
  align-self: flex-end;
  background: var(--accent);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.message.assistant {
  align-self: flex-start;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}

/* Typing indicator */
.typing-indicator {
  align-self: flex-start;
  padding: 0.875rem 1.125rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  border-bottom-left-radius: 4px;
  display: flex;
  gap: 4px;
  align-items: center;
}

.typing-indicator span {
  width: 6px;
  height: 6px;
  background: var(--text-muted);
  border-radius: 50%;
  animation: typing 1.4s infinite;
}

.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

/* Reward writing indicator */
.reward-indicator {
  align-self: flex-start;
  padding: 1rem 1.25rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  display: flex;
  gap: 6px;
  align-items: center;
}

.reward-indicator-dot {
  width: 6px;
  height: 6px;
  background: var(--accent);
  border-radius: 50%;
  animation: typing 1.4s infinite;
}

.reward-indicator-dot:nth-child(2) { animation-delay: 0.2s; }
.reward-indicator-dot:nth-child(3) { animation-delay: 0.4s; }

.reward-indicator-text {
  margin-left: 0.5rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}

@keyframes typing {
  0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-4px); }
}

/* Input Bar */
#input-bar {
  display: flex;
  gap: 0.5rem;
  padding: 0.75rem 0;
  border-top: 1px solid var(--border);
  position: sticky;
  bottom: 0;
  background: var(--bg);
  padding-bottom: calc(0.75rem + env(safe-area-inset-bottom, 0px));
}

#user-input {
  flex: 1;
  padding: 0.75rem 1rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.5;
  resize: none;
  min-height: 44px;
  max-height: 120px;
  outline: none;
  transition: border-color 0.2s;
}

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

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

#send-btn {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.2s, opacity 0.2s;
  align-self: flex-end;
}

#send-btn:hover {
  background: var(--accent-hover);
}

#send-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Reward Cards */
.reward-container {
  align-self: stretch;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-top: 0.5rem;
}

.reward-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  overflow: hidden;
}

.reward-card.playbook {
  border-left: 3px solid var(--accent);
}

/* Visual separator between workflows */
.reward-card.playbook p:has(> strong:only-child) ~ p:has(> strong:only-child) {
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  padding-top: 1rem;
  margin-top: 0.5rem;
}

.reward-card.video {
  border-left: 3px solid #f59e0b;
}

.reward-card.prompt {
  border-left: 3px solid #a78bfa;
}

/* Video embed */
.video-embed {
  position: relative;
  padding-bottom: 56.25%; /* 16:9 */
  height: 0;
  margin-top: 0.75rem;
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.video-embed iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

/* Prompt tease */
.prompt-tease {
  color: var(--accent);
  font-size: 0.9rem;
  font-weight: 500;
  margin-top: 0.5rem;
  margin-bottom: 0;
}

.reward-card.email-cta {
  border-left: 3px solid var(--success);
}

.reward-card h2, .reward-card h3 {
  margin-bottom: 0.75rem;
  line-height: 1.3;
}

.reward-card h2 {
  font-size: 1.2rem;
}

.reward-card h3 {
  font-size: 1.05rem;
  color: var(--text-muted);
}

.reward-card p {
  margin-bottom: 0.5rem;
}

.reward-card ul, .reward-card ol {
  margin: 0.5rem 0;
  padding-left: 1.5rem;
}

.reward-card li {
  margin-bottom: 0.35rem;
}

.reward-card strong {
  color: #fff;
}

/* Prompt code block */
.prompt-block {
  position: relative;
  margin-top: 0.75rem;
}

.prompt-code {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1rem;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  line-height: 1.6;
  overflow-x: auto;
  white-space: pre-wrap;
  color: var(--text-muted);
  max-height: 400px;
  overflow-y: auto;
}

.copy-btn {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  padding: 0.4rem 0.75rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s;
}

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

.copy-btn.copied {
  background: var(--success);
}

/* Email form */
.email-form {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.email-form input[type="email"] {
  flex: 1;
  padding: 0.75rem 1rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font);
  font-size: 0.95rem;
  outline: none;
  min-width: 0;
}

.email-form input[type="email"]:focus {
  border-color: var(--accent);
}

.email-form input[type="email"]::placeholder {
  color: var(--text-muted);
}

.email-form button {
  padding: 0.75rem 1.25rem;
  background: var(--success);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s;
  white-space: nowrap;
}

.email-form button:hover {
  opacity: 0.9;
}

.email-form button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.email-success {
  color: var(--success);
  font-weight: 500;
  margin-top: 0.75rem;
}

.email-error {
  color: var(--error);
  font-size: 0.85rem;
  margin-top: 0.5rem;
}

/* Footer */
footer {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* Scrollbar */
#messages::-webkit-scrollbar {
  width: 4px;
}

#messages::-webkit-scrollbar-track {
  background: transparent;
}

#messages::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}

/* Responsive */
@media (max-width: 480px) {
  .message {
    max-width: 92%;
  }

  .reward-card {
    padding: 1.125rem;
  }

  .email-form {
    flex-direction: column;
  }

  .email-form button {
    width: 100%;
  }
}
