/* =====================================================
   TRY YOUR PRIME — Design System
   Dark Luxury Editorial • Cormorant + Syne
   ===================================================== */

@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@0,300;0,400;0,500;0,600;1,300;1,400&family=Syne:wght@400;500;600;700;800&display=swap');

:root {
  --bg:          #0e0d0b;
  --surface:     #161512;
  --surface-2:   #1e1c18;
  --surface-3:   #252320;
  --border:      rgba(255, 248, 230, 0.07);
  --border-mid:  rgba(255, 248, 230, 0.13);
  --border-hi:   rgba(255, 248, 230, 0.22);

  --text:        #f2ece0;
  --text-muted:  #7d7668;
  --text-dim:    #4a4640;

  --accent:      #c9a55a;
  --accent-dim:  rgba(201, 165, 90, 0.10);
  --accent-glow: rgba(201, 165, 90, 0.20);

  --danger:      #d4706a;
  --danger-dim:  rgba(212, 112, 106, 0.10);
  --success:     #6ab48a;
  --success-dim: rgba(106, 180, 138, 0.10);
  --info:        #6b9fd4;

  --font-display: 'Cormorant Garamond', Georgia, serif;
  --font-ui:      'Syne', system-ui, sans-serif;

  --r-sm:  6px;
  --r-md:  12px;
  --r-lg:  18px;
  --r-xl:  28px;

  --shadow-sm:  0 1px 3px rgba(0,0,0,0.3);
  --shadow-md:  0 4px 16px rgba(0,0,0,0.4);
  --shadow-lg:  0 16px 48px rgba(0,0,0,0.5);

  --container: min(1240px, calc(100vw - 48px));
  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Grain overlay */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='1'/%3E%3C/svg%3E");
  background-size: 180px;
}

.container {
  width: var(--container);
  margin: 0 auto;
  position: relative;
  z-index: 1;
}

img { display: block; max-width: 100%; }

/* ── Typography ─────────────────────────────────────── */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: 400;
  letter-spacing: -0.01em;
  line-height: 1.1;
  color: var(--text);
}

h1 { font-size: clamp(2.4rem, 5.5vw, 5.5rem); font-weight: 300; }
h2 { font-size: clamp(1.8rem, 3.5vw, 3.5rem); font-weight: 300; }
h3 { font-size: 1.5rem; font-weight: 500; }

p { line-height: 1.7; }

.eyebrow {
  font-family: var(--font-ui);
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--accent);
}

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

/* ── Links & Buttons ────────────────────────────────── */
a { text-decoration: none; color: inherit; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 32px;
  border-radius: var(--r-sm);
  font-family: var(--font-ui);
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  border: none;
  transition: all var(--transition);
  white-space: nowrap;
}

.btn-primary {
  background: var(--accent);
  color: var(--bg);
}
.btn-primary:hover {
  background: #d9b86a;
  transform: translateY(-1px);
  box-shadow: 0 8px 24px rgba(201, 165, 90, 0.3);
}
.btn-primary:active { transform: translateY(0); }

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

.btn-outline {
  background: transparent;
  color: var(--accent);
  border: 1px solid rgba(201, 165, 90, 0.4);
}
.btn-outline:hover {
  background: var(--accent-dim);
  border-color: var(--accent);
}

