/* =======================================================================
   iamthegraytest — brand design system
   Grey base + one warm accent (Ember). Calm, spacious, grayscale-led.
   Dark mode is a first-class citizen, not an afterthought.
   ======================================================================= */

:root {
  --ink: #1C1E22;
  --slate: #3B3F46;
  --graphite: #6B6F76;
  --mist: #A8ACB3;
  --fog: #E4E6E9;
  --cloud: #F6F7F8;
  --ember: #F4795B;
  --ember-deep: #DA5E40;
  --white: #FFFFFF;

  --font-display: "Space Grotesk", "Inter", system-ui, sans-serif;
  --font-body: "Inter", system-ui, -apple-system, sans-serif;
  --font-pebble: "Nunito", "Quicksand", system-ui, sans-serif;

  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --radius-pill: 999px;

  --shadow-sm: 0 1px 2px rgba(28, 30, 34, 0.06), 0 1px 1px rgba(28, 30, 34, 0.04);
  --shadow-md: 0 8px 24px rgba(28, 30, 34, 0.08), 0 2px 6px rgba(28, 30, 34, 0.04);
  --shadow-lg: 0 20px 48px rgba(28, 30, 34, 0.16), 0 4px 12px rgba(28, 30, 34, 0.06);

  --transition-fast: 150ms cubic-bezier(.2,.8,.2,1);
  --transition-soft: 400ms cubic-bezier(.2,.8,.2,1);

  /* light theme (default) */
  --bg: var(--cloud);
  --bg-elevated: var(--white);
  --surface: var(--white);
  --surface-muted: var(--fog);
  --border: var(--fog);
  --text: var(--ink);
  --text-muted: var(--graphite);
  --text-faint: var(--mist);
  --accent: var(--ember);
  --accent-deep: var(--ember-deep);
  --accent-on: var(--white);
  --nav-bg: rgba(246, 247, 248, 0.85);
}

html[data-theme="dark"] {
  --bg: var(--ink);
  --bg-elevated: #23262B;
  --surface: #23262B;
  --surface-muted: #2C2F35;
  --border: #34383F;
  --text: var(--cloud);
  --text-muted: var(--mist);
  --text-faint: #6B6F76;
  --accent: var(--ember);
  --accent-deep: #ff9276;
  --accent-on: var(--ink);
  --nav-bg: rgba(28, 30, 34, 0.85);
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  transition: background var(--transition-soft), color var(--transition-soft);
  min-height: 100vh;
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.15;
  margin: 0 0 0.5em;
  letter-spacing: -0.01em;
}

p { margin: 0 0 1em; color: var(--text); }
a { color: inherit; text-decoration: none; }
.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); }

button { font-family: var(--font-body); cursor: pointer; }
input, textarea, select {
  font-family: var(--font-body);
  font-size: 1rem;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
}

/* layout helpers ------------------------------------------------------ */

.container {
  max-width: 1040px;
  margin: 0 auto;
  padding: 0 24px;
}
.container-narrow {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 24px;
}
.stack { display: flex; flex-direction: column; }
.row { display: flex; align-items: center; }
.gap-sm { gap: 8px; }
.gap-md { gap: 16px; }
.gap-lg { gap: 28px; }
.flex-1 { flex: 1; }
.text-center { text-align: center; }
.section { padding: 72px 0; }
.section-tight { padding: 40px 0; }
.hide { display: none !important; }

@media (max-width: 720px) {
  .section { padding: 48px 0; }
}

/* nav ------------------------------------------------------------------ */

