/* ============================================================
   CASPER AI — Style System
   Ghost aesthetic, purple/dark theme, mobile-first
   ============================================================ */

/* ── Reset & Base ───────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --font-body: 'General Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

  /* Casper color system */
  --bg-deep: #0d0f1a;
  --bg-surface: #131525;
  --bg-elevated: #1a1d32;
  --bg-hover: #222640;
  --bg-input: #181b2e;

  --border: rgba(167, 139, 250, 0.1);
  --border-focus: rgba(167, 139, 250, 0.4);

  --text-primary: #e8e6f0;
  --text-secondary: #9896a8;
  --text-muted: #6b6980;

  --purple: #a78bfa;
  --purple-dim: rgba(167, 139, 250, 0.15);
  --purple-glow: rgba(167, 139, 250, 0.25);
  --blue: #7dd3fc;
  --blue-dim: rgba(125, 211, 252, 0.15);

  --gradient-ghost: linear-gradient(135deg, #c4b5fd, #7dd3fc);
  --gradient-button: linear-gradient(135deg, #a78bfa, #7dd3fc);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-full: 9999px;

  --shadow-glow: 0 0 40px rgba(167, 139, 250, 0.08);
  --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.3);

  --transition: 200ms cubic-bezier(0.16, 1, 0.3, 1);

  --sidebar-width: 280px;
  --header-height: 56px;
  --input-height: 60px;
}

html, body {
  -webkit-text-size-adjust: none;
  text-size-adjust: none;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  height: 100%;
  overflow: hidden;
  position: fixed;
  width: 100%;
  max-width: 100vw;
}

body {
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.6;
  color: var(--text-primary);
  background: var(--bg-deep);
  overflow: hidden;
  position: fixed;
  width: 100%;
  height: 100%;
}

button { cursor: pointer; background: none; border: none; font: inherit; color: inherit; }
input, textarea { font: inherit; color: inherit; }

::selection {
  background: var(--purple-dim);
  color: var(--text-primary);
}

/* ── Screen Management ──────────────────────────────────────── */
.screen { display: none; width: 100%; height: 100dvh; overflow: hidden; }
.screen.active { display: flex; }

/* ── AUTH SCREEN ────────────────────────────────────────────── */
.auth-container {
  margin: auto;
  padding: 24px;
  max-width: 380px;
  width: 100%;
  text-align: center;
  position: relative;
  z-index: 1;
  max-height: 100dvh;
  overflow-y: auto;
}

.ghost-logo {
  display: flex;
  justify-content: center;
  margin-bottom: 16px;
}

.ghost-svg {
  width: 80px;
  height: 100px;
  filter: drop-shadow(0 0 20px rgba(167, 139, 250, 0.3));
  animation: ghostFloat 4s ease-in-out infinite;
}

@keyframes ghostFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

.brand-title {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.brand-dot { color: var(--purple); }

.brand-tagline {
  color: var(--text-secondary);
  font-size: 0.95rem;
  margin-top: 4px;
  margin-bottom: 32px;
}

.auth-form { width: 100%; }

.input-group {
  margin-bottom: 12px;
}

.input-group input {
  width: 100%;
  padding: 14px 16px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 0.95rem;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.input-group input::placeholder {
  color: var(--text-muted);
}

.input-group input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--purple-dim);
}

.btn-primary {
  width: 100%;
  padding: 14px;
  background: var(--gradient-button);
  border: none;
  border-radius: var(--radius-md);
  color: #0d0f1a;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: opacity var(--transition), transform var(--transition);
  margin-top: 8px;
}

.btn-primary:hover { opacity: 0.9; }
.btn-primary:active { transform: scale(0.98); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-wide { max-width: 300px; }

.btn-link {
  color: var(--purple);
  background: none;
  border: none;
  font-size: 0.875rem;
  cursor: pointer;
  text-decoration: none;
}

.btn-link:hover { text-decoration: underline; }

.auth-switch {
  margin-top: 20px;
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.auth-error {
  margin-top: 16px;
  padding: 12px;
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.2);
  border-radius: var(--radius-sm);
  color: #f87171;
  font-size: 0.875rem;
}

.parent-link {
  display: block;
  margin-top: 32px;
  font-size: 0.8rem;
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.2s;
}
.parent-link:hover { color: var(--text-secondary); }

/* ── Progressive Name Flow ────────────────────────────────── */
#name-flow-area {
  width: 100%;
  margin-top: 0;
  transition: all 0.3s ease;
}

