/* ═══════════════════════════════════════════════════════════
   PreFi — Clarity Engine Prototype
   Chat-first layout · "Calm Confidence" design system
   ═══════════════════════════════════════════════════════════ */

:root {
  --color-bg: #F7F7F5;
  --color-surface: #FFFFFF;
  --color-primary: #1B2332;
  --color-secondary: #5A6478;
  --color-muted: #8E95A2;
  --color-accent: #9CA3AF;
  --color-accent-light: #F3F4F6;
  --color-border: #E5E7EB;
  --color-border-light: #F0F0EE;
  --color-archetype: #9CA3AF;
  --color-archetype-text: #1B2332;
  --color-glow: transparent;
  --glow-opacity: 0;

  --color-moment-bg: #FAFAF8;
  --color-moment-border: #E5E7EB;
  --color-moment-text: #6B7280;
  --color-moment-accent: #9CA3AF;

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --text-xs: 0.75rem;
  --text-sm: 0.8125rem;
  --text-base: 0.9375rem;
  --text-lg: 1.125rem;
  --text-xl: 1.375rem;
  --text-2xl: 1.75rem;
  --text-3xl: 2.25rem;

  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;

  --ease-standard: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-decelerate: cubic-bezier(0, 0, 0.2, 1);
  --ease-moment: cubic-bezier(0.25, 0.46, 0.45, 0.94);

  /* Multi-layer shadows instead of borders (per jakub.kr) */
  --shadow-border: 0px 0px 0px 1px rgba(0,0,0,0.06), 0px 1px 2px -1px rgba(0,0,0,0.06), 0px 2px 4px 0px rgba(0,0,0,0.04);
  --shadow-border-hover: 0px 0px 0px 1px rgba(0,0,0,0.08), 0px 2px 4px -1px rgba(0,0,0,0.08), 0px 4px 8px 0px rgba(0,0,0,0.05);
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.06);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.08);
  --shadow-moment: 0 8px 32px rgba(184,134,11,0.12);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
}

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: 16px; -webkit-font-smoothing: antialiased; }
body {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  color: var(--color-primary);
  background: var(--color-bg);
  line-height: 1.6;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
button { font-family: inherit; cursor: pointer; border: none; background: none; }
table { border-collapse: collapse; width: 100%; }


/* ── Color Progression ─────────────────────────────── */

.color-bg {
  position: fixed;
  width: 200%;
  height: 200%;
  top: -50%;
  left: -50%;
  pointer-events: none;
  z-index: 0;
  opacity: var(--grad-opacity, 0);
  animation: gradientDrift 60s linear infinite;
  transition: opacity 1500ms var(--ease-moment);
  will-change: transform, opacity;
}

.color-bg-inner {
  width: 100%;
  height: 100%;
  background:
    radial-gradient(circle at 30% 20%, var(--grad-1, transparent) 0%, transparent 50%),
    radial-gradient(circle at 70% 80%, var(--grad-2, transparent) 0%, transparent 50%),
    radial-gradient(circle at 80% 30%, var(--grad-3, transparent) 0%, transparent 40%),
    radial-gradient(circle at 20% 70%, var(--grad-4, transparent) 0%, transparent 40%);
  filter: blur(100px);
  will-change: transform, filter;
}

.color-bg-inner.burst {
  animation: milestoneBurst 1.8s var(--ease-moment) forwards;
}

@keyframes milestoneBurst {
  0% {
    transform: rotate(var(--burst-from, 0deg)) scale(1);
    filter: blur(100px);
  }
  40% {
    transform: rotate(var(--burst-to, 180deg)) scale(1.3);
    filter: blur(50px);
  }
  100% {
    transform: rotate(var(--burst-to, 180deg)) scale(1);
    filter: blur(100px);
  }
}

@keyframes gradientDrift {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.stage-bar,
.hero,
.app-layout,
.chat-container,
.input-area {
  position: relative;
  z-index: 1;
}

/* Header needs high z-index so settings dropdown paints above stage-bar, panels, etc */
.header {
  position: relative;
  z-index: 50;
}

body { transition: background-color 800ms var(--ease-moment); }
.chat-user { transition: background-color 600ms var(--ease-moment); }
.chat-label { transition: color 600ms var(--ease-moment); }
.system-dot { transition: background-color 600ms var(--ease-moment); }


/* ── Header ──────────────────────────────────────────── */

.header {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  padding: var(--space-sm) var(--space-lg);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  flex-shrink: 0;
  flex-wrap: wrap;
}

.header-left {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.logo {
  font-size: var(--text-xl);
  font-weight: 700;
  letter-spacing: -0.02em;
}

.header-subtitle {
  font-size: var(--text-xs);
  color: var(--color-muted);
  font-weight: 500;
}

.archetype-nav {
  display: flex;
  gap: var(--space-xs);
  flex-wrap: wrap;
}

.tab {
  padding: 5px 14px;
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--color-secondary);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 100px;
  transition: all 150ms var(--ease-standard);
  white-space: nowrap;
}
.tab:hover { border-color: var(--color-archetype); color: var(--color-primary); }
.tab:focus-visible { outline: 2px solid var(--color-archetype); outline-offset: 2px; }
.tab.active { background: var(--color-archetype); border-color: var(--color-archetype); color: var(--color-archetype-text); }


/* ── Stage Bar ───────────────────────────────────────── */

.stage-bar {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border-light);
  padding: var(--space-sm) var(--space-lg);
  display: flex;
  align-items: center;
  gap: var(--space-lg);
  flex-shrink: 0;
}

.stage-dots {
  display: flex;
  gap: 2px;
  flex-shrink: 0;
  position: relative;
  background: var(--color-border-light);
  border-radius: 100px;
  padding: 2px;
}

.stage-dot {
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--color-muted);
  padding: 3px 12px;
  border-radius: 100px;
  position: relative;
  z-index: 1;
  transition: color 300ms var(--ease-standard), font-weight 300ms;
}
.stage-dot[data-stage="arrive"] { cursor: pointer; }
.stage-dot[data-stage="arrive"]:hover { opacity: 0.7; }
.stage-dot.active {
  color: var(--color-archetype-text);
  font-weight: 600;
}
.stage-dot.done {
  color: var(--color-secondary);
  font-weight: 500;
}

/* Sliding pill behind active dot */
.stage-dots::after {
  content: '';
  position: absolute;
  top: 2px;
  bottom: 2px;
  left: var(--pill-left, 2px);
  width: var(--pill-width, 52px);
  background: var(--color-archetype);
  border-radius: 100px;
  transition: left 400ms var(--ease-moment), width 400ms var(--ease-moment);
  z-index: 0;
}

.stage-annotation {
  font-size: var(--text-xs);
  color: var(--color-muted);
  line-height: 1.4;
  flex: 1;
  min-width: 0;
}


/* ── Hero / Landing ──────────────────────────────────── */

.hero {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-2xl);
  transition: opacity 500ms var(--ease-moment), filter 400ms var(--ease-moment), transform 500ms var(--ease-moment);
}

.hero.exiting {
  opacity: 0;
  filter: blur(6px);
  transform: scale(0.98);
  pointer-events: none;
}

