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

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=DM+Serif+Display&display=swap');

:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --border: #e2e8f0;
  --text: #0f172a;
  --text-secondary: #64748b;
  --primary: #1A73E8;
  --primary-hover: #1557b0;
  --accent: #eff6ff; 
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --radius: 24px;
  --radius-sm: 12px;
  --radius-pill: 9999px;
  --shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.05), 0 8px 10px -6px rgba(0, 0, 0, 0.01);
  --shadow-lg: 0 20px 40px -5px rgba(0, 0, 0, 0.05), 0 10px 15px -5px rgba(0, 0, 0, 0.02);
  --font: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-serif: 'DM Serif Display', 'Georgia', serif;
  --mono: "SF Mono", Menlo, Monaco, monospace;
}

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

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Layout */
.container { max-width: 1200px; margin: 0 auto; padding: 0 24px; }
.header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 16px 0;
}
.header-inner {
  display: flex; justify-content: space-between; align-items: center;
  max-width: 1200px; margin: 0 auto; padding: 0 24px;
}
.logo { font-size: 1.25rem; font-weight: 700; color: var(--text); }
.logo:hover { text-decoration: none; }
.header-actions { display: flex; gap: 12px; align-items: center; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 24px; border-radius: var(--radius-pill); font-size: 0.95rem;
  font-weight: 500; cursor: pointer; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); transition: all 0.2s ease;
  box-shadow: 0 2px 4px rgba(0,0,0,0.02);
}
.btn:hover { background: var(--bg); text-decoration: none; transform: translateY(-1px); box-shadow: 0 4px 6px rgba(0,0,0,0.04); }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); font-weight: 600; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; box-shadow: none; }
.btn-sm { padding: 6px 12px; font-size: 0.8rem; }
.btn-danger { color: var(--danger); border-color: var(--danger); }
.btn-danger:hover { background: #fef2f2; }

/* Cards */
.card {
  background: var(--surface); border: 1px solid rgba(226, 232, 240, 0.5);
  border-radius: var(--radius); padding: 32px; box-shadow: var(--shadow-lg);
}

/* Hero (landing) */
.hero {
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: center;
  gap: 48px;
  max-width: 1200px;
  margin: 0 auto;
  padding: 100px 24px;
  text-align: left;
}

@media (max-width: 992px) {
  .hero { grid-template-columns: 1fr; text-align: center; padding: 60px 24px; }
  .hero-content { order: 2; }
  .hero-image { order: 1; }
}

.hero h1 { 
  font-size: 3.5rem; 
  font-family: var(--font-serif);
  font-weight: 800; 
  margin-bottom: 24px; 
  line-height: 1.1;
  color: #111827;
}

.hero h1 span { color: var(--primary); }

.hero p { 
  font-size: 1.25rem; 
  color: var(--text-secondary); 
  margin-bottom: 40px;
}

.hero-actions {
  display: flex;
  gap: 16px;
  justify-content: flex-start;
}
@media (max-width: 992px) { .hero-actions { justify-content: center; } }

.hero-image img {
  width: 100%;
  height: auto;
  border-radius: var(--radius);
  max-width: 600px;
}

/* Steps */
.steps {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 24px; padding: 40px 0;
}
.step {
  text-align: center; padding: 32px 20px;
}
.step-num {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--primary); color: #fff; font-weight: 700; margin-bottom: 16px;
}
.step h3 { margin-bottom: 8px; }
.step p { color: var(--text-secondary); font-size: 0.9rem; }

/* Live feed */
.feed { padding: 40px 0; }
.feed h2 { text-align: center; margin-bottom: 24px; }
.feed-list { display: flex; flex-direction: column; gap: 12px; max-width: 700px; margin: 0 auto; }
.feed-item {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 20px;
  display: flex; justify-content: space-between; align-items: center;
}
.feed-outcome { font-size: 0.8rem; padding: 4px 10px; border-radius: 12px; font-weight: 500; }
.feed-outcome.high { background: #d1fae5; color: #065f46; }
.feed-outcome.moderate { background: #fef3c7; color: #92400e; }
.feed-outcome.low { background: #fee2e2; color: #991b1b; }

/* Dashboard layout */
.dashboard { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; padding: 24px 0; }
@media (max-width: 768px) { .dashboard { grid-template-columns: 1fr; } }

/* Poll form */
.poll-form textarea {
  width: 100%; min-height: 120px; padding: 16px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); font-family: var(--font); font-size: 0.95rem;
  resize: vertical; background: var(--bg); transition: all 0.2s;
}
.poll-form textarea:focus { outline: none; border-color: var(--primary); background: var(--surface); box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1); }
.form-group { margin-bottom: 20px; }
.form-group label { display: block; font-weight: 600; margin-bottom: 8px; font-size: 0.9rem; color: var(--text); }
.form-group input, .form-group select {
  width: 100%; padding: 12px 16px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); font-size: 0.95rem; background: var(--bg); transition: all 0.2s;
}
.form-group input:focus, .form-group select:focus { outline: none; border-color: var(--primary); background: var(--surface); box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1); }
.char-count { font-size: 0.8rem; color: var(--text-secondary); text-align: right; margin-top: 4px; }
.form-footer { display: flex; justify-content: space-between; align-items: center; margin-top: 16px; }