#name-flow-area:empty { display: none; }

.name-status {
  padding: 10px 0;
  text-align: center;
}

.name-available {
  color: #6ee7b7;
  font-weight: 600;
  font-size: 0.9rem;
}

.name-taken {
  color: #fbbf24;
  font-weight: 600;
  font-size: 0.9rem;
}

.name-checking {
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-style: italic;
}

.name-help {
  color: var(--text-secondary);
  font-size: 0.85rem;
  margin: 6px 0 10px;
}

.name-combo-row {
  display: flex;
  align-items: center;
  gap: 0;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0 14px;
  transition: border-color 0.2s;
}

.name-combo-row:focus-within {
  border-color: var(--border-focus);
}

.name-prefix {
  color: var(--text-secondary);
  font-size: 1rem;
  font-weight: 500;
  white-space: nowrap;
  user-select: none;
}

.name-combo-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-size: 1rem;
  font-family: var(--font-body);
  padding: 14px 0;
  min-width: 0;
}

.name-combo-input::placeholder {
  color: var(--text-muted);
}

#name-combo-status, #name-nick-status {
  margin-top: 8px;
  text-align: center;
  min-height: 1.4em;
}

/* Ghost Key Reveal */
.ghost-key-display {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 16px;
}

.ghost-key-label {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.ghost-key-value {
  font-size: 2.2rem;
  font-weight: 700;
  letter-spacing: 0.3em;
  background: var(--gradient-ghost);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.ghost-key-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 8px;
}

/* ── CHAT SCREEN ────────────────────────────────────────────── */
#chat-screen {
  flex-direction: row;
  overflow: hidden;
  width: 100%;
  max-width: 100vw;
}

/* ── Sidebar ────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  height: 100dvh;
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  z-index: 100;
  overflow: hidden;
  /* Mobile-first: sidebar is hidden off-screen by default */
  position: fixed;
  left: 0;
  top: 0;
  transform: translateX(-100%);
  transition: transform 300ms cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: var(--shadow-md);
}

.sidebar.open {
  transform: translateX(0);
}

.sidebar.open + .chat-main + .sidebar-overlay {
  display: block;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  border-bottom: 1px solid var(--border);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 0.95rem;
}

.sidebar-brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.beta-badge {
  display: inline-block;
  font-size: 0.55rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: #c4b5fd;
  border: 1px solid rgba(196,181,253,0.35);
  border-radius: 4px;
  padding: 1px 5px;
  vertical-align: middle;
  margin-left: 4px;
  opacity: 0.7;
}

.sidebar-tagline {
  font-size: 0.65rem;
  font-weight: 500;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

.sidebar-ghost {
  filter: drop-shadow(0 0 8px rgba(167, 139, 250, 0.2));
}

.btn-icon {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  transition: background var(--transition), color var(--transition);
}

.btn-icon:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

/* Conversation list */
.conversation-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.conv-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.875rem;
  color: var(--text-secondary);
  transition: background var(--transition), color var(--transition);
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
}

.conv-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.conv-item.active { background: var(--purple-dim); color: var(--text-primary); }

.conv-item svg {
  flex-shrink: 0;
  opacity: 0.5;
}

/* Sidebar footer */
.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.user-info {
  display: flex;
  flex-direction: column;
  margin-bottom: 12px;
}

.sidebar-user-name {
  font-weight: 600;
  font-size: 0.875rem;
}

.sidebar-user-status {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.sidebar-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.btn-small {
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 500;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  transition: all var(--transition);
  text-align: center;
}

.btn-small:hover { background: var(--bg-hover); color: var(--text-primary); }

.btn-accent {
  background: var(--gradient-button);
  color: #0d0f1a;
  border: none;
  font-weight: 600;
  border-radius: var(--radius-full);
}

.btn-accent:hover { opacity: 0.9; }

.btn-ghost { border-color: transparent; }
.btn-ghost:hover { border-color: var(--border); }

.btn-pill {
  border-radius: var(--radius-full);
  border-color: var(--border);
  padding: 8px 20px;
}
.btn-pill:hover {
  background: var(--bg-hover);
  border-color: rgba(167, 139, 250, 0.25);
  color: var(--text-primary);
}

.sidebar-copyright {
  margin-top: 16px;
  font-size: 0.6rem;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.4;
}

/* ── Chat Main Area ─────────────────────────────────────────── */
.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100dvh;
  min-width: 0;
  position: relative;
  z-index: 1;
}