.nav {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--nav-bg);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.nav-inner {
  max-width: 1040px;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.nav-links {
  display: flex;
  align-items: center;
  gap: 22px;
}
.nav-link {
  font-size: 0.95rem;
  color: var(--text-muted);
  font-weight: 500;
  transition: color var(--transition-fast);
}
.nav-link:hover, .nav-link.active { color: var(--text); }
.nav-actions { display: flex; align-items: center; gap: 10px; }

@media (max-width: 640px) {
  .nav-links { display: none; }
}

/* logo / wordmark -------------------------------------------------------- */

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text);
}
.wordmark { letter-spacing: -0.02em; }
.wordmark .gray {
  background: linear-gradient(90deg, var(--graphite), var(--mist));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.wordmark .dot-i { color: var(--accent); }

/* buttons ---------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 600;
  font-size: 0.95rem;
  border: none;
  border-radius: var(--radius-pill);
  padding: 12px 22px;
  transition: transform var(--transition-fast), background var(--transition-fast), box-shadow var(--transition-fast), opacity var(--transition-fast);
  white-space: nowrap;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  background: var(--accent);
  color: var(--accent-on);
  box-shadow: var(--shadow-sm);
}
.btn-primary:hover { background: var(--accent-deep); }

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

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.btn-ghost:hover { color: var(--text); border-color: var(--mist); }

.btn-sm { padding: 8px 16px; font-size: 0.85rem; }
.btn-lg { padding: 16px 30px; font-size: 1.05rem; }
.btn-block { width: 100%; }
.btn-icon {
  width: 40px; height: 40px; padding: 0; border-radius: 50%;
}

/* cards ------------------------------------------------------------------ */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  box-shadow: var(--shadow-sm);
}
.card-hover { transition: transform var(--transition-fast), box-shadow var(--transition-fast); }
.card-hover:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: var(--radius-pill);
  background: var(--surface-muted);
  color: var(--text-muted);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.badge-ember { background: rgba(244, 121, 91, 0.14); color: var(--ember-deep); }
html[data-theme="dark"] .badge-ember { color: #ffb39c; }

/* hero --------------------------------------------------------------- */

.hero {
  padding: 96px 0 64px;
  text-align: center;
}
.hero h1 {
  font-size: clamp(2.2rem, 5vw, 3.6rem);
  max-width: 820px;
  margin: 0 auto 18px;
}
.hero .lede {
  font-size: 1.15rem;
  color: var(--text-muted);
  max-width: 600px;
  margin: 0 auto 32px;
}
.hero-actions { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; }

.trust-strip {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 28px;
  margin-top: 44px;
  color: var(--text-faint);
  font-size: 0.85rem;
}
.trust-strip span { display: flex; align-items: center; gap: 6px; }

/* mode cards -------------------------------------------------------------- */

.mode-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}
@media (max-width: 820px) { .mode-grid { grid-template-columns: 1fr; } }

.mode-card {
  text-align: left;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--surface);
}
.mode-card .mode-emoji {
  width: 48px; height: 48px;
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem;
  background: var(--surface-muted);
  margin-bottom: 16px;
}
.mode-card h3 { margin-bottom: 6px; }
.mode-card p { color: var(--text-muted); font-size: 0.95rem; margin-bottom: 0; }
.mode-card.selected { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(244,121,91,0.18); }

/* onboarding chat --------------------------------------------------------- */

.chat-shell {
  display: flex;
  flex-direction: column;
  height: 100%;
}
.chat-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 24px 0 12px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.bubble {
  max-width: 78%;
  padding: 13px 17px;
  border-radius: var(--radius-md);
  font-size: 0.97rem;
  line-height: 1.5;
  box-shadow: var(--shadow-sm);
  animation: bubbleIn 280ms cubic-bezier(.2,.8,.2,1);
}
@keyframes bubbleIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
.bubble-bot {
  align-self: flex-start;
  background: var(--surface);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}
.bubble-user {
  align-self: flex-end;
  background: var(--accent);
  color: var(--accent-on);
  border-bottom-right-radius: 4px;
}
.bubble-system {
  align-self: center;
  background: transparent;
  color: var(--text-faint);
  font-size: 0.82rem;
  box-shadow: none;
  text-align: center;
}
.bubble-bot.has-voice {
  position: relative;
  padding-right: 36px;
}
.bubble-voice-btn {
  position: absolute;
  right: 6px;
  bottom: 6px;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: inherit;
  font-size: 0.78rem;
  line-height: 1;
  padding: 0;
  cursor: pointer;
  opacity: 0.55;
  transition: opacity 120ms ease, background 120ms ease;
}
.bubble-voice-btn:hover {
  opacity: 1;
  background: rgba(28, 30, 34, 0.08);
}
html[data-theme="dark"] .bubble-voice-btn:hover {
  background: rgba(255, 255, 255, 0.14);
}
.bubble-meta {
  font-size: 0.72rem;
  color: var(--text-faint);
  margin-top: 4px;
}