/* User info bar */
.user-bar {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 20px; padding-bottom: 16px; border-bottom: 1px solid var(--border);
}
.user-email { font-weight: 500; }
.balance-display { font-size: 0.9rem; color: var(--text-secondary); }
.balance-amount { font-weight: 600; color: var(--text); }

/* History list */
.history-list { display: flex; flex-direction: column; gap: 10px; }
.history-item {
  padding: 14px 16px; border: 1px solid var(--border); border-radius: var(--radius);
  display: flex; justify-content: space-between; align-items: center; cursor: pointer;
  transition: background 0.15s;
}
.history-item:hover { background: var(--bg); }
.history-summary { font-size: 0.9rem; flex: 1; margin-right: 12px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history-meta { font-size: 0.8rem; color: var(--text-secondary); white-space: nowrap; }

/* Result detail */
.result-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; padding: 24px 0; }
@media (max-width: 768px) { .result-layout { grid-template-columns: 1fr; } }
.result-header { padding: 24px 0 0; }
.result-header h1 { font-size: 1.5rem; }
.result-id { color: var(--text-secondary); font-family: var(--mono); font-size: 0.85rem; }

.confidence-badge {
  display: inline-block; padding: 4px 12px; border-radius: 12px;
  font-weight: 500; font-size: 0.85rem;
}
.confidence-badge.high { background: #d1fae5; color: #065f46; }
.confidence-badge.moderate { background: #fef3c7; color: #92400e; }
.confidence-badge.low { background: #fee2e2; color: #991b1b; }

.model-card {
  border: 1px solid rgba(226, 232, 240, 0.5); border-radius: var(--radius);
  padding: 24px; margin-bottom: 16px; box-shadow: var(--shadow); background: var(--surface);
}
.model-card h4 { font-size: 1.1rem; margin-bottom: 8px; font-family: var(--font-serif); color: var(--primary); }
.model-card p { font-size: 0.85rem; color: var(--text-secondary); white-space: pre-wrap; }
.model-meta { display: flex; gap: 16px; font-size: 0.8rem; color: var(--text-secondary); margin-top: 8px; }

/* Loading */
.loading { text-align: center; padding: 40px; color: var(--text-secondary); }
.spinner {
  display: inline-block; width: 24px; height: 24px; border: 3px solid var(--border);
  border-top-color: var(--primary); border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Pricing */
.pricing-card { max-width: 500px; margin: 40px auto; }
.pricing-card h2 { margin-bottom: 8px; }
.pricing-card .fee-note { color: var(--text-secondary); font-size: 0.9rem; margin-bottom: 20px; }
.pricing-breakdown { background: var(--bg); padding: 16px; border-radius: var(--radius); margin: 16px 0; font-size: 0.9rem; }
.pricing-breakdown div { display: flex; justify-content: space-between; padding: 4px 0; }
.pricing-breakdown .total { font-weight: 600; border-top: 1px solid var(--border); margin-top: 8px; padding-top: 8px; }

/* Footer */
.footer {
  border-top: 1px solid var(--border); padding: 24px 0; margin-top: 60px;
  text-align: center; font-size: 0.8rem; color: var(--text-secondary);
}
.footer a { color: var(--text-secondary); margin: 0 8px; }

/* Alert */
.alert {
  padding: 12px 16px; border-radius: var(--radius); margin-bottom: 16px; font-size: 0.9rem;
}
.alert-success { background: #d1fae5; color: #065f46; border: 1px solid #a7f3d0; }
.alert-error { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }

/* Option rows */
.option-row {
  display: flex; gap: 8px; align-items: center; margin-bottom: 8px;
}
.option-row .option-input { flex: 1; }
.btn-remove-option {
  padding: 6px 10px; font-size: 1rem; line-height: 1; color: var(--danger);
  border-color: var(--danger); background: transparent;
}
.btn-remove-option:disabled { opacity: 0.3; cursor: not-allowed; }

/* Tally bars */
.tally-row { margin-bottom: 10px; }
.tally-label { display: block; font-size: 0.9rem; font-weight: 500; margin-bottom: 4px; }
.tally-bar-bg {
  background: var(--bg); border: 1px solid var(--border); border-radius: 4px;
  height: 24px; overflow: hidden;
}
.tally-bar-fill {
  background: var(--primary); height: 100%; border-radius: 3px;
  transition: width 0.3s ease;
}
.tally-pct { font-size: 0.8rem; color: var(--text-secondary); margin-top: 2px; display: block; }

/* Winner / Tie badges */
.winner-badge {
  display: inline-block; padding: 4px 12px; border-radius: 12px;
  font-weight: 500; font-size: 0.85rem;
  background: #d1fae5; color: #065f46;
}
.tie-badge {
  display: inline-block; padding: 4px 12px; border-radius: 12px;
  font-weight: 500; font-size: 0.85rem;
  background: #fef3c7; color: #92400e;
}

/* Poll result animation */
.poll-result { animation: fadeIn 0.3s ease-in; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* ── Dark Mode ── */
html.dark {
  --bg: #0f172a;
  --surface: #1e293b;
  --border: #334155;
  --text: #f1f5f9;
  --text-secondary: #94a3b8;
  --accent: #1e293b;
  --shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.3), 0 8px 10px -6px rgba(0, 0, 0, 0.2);
  --shadow-lg: 0 20px 40px -5px rgba(0, 0, 0, 0.4), 0 10px 15px -5px rgba(0, 0, 0, 0.3);
}
html.dark .hero h1 { color: #f1f5f9; }

/* ── Visitor Mode Visibility ── */
body.mode-human [data-mode="agent"] { display: none !important; }
body.mode-agent [data-mode="human"] { display: none !important; }

/* ── Mode Toggle (pill slider) ── */
.mode-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 9999px;
  padding: 3px;
  cursor: pointer;
  font-size: 0.75rem;
  font-weight: 500;
  user-select: none;
}
html.dark .mode-toggle { background: #334155; border-color: #475569; }
.mode-toggle-option {
  padding: 4px 10px;
  border-radius: 9999px;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 4px;
  color: #64748b;
}
.mode-toggle-option.active {
  background: #fff;
  color: #0f172a;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
html.dark .mode-toggle-option.active { background: #1e293b; color: #f1f5f9; }

/* ── Theme Toggle Button ── */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid #e2e8f0;
  background: #fff;
  cursor: pointer;
  transition: all 0.2s;
  color: #64748b;
}
.theme-toggle:hover { background: #f1f5f9; color: #0f172a; }
html.dark .theme-toggle { border-color: #475569; background: #334155; color: #94a3b8; }
html.dark .theme-toggle:hover { background: #475569; color: #f1f5f9; }
.theme-toggle .icon-sun,
.theme-toggle .icon-moon { width: 18px; height: 18px; }
html.dark .theme-toggle .icon-sun { display: none; }
html:not(.dark) .theme-toggle .icon-moon { display: none; }

/* ── Callout Tooltip (points up at toggle) ── */
.visitor-toast {
  position: absolute;
  top: calc(100% + 12px);
  left: 50%;
  transform: translateX(-50%) translateY(8px);
  z-index: 100;
  width: max-content;
  max-width: 320px;
  background: linear-gradient(135deg, #6366f1, #8b5cf6, #a855f7);
  border: none;
  border-radius: 14px;
  padding: 12px 16px;
  box-shadow: 0 8px 30px rgba(99, 102, 241, 0.4), 0 2px 8px rgba(0,0,0,0.1);
  display: flex;
  align-items: center;
  gap: 10px;
  opacity: 0;
  transition: opacity 0.35s ease, transform 0.35s ease;
  pointer-events: none;
}
.visitor-toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
  animation: toast-pulse 2s ease-in-out 0.5s 2;
}
@keyframes toast-pulse {
  0%, 100% { box-shadow: 0 8px 30px rgba(99, 102, 241, 0.4), 0 2px 8px rgba(0,0,0,0.1); }
  50% { box-shadow: 0 8px 40px rgba(139, 92, 246, 0.6), 0 2px 12px rgba(0,0,0,0.15); }
}
html.dark .visitor-toast {
  background: linear-gradient(135deg, #7c3aed, #6d28d9, #5b21b6);
  box-shadow: 0 8px 30px rgba(124, 58, 237, 0.5), 0 2px 8px rgba(0,0,0,0.3);
}

/* Upward-pointing arrow */
.visitor-toast-arrow {
  position: absolute;
  top: -7px;
  left: 50%;
  transform: translateX(-50%);
  width: 14px;
  height: 14px;
  background: #6366f1;
  border-radius: 2px;
  clip-path: polygon(50% 0%, 100% 100%, 0% 100%);
}
html.dark .visitor-toast-arrow { background: #7c3aed; }

.visitor-toast-body {
  flex: 1;
  min-width: 0;
  font-size: 0.8rem;
  color: #fff;
  line-height: 1.4;
}
.visitor-toast-body strong {
  color: #fff;
  font-weight: 700;
  font-size: 0.85rem;
}
.visitor-toast-switch {
  display: inline;
  color: #fde68a;
  cursor: pointer;
  font-weight: 700;
  border-bottom: 2px solid rgba(253, 230, 138, 0.5);
  transition: border-color 0.2s;
  text-decoration: none;
}
.visitor-toast-switch:hover { border-color: #fde68a; }
.visitor-toast-dismiss {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,0.2);
  color: #fff;
  cursor: pointer;
  font-size: 0.85rem;
  line-height: 1;
  transition: all 0.15s;
}
.visitor-toast-dismiss:hover { background: rgba(255,255,255,0.35); }

/* Mobile: position below header full-width instead of anchored to toggle */
@media (max-width: 768px) {
  .visitor-toast {
    position: fixed;
    top: auto;
    bottom: 16px;
    left: 12px;
    right: 12px;
    transform: translateX(0) translateY(8px);
    max-width: none;
    width: auto;
  }
  .visitor-toast.visible {
    transform: translateX(0) translateY(0);
  }
  .visitor-toast-arrow { display: none; }
}