/* ── Navigation ─────────────────────────────────────── */
.site-nav, .topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 28px 0;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(14, 13, 11, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

.logo, .brand {
  display: flex;
  align-items: center;
  gap: 14px;
  color: var(--text);
  font-family: var(--font-ui);
}

.logo-mark, .brand-mark {
  width: 38px;
  height: 38px;
  background: var(--accent);
  color: var(--bg);
  border-radius: var(--r-sm);
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 0.7rem;
  letter-spacing: 0.05em;
}

.logo-text {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
}

.brand-copy strong {
  display: block;
  font-size: 0.95rem;
  font-weight: 700;
}
.brand-copy small {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.nav-links, .topnav {
  display: flex;
  align-items: center;
  gap: 36px;
}

.nav-links a, .topnav a {
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  transition: color var(--transition);
}
.nav-links a:hover, .topnav a:hover { color: var(--text); }

.nav-cta {
  padding: 10px 22px;
  background: var(--accent) !important;
  color: var(--bg) !important;
  border-radius: var(--r-sm);
}
.nav-cta:hover { background: #d9b86a !important; }

.back-link {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  transition: color var(--transition);
}
.back-link:hover { color: var(--text); }

/* ── Cards ──────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  transition: border-color var(--transition);
}
.card:hover { border-color: var(--border-mid); }

.data-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 28px;
}

/* ── LANDING PAGE ───────────────────────────────────── */

/* Hero */
.hero {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 80px;
  align-items: center;
  padding: 100px 0 120px;
  min-height: calc(100vh - 95px);
}

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

.hero-eyebrow {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 32px;
}

.hero-eyebrow-line {
  width: 40px;
  height: 1px;
  background: var(--accent);
}

.hero h1 {
  margin-bottom: 28px;
  position: relative;
}

.hero h1 em {
  font-style: italic;
  color: var(--accent);
}

.hero-text {
  font-size: 1.05rem;
  color: var(--text-muted);
  margin-bottom: 48px;
  max-width: 520px;
  line-height: 1.8;
}

.hero-actions {
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}

.hero-sub {
  margin-top: 20px;
  display: flex;
  align-items: center;
  gap: 24px;
}

.hero-sub-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 500;
}

.hero-sub-dot {
  width: 5px;
  height: 5px;
  background: var(--success);
  border-radius: 50%;
}

/* Hero Panel / Bento */
.hero-panel {
  position: relative;
}

.bento-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px;
  background: var(--border);
  border-radius: var(--r-xl);
  overflow: hidden;
  border: 1px solid var(--border);
}

.bento-cell {
  background: var(--surface);
  padding: 28px;
  transition: background var(--transition);
}

.bento-cell:hover { background: var(--surface-2); }

.bento-span-2 { grid-column: span 2; }

.bento-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 28px;
  background: var(--surface);
  border-bottom: none;
}

.live-badge {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--success);
}

.live-dot {
  width: 6px;
  height: 6px;
  background: var(--success);
  border-radius: 50%;
  animation: livepulse 2s infinite;
}

@keyframes livepulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(106, 180, 138, 0.5); }
  50%       { opacity: 0.7; box-shadow: 0 0 0 4px rgba(106, 180, 138, 0); }
}

.score-ring-wrap {
  display: flex;
  align-items: center;
  gap: 20px;
}

.score-ring {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  border: 1.5px solid var(--border-hi);
  display: grid;
  place-items: center;
  position: relative;
}

.score-ring-accent {
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 1.5px solid transparent;
  border-top-color: var(--accent);
  border-right-color: var(--accent);
  transform: rotate(-30deg);
}

.score-ring-num {
  font-family: var(--font-display);
  font-size: 1.9rem;
  font-weight: 500;
  color: var(--text);
  line-height: 1;
}

.score-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.score-trend {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 500;
  color: var(--success);
}

.bento-metric-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.bento-metric-val {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 400;
  color: var(--text);
}

.bento-metric-val.danger { color: var(--danger); }

/* Horizontal rule for sections */
.section-rule {
  border: none;
  border-top: 1px solid var(--border);
  margin: 0;
}

/* Features Section */
.section {
  padding: 120px 0;
}

.section-head {
  margin-bottom: 72px;
}

.section-head .eyebrow {
  margin-bottom: 20px;
}

.section-head h2 {
  margin-bottom: 20px;
}

.section-head p {
  font-size: 1.05rem;
  color: var(--text-muted);
  max-width: 520px;
  line-height: 1.8;
}

.feature-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  overflow: hidden;
}

.feature-card {
  background: var(--surface);
  padding: 48px 40px;
  transition: background var(--transition);
}

.feature-card:hover { background: var(--surface-2); }

.feature-num {
  font-family: var(--font-display);
  font-size: 4rem;
  font-weight: 300;
  color: var(--text-dim);
  line-height: 1;
  margin-bottom: 32px;
  display: block;
}

.feature-card h3 {
  font-size: 1.4rem;
  margin-bottom: 16px;
  color: var(--text);
}