/* Chat Header */
.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  height: var(--header-height);
  border-bottom: 1px solid var(--border);
  background: var(--bg-surface);
  flex-shrink: 0;
}

.chat-header-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 0.95rem;
}

.header-brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.header-tagline {
  font-size: 0.6rem;
  font-weight: 500;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

/* Messages Container */
.messages-container {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  scroll-behavior: smooth;
  padding: 0;
}

.messages {
  max-width: 768px;
  margin: 0 auto;
  padding: 20px 16px;
}

/* Welcome State */
.welcome-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  min-height: 50vh;
  text-align: center;
}

.welcome-ghost {
  opacity: 0.15;
  margin-bottom: 16px;
  animation: ghostFloat 4s ease-in-out infinite;
}

.welcome-state h2 {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 24px;
}

.suggested-prompts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  max-width: 500px;
}

.prompt-chip {
  padding: 10px 16px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  color: var(--text-secondary);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all var(--transition);
}

.prompt-chip:hover {
  background: var(--purple-dim);
  border-color: var(--purple);
  color: var(--text-primary);
}

/* Message Bubbles */
.message {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
  animation: messageIn 300ms ease-out;
}

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

.message-avatar {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 600;
  margin-top: 2px;
}

.message.casper .message-avatar {
  background: var(--purple-dim);
  color: var(--purple);
}

.casper-ghost-avatar {
  background: transparent !important;
  overflow: visible;
}

.message.user .message-avatar {
  background: var(--blue-dim);
  color: var(--blue);
}

.message-body {
  flex: 1;
  min-width: 0;
}

.message-name {
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 4px;
  color: var(--text-secondary);
}

.message-content {
  font-size: 0.95rem;
  line-height: 1.65;
  color: var(--text-primary);
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.message-content p { margin-bottom: 8px; }
.message-content p:last-child { margin-bottom: 0; }

.message-content code {
  background: var(--bg-elevated);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.85em;
  font-family: 'JetBrains Mono', monospace;
}

.message-content pre {
  background: var(--bg-elevated);
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  overflow-x: auto;
  margin: 8px 0;
  font-size: 0.85em;
  font-family: 'JetBrains Mono', monospace;
  line-height: 1.5;
}

.message-content pre code {
  background: none;
  padding: 0;
}

.message-content ul, .message-content ol {
  padding-left: 20px;
  margin: 8px 0;
}

.message-content li {
  margin-bottom: 4px;
}

.message-content strong {
  font-weight: 600;
  color: var(--text-primary);
}

.message-actions {
  display: flex;
  gap: 4px;
  margin-top: 6px;
  opacity: 0;
  transition: opacity var(--transition);
}

.message:hover .message-actions { opacity: 1; }

.msg-action-btn {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  transition: all var(--transition);
}

.msg-action-btn:hover {
  background: var(--bg-hover);
  color: var(--text-secondary);
}

/* Typing indicator */
.typing-indicator {
  display: flex;
  gap: 4px;
  padding: 4px 0;
}

.typing-indicator span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--purple);
  animation: typingBounce 1.4s infinite ease-in-out both;
}

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

@keyframes typingBounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

/* ── Input Area ─────────────────────────────────────────────── */
.input-area {
  padding: 12px 16px 16px;
  flex-shrink: 0;
  max-width: 768px;
  margin: 0 auto;
  width: 100%;
}

.input-wrapper {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 8px 8px 8px 16px;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.input-wrapper:focus-within {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--purple-dim);
}

#chat-input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  resize: none;
  color: var(--text-primary);
  font-size: 0.95rem;
  line-height: 1.5;
  max-height: 120px;
  padding: 6px 0;
}

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

.input-actions {
  display: flex;
  gap: 2px;
  flex-shrink: 0;
  position: relative;
}