.hero.gone {
  display: none;
}

.hero-content {
  text-align: center;
  max-width: 560px;
  width: 100%;
  animation: heroIn 800ms var(--ease-moment) backwards;
}

.hero-title {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  color: var(--color-primary);
  margin-bottom: var(--space-sm);
  text-wrap: balance;
}

.hero-sub {
  font-size: var(--text-lg);
  color: var(--color-secondary);
  margin-bottom: var(--space-xl);
  font-weight: 400;
}

.hero-trust {
  font-size: var(--text-xs);
  color: var(--color-muted);
  margin-top: var(--space-xl);
  line-height: 1.5;
}

/* Address Search */
.address-search {
  position: relative;
  max-width: 480px;
  margin: 0 auto;
}

.address-input-wrap {
  display: flex;
  align-items: center;
  background: var(--color-surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-border), var(--shadow-md);
  padding: 0 var(--space-lg);
  transition: box-shadow 200ms var(--ease-standard);
}

.address-input-wrap:focus-within {
  box-shadow: var(--shadow-border-hover), var(--shadow-lg), 0 0 0 3px color-mix(in srgb, var(--color-archetype) 12%, transparent);
}

.address-icon {
  color: var(--color-muted);
  flex-shrink: 0;
  margin-right: var(--space-md);
}

.address-input {
  flex: 1;
  font-family: inherit;
  font-size: var(--text-base);
  padding: var(--space-md) 0;
  border: none;
  outline: none;
  background: transparent;
  color: var(--color-primary);
  min-height: 52px;
}
.address-input::placeholder { color: var(--color-muted); }

/* Suggestions dropdown */
.address-suggestions {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-border), var(--shadow-lg);
  list-style: none;
  overflow: hidden;
  opacity: 0;
  transform: translateY(-4px);
  pointer-events: none;
  transition: opacity 200ms var(--ease-standard), transform 200ms var(--ease-standard);
  z-index: 10;
}

.address-suggestions.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.address-suggestion {
  padding: var(--space-md) var(--space-lg);
  font-size: var(--text-sm);
  color: var(--color-primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: var(--space-md);
  transition: background 100ms;
}

.address-suggestion:hover,
.address-suggestion.highlighted {
  background: var(--color-bg);
}

.address-suggestion .sug-icon {
  color: var(--color-muted);
  flex-shrink: 0;
}

.address-suggestion .sug-main {
  font-weight: 500;
}

.address-suggestion .sug-secondary {
  color: var(--color-muted);
  font-weight: 400;
}

@keyframes heroIn {
  from { opacity: 0; filter: blur(5px); transform: translateY(12px); }
  to { opacity: 1; filter: blur(0); transform: translateY(0); }
}


/* ── App Layout (progressive multi-panel) ────────────── */

.app-layout {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: 1fr;
  overflow: hidden;
  position: relative;
  z-index: 1;
  transition: grid-template-columns 400ms var(--ease-standard);
  min-height: 0; /* allow children to scroll */
}

.app-layout.hidden { display: none; }

.app-layout.entering {
  display: grid;
  animation: chatEnter 600ms var(--ease-moment) backwards;
  animation-delay: 300ms;
}

/* Panel states — panels start hidden, slide in when .open */
.app-layout.has-about { grid-template-columns: 280px 1fr; }
.app-layout.has-scenarios { grid-template-columns: 1fr 320px; }
.app-layout.has-about.has-scenarios { grid-template-columns: 280px 1fr 320px; }


/* ── Side Panels ────────────────────────────────────── */

.side-panel {
  display: none;
  flex-direction: column;
  background: var(--color-surface);
  border-right: 1px solid var(--color-border);
  overflow-y: auto;
  animation: panelSlideIn 400ms var(--ease-decelerate) backwards;
}

.side-panel.open { display: flex; }

.panel-scenarios { border-right: none; border-left: 1px solid var(--color-border); }

.panel-head {
  padding: var(--space-md) var(--space-lg);
  border-bottom: 1px solid var(--color-border-light);
  font-size: var(--text-sm);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-muted);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}

.panel-close {
  font-size: 18px;
  color: var(--color-muted);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  line-height: 1;
  display: none; /* only on mobile */
}
.panel-close:hover { background: var(--color-border-light); }

.panel-body {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-md);
}

@keyframes panelSlideIn {
  from { opacity: 0; transform: translateX(-16px); }
  to   { opacity: 1; transform: translateX(0); }
}

.panel-scenarios.open {
  animation-name: panelSlideInRight;
}

@keyframes panelSlideInRight {
  from { opacity: 0; transform: translateX(16px); }
  to   { opacity: 1; transform: translateX(0); }
}


/* ── Panel content (AboutYou) ───────────────────────── */

/* Wire blocks — the card containers */
.wire-block {
  border: 1px solid #EEE;
  background: #FAFAFA;
  padding: 10px 12px;
  margin-bottom: 12px;
  animation: fadeIn 0.3s ease-out;
}

.wire-label {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #BBB;
  margin-bottom: 6px;
}

/* Wire rows — label/value pairs */
.wire-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 3px 0;
  font-size: var(--text-sm);
}

.wire-row-label { color: var(--color-muted); white-space: nowrap; }
.wire-row-val {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-align: right;
  display: flex;
  align-items: baseline;
  gap: 4px;
}