.feature-card p {
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.75;
}

/* CTA Band */
.cta-band {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 48px;
  padding: 80px;
  background: var(--surface-2);
  border: 1px solid var(--border-mid);
  border-radius: var(--r-xl);
  position: relative;
  overflow: hidden;
}

.cta-band::before {
  content: '';
  position: absolute;
  top: 0; right: 0;
  width: 400px; height: 400px;
  background: radial-gradient(circle, rgba(201,165,90,0.06) 0%, transparent 70%);
  pointer-events: none;
}

.cta-content .eyebrow { margin-bottom: 16px; }

.cta-content h2 {
  margin-bottom: 12px;
}

.cta-content p {
  color: var(--text-muted);
  font-size: 1rem;
}

/* ── CHAT / ASSESSMENT PAGE ─────────────────────────── */

.app-layout {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 24px;
  align-items: start;
  padding: 40px 0 60px;
  min-height: calc(100vh - 95px);
}

/* Chat Interface */
.chat-interface {
  display: flex;
  flex-direction: column;
  height: calc(100dvh - 175px);
  min-height: 600px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  overflow: hidden;
}

.chat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 28px 36px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}

.chat-title {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 500;
  margin-bottom: 4px;
  color: var(--text);
}

.chat-subtitle {
  font-size: 0.82rem;
  color: var(--text-muted);
  letter-spacing: 0.01em;
}

.progress-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 18px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 100px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
}

/* Chat Messages */
.chat-history {
  flex: 1;
  overflow-y: auto;
  padding: 36px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  scroll-behavior: smooth;
}

.chat-history::-webkit-scrollbar { width: 4px; }
.chat-history::-webkit-scrollbar-track { background: transparent; }
.chat-history::-webkit-scrollbar-thumb { background: var(--border-mid); border-radius: 4px; }

.chat-message {
  display: flex;
  gap: 14px;
  animation: msgIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

.chat-message.user {
  flex-direction: row-reverse;
}

.msg-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin-top: 2px;
}

.msg-avatar.ai-avatar {
  background: var(--accent-dim);
  border: 1px solid rgba(201, 165, 90, 0.25);
  color: var(--accent);
}

.msg-avatar.user-avatar {
  background: var(--surface-3);
  border: 1px solid var(--border-mid);
  color: var(--text-muted);
}

.chat-bubble {
  max-width: 78%;
  padding: 16px 22px;
  border-radius: 16px;
  font-size: 0.95rem;
  line-height: 1.6;
  word-wrap: break-word;
}

.chat-message.assistant .chat-bubble {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-bottom-left-radius: 4px;
}

.chat-message.user .chat-bubble {
  background: var(--accent);
  color: var(--bg);
  border-bottom-right-radius: 4px;
  font-weight: 500;
}

/* Typing Indicator */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 16px 22px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 16px;
  border-bottom-left-radius: 4px;
  width: fit-content;
  margin-left: 46px;
  animation: msgIn 0.3s ease;
}

.typing-indicator[hidden] { display: none; }

.dot {
  width: 7px;
  height: 7px;
  background: var(--text-muted);
  border-radius: 50%;
  animation: typingBounce 1.4s infinite;
}
.dot:nth-child(2) { animation-delay: 0.2s; }
.dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.35; }
  30%            { transform: translateY(-5px); opacity: 1; }
}

/* Chat Controls */
.chat-controls {
  flex-shrink: 0;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.quick-reply-wrapper {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 16px 28px 0;
  min-height: 0;
}

.quick-reply-wrapper:empty { display: none; }

.quick-reply {
  padding: 8px 18px;
  border-radius: 100px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--surface-2);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all var(--transition);
  font-family: var(--font-ui);
}

.quick-reply:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-dim);
}

.chat-input-area {
  display: flex;
  gap: 12px;
  padding: 20px 28px 24px;
}

#chatInput {
  flex: 1;
  padding: 14px 20px;
  border: 1px solid var(--border-mid);
  border-radius: 12px;
  font-family: var(--font-ui);
  font-size: 0.92rem;
  color: var(--text);
  background: var(--surface-2);
  outline: none;
  transition: border-color var(--transition);
}