.input-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
}

.btn-send {
  color: var(--text-muted);
  transition: all var(--transition);
}

.btn-send:not(:disabled) {
  color: #0d0f1a;
  background: var(--gradient-button);
}

.btn-send:not(:disabled):hover { opacity: 0.9; }

/* ── Voice Orb Button ───────────────────────────────────────── */
.btn-voice-orb {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  padding: 0;
  background: var(--gradient-button);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  position: relative;
  box-shadow: 0 0 12px rgba(167, 139, 250, 0.4), 0 0 24px rgba(125, 211, 252, 0.2);
  transition: transform var(--transition), box-shadow var(--transition);
}

.btn-voice-orb:hover {
  transform: scale(1.1);
  box-shadow: 0 0 18px rgba(167, 139, 250, 0.6), 0 0 36px rgba(125, 211, 252, 0.3);
}

.btn-voice-orb:active {
  transform: scale(0.95);
}

.voice-orb-inner {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.9);
  display: block;
  animation: orbPulse 2.5s ease-in-out infinite;
}

@keyframes orbPulse {
  0%, 100% { transform: scale(1); opacity: 0.9; }
  50% { transform: scale(0.75); opacity: 0.6; }
}

/* Message counter */
.message-counter {
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 8px;
}

/* ── Sidebar Overlay (mobile) ───────────────────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 99;
}

/* ── Paywall Modal ──────────────────────────────────────────── */
.modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
}

.modal-content {
  position: relative;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 40px 32px;
  max-width: 380px;
  width: 90%;
  text-align: center;
  box-shadow: var(--shadow-glow);
}

.modal-ghost {
  margin-bottom: 16px;
}

.modal-ghost svg {
  filter: drop-shadow(0 0 20px rgba(167, 139, 250, 0.3));
  margin: 0 auto;
  display: block;
}

.modal-content h2 {
  font-size: 1.3rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.modal-content p {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: 20px;
}

.price-tag {
  font-size: 2.5rem;
  font-weight: 700;
  background: var(--gradient-ghost);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 20px;
}

.price-tag span {
  font-size: 1rem;
  font-weight: 400;
}

/* ── Scrollbar ──────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg-hover); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ── Mobile Responsive ──────────────────────────────────────── */
@media (max-width: 1199px) {
  .chat-main { width: 100%; }

  .messages { padding: 16px 12px; }

  .input-area { padding: 8px 12px 12px; }

  .suggested-prompts { max-width: 100%; }
}

/* Sidebar is always an overlay — never permanently visible, any screen size */

/* ── Wandering Ghosts (Pac-Man style) ── */
.ghost-wander-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}
.ghost-sprite {
  position: absolute;
  opacity: 0;
  transition: opacity 1.5s ease, filter 0.6s ease;
  will-change: transform;
}
.ghost-sprite.active {
  opacity: 1;
}
.ghost-sprite svg {
  filter: drop-shadow(0 0 6px currentColor);
}
/* Guiding mode — ghosts glow bright when summoned */
.ghost-sprite.guiding {
  opacity: 1 !important;
  filter: drop-shadow(0 0 12px currentColor) drop-shadow(0 0 24px currentColor);
  z-index: 10;
}
.ghost-sprite.guiding svg {
  filter: drop-shadow(0 0 8px currentColor);
}
/* Pulse ring that appears around the target element */
.ghost-guide-ring {
  position: fixed;
  border-radius: 50%;
  border: 2px solid rgba(167,139,250,0.5);
  pointer-events: none;
  z-index: 9;
  animation: guideRingPulse 1.5s ease-in-out infinite;
}
@keyframes guideRingPulse {
  0%, 100% { transform: translate(-50%,-50%) scale(1); opacity: 0.6; }
  50% { transform: translate(-50%,-50%) scale(1.25); opacity: 0.15; }
}

/* Keep content above the ghosts */
.auth-container, .chat-main {
  position: relative;
  z-index: 1;
}