/* Tags — Est. and You said */
.wire-tag {
  font-size: 9px;
  padding: 1px 5px;
  border-radius: 3px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
  flex-shrink: 0;
}
.wire-tag.est { border: 1px solid #E5E5E5; color: #B0B0B0; background: transparent; }
.wire-tag.user { border: 1px solid var(--color-archetype); color: var(--color-archetype); background: transparent; }

/* Data accuracy bars */
.about-accuracy { margin-bottom: 14px; }
.data-accuracy {
  display: flex;
  gap: 3px;
  margin-bottom: 6px;
}
.accuracy-bar {
  flex: 1;
  height: 4px;
  border-radius: 2px;
  background: #EFEFEF;
  transition: background 300ms;
}
.accuracy-bar.estimated { background: #CCC; }
.accuracy-bar.confirmed { background: #1A1A1A; }
.accuracy-hint {
  font-size: 10px;
  color: #999;
  line-height: 1.4;
}

/* Property card with aerial view */
.prop-wire {
  border: 1px solid #EEE;
  background: #FFF;
  margin-bottom: 12px;
  overflow: hidden;
  animation: fadeIn 0.3s ease-out;
}

.aerial-view {
  height: 100px;
  position: relative;
  overflow: hidden;
  background: #EFEFEF;
}

/* Aerial video background */
.aerial-video {
  position: absolute;
  inset: -20px;
  width: calc(100% + 40px);
  height: calc(100% + 40px);
  object-fit: cover;
  filter: grayscale(1) contrast(1.1);
  transition: filter 0.6s;
}
.aerial-view:hover .aerial-video {
  filter: contrast(1.05);
}

/* Property data area below aerial */
.prop-data {
  padding: 10px 12px;
}
.prop-address {
  font-weight: 700;
  font-size: 14px;
  color: #1A1A1A;
}
.prop-city {
  font-size: 11px;
  color: #999;
  margin-bottom: 2px;
}
.prop-rows {
  margin-top: 8px;
}

/* Expand toggle button */
.prop-expand-btn {
  width: 100%;
  padding: 8px 0;
  margin-top: 8px;
  border: none;
  border-top: 1px solid #EEE;
  background: transparent;
  font-size: 10px;
  font-weight: 600;
  color: #999;
  cursor: pointer;
  font-family: inherit;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  transition: color 150ms;
}
.prop-expand-btn:hover { color: #666; }

/* Expandable property details */
.prop-details {
  max-height: 0;
  overflow: hidden;
  transition: max-height 350ms var(--ease-standard);
}
.prop-details.expanded {
  max-height: 600px;
}

.prop-section {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid #EEE;
}
.prop-section-label {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #BBB;
  margin-bottom: 4px;
}
.prop-attribution {
  font-size: 9px;
  color: #CCC;
  text-align: center;
  margin-top: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Empty state hint */
.about-hint {
  padding: 14px 12px;
  border: 1px dashed #DDD;
  font-size: 11px;
  color: #BBB;
  line-height: 1.5;
  text-align: center;
  margin-bottom: 12px;
}


/* ── Panel content (Scenarios) ──────────────────────── */

.sp-cards { display: flex; flex-direction: column; gap: var(--space-sm); }

.sp-card {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: border-color 200ms, box-shadow 200ms;
}
.sp-card:hover { box-shadow: var(--shadow-border-hover); }
.sp-card.expanded { border-color: var(--color-archetype); }

.sp-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-md);
  cursor: pointer;
  user-select: none;
}

.sp-collapsed-value {
  font-size: var(--text-sm);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--color-archetype);
  white-space: nowrap;
  margin-right: var(--space-sm);
  transition: opacity 200ms;
}
.sp-card.expanded .sp-collapsed-value { opacity: 0; width: 0; margin: 0; overflow: hidden; }

.sp-chevron {
  color: var(--color-muted);
  transition: transform 200ms var(--ease-standard);
  flex-shrink: 0;
}
.sp-card.expanded .sp-chevron { transform: rotate(180deg); }

.sp-card-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height 300ms var(--ease-standard);
  padding: 0 var(--space-md);
}
.sp-card.expanded .sp-card-body {
  max-height: 600px;
  padding: 0 var(--space-md) var(--space-md);
}

.sp-accordion-sliders {
  margin-top: var(--space-md);
  padding-top: var(--space-md);
  border-top: 1px solid var(--color-border-light);
}


/* ── Clarity Report ─────────────────────────────────── */

.clarity-report {
  animation: fadeIn 300ms var(--ease-decelerate);
}

.cr-header {
  font-size: var(--text-base);
  font-weight: 700;
  color: var(--color-primary);
  margin-bottom: 2px;
}

.cr-subtitle {
  font-size: var(--text-xs);
  color: var(--color-muted);
  margin-bottom: var(--space-lg);
}

.cr-section {
  margin-bottom: var(--space-md);
}

.cr-section-label {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-archetype);
  margin-bottom: var(--space-sm);
}

.cr-item {
  font-size: var(--text-sm);
  color: var(--color-secondary);
  padding: var(--space-sm) 0;
  border-bottom: 1px solid var(--color-border-light);
  line-height: 1.5;
  animation: crItemIn 400ms var(--ease-decelerate) backwards;
}
.cr-item:last-child { border-bottom: none; }

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

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

.sp-card-name { font-size: var(--text-sm); font-weight: 700; }
.sp-card-desc { font-size: var(--text-xs); color: var(--color-muted); margin-top: 2px; }

.sp-hero {
  text-align: center;
  padding: var(--space-md) 0;
  margin: var(--space-sm) 0;
  border: 1px dashed var(--color-border);
  border-radius: var(--radius-sm);
}

.sp-hero-label {
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-muted);
}

.sp-hero-value {
  font-size: var(--text-2xl);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  line-height: 1;
  margin: 2px 0;
}

.sp-hero-unit {
  font-size: var(--text-xs);
  color: var(--color-muted);
}

.sp-detail-row {
  display: flex;
  justify-content: space-between;
  padding: 3px 0;
  font-size: var(--text-xs);
  border-bottom: 1px solid var(--color-border-light);
}
.sp-detail-row:last-child { border-bottom: none; }
.sp-detail-label { color: var(--color-muted); }
.sp-detail-value { font-weight: 600; font-variant-numeric: tabular-nums; }

/* Panel sliders (full 4-slider set) */
.sp-sliders {
  margin-top: var(--space-lg);
  padding-top: var(--space-md);
  border-top: 1px solid var(--color-border-light);
}

.sp-slider-group { margin-bottom: var(--space-md); }
.sp-slider-group:last-child { margin-bottom: 0; }

.pin-toggle {
  font-size: 9px;
  font-weight: 600;
  padding: 1px 6px;
  border: 1px solid var(--color-border);
  border-radius: 3px;
  background: var(--color-surface);
  color: var(--color-muted);
  cursor: pointer;
  margin-left: 6px;
  font-family: inherit;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  transition: all 150ms;
}
.pin-toggle.pinned {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: white;
}


/* ── Mobile: edge pull tabs ──────────────────────────── */

.edge-tab {
  display: none; /* shown only on mobile via media query */
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  z-index: 25;
  background: var(--color-surface);
  padding: 10px 6px;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  color: var(--color-muted);
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  writing-mode: vertical-lr;
  box-shadow: var(--shadow-md);
  transition: all 200ms var(--ease-standard);
}

.edge-tab.hidden { display: none !important; }

.edge-tab-left {
  left: 0;
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  text-orientation: mixed;
}

.edge-tab-right {
  right: 0;
  border-radius: var(--radius-md) 0 0 var(--radius-md);
  text-orientation: mixed;
  transform: translateY(-50%) rotate(180deg);
}

.edge-tab-handle {
  width: 3px;
  height: 20px;
  border-radius: 2px;
  background: var(--color-border);
  margin: 4px 0;
}

.edge-tab-label {
  white-space: nowrap;
}

.edge-tab:hover {
  color: var(--color-archetype);
  box-shadow: var(--shadow-lg);
}

.edge-tab:active {
  transform: translateY(-50%) scale(0.95);
}
.edge-tab-right:active {
  transform: translateY(-50%) rotate(180deg) scale(0.95);
}

.drawer-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.3);
  z-index: 29;
}
.drawer-backdrop.visible { display: block; }

/* Mode toggle */
.mode-toggle {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: var(--text-xs);
  color: var(--color-muted);
  cursor: pointer;
}
.mode-toggle input { accent-color: var(--color-archetype); }
.mode-label { user-select: none; }


/* ── Chat Container ──────────────────────────────────── */

.chat-container {
  flex: 1;
  overflow-y: auto;
  scroll-behavior: smooth;
}

.chat-container.hidden {
  display: none;
}

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