.composer {
  display: flex;
  gap: 10px;
  padding: 14px 0 6px;
  border-top: 1px solid var(--border);
}
.composer textarea, .composer input {
  flex: 1;
  border-radius: var(--radius-pill);
  padding: 12px 18px;
  resize: none;
  outline: none;
  border: 1px solid var(--border);
  background: var(--surface);
}
.composer textarea:focus, .composer input:focus { border-color: var(--mist); }

/* rehearsal screen --------------------------------------------------------- */

.rehearsal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
}
.character-id { display: flex; align-items: center; gap: 12px; }
.avatar {
  width: 46px; height: 46px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: white;
  font-family: var(--font-display);
  font-weight: 700;
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
}
.avatar-lg { width: 76px; height: 76px; font-size: 1.4rem; }
.character-id h3 { margin: 0; font-size: 1.05rem; }
.character-id .sub { font-size: 0.82rem; color: var(--text-muted); }

.rehearsal-body {
  display: flex;
  flex-direction: column;
  min-height: 60vh;
}

.typing-dots { display: inline-flex; gap: 3px; align-items: center; }
.typing-dots span {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--text-faint);
  animation: typingBlink 1.1s infinite ease-in-out;
}
.typing-dots span:nth-child(2) { animation-delay: 0.15s; }
.typing-dots span:nth-child(3) { animation-delay: 0.3s; }
@keyframes typingBlink { 0%, 80%, 100% { opacity: 0.25; } 40% { opacity: 1; } }

/* feedback card ------------------------------------------------------------ */

.feedback-card {
  border-radius: var(--radius-lg);
  padding: 36px;
  background: var(--surface);
  border: 1px solid var(--border);
}
.feedback-section { margin-bottom: 26px; }
.feedback-section h4 {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-faint);
  margin-bottom: 8px;
}
.feedback-section p { font-size: 1.05rem; margin-bottom: 0; }
.feedback-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  margin-top: 8px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}
.stat { text-align: center; }
.stat .num { font-family: var(--font-display); font-size: 1.4rem; font-weight: 700; }
.stat .label { font-size: 0.72rem; color: var(--text-faint); text-transform: uppercase; }

/* history ------------------------------------------------------------------- */

.history-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 18px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface);
  transition: box-shadow var(--transition-fast), transform var(--transition-fast);
}
.history-item:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.history-item .meta { flex: 1; }
.history-item .meta h4 { margin: 0 0 2px; font-size: 1rem; }
.history-item .meta .sub { font-size: 0.83rem; color: var(--text-muted); }

.empty-state {
  text-align: center;
  padding: 64px 20px;
  color: var(--text-muted);
}

/* pricing ------------------------------------------------------------------- */

.pricing-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  align-items: stretch;
}
@media (max-width: 860px) { .pricing-grid { grid-template-columns: 1fr; } }
.pricing-card { display: flex; flex-direction: column; }
.pricing-card.featured { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(244,121,91,0.16); }
.price { font-family: var(--font-display); font-size: 2.1rem; font-weight: 700; margin: 6px 0 18px; }
.price small { font-size: 0.95rem; color: var(--text-muted); font-weight: 500; }
.feature-list { list-style: none; padding: 0; margin: 0 0 24px; flex: 1; }
.feature-list li {
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.92rem;
  color: var(--text-muted);
  display: flex;
  gap: 8px;
}
.feature-list li:last-child { border-bottom: none; }

/* toast ----------------------------------------------------------------- */

.toast {
  position: fixed;
  bottom: 26px;
  left: 50%;
  transform: translateX(-50%) translateY(10px);
  background: var(--ink);
  color: var(--cloud);
  padding: 12px 20px;
  border-radius: var(--radius-pill);
  font-size: 0.88rem;
  box-shadow: var(--shadow-lg);
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity 220ms ease, transform 220ms ease;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); pointer-events: auto; }

/* =======================================================================
   PEBBLE — the companion mascot
   ======================================================================= */

.pebble-dock {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 150;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
}