/* ── Voice Orb hint pulse (first visit) ── */
.btn-voice-orb.hint-pulse {
  animation: orbHintPulse 2s ease-in-out infinite;
}
@keyframes orbHintPulse {
  0%, 100% { transform: scale(1); box-shadow: 0 0 12px rgba(167, 139, 250, 0.4); }
  50% { transform: scale(1.2); box-shadow: 0 0 28px rgba(167, 139, 250, 0.8), 0 0 48px rgba(125, 211, 252, 0.4); }
}
.mic-label {
  position: absolute;
  bottom: calc(100% + 8px);
  right: 0;
  background: var(--bg-elevated);
  border: 1px solid var(--purple);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  font-size: 0.75rem;
  color: var(--purple);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s ease;
  z-index: 10;
}
.mic-label.visible {
  opacity: 1;
}
.mic-label::after {
  content: '';
  position: absolute;
  top: 100%;
  right: 12px;
  border: 5px solid transparent;
  border-top-color: var(--purple);
}

/* ── Voice Mode Overlay ─────────────────────────────────────── */
.voice-overlay {
  position: fixed;
  inset: 0;
  z-index: 350;
  background: #0d0f1a;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 400ms ease;
}

.voice-overlay.active {
  opacity: 1;
  pointer-events: all;
}

#voice-intro-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 1;
  opacity: 1;
  transition: opacity 600ms ease;
}

#voice-intro-video.hidden {
  opacity: 0;
  pointer-events: none;
}

#voice-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 2;
  opacity: 0;
  transition: opacity 600ms ease;
}

#voice-canvas.active {
  opacity: 1;
}

.voice-status {
  position: absolute;
  bottom: 100px;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
  letter-spacing: 0.05em;
  z-index: 10;
  transition: opacity 300ms ease;
  pointer-events: none;
}

.voice-status.thinking {
  color: var(--text-secondary);
  animation: thinkingDots 1.4s infinite;
}

@keyframes thinkingDots {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}

.voice-status.speaking {
  color: var(--purple);
}

.voice-subtitle {
  position: absolute;
  bottom: 44px;
  left: 16px;
  right: 16px;
  text-align: center;
  font-size: 1.05rem;
  font-weight: 500;
  color: var(--text-primary);
  line-height: 1.5;
  z-index: 10;
  min-height: 2em;
  pointer-events: none;
  text-shadow: 0 2px 12px rgba(0,0,0,0.8);
  opacity: 0;
  transition: opacity 300ms ease;
}

.voice-subtitle.visible {
  opacity: 1;
}

.voice-close-btn {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
  transition: background var(--transition), color var(--transition), transform var(--transition);
  cursor: pointer;
}

.voice-close-btn:hover {
  background: rgba(255, 255, 255, 0.14);
  color: var(--text-primary);
  transform: scale(1.05);
}

.voice-close-btn:active {
  transform: scale(0.95);
}

/* ── Site Footer ──────────────────────────────────────────── */
.input-copyright {
  text-align: center;
  font-size: 0.6rem;
  color: var(--text-muted);
  opacity: 0.5;
  margin: 4px 0 0;
  line-height: 1.4;
}


/* ── Golden Ticket (Ghost Key reveal) ─────────────────────── */
.golden-ticket {
  display: inline-block;
  margin: 12px 0 6px;
  padding: 16px 28px;
  background: linear-gradient(135deg, #d4a017 0%, #f7d663 25%, #e6b422 50%, #f7d663 75%, #d4a017 100%);
  background-size: 200% 200%;
  animation: goldenTicketEntry 0.8s cubic-bezier(0.16, 1, 0.3, 1) both, goldenShimmer 3s ease-in-out infinite 0.8s;
  border-radius: 10px;
  border: 2px solid #f7d663;
  box-shadow:
    0 0 20px rgba(247, 214, 99, 0.4),
    0 0 60px rgba(247, 214, 99, 0.15),
    inset 0 1px 0 rgba(255, 255, 255, 0.3);
  position: relative;
  overflow: hidden;
  text-align: center;
}

.golden-ticket::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: linear-gradient(
    45deg,
    transparent 30%,
    rgba(255, 255, 255, 0.15) 45%,
    rgba(255, 255, 255, 0.3) 50%,
    rgba(255, 255, 255, 0.15) 55%,
    transparent 70%
  );
  animation: ticketSheen 4s ease-in-out infinite 1.5s;
  pointer-events: none;
}

.golden-ticket-label {
  display: block;
  font-size: 0.6rem;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: #5c3d00;
  margin-bottom: 6px;
  opacity: 0.7;
}