.chat-disclosure {
  max-width: 720px;
  margin: 0 auto;
  padding: var(--space-sm) var(--space-lg);
  font-size: var(--text-xs);
  color: var(--color-muted);
  text-align: center;
  line-height: 1.4;
  opacity: 0;
  transition: opacity 400ms var(--ease-standard);
}
.chat-disclosure.visible {
  opacity: 1;
}

.chat-stream {
  max-width: 720px;
  margin: 0 auto;
  padding: var(--space-xl) var(--space-lg) 120px;
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}


/* ── Chat Bubbles ────────────────────────────────────── */

.chat-bubble {
  max-width: 85%;
  padding: var(--space-md) var(--space-lg);
  border-radius: var(--radius-lg);
  animation: bubbleIn 600ms var(--ease-moment) backwards;
}

.chat-prefi {
  align-self: flex-start;
  background: var(--color-surface);
  box-shadow: var(--shadow-border);
  border-bottom-left-radius: var(--radius-sm);
}

.chat-user {
  align-self: flex-end;
  background: var(--color-accent-light);
  box-shadow: var(--shadow-border);
  border-bottom-right-radius: var(--radius-sm);
}

.chat-label {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--color-archetype);
  display: block;
  margin-bottom: 4px;
}

.chat-text {
  font-size: var(--text-sm);
  line-height: 1.65;
  color: var(--color-primary);
  text-wrap: pretty;
}

.chat-user .chat-text {
  color: var(--color-primary);
}

/* Markdown inside chat — blends with chat style, no "document" feel */
.chat-md p { margin: 0; }
.chat-md p + p { margin-top: 0.5em; }
.chat-md strong { font-weight: 600; }
.chat-md em { font-style: italic; }
.chat-md ul, .chat-md ol {
  padding-left: 1.25em;
  margin: 0.35em 0;
}
.chat-md li { margin: 0.15em 0; }
.chat-md li::marker { color: var(--color-muted); }
.chat-md code {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 0.85em;
  background: var(--color-accent-light);
  padding: 1px 4px;
  border-radius: 3px;
  color: var(--color-secondary);
}
.chat-md pre {
  background: var(--color-accent-light);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-sm);
  overflow-x: auto;
  margin: 0.4em 0;
  font-size: 0.8em;
  line-height: 1.5;
}
.chat-md pre code {
  background: none;
  padding: 0;
  color: var(--color-primary);
}
.chat-md h1, .chat-md h2, .chat-md h3,
.chat-md h4, .chat-md h5, .chat-md h6 {
  font-size: inherit;
  font-weight: 600;
  margin: 0.5em 0 0.2em;
}
.chat-md blockquote {
  border-left: 2px solid var(--color-border);
  padding-left: var(--space-md);
  color: var(--color-secondary);
  margin: 0.35em 0;
}
.chat-md a {
  color: var(--color-archetype);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.chat-md hr {
  border: none;
  border-top: 1px solid var(--color-border-light);
  margin: 0.5em 0;
}

/* System messages */
.chat-system {
  align-self: center;
  font-size: var(--text-xs);
  color: var(--color-muted);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  animation: bubbleIn 300ms var(--ease-decelerate) backwards;
}

.system-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--color-archetype);
  animation: pulse 1.5s infinite;
}


/* ── Typing Indicator ────────────────────────────────── */

.typing-bubble { min-width: 80px; }

.typing-dots {
  display: flex;
  gap: 5px;
  padding: 4px 0;
}

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


/* ── Chat Blocks (inline UI) ─────────────────────────── */

.chat-block {
  align-self: stretch;
  animation: blockIn 800ms var(--ease-moment) backwards;
}


/* ── Property Card ───────────────────────────────────── */

.property-card {
  background: var(--color-surface);
  border-radius: var(--radius-xl);
  overflow: hidden;
  box-shadow: var(--shadow-border), var(--shadow-md);
}

.property-header {
  padding: var(--space-lg) var(--space-xl) var(--space-md);
  border-bottom: 1px solid var(--color-border-light);
}

.property-address {
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--color-primary);
}

.property-city {
  font-size: var(--text-sm);
  color: var(--color-secondary);
}

.property-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 1px;
  background: var(--color-border-light);
  padding: 1px;
}

.property-item {
  background: var(--color-surface);
  padding: var(--space-md) var(--space-lg);
  display: flex;
  flex-direction: column;
  gap: 2px;
  animation: blockIn 500ms var(--ease-moment) backwards;
  animation-delay: calc(var(--i, 0) * 80ms);
}

.property-item.highlight {
  background: var(--color-accent-light);
}

.prop-label {
  font-size: var(--text-xs);
  color: var(--color-muted);
  font-weight: 500;
}

.prop-value {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-primary);
  font-variant-numeric: tabular-nums;
}

.property-footer {
  padding: var(--space-sm) var(--space-xl);
  background: var(--color-bg);
}

.rate-badge {
  font-size: 10px;
  color: var(--color-muted);
  letter-spacing: 0.01em;
}


/* ── Scenario Block ──────────────────────────────────── */

.scenario-block {
  transition: opacity 500ms var(--ease-moment), filter 500ms var(--ease-moment);
}

.scenarios-row {
  display: flex;
  gap: var(--space-md);
  margin-bottom: var(--space-md);
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  padding-bottom: var(--space-xs); /* space for scroll shadow */
}
.scenarios-row::-webkit-scrollbar { display: none; }
.scenarios-row > .scenario-card {
  min-width: 200px;
  flex: 1 0 0;
}

.scenario-card {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  box-shadow: var(--shadow-border);
  transition: box-shadow 200ms var(--ease-standard);
  animation: blockIn 600ms var(--ease-moment) backwards;
  animation-delay: calc(var(--i, 0) * 100ms);
}
.scenario-card:hover { box-shadow: var(--shadow-border-hover); }

.sc-color-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: middle;
  flex-shrink: 0;
}

.sc-color-bar {
  height: 3px;
  border-radius: 2px;
  margin-bottom: var(--space-sm);
}