#chatInput::placeholder { color: var(--text-dim); }

#chatInput:focus {
  border-color: rgba(201, 165, 90, 0.5);
  background: var(--surface-3);
}

.btn-primary-small {
  padding: 14px 26px;
  background: var(--accent);
  color: var(--bg);
  border: none;
  border-radius: 12px;
  font-family: var(--font-ui);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}

.btn-primary-small:hover {
  background: #d9b86a;
  transform: translateY(-1px);
}

.btn-primary-small:active { transform: translateY(0); }

.btn-cancel {
  padding: 14px 26px;
  background: #e74c3c;
  color: white;
  border: none;
  border-radius: 12px;
  font-family: var(--font-ui);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}

.btn-cancel:hover {
  background: #c0392b;
  transform: translateY(-1px);
}

.btn-cancel:active { transform: translateY(0); }

/* ── Analysis Panel ─────────────────────────────────── */
.analysis-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: sticky;
  top: calc(95px + 40px);
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.panel-header h3 {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 500;
  color: var(--text);
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
}

.status-indicator::before {
  content: '';
  display: block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  animation: livepulse 2s infinite;
}

.live-pulse { color: var(--success); }
.live-pulse::before { background: var(--success); }

.bento-stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.bento-main {
  position: relative;
  overflow: hidden;
}

.bento-main::before {
  content: '';
  position: absolute;
  top: 0; right: 0;
  width: 160px; height: 160px;
  background: radial-gradient(circle, var(--accent-glow) 0%, transparent 65%);
  pointer-events: none;
}

