:root {
  --primer: #ECEEEF;
  --panel: #FFFFFF;
  --ink: #2D3035;
  --steel: #656666;
  --redline: #EA3225;
  --radius: 10px;
  --maxw: 640px;
  box-sizing: border-box;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: inherit; }

html { scroll-padding-top: env(safe-area-inset-top, 0px); }

body {
  margin: 0;
  background: var(--primer);
  color: var(--ink);
  font-family: "Barlow", "Helvetica Neue", Arial, sans-serif;
  font-size: 17px;
  line-height: 1.45;
  display: flex;
  flex-direction: column;
  min-height: 100%;
}

.masthead {
  position: sticky;
  top: env(safe-area-inset-top, 0px);
  background: var(--panel);
  border-bottom: 1px solid #DDE1E3;
  z-index: 10;
}

.masthead-inner {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 14px 16px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.logo {
  display: block;
  width: 340px;
  max-width: 62vw;
  height: auto;
}

.phone {
  color: var(--ink);
  font-weight: 600;
  font-size: 15px;
  text-decoration: none;
  border-bottom: 2px solid var(--redline);
  padding-bottom: 1px;
}

/* The tach: progress sweeps left to right toward a fixed redline tick */
.tach {
  position: relative;
  height: 6px;
  background: #D8DCDE;
  overflow: hidden;
}

.tach-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 9%;
  background: var(--ink);
  transition: width 400ms ease;
}

.tach-redline {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 10%;
  background: var(--redline);
}

.chat {
  flex: 1;
  width: 100%;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 20px 16px 8px;
}

.bubble {
  background: var(--panel);
  border: 1px solid #DDE1E3;
  border-radius: var(--radius);
  padding: 12px 14px;
  margin: 0 0 12px;
  max-width: 92%;
}

.bubble.user {
  background: var(--ink);
  color: var(--panel);
  border-color: var(--ink);
  margin-left: auto;
  max-width: 80%;
}

.composer {
  width: 100%;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 16px 16px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  font: inherit;
  font-weight: 600;
  font-size: 15px;
  background: var(--panel);
  border: 1.5px solid var(--ink);
  border-radius: 999px;
  padding: 9px 16px;
  cursor: pointer;
  color: var(--ink);
}

.chip:hover { background: #F4F6F7; }

.chip:focus-visible,
.phone:focus-visible {
  outline: 3px solid var(--redline);
  outline-offset: 2px;
}

.legal {
  width: 100%;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 16px 16px calc(24px + env(safe-area-inset-bottom, 0px));
  font-size: 13px;
  color: var(--steel);
}

@media (prefers-reduced-motion: reduce) {
  .tach-fill { transition: none; }
}

/* Block 3 additions: typed input row and the typing indicator */

.hidden { display: none; }

.input-row {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.input-row input {
  flex: 1;
  font: inherit;
  font-size: 16px;
  padding: 11px 14px;
  border: 1.5px solid var(--ink);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--ink);
  min-width: 0;
}

.input-row input:focus-visible {
  outline: 3px solid var(--redline);
  outline-offset: 1px;
}

.send {
  font: inherit;
  font-weight: 600;
  font-size: 15px;
  background: var(--ink);
  color: var(--panel);
  border: none;
  border-radius: var(--radius);
  padding: 0 18px;
  cursor: pointer;
}

.chip.selected {
  background: var(--ink);
  color: var(--panel);
}

.bubble.typing {
  display: inline-flex;
  gap: 5px;
  align-items: center;
  padding: 14px 16px;
}

.typing .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--steel);
  animation: pulse 1.1s infinite ease-in-out;
}

.typing .dot:nth-child(2) { animation-delay: 0.18s; }
.typing .dot:nth-child(3) { animation-delay: 0.36s; }

@keyframes pulse {
  0%, 70%, 100% { opacity: 0.35; transform: translateY(0); }
  35% { opacity: 1; transform: translateY(-2px); }
}

@media (prefers-reduced-motion: reduce) {
  .typing .dot { animation: none; opacity: 0.7; }
}

/* Back control: quiet, present, never competing with the question */

.back-btn {
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  color: var(--steel);
  background: none;
  border: none;
  padding: 2px 0 10px;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.back-btn:hover { color: var(--ink); }

.back-btn:focus-visible {
  outline: 3px solid var(--redline);
  outline-offset: 2px;
}