.sc-name { font-size: var(--text-base); font-weight: 600; margin-bottom: var(--space-xs); display: flex; align-items: center; }
.sc-desc { font-size: var(--text-sm); color: var(--color-muted); margin-bottom: var(--space-md); }
.sc-payment { font-size: var(--text-xl); font-weight: 700; font-variant-numeric: tabular-nums; }
.sc-per { font-size: var(--text-sm); font-weight: 400; color: var(--color-muted); }
.sc-delta { font-size: var(--text-sm); font-weight: 600; margin-top: var(--space-xs); font-variant-numeric: tabular-nums; }
.sc-delta.saves { color: #2B8A6B; }
.sc-delta.costs { color: #B54A4A; }
.sc-delta.uncertain { color: var(--color-muted); }
.sc-delta.neutral { color: var(--color-muted); }


/* ── Visualization Wrapper ───────────────────────────── */

.viz-wrapper {
  display: grid;
  grid-template: 1fr / 1fr;
  min-height: 200px;
}

.chart-area, .simplified-area {
  grid-area: 1 / 1;
  background: var(--color-surface);
  box-shadow: var(--shadow-border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  transition: opacity 400ms var(--ease-standard);
}
.chart-area { opacity: 1; }
.simplified-area { opacity: 0; pointer-events: none; display: flex; align-items: center; justify-content: center; }


/* ── Doc Reference Annotations ───────────────────────── */

.doc-ref-highlight {
  outline: 2px dashed rgba(59, 130, 246, 0.4);
  outline-offset: 3px;
  border-radius: var(--radius-sm);
}

/* Doc ref: small "i" icon, click to expand a tooltip */
.doc-ref-badge {
  z-index: 100;
  width: 20px;
  height: 20px;
  background: #3B82F6;
  color: white;
  border-radius: 50%;
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
  animation: badgeIn 300ms var(--ease-decelerate) backwards;
  transition: transform 200ms var(--ease-standard);
  pointer-events: auto;
}

.doc-ref-badge:hover {
  transform: scale(1.15);
}

.doc-ref-icon {
  font-size: 10px;
  font-style: italic;
  line-height: 1;
}

/* Tooltip: hidden by default, shown on expand */
.doc-ref-tooltip {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 6px;
  width: 260px;
  background: #1E293B;
  border-radius: var(--radius-md);
  padding: var(--space-sm) var(--space-md);
  box-shadow: 0 8px 24px rgba(0,0,0,0.25);
  pointer-events: auto;
}

.doc-ref-badge.expanded .doc-ref-tooltip {
  display: block;
  animation: tooltipIn 200ms var(--ease-decelerate);
}

.doc-ref-badge.expanded .doc-ref-icon { display: none; }
.doc-ref-badge.expanded {
  background: #2563EB;
}

.doc-ref-tag {
  font-weight: 700;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #60A5FA;
  margin-bottom: 4px;
  white-space: nowrap;
}

.doc-ref-text {
  color: #CBD5E1;
  font-size: 11px;
  line-height: 1.5;
}

@keyframes badgeIn {
  from { opacity: 0; transform: scale(0.5); }
  to   { opacity: 1; transform: scale(1); }
}

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


/* ── Suggestion Chips ───────────────────────────────── */

/* Sits inside .input-field, same width as the textarea */
.suggestion-chips {
  width: 100%;
  padding: var(--space-xs) 0;
  overflow: hidden;
  z-index: 2;
  mask-image: linear-gradient(to right, transparent 0%, black 16px, black calc(100% - 16px), transparent 100%);
  -webkit-mask-image: linear-gradient(to right, transparent 0%, black 16px, black calc(100% - 16px), transparent 100%);
}

.suggestion-chips-track {
  display: flex;
  width: max-content;
  animation: chipScroll var(--chip-duration, 12s) linear infinite;
}

.suggestion-chips:hover .suggestion-chips-track {
  animation-play-state: paused;
}

/* Each chip has its own right margin to maintain consistent spacing,
   including between the last item of set 1 and first item of set 2 */
.suggestion-chip {
  margin-right: var(--space-sm);
}

@keyframes chipScroll {
  0% { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}

.suggestion-chip {
  font-family: inherit;
  font-size: var(--text-xs);
  color: var(--color-archetype);
  background: var(--color-accent-light);
  border: 1px solid transparent;
  border-radius: 20px;
  padding: 6px 14px;
  cursor: pointer;
  transition: all 200ms var(--ease-standard);
  white-space: nowrap;
}

.suggestion-chip:hover {
  background: var(--color-surface);
  border-color: var(--color-archetype);
}

.suggestion-chip:active {
  transform: scale(0.96);
}

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

/* ── Settings Dropdown ───────────────────────────────── */

.settings-anchor {
  position: relative;
  margin-left: var(--space-md);
}

.settings-btn {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-muted);
  transition: color 200ms, background 200ms;
}
.settings-btn:hover { color: var(--color-primary); background: var(--color-border-light); }

.settings-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  width: 320px;
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 32px rgba(0,0,0,0.15);
  z-index: 200;
  padding: var(--space-md);
  animation: settingsIn 200ms var(--ease-decelerate);
}

.settings-dropdown.open { display: block; }

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

.settings-section {
  margin-bottom: var(--space-md);
  padding-bottom: var(--space-md);
  border-bottom: 1px solid var(--color-border-light);
}
.settings-section:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }

.settings-label {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-muted);
  margin-bottom: var(--space-sm);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.settings-link {
  font-size: 9px;
  color: var(--color-archetype);
  text-transform: none;
  letter-spacing: normal;
  font-weight: 500;
}
.settings-link:hover { text-decoration: underline; }

.settings-toggle {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: var(--text-xs);
  color: var(--color-secondary);
  cursor: pointer;
  padding: 3px 0;
}
.settings-toggle input { accent-color: var(--color-archetype); }

.settings-input {
  width: 100%;
  font-family: inherit;
  font-size: var(--text-xs);
  padding: 6px var(--space-sm);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-bg);
  color: var(--color-primary);
  outline: none;
  margin-bottom: var(--space-sm);
}
.settings-input:focus { border-color: var(--color-archetype); }
.settings-input[type="text"] { font-family: var(--font-sans); }

.settings-select {
  width: 100%;
  font-family: inherit;
  font-size: var(--text-xs);
  padding: 6px var(--space-sm);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-bg);
  color: var(--color-primary);
  outline: none;
  margin-bottom: var(--space-sm);
  cursor: pointer;
}

.settings-custom-model {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  position: relative;
}

.settings-model-results {
  list-style: none;
  max-height: 180px;
  overflow-y: auto;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  box-shadow: var(--shadow-md);
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 10;
}

.settings-model-result {
  padding: 5px var(--space-sm);
  cursor: pointer;
  border-bottom: 1px solid var(--color-border-light);
  transition: background 100ms;
}
.settings-model-result:last-child { border-bottom: none; }
.settings-model-result:hover { background: var(--color-bg); }

.smr-name {
  font-size: var(--text-xs);
  font-weight: 500;
  display: block;
}
.smr-meta {
  font-size: 10px;
  color: var(--color-muted);
  display: block;
}

.settings-or-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 10px;
  color: var(--color-muted);
  text-decoration: none;
  padding: 2px 0;
  transition: color 150ms;
}
.settings-or-link:hover { color: var(--color-primary); }
.settings-or-link img { border-radius: 2px; }

.settings-prompt-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: 8px var(--space-md);
  font-family: inherit;
  font-size: var(--text-xs);
  color: var(--color-secondary);
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 150ms;
}
.settings-prompt-btn:hover { border-color: var(--color-archetype); color: var(--color-primary); }

/* Prompt Editor Modal */
.prompt-editor-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 500;
  align-items: center;
  justify-content: center;
  padding: var(--space-xl);
}
.prompt-editor-overlay.open {
  display: flex;
  animation: fadeIn 200ms var(--ease-decelerate);
}

.prompt-editor {
  width: 100%;
  max-width: 1000px;
  height: 80vh;
  background: var(--color-surface);
  border-radius: var(--radius-xl);
  box-shadow: 0 16px 48px rgba(0,0,0,0.2);
  display: flex;
  flex-direction: column;
  animation: settingsIn 250ms var(--ease-decelerate);
}