.pebble-speech {
  font-family: var(--font-pebble);
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 12px 16px;
  border-radius: var(--radius-md);
  max-width: 230px;
  font-size: 0.92rem;
  box-shadow: var(--shadow-md);
  transform-origin: bottom right;
  animation: pebbleSpeechIn 260ms cubic-bezier(.2,.8,.2,1);
}
@keyframes pebbleSpeechIn {
  from { opacity: 0; transform: scale(0.92) translateY(6px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.pebble-btn {
  width: 68px;
  height: 68px;
  border: none;
  background: transparent;
  padding: 0;
  cursor: pointer;
  filter: drop-shadow(0 6px 16px rgba(28,30,34,0.18));
  transition: transform 120ms cubic-bezier(.3,1.4,.4,1);
}
.pebble-btn:active,
.pebble-btn.squeezing {
  transform: scaleX(1.18) scaleY(0.8);
}
.pebble-btn.breathing-anim {
  animation: pebbleBreathe 8s ease-in-out infinite;
}
@keyframes pebbleBreathe {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.22); }
}

.pebble-svg-body { transition: transform 120ms ease; }

.pebble-body {
  width: 100%;
  height: 100%;
  position: relative;
  border-radius: 50% 50% 48% 52% / 55% 52% 48% 45%;
  background: radial-gradient(circle at 32% 26%, var(--mist) 0%, var(--graphite) 68%);
  box-shadow: inset 0 -6px 10px rgba(28,30,34,0.18), inset 0 4px 8px rgba(255,255,255,0.25);
}
html[data-theme="dark"] .pebble-body {
  background: radial-gradient(circle at 32% 26%, #8a8e95 0%, var(--slate) 68%);
}
.pebble-eye {
  position: absolute;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ink);
  top: 42%;
}
.pebble-eye.left { left: 32%; }
.pebble-eye.right { left: 56%; }
.pebble-ember-heart {
  position: absolute;
  width: 9px;
  height: 9px;
  background: var(--ember);
  border-radius: 2px;
  transform: rotate(45deg);
  top: 58%;
  left: 60%;
  box-shadow: 0 0 6px rgba(244,121,91,0.7);
}
.pebble-btn.sm .pebble-eye { width: 4px; height: 4px; }
.pebble-btn.lg { width: 110px; height: 110px; }

.pebble-panel {
  position: fixed;
  inset: 0;
  background: rgba(28,30,34,0.45);
  z-index: 250;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 220ms ease;
}
.pebble-panel.open { opacity: 1; pointer-events: auto; }
.pebble-panel-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 32px;
  max-width: 380px;
  width: 100%;
  text-align: center;
  box-shadow: var(--shadow-lg);
  font-family: var(--font-pebble);
  transform: translateY(12px) scale(0.97);
  transition: transform 220ms cubic-bezier(.2,.8,.2,1);
}
.pebble-panel.open .pebble-panel-card { transform: translateY(0) scale(1); }
.pebble-panel-card h3 { font-family: var(--font-pebble); font-size: 1.2rem; }
.pebble-panel-card p { color: var(--text-muted); font-family: var(--font-pebble); }

.pebble-breath-circle {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, var(--mist), var(--graphite));
  margin: 18px auto 22px;
  animation: breathCircle 8s ease-in-out infinite;
}
@keyframes breathCircle {
  0%, 100% { transform: scale(0.75); opacity: 0.85; }
  50% { transform: scale(1.05); opacity: 1; }
}
.breath-caption {
  font-family: var(--font-pebble);
  font-weight: 600;
  color: var(--text-muted);
  min-height: 1.4em;
}

.crisis-panel { text-align: left; }
.crisis-panel h3 { text-align: center; }
.crisis-resource {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin-bottom: 10px;
  font-family: var(--font-body);
}
.crisis-resource .name { font-weight: 600; font-size: 0.92rem; }
.crisis-resource .num { font-size: 0.85rem; color: var(--text-muted); }

/* footer --------------------------------------------------------------- */

.footer {
  border-top: 1px solid var(--border);
  padding: 40px 0;
  color: var(--text-faint);
  font-size: 0.85rem;
}
.footer .row { justify-content: space-between; flex-wrap: wrap; gap: 12px; }

/* misc -------------------------------------------------------------------- */

.divider { height: 1px; background: var(--border); margin: 28px 0; border: none; }
.skeleton {
  background: linear-gradient(90deg, var(--surface-muted) 25%, var(--border) 37%, var(--surface-muted) 63%);
  background-size: 400% 100%;
  animation: skeletonShine 1.4s ease infinite;
  border-radius: var(--radius-sm);
}
@keyframes skeletonShine { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

.theme-toggle {
  width: 38px; height: 38px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted);
}

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; }
::-webkit-scrollbar-track { background: transparent; }

.field { margin-bottom: 18px; }
.field label {
  display: block;
  font-size: 0.85rem;