.data-label {
  display: block;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.data-value {
  display: block;
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 400;
  color: var(--text);
  line-height: 1.2;
  margin-bottom: 16px;
}

.text-red { color: var(--danger); }

.progress-bar-container {
  height: 3px;
  background: var(--border-mid);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 10px;
}

.progress-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.mt-3 { margin-top: 12px; }

.data-metric {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
}

.data-detail {
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.65;
  margin-top: 8px;
}

.bento-sub {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 22px 24px;
}

.bento-sub.warning {
  border-color: rgba(212, 112, 106, 0.2);
  background: rgba(212, 112, 106, 0.05);
}

.bento-sub.warning .data-label { color: var(--danger); opacity: 0.8; }

.bento-sub.highlight {
  border-color: rgba(107, 159, 212, 0.2);
  background: rgba(107, 159, 212, 0.04);
}

.bento-sub.highlight .data-label { color: var(--info); opacity: 0.8; }

/* ── Scroll Reveal Animation ────────────────────────── */
.reveal {
  opacity: 0;
  transform: translateY(30px);
  transition: opacity 0.7s ease, transform 0.7s ease;
}
.reveal.visible {
  opacity: 1;
  transform: translateY(0);
}

/* ── Scrollbar Global ───────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-mid); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-hi); }

/* ── Responsive ─────────────────────────────────────── */

/* Tablet landscape / small laptop */
@media (max-width: 1100px) {
  .app-layout {
    grid-template-columns: 1fr;
    padding: 28px 0 48px;
    min-height: unset;
  }
  .analysis-panel {
    position: static;
  }
  /* 3-col metrics row on tablet */
  .bento-stack {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
  }
  .chat-interface {
    height: 620px;
  }
}

/* Tablet portrait */
@media (max-width: 900px) {
  .hero {
    grid-template-columns: 1fr;
    padding: 64px 0 72px;
    gap: 40px;
    min-height: auto;
  }
  .section {
    padding: 80px 0;
  }
  .section-head {
    margin-bottom: 48px;
  }
  .feature-grid {
    grid-template-columns: 1fr;
  }
  .feature-card {
    padding: 36px 32px;
  }
  .cta-band {
    flex-direction: column;
    padding: 56px 40px;
    text-align: center;
  }
}

/* Large phone / small tablet — most critical breakpoint */
@media (max-width: 640px) {
  :root {
    --container: calc(100vw - 28px);
    --r-xl: 18px;
  }

  /* Tighter base type */
  h1 { font-size: clamp(2.1rem, 9vw, 3rem); }
  h2 { font-size: clamp(1.7rem, 7vw, 2.4rem); }
  h3 { font-size: 1.25rem; }

  /* Nav — hide text links, keep logo + CTA button only */
  .topbar, .site-nav {
    padding: 16px 0;
  }
  .topnav a:not(.nav-cta),
  .nav-links a:not(.back-link) {
    display: none;
  }
  .topnav, .nav-links { gap: 12px; }
  .back-link { font-size: 0.78rem; }

  /* Hero */
  .hero {
    padding: 44px 0 52px;
    gap: 36px;
  }
  .hero-text {
    font-size: 0.95rem;
    margin-bottom: 32px;
  }
  .hero-actions {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }
  .hero-actions .btn {
    width: 100%;
    justify-content: center;
    padding: 15px 24px;
  }
  /* Simplify bento panel on mobile — hide bulky ring, keep key stats */
  .hero-panel .bento-cell:has(.score-ring-wrap) {
    padding: 20px;
  }
  .score-ring-wrap { gap: 16px; }
  .score-ring { width: 56px; height: 56px; }
  .score-ring-num { font-size: 1.5rem; }
  .hero-sub { display: none; }

  /* Sections */
  .section { padding: 60px 0; }
  .section-head { margin-bottom: 32px; }
  .section-head p { font-size: 0.95rem; }

  /* Feature cards */
  .feature-card { padding: 28px 24px; }
  .feature-num { font-size: 3rem; margin-bottom: 20px; }

  /* CTA */
  .cta-band {
    padding: 36px 24px;
    gap: 24px;
    border-radius: var(--r-lg);
  }
  .cta-content h2 { font-size: 1.9rem; }

  /* Chat layout */
  .app-layout {
    padding: 16px 0 32px;
  }
  /* Stack analysis panel below chat on phone */
  .bento-stack {
    grid-template-columns: 1fr;
  }
  .chat-interface {
    /* Fill the available viewport height minus nav */
    height: calc(100dvh - 150px);
    min-height: 460px;
    border-radius: var(--r-lg);
  }
  .chat-header {
    padding: 16px 20px;
    gap: 12px;
  }
  .chat-title { font-size: 1.2rem; }
  .chat-subtitle { font-size: 0.76rem; }
  .progress-pill {
    padding: 6px 12px;
    font-size: 0.7rem;
    flex-shrink: 0;
  }
  .chat-history {
    padding: 18px 16px;
    gap: 14px;
  }
  .chat-message { gap: 10px; }
  .chat-bubble {
    max-width: 88%;
    padding: 12px 16px;
    font-size: 0.9rem;
  }
  .msg-avatar {
    width: 28px;
    height: 28px;
    font-size: 0.58rem;
  }
  .typing-indicator {
    margin-left: 38px;
    padding: 12px 16px;
  }
  .quick-reply-wrapper {
    padding: 10px 16px 0;
    gap: 6px;
  }
  .quick-reply {
    font-size: 0.78rem;
    padding: 7px 14px;
  }
  .chat-input-area {
    padding: 10px 16px 16px;
    flex-direction: row;
    gap: 8px;
  }
  #chatInput {
    padding: 12px 14px;
    font-size: 0.88rem;
  }
  .btn-primary-small {
    padding: 12px 18px;
    font-size: 0.78rem;
    white-space: nowrap;
    flex-shrink: 0;
  }

  /* Sidebar metrics */
  .analysis-panel { gap: 10px; }
  .panel-header h3 { font-size: 1.1rem; }
  .data-card { padding: 18px 20px; }
  .bento-sub { padding: 16px 18px; }
  .data-value { font-size: 1.1rem; }
}

/* Small phones (375px and under) */
@media (max-width: 400px) {
  :root { --container: calc(100vw - 20px); }

  .brand-copy small { display: none; }
  .hero { padding: 32px 0 44px; }

  .chat-interface {
    height: calc(100dvh - 130px);
    min-height: 420px;
  }
  /* Input row stays horizontal on tiny phones */
  .chat-input-area { flex-direction: row; }

  .cta-band { padding: 28px 20px; }
}