.golden-ticket-code {
  display: block;
  font-size: 1.8rem;
  font-weight: 700;
  font-family: 'Courier New', monospace;
  letter-spacing: 0.25em;
  color: #3a2200;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.4);
}

.golden-ticket-hint {
  display: block;
  font-size: 0.55rem;
  font-weight: 500;
  color: #6b4a00;
  margin-top: 6px;
  opacity: 0.6;
  letter-spacing: 0.05em;
}

@keyframes goldenTicketEntry {
  0% {
    opacity: 0;
    transform: translateY(-60px) scale(0.7) rotate(-3deg);
    filter: blur(4px);
  }
  60% {
    opacity: 1;
    transform: translateY(5px) scale(1.03) rotate(0.5deg);
    filter: blur(0);
  }
  80% {
    transform: translateY(-2px) scale(0.99) rotate(-0.2deg);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1) rotate(0deg);
    filter: blur(0);
  }
}

@keyframes goldenShimmer {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

@keyframes ticketSheen {
  0%, 100% { transform: translateX(-100%) rotate(45deg); }
  50% { transform: translateX(100%) rotate(45deg); }
}

/* ── Utility ────────────────────────────────────────────────── */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border-width: 0;
}

/* Ghost Key Reveal Modal */
.ghostkey-reveal-content {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.golden-ticket-modal {
  padding: 24px 40px;
  animation: goldenTicketEntry 0.8s cubic-bezier(0.16, 1, 0.3, 1) both, goldenShimmer 3s ease-in-out infinite 0.8s;
}

.golden-ticket-modal .golden-ticket-code {
  font-size: 2.2rem;
  letter-spacing: 0.3em;
}

.golden-ticket-modal .golden-ticket-label {
  font-size: 0.7rem;
  margin-bottom: 8px;
}

.golden-ticket-modal .golden-ticket-hint {
  font-size: 0.65rem;
  margin-top: 8px;
}

.btn-ghostkey-reveal {
  background: linear-gradient(135deg, #d4a017 0%, #f7d663 50%, #d4a017 100%) !important;
  color: #3a2200 !important;
  font-weight: 600 !important;
  border: 1px solid rgba(247, 214, 99, 0.5) !important;
  text-shadow: 0 1px 0 rgba(255,255,255,0.3);
}

.btn-ghostkey-reveal:hover {
  box-shadow: 0 0 12px rgba(247, 214, 99, 0.4);
}

/* Golden Ticket sidebar float-down container */
.sidebar-golden-ticket {
  padding: 12px 16px;
  display: flex;
  justify-content: center;
  flex-shrink: 0;
}

.sidebar-golden-ticket .sidebar-ticket-card {
  width: 100%;
  animation: none; /* override the default goldenTicketEntry */
}

/* Float-down animation — smooth leaf-like descent */
.sidebar-golden-ticket.golden-float {
  animation: goldenFloat 4s cubic-bezier(0.25, 0.1, 0.25, 1) both;
}

@keyframes goldenFloat {
  0% {
    opacity: 0;
    transform: translateY(-500px) translateX(0) rotate(-2deg);
  }
  5% {
    opacity: 1;
  }
  15% {
    transform: translateY(-400px) translateX(18px) rotate(2deg);
  }
  25% {
    transform: translateY(-310px) translateX(-16px) rotate(-2deg);
  }
  35% {
    transform: translateY(-230px) translateX(14px) rotate(1.5deg);
  }
  45% {
    transform: translateY(-160px) translateX(-12px) rotate(-1.5deg);
  }
  55% {
    transform: translateY(-100px) translateX(10px) rotate(1deg);
  }
  65% {
    transform: translateY(-55px) translateX(-8px) rotate(-0.8deg);
  }
  75% {
    transform: translateY(-25px) translateX(5px) rotate(0.5deg);
  }
  85% {
    transform: translateY(-8px) translateX(-3px) rotate(-0.2deg);
  }
  93% {
    transform: translateY(2px) translateX(1px) rotate(0.1deg);
  }
  100% {
    opacity: 1;
    transform: translateY(0) translateX(0) rotate(0);
  }
}

/* Copy button on inline golden ticket */
.golden-ticket-copy {
  display: block;
  margin: 10px auto 0;
  padding: 5px 18px;
  background: rgba(58, 34, 0, 0.15);
  color: #3a2200;
  border: 1.5px solid rgba(58, 34, 0, 0.3);
  border-radius: 20px;
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}

.golden-ticket-copy:hover {
  background: rgba(58, 34, 0, 0.25);
  border-color: rgba(58, 34, 0, 0.5);
}

.golden-ticket-copy:active {
  transform: scale(0.96);
}

/* -- Countdown Overlay: Grandfather Clock Nap Screen -- */
#countdown-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  opacity: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 20px 0;
}

#countdown-overlay[style*="display: flex"],
#countdown-overlay[style*="display:flex"] {
  pointer-events: auto;
}