.prompt-editor-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-md) var(--space-lg);
  border-bottom: 1px solid var(--color-border-light);
  flex-shrink: 0;
}

.prompt-editor-title {
  font-size: var(--text-sm);
  font-weight: 700;
}

.prompt-editor-actions {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.prompt-editor-save {
  font-family: inherit;
  font-size: var(--text-xs);
  font-weight: 600;
  padding: 5px 14px;
  background: var(--color-archetype);
  color: var(--color-archetype-text);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: opacity 150ms;
}
.prompt-editor-save:hover { opacity: 0.85; }

.prompt-editor-close {
  font-size: 20px;
  color: var(--color-muted);
  padding: 2px 6px;
  line-height: 1;
  border-radius: var(--radius-sm);
}
.prompt-editor-close:hover { background: var(--color-border-light); }

/* Source toggle (Default / Yours) */
.prompt-source-toggle {
  display: flex;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.pst-btn {
  font-family: inherit;
  font-size: 10px;
  font-weight: 600;
  padding: 3px 10px;
  background: var(--color-bg);
  color: var(--color-muted);
  border: none;
  cursor: pointer;
  transition: all 150ms;
}
.pst-btn:not(:last-child) { border-right: 1px solid var(--color-border); }
.pst-btn.active {
  background: var(--color-primary);
  color: white;
}
.pst-btn:not(.active):hover { color: var(--color-primary); }

/* "Yours" dot — shows when a custom prompt is saved */
.pst-btn .pst-dot {
  display: inline-block;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--color-archetype);
  margin-left: 4px;
  vertical-align: middle;
}

/* "in use" label inside source tab */
.pst-in-use {
  font-size: 8px;
  font-weight: 400;
  text-transform: lowercase;
  letter-spacing: 0;
  opacity: 0.6;
  margin-left: 3px;
}

/* Edit/Preview toggle */
.prompt-view-toggle {
  display: flex;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.pvt-btn {
  font-family: inherit;
  font-size: 10px;
  font-weight: 600;
  padding: 3px 10px;
  background: var(--color-bg);
  color: var(--color-muted);
  border: none;
  cursor: pointer;
  transition: all 150ms;
}
.pvt-btn:not(:last-child) { border-right: 1px solid var(--color-border); }
.pvt-btn.active {
  background: var(--color-primary);
  color: white;
}

.prompt-editor-textarea {
  flex: 1;
  width: 100%;
  font-family: monospace;
  font-size: 12px;
  padding: var(--space-lg);
  border: none;
  outline: none;
  resize: none;
  background: var(--color-bg);
  color: var(--color-primary);
  line-height: 1.6;
  min-height: 0;
  overflow-y: auto;
}

.prompt-editor-preview {
  display: none;
  flex: 1;
  width: 100%;
  padding: var(--space-lg);
  background: var(--color-bg);
  overflow-y: auto;
  font-size: 13px;
  line-height: 1.7;
  color: var(--color-primary);
  min-height: 0;
}

.prompt-editor-preview h1,
.prompt-editor-preview h2,
.prompt-editor-preview h3 { margin: 1em 0 0.5em; font-weight: 700; }
.prompt-editor-preview h1 { font-size: 18px; }
.prompt-editor-preview h2 { font-size: 15px; }
.prompt-editor-preview h3 { font-size: 13px; }
.prompt-editor-preview p { margin: 0.5em 0; }
.prompt-editor-preview ul, .prompt-editor-preview ol { padding-left: 1.5em; margin: 0.5em 0; }
.prompt-editor-preview li { margin: 0.25em 0; }
.prompt-editor-preview code {
  font-family: monospace;
  font-size: 11px;
  background: var(--color-border-light);
  padding: 1px 4px;
  border-radius: 3px;
}
.prompt-editor-preview pre {
  background: var(--color-border-light);
  padding: var(--space-md);
  border-radius: var(--radius-sm);
  overflow-x: auto;
  font-size: 11px;
  line-height: 1.5;
  margin: 0.5em 0;
}
.prompt-editor-preview pre code { background: none; padding: 0; }
.prompt-editor-preview strong { font-weight: 700; }
.prompt-editor-preview em { font-style: italic; }

.prompt-editor-footer {
  padding: var(--space-sm) var(--space-lg);
  border-top: 1px solid var(--color-border-light);
  font-size: var(--text-xs);
  color: var(--color-muted);
  flex-shrink: 0;
}


/* ── Amortization Curve Chart ────────────────────────── */

.amort-chart-wrap {
  padding: var(--space-sm) 0;
}

.amort-label {
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-muted);
  margin-bottom: var(--space-sm);
}

.amort-svg {
  width: 100%;
  height: auto;
  display: block;
}

.amort-line {
  transition: d 400ms var(--ease-standard);
  vector-effect: non-scaling-stroke;
}


/* ── Simplified View ─────────────────────────────────── */

.simplified { text-align: center; }
.simp-nums { display: flex; align-items: baseline; justify-content: center; gap: var(--space-md); margin-bottom: var(--space-sm); }
.simp-before { font-size: var(--text-2xl); font-weight: 400; color: var(--color-muted); text-decoration: line-through; text-decoration-color: rgba(0,0,0,0.15); font-variant-numeric: tabular-nums; }
.simp-arrow { font-size: var(--text-xl); color: var(--color-muted); }
.simp-after { font-size: var(--text-3xl); font-weight: 700; color: var(--color-archetype); font-variant-numeric: tabular-nums; }
.simp-delta { font-size: var(--text-xl); font-weight: 600; color: var(--color-archetype); margin-bottom: var(--space-xs); font-variant-numeric: tabular-nums; }
.simp-label { font-size: var(--text-base); color: var(--color-secondary); }


/* ── Analogy Card ────────────────────────────────────── */

.analogy-card {
  background: var(--color-moment-bg);
  border: 1px solid var(--color-moment-border);
  border-radius: var(--radius-xl);
  padding: var(--space-xl) var(--space-2xl);
  box-shadow: var(--shadow-moment);
  text-align: center;
}

.analogy-icon { font-size: var(--text-xl); color: var(--color-moment-accent); margin-bottom: var(--space-md); }

.analogy-text {
  font-size: var(--text-lg);
  line-height: 1.7;
  color: var(--color-moment-text);
  font-weight: 450;
  max-width: 520px;
  margin: 0 auto var(--space-lg);
  transition: opacity 200ms var(--ease-standard);
  text-wrap: balance;
}

.analogy-cta {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-moment-accent);
  padding: var(--space-sm) var(--space-md);
  border-radius: 100px;
  border: 1px solid var(--color-moment-border);
  background: rgba(184,134,11,0.06);
  transition: all 200ms var(--ease-standard);
}
.analogy-cta:hover { background: rgba(184,134,11,0.12); border-color: var(--color-moment-accent); }
.analogy-cta:focus-visible { outline: 2px solid var(--color-moment-accent); outline-offset: 2px; }

.analogy-recovery {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs);
  justify-content: center;
}

