/* Task-to-Flow — warm, premium, mobile-first. No frameworks. */
:root {
  --bg: #faf8f6;
  --surface: #ffffff;
  --ink: #2a2a2a;
  --ink-soft: #6b6b6b;
  --accent: #0e7490; /* muted teal */
  --accent-soft: #e0f2f7;
  --amber: #b45309;
  --amber-soft: #fef3c7;
  --radius-bubble: 1.25rem;
  --radius-box: 0.75rem;
}

* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  height: 100%;
}
body {
  background: var(--bg);
  color: var(--ink);
  font:
    16px/1.5 system-ui,
    -apple-system,
    'Segoe UI',
    Roboto,
    sans-serif;
}
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.app {
  display: flex;
  flex-direction: column;
  max-width: 560px;
  height: 100dvh;
  margin: 0 auto;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 0.9rem 1.25rem;
  font-size: 0.85rem;
}
.brand {
  font-weight: 650;
  letter-spacing: -0.02em;
  font-size: 1.05rem;
}
.brand-accent {
  color: var(--accent);
}
.attribution {
  color: var(--ink-soft);
}

.thread {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem 1rem 1rem;
}
.row {
  display: flex;
  margin: 0.5rem 0;
}
.row-user {
  justify-content: flex-end;
}
.row-bot {
  justify-content: flex-start;
}

.bubble {
  max-width: 92%;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-bubble);
}
.bubble-user {
  background: var(--ink);
  color: #fff;
  border-bottom-right-radius: 0.4rem;
  white-space: pre-wrap;
}
.bubble-bot {
  background: var(--surface);
  border-bottom-left-radius: 0.4rem;
  box-shadow:
    0 1px 3px rgba(42, 42, 42, 0.08),
    0 8px 24px rgba(42, 42, 42, 0.06);
}

.confirm {
  font-size: 1rem;
  margin-bottom: 0.35rem;
}
.honesty-note {
  margin: 0 0 0.9rem;
  padding-top: 0.5rem;
  border-top: 1px dashed #e5e0da;
  font-size: 0.72rem;
  color: var(--ink-soft);
  font-style: italic;
}

/* Flow diagram — vertical on phones, simple rounded boxes with icons. */
.flow {
  list-style: none;
  margin: 0;
  padding: 0;
  counter-reset: step;
}
.flow li {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  background: var(--accent-soft);
  border-radius: var(--radius-box);
  padding: 0.6rem 0.75rem;
  margin-bottom: 1.4rem;
  opacity: 0;
  transform: translateY(10px);
  transition:
    opacity 0.45s ease-out,
    transform 0.45s ease-out;
}
.flow li.visible {
  opacity: 1;
  transform: none;
}
.flow li::after {
  content: '↓';
  position: absolute;
  left: 50%;
  bottom: -1.15rem;
  transform: translateX(-50%);
  color: var(--accent);
  font-size: 0.8rem;
  opacity: 0;
  transition: opacity 0.4s ease-out 0.25s;
}
.flow li.visible::after {
  opacity: 1;
}
.flow li:last-child::after {
  content: none;
}
.step-icon {
  font-size: 1.1rem;
}
.step-label {
  font-size: 0.88rem;
}
.step-num {
  margin-left: auto;
  font-size: 0.68rem;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* Savings block */
.savings {
  margin-top: 0.5rem;
}
.savings-count {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--amber);
  background: var(--amber-soft);
  border-radius: var(--radius-box);
  padding: 0.5rem 0.9rem;
  text-align: center;
}
.savings-count .unit {
  font-size: 0.95rem;
  font-weight: 600;
  margin-left: 0.25rem;
}
.sliders label {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.5rem;
  align-items: center;
  font-size: 0.78rem;
  color: var(--ink-soft);
  width: 100%;
  margin-top: 0.55rem;
}
.sliders output {
  min-width: 2ch;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.assumption-note {
  font-size: 0.72rem;
  color: var(--ink-soft);
  margin: 0.4rem 0 0.8rem;
}
.cta {
  display: block;
  text-align: center;
  text-decoration: none;
  background: var(--ink);
  color: #fff;
  border-radius: 999px;
  padding: 0.7rem 1rem;
  font-size: 0.9rem;
  font-weight: 600;
}
.cta:hover {
  background: #000;
}

/* Composer */
.composer {
  padding: 0.75rem 1rem calc(0.75rem + env(safe-area-inset-bottom));
}
#ask-form {
  display: flex;
  gap: 0.5rem;
}
#ask-input {
  flex: 1;
  border: 1px solid #ddd6cf;
  border-radius: 999px;
  padding: 0.75rem 1.1rem;
  font: inherit;
  background: var(--surface);
}
#ask-input:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
}
#ask-form button {
  width: 48px;
  height: 48px;
  flex-shrink: 0;
  border: none;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 1.1rem;
  cursor: pointer;
}
.chips {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding-top: 0.6rem;
  scrollbar-width: none;
}
.chip {
  flex-shrink: 0;
  border: 1px solid #ddd6cf;
  background: var(--surface);
  border-radius: 999px;
  padding: 0.45rem 0.9rem;
  font-size: 0.8rem;
  cursor: pointer;
  color: var(--ink);
  min-height: 44px;
}
.chip:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* Desktop: widen, flow becomes a horizontal two-column story is unnecessary —
   keep single readable column but let bubbles breathe. */
@media (min-width: 600px) {
  .app {
    max-width: 640px;
  }
  .bubble {
    max-width: 85%;
  }
}

/* Reduced motion: instant render (JS also skips stagger timing). */
@media (prefers-reduced-motion: reduce) {
  .flow li,
  .flow li::after {
    transition: none;
    opacity: 1;
    transform: none;
  }
  .flow li::after {
    opacity: 1;
  }
}