/* Phase 1: backdrop dissolves the chat into ethereal mist */
.countdown-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(13, 15, 26, 0.4);
  backdrop-filter: blur(0px);
  opacity: 0;
  animation: backdropDissolve 1.8s ease-out forwards;
}

/* Sora video background */
.nap-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 0;
  opacity: 0;
  animation: videoFadeIn 2.5s ease-out 0.3s forwards;
}

@keyframes videoFadeIn {
  0% { opacity: 0; }
  50% { opacity: 0.6; }
  100% { opacity: 0.85; }
}

@keyframes backdropDissolve {
  0% {
    opacity: 0;
    backdrop-filter: blur(0px);
  }
  40% {
    opacity: 0.6;
    backdrop-filter: blur(4px);
  }
  100% {
    opacity: 1;
    backdrop-filter: blur(12px);
  }
}

/* Floating mist particles */
.countdown-backdrop::before,
.countdown-backdrop::after {
  content: '';
  position: absolute;
  border-radius: 50%;
  opacity: 0;
  animation: mistAppear 2s ease-out 0.8s forwards;
}

.countdown-backdrop::before {
  width: 300px;
  height: 300px;
  top: 10%;
  left: 15%;
  background: radial-gradient(circle, rgba(167, 139, 250, 0.12) 0%, transparent 70%);
  animation: mistAppear 2s ease-out 0.8s forwards, mistDrift 8s ease-in-out 2s infinite;
}

.countdown-backdrop::after {
  width: 250px;
  height: 250px;
  bottom: 15%;
  right: 10%;
  background: radial-gradient(circle, rgba(125, 211, 252, 0.1) 0%, transparent 70%);
  animation: mistAppear 2s ease-out 1s forwards, mistDrift 10s ease-in-out 2.5s infinite reverse;
}

@keyframes mistAppear {
  from { opacity: 0; transform: scale(0.8); }
  to { opacity: 1; transform: scale(1); }
}

@keyframes mistDrift {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(15px, -10px) scale(1.05); }
  66% { transform: translate(-10px, 8px) scale(0.95); }
}

/* The whole scene fades in after the backdrop */
.countdown-scene {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  max-width: 340px;
  width: 90%;
  opacity: 0;
  transform: translateY(20px) scale(0.9);
  animation: sceneEmerge 1.2s ease-out 1s forwards;
  flex-shrink: 0;
  margin: auto;
  padding-bottom: 24px;
}