.recovery-option {
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--color-muted);
  padding: var(--space-xs) var(--space-md);
  border-radius: 100px;
  border: 1px solid var(--color-border);
  background: transparent;
  transition: all 200ms var(--ease-standard);
  cursor: pointer;
}
.recovery-option:hover {
  color: var(--color-primary);
  border-color: var(--color-secondary);
  background: rgba(0,0,0,0.03);
}

/* ── Moment Detection Cue ──────────────────────────── */

.moment-cue {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-md) var(--space-lg);
  background: rgba(184,134,11,0.06);
  border: 1px solid var(--color-moment-border);
  border-radius: var(--radius-lg);
  color: var(--color-moment-accent);
  font-size: var(--text-sm);
  font-weight: 500;
  animation: momentCueFadeIn 600ms var(--ease-decelerate) both;
}

.moment-cue-icon {
  font-size: var(--text-lg);
  flex-shrink: 0;
}

.moment-cue.fading-out {
  opacity: 0;
  transition: opacity 400ms var(--ease-standard);
}

@keyframes momentCueFadeIn {
  from { opacity: 0; transform: translateY(8px); filter: blur(4px); }
  to { opacity: 1; transform: translateY(0); filter: blur(0); }
}


/* ── Benefit Reveal ─────────────────────────────────── */

.benefit-cascade {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.benefit-card {
  display: flex;
  gap: var(--space-md);
  align-items: flex-start;
  background: var(--color-surface);
  border-radius: var(--radius-md);
  padding: var(--space-md) var(--space-lg);
  box-shadow: var(--shadow-border);
  animation: benefitIn 600ms var(--ease-moment) backwards;
}

.ben-amount {
  font-size: var(--text-lg);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--color-archetype);
  white-space: nowrap;
  min-width: 100px;
}

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

.ben-label {
  font-size: var(--text-sm);
  font-weight: 600;
  margin-bottom: 2px;
}

.ben-explanation {
  font-size: var(--text-sm);
  color: var(--color-secondary);
  margin-bottom: 4px;
}

.ben-source {
  font-size: var(--text-xs);
  color: var(--color-muted);
  font-style: italic;
}

@keyframes benefitIn {
  from { opacity: 0; transform: translateY(8px); filter: blur(4px); }
  to   { opacity: 1; transform: translateY(0);   filter: blur(0); }
}


/* ── Scenario Card Sliders ─────────────────────────── */

.sc-sliders {
  margin-top: var(--space-md);
  padding-top: var(--space-md);
  border-top: 1px solid var(--color-border-light);
}

.slider-row {
  margin-bottom: var(--space-sm);
}
.slider-row:last-child { margin-bottom: 0; }

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

.sl-name {
  font-size: var(--text-xs);
  color: var(--color-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.sl-val {
  font-size: var(--text-sm);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.slider-range {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: var(--color-muted);
  margin-top: 2px;
}

/* Custom range input — matches prefiproto style */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  border-radius: 2px;
  background: #DDD;
  outline: none;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--color-surface);
  border: 2px solid var(--color-primary);
  cursor: pointer;
  transition: border-color 150ms;
}

input[type="range"]::-webkit-slider-thumb:hover {
  border-color: var(--color-archetype);
}

input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--color-surface);
  border: 2px solid var(--color-primary);
  cursor: pointer;
}

/* WCAG: 44px touch target for mobile */
@media (max-width: 600px) {
  input[type="range"]::-webkit-slider-thumb {
    width: 22px;
    height: 22px;
  }
  input[type="range"]::-moz-range-thumb {
    width: 22px;
    height: 22px;
  }
}


/* ── Summary Card ───────────────────────────────────── */

.summary-card {
  background: var(--color-surface);
  border-radius: var(--radius-xl);
  padding: var(--space-xl) var(--space-2xl);
  box-shadow: var(--shadow-md);
  animation: blockIn 600ms var(--ease-moment) backwards;
}

.summary-header {
  font-size: var(--text-base);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-archetype);
  margin-bottom: var(--space-lg);
  padding-bottom: var(--space-sm);
  border-bottom: 2px solid var(--color-border-light);
}

.summary-section {
  margin-bottom: var(--space-md);
}

.summary-label {
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-muted);
  margin-bottom: 4px;
}

.summary-value {
  font-size: var(--text-base);
  color: var(--color-primary);
  line-height: 1.5;
}

.summary-next {
  margin-top: var(--space-lg);
  padding-top: var(--space-md);
  border-top: 1px solid var(--color-border-light);
  font-size: var(--text-sm);
  color: var(--color-secondary);
  line-height: 1.6;
}

/* Clarity Package enhancements */
.clarity-package {
  border: 1px solid var(--color-moment-border);
  background: var(--color-moment-bg);
}

.clarity-package .summary-header {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  border-bottom-color: var(--color-moment-border);
}

.summary-icon {
  color: var(--color-moment-accent);
}

.summary-divider {
  height: 1px;
  background: var(--color-moment-border);
  margin: var(--space-md) 0;
}

.summary-unknowns {
  list-style: none;
  padding: 0;
  margin: 0;
}

.summary-unknowns li {
  font-size: var(--text-sm);
  color: var(--color-secondary);
  padding: var(--space-xs) 0;
  padding-left: var(--space-lg);
  position: relative;
  line-height: 1.5;
}

.summary-unknowns li::before {
  content: '○';
  position: absolute;
  left: 0;
  color: var(--color-muted);
  font-size: var(--text-xs);
  top: 6px;
}

.summary-save-cta {
  display: block;
  width: 100%;
  margin-top: var(--space-lg);
  padding: var(--space-md);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-surface);
  background: var(--color-archetype, var(--color-accent));
  border: none;
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: all 200ms var(--ease-standard);
}

.summary-save-cta:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
}


/* ── Magical Moment Transitions ──────────────────────── */

.scenario-block.moment-fading {
  opacity: 0.2;
  filter: blur(4px);
}

.scenario-block.moment-simplified .chart-area { opacity: 0; pointer-events: none; }
.scenario-block.moment-simplified .simplified-area { opacity: 1; pointer-events: auto; }
.scenario-block.moment-simplified .scenarios-row { opacity: 0.3; transition: opacity 400ms var(--ease-standard); }


/* ── Input Area ──────────────────────────────────────── */

.input-area {
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  padding: var(--space-md) var(--space-lg);
  flex-shrink: 0;
  animation: chatEnter 400ms var(--ease-moment) backwards;
}

.input-wrapper {
  max-width: 720px;
  margin: 0 auto;
  display: flex;
  gap: var(--space-sm);
  align-items: center;
}

/* When panels are open, offset input to align with the chat column */
.app-layout.has-about ~ .input-area { padding-left: calc(280px + var(--space-lg)); }
.app-layout.has-scenarios ~ .input-area { padding-right: calc(320px + var(--space-lg)); }
.app-layout.has-about.has-scenarios ~ .input-area { padding-left: calc(280px + var(--space-lg)); padding-right: calc(320px + var(--space-lg)); }

.input-field {
  flex: 1;
  min-width: 0;
  position: relative;
}