@keyframes sceneEmerge {
  0% {
    opacity: 0;
    transform: translateY(20px) scale(0.9);
  }
  60% {
    opacity: 1;
    transform: translateY(-4px) scale(1.02);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Sleeping Casper floats gently above the clock */
.sleeping-casper {
  position: relative;
  z-index: 2;
  margin-bottom: -10px;
  animation: casperFloat 3s ease-in-out 2.2s infinite;
  opacity: 0;
  animation: casperAppear 0.8s ease-out 1.6s forwards, casperFloat 3s ease-in-out 2.4s infinite;
}

.sleeping-casper svg {
  filter: drop-shadow(0 0 24px rgba(167, 139, 250, 0.5));
}

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

@keyframes casperFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

/* Zzz bubbles */
.zzz-bubbles {
  position: absolute;
  top: -4px;
  right: -18px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
}

.zzz-bubbles span {
  font-weight: 700;
  color: #a78bfa;
  opacity: 0;
  animation: zzzFloat 2.4s ease-in-out infinite;
  text-shadow: 0 0 8px rgba(167, 139, 250, 0.5);
}

.zzz-bubbles span:nth-child(1) {
  font-size: 0.55rem;
  animation-delay: 2.5s;
}

.zzz-bubbles span:nth-child(2) {
  font-size: 0.7rem;
  animation-delay: 2.9s;
  transform: translateX(5px);
}

.zzz-bubbles span:nth-child(3) {
  font-size: 0.9rem;
  animation-delay: 3.3s;
  transform: translateX(10px);
}

@keyframes zzzFloat {
  0% { opacity: 0; transform: translateY(3px); }
  15% { opacity: 0.8; }
  85% { opacity: 0.8; }
  100% { opacity: 0; transform: translateY(-10px); }
}

/* Grandfather Clock */
.grandfather-clock {
  position: relative;
  z-index: 1;
}

.clock-svg {
  width: 160px;
  height: auto;
  filter: drop-shadow(0 4px 30px rgba(167, 139, 250, 0.2))
          drop-shadow(0 0 60px rgba(125, 211, 252, 0.08));
}

/* Pendulum swing — smooth, hypnotic */
.pendulum-arm {
  animation: pendulumSwing 2.4s ease-in-out infinite;
  transform-origin: 100px 196px;
}

@keyframes pendulumSwing {
  0% { transform: rotate(-10deg); }
  50% { transform: rotate(10deg); }
  100% { transform: rotate(-10deg); }
}

/* Text area below clock */
.countdown-text-area {
  position: relative;
  z-index: 2;
  text-align: center;
  margin-top: 16px;
  opacity: 0;
  animation: textFadeIn 0.8s ease-out 1.8s forwards;
}

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

.countdown-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0 0 4px;
}

.countdown-subtitle {
  color: var(--text-secondary);
  font-size: 0.85rem;
  margin: 0;
}

.countdown-timer {
  font-size: 3.2rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  background: var(--gradient-ghost);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: 3px;
  margin: 8px 0 14px;
  line-height: 1;
}

.countdown-reset-note {
  color: var(--text-secondary);
  font-size: 0.75rem;
  margin: 4px 0 10px;
  opacity: 0.7;
}

.countdown-divider {
  width: 50px;
  height: 1px;
  background: var(--border);
  margin: 0 auto 14px;
}

.countdown-cta {
  color: var(--text-muted);
  font-size: 0.78rem;
  margin: 0 0 8px;
}

.countdown-text-area .price-tag {
  font-size: 2rem;
  margin-bottom: 14px;
}

.countdown-text-area .btn-wide {
  min-width: 200px;
}

/* Override the overlay to fade in as a whole */
#countdown-overlay.active {
  animation: overlayFadeIn 0.3s ease-out forwards;
}

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

/* Breathing glow on the clock during sleep */
.grandfather-clock .clock-svg {
  animation: clockBreathe 4s ease-in-out infinite;
}

@keyframes clockBreathe {
  0%, 100% {
    filter: drop-shadow(0 4px 30px rgba(167, 139, 250, 0.15))
            drop-shadow(0 0 40px rgba(125, 211, 252, 0.05));
  }
  50% {
    filter: drop-shadow(0 4px 40px rgba(167, 139, 250, 0.35))
            drop-shadow(0 0 70px rgba(125, 211, 252, 0.15));
  }
}

/* Sleeping Casper also breathes gently */
.sleeping-casper svg {
  animation: casperBreathe 3.5s ease-in-out infinite;
}

@keyframes casperBreathe {
  0%, 100% {
    filter: drop-shadow(0 0 20px rgba(167, 139, 250, 0.35));
  }
  50% {
    filter: drop-shadow(0 0 32px rgba(167, 139, 250, 0.55));
  }
}

/* Mobile: scale down nap screen so subscribe button is reachable */
@media (max-height: 750px) {
  .clock-svg {
    width: 120px;
  }
  .countdown-timer {
    font-size: 2.4rem;
    margin: 4px 0 10px;
  }
  .countdown-text-area {
    margin-top: 10px;
  }
  .countdown-text-area .price-tag {
    font-size: 1.6rem;
    margin-bottom: 10px;
  }
  .sleeping-casper svg {
    width: 36px;
    height: 45px;
  }
}