/*
 * Concentric radius: mic button nests inside textarea's bottom-right corner.
 * Textarea outer radius = 14px. 1px border → inner radius = 13px.
 * Gap from inner border to button = 6px → button bottom-right corner radius = 13 - 6 = 7px.
 * Other corners use a softer radius (6px) since they face the textarea interior.
 */
.chat-input {
  display: block;
  width: 100%;
  font-family: inherit;
  font-size: var(--text-sm);
  padding: 10px var(--space-md);
  padding-right: 46px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg); /* 14px */
  outline: none;
  transition: border-color 200ms var(--ease-standard);
  color: var(--color-primary);
  background: var(--color-bg);
  resize: none;
  line-height: 1.5;
  min-height: 44px;
  max-height: 120px;
}
.chat-input:focus { border-color: var(--color-archetype); }
.chat-input:disabled { opacity: 0.5; cursor: default; }
.chat-input::placeholder { color: var(--color-muted); }

.mic-btn {
  position: absolute;
  right: 6px;
  bottom: 6px;
  width: 28px;
  height: 28px;
  border-radius: 6px 6px 7px 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 200ms var(--ease-standard), background 200ms var(--ease-standard), transform 200ms var(--ease-standard);
  color: var(--color-muted);
  background: transparent;
  outline: none;
}
.mic-btn:hover {
  color: var(--color-archetype);
  transform: scale(1.15);
}
.mic-btn:active {
  transform: scale(0.95);
}

.mic-btn.recording {
  color: #E53E3E;
  background: rgba(229, 62, 62, 0.08);
  animation: micRecording 1.6s ease-in-out infinite;
}

@keyframes micRecording {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.12); }
}

.send-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--color-archetype);
  color: var(--color-archetype-text);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 200ms var(--ease-standard);
  flex-shrink: 0;
}
.send-btn:hover { opacity: 0.85; }
.send-btn:focus-visible { outline: 2px solid var(--color-archetype); outline-offset: 2px; }

@keyframes micPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(229, 62, 62, 0.3); }
  50% { box-shadow: 0 0 0 5px rgba(229, 62, 62, 0); }
}

.input-controls {
  max-width: 720px;
  margin: var(--space-sm) auto 0;
  display: flex;
  gap: var(--space-sm);
}

.ctrl-btn {
  font-size: var(--text-xs);
  color: var(--color-muted);
  padding: 2px var(--space-sm);
  border-radius: var(--radius-sm);
  transition: color 150ms;
}
.ctrl-btn:hover { color: var(--color-primary); }


/* ── Animations ──────────────────────────────────────── */

@keyframes bubbleIn {
  from { opacity: 0; filter: blur(4px); transform: translateY(8px); }
  to { opacity: 1; filter: blur(0px); transform: translateY(0); }
}

@keyframes blockIn {
  from { opacity: 0; filter: blur(5px); transform: translateY(12px); }
  to { opacity: 1; filter: blur(0px); transform: translateY(0); }
}

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

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}


/* ── Reduced Motion ──────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}


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

@media (max-width: 768px) {
  .header { flex-direction: column; align-items: flex-start; gap: var(--space-sm); }

  /* Horizontal scrollable archetype tabs — single row */
  .archetype-nav {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    gap: 4px;
    padding-right: var(--space-xl);
  }
  .archetype-nav::-webkit-scrollbar { display: none; }
  .tab { font-size: 10px; padding: 4px 10px; flex-shrink: 0; }

  .stage-bar { flex-direction: column; align-items: flex-start; gap: var(--space-sm); }

  /* Scenario cards — scroll horizontally on mobile, smaller min-width */
  .scenarios-row { gap: var(--space-sm); }
  .scenarios-row > .scenario-card { min-width: 220px; flex: 0 0 75vw; }

  .chat-stream { padding: var(--space-md) var(--space-md) 100px; gap: var(--space-sm); }
  .chat-bubble { max-width: 92%; }

  /* Address suggestions — tighter on mobile */
  .address-suggestion { padding: var(--space-sm) var(--space-md); }

  .analogy-card { padding: var(--space-lg); }
  .analogy-text { font-size: var(--text-base); }
  .simp-nums { flex-direction: column; gap: var(--space-xs); }
  .simp-before { font-size: var(--text-lg); }
  .simp-after { font-size: var(--text-2xl); }

  /* Benefit cards — stack vertically */
  .benefit-card { flex-direction: column; gap: var(--space-sm); }
  .ben-amount { min-width: unset; }

  /* Summary card — tighter padding */
  .summary-card { padding: var(--space-lg); }

  /* Multi-panel → single column on mobile, panels become drawers */
  .app-layout,
  .app-layout.has-about,
  .app-layout.has-scenarios,
  .app-layout.has-about.has-scenarios {
    grid-template-columns: 1fr;
  }

  .side-panel {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    top: auto;
    height: 70vh;
    z-index: 30;
    border: none;
    border-top: 1px solid var(--color-border);
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    box-shadow: 0 -8px 32px rgba(0,0,0,0.12);
    animation: none;
  }

  .side-panel.open {
    display: flex;
    animation: drawerUp 400ms var(--ease-decelerate);
  }

  .panel-close { display: block; }

  /* Show edge pull tabs on mobile */
  .edge-tab:not(.hidden) { display: flex; }

  @keyframes drawerUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
  }

  /* Reset panel padding offsets on mobile — panels are drawers, not side columns */
  .app-layout.has-about ~ .input-area,
  .app-layout.has-scenarios ~ .input-area,
  .app-layout.has-about.has-scenarios ~ .input-area {
    padding-left: var(--space-md);
    padding-right: var(--space-md);
  }

  /* Input area: full width, proper sizing */
  .input-area {
    padding: var(--space-sm) var(--space-md);
  }

  .input-wrapper {
    max-width: 100%;
    gap: var(--space-xs);
  }

  /* Textarea: shorter on mobile */
  .chat-input {
    font-size: var(--text-sm);
    padding: 8px var(--space-md);
    padding-right: 38px;
    min-height: 40px;
  }

  /* Mic button: slightly smaller */
  .mic-btn {
    width: 24px;
    height: 24px;
    right: 5px;
    bottom: 5px;
  }

  /* Send button: smaller */
  .send-btn {
    width: 36px;
    height: 36px;
  }

  /* Suggestion chips: constrained to screen */
  .suggestion-chips {
    width: 100% !important;
    margin-left: 0 !important;
  }

  /* Settings dropdown: bottom sheet on mobile */
  .settings-dropdown {
    position: fixed;
    left: var(--space-md);
    right: var(--space-md);
    top: auto;
    bottom: var(--space-md);
    width: auto;
    max-height: 70vh;
    overflow-y: auto;
    z-index: 500;
  }

  /* Prompt editor: tighter on mobile */
  .prompt-editor-overlay { padding: var(--space-md); }
  .prompt-editor { height: 85vh; }
  .prompt-editor-textarea,
  .prompt-editor-preview { font-size: 11px; }

  /* Hero: tighter padding */
  .hero-content { padding: var(--space-xl) var(--space-md); }
  .hero-title { font-size: var(--text-xl); }

  /* Hide reset — just refresh the page */
  .input-controls { display: none; }
}
