:root {
  --bg: #f4f7f5;
  --surface: #ffffff;
  --ink: #1a2421;
  --muted: #5a6b65;
  --line: #d5e0db;
  --teal: #1a6b5a;
  --teal-dark: #145447;
  --teal-soft: #e4f3ee;
  --amber: #c47a14;
  --amber-soft: #fff4e3;
  --rose: #b43d3d;
  --rose-soft: #fdeeee;
  --radius: 16px;
  --shadow: 0 8px 28px rgba(26, 36, 33, 0.08);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  font-family: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  min-height: 100%;
  -webkit-text-size-adjust: 100%;
}

body {
  line-height: 1.45;
}

.app {
  max-width: 440px;
  margin: 0 auto;
  padding: calc(12px + var(--safe-t)) 16px calc(28px + var(--safe-b));
  min-height: 100dvh;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  min-width: 0;
  flex: 1;
}

.brand > div {
  min-width: 0;
}

.logo {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: var(--teal);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 1.25rem;
  flex-shrink: 0;
}

.brand h1 {
  margin: 0;
  font-size: 1.35rem;
  letter-spacing: -0.02em;
}

.tagline {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.78rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.icon-btn {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  cursor: pointer;
}

.icon-btn:active { transform: scale(0.97); }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 16px 20px;
  box-shadow: var(--shadow);
  margin-bottom: 14px;
}

.card h2 {
  margin: 0 0 6px;
  font-size: 1.1rem;
}

.hint {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 0.9rem;
}

.hint.tiny { font-size: 0.8rem; margin-top: 12px; }

textarea,
.text-input {
  width: 100%;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  font: inherit;
  font-size: 1rem;
  background: #fafcfb;
  color: var(--ink);
  resize: vertical;
  min-height: 44px;
}

textarea:focus,
.text-input:focus {
  outline: 2px solid var(--teal);
  outline-offset: 1px;
  border-color: var(--teal);
  background: #fff;
}

.field-label {
  display: block;
  margin: 14px 0 6px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
}

.field-hint {
  margin: 6px 0 0;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--rose);
}

.field-hint[hidden] {
  display: none !important;
}

.text-input.needs-home {
  border-color: var(--rose);
  background: #fff8f8;
}

.count-line {
  margin: 8px 0 0;
  font-size: 0.85rem;
  color: var(--muted);
}

.btn {
  display: block;
  width: 100%;
  border: none;
  border-radius: 14px;
  padding: 14px 16px;
  font: inherit;
  font-size: 1.05rem;
  font-weight: 650;
  cursor: pointer;
  margin-top: 14px;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--teal);
  color: #fff;
}

.btn-primary:not(:disabled):active {
  background: var(--teal-dark);
}

.input-actions {
  display: grid;
  grid-template-columns: minmax(88px, 0.75fr) minmax(0, 2fr);
  gap: 10px;
  margin-top: 14px;
}

.input-actions .btn {
  margin-top: 0;
}

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

.mode-pill {
  margin: 10px 0 0;
  text-align: center;
  font-size: 0.8rem;
  color: var(--muted);
}

.results-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
}

.results-head h2 { margin: 0; }

.badge {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: var(--amber-soft);
  color: var(--amber);
  padding: 4px 8px;
  border-radius: 999px;
  white-space: nowrap;
}

.worth-block {
  background: var(--teal-soft);
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 16px;
}

.worth-label {
  margin: 0;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--teal-dark);
  letter-spacing: 0.01em;
}

.worth-value {
  margin: 6px 0 0;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--ink);
}

.confidence {
  margin: 6px 0 0;
  font-size: 0.78rem;
  color: var(--muted);
  opacity: 0.85;
}

.order-list {
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: stop;
}

.order-list li {
  counter-increment: stop;
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.order-list li:last-child { border-bottom: none; }

.order-list li::before {
  content: counter(stop);
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--teal);
  color: #fff;
  font-weight: 700;
  font-size: 0.85rem;
  display: grid;
  place-items: center;
}

.order-list li > .stop-copy {
  flex: 1;
  min-width: 0;
}

.order-list .stop-name {
  font-weight: 600;
  font-size: 1.02rem;
  display: block;
}

.order-list .stop-location,
.order-list .stop-meta {
  display: block;
  font-size: 0.8rem;
  color: var(--muted);
  font-weight: 400;
  margin-top: 2px;
}

.order-list .stop-location {
  color: var(--ink);
  opacity: 0.78;
  line-height: 1.3;
}

.order-list .stop-meta {
  margin-top: 5px;
}

.soft-note {
  margin: 14px 0 0;
  padding: 10px 12px;
  background: var(--amber-soft);
  color: #7a4e0c;
  border-radius: 10px;
  font-size: 0.88rem;
}

.soft-note.muted {
  background: transparent;
  color: var(--muted);
  padding: 8px 0 0;
}

.empty-msg,
.error-msg {
  text-align: center;
  padding: 14px;
  border-radius: 12px;
  font-size: 0.95rem;
}

.empty-msg {
  background: var(--surface);
  color: var(--muted);
  border: 1px dashed var(--line);
}

.error-msg {
  background: var(--rose-soft);
  color: var(--rose);
  border: 1px solid #f0c4c4;
}

.error-msg.soft {
  background: var(--amber-soft);
  color: var(--amber);
  border: 1px solid #f0e0b8;
}

.about-dialog {
  border: none;
  border-radius: 18px;
  padding: 0;
  width: min(92vw, 400px);
  box-shadow: 0 20px 50px rgba(0,0,0,0.2);
}

.about-dialog::backdrop {
  background: rgba(20, 30, 28, 0.45);
}

.about-form {
  padding: 22px 18px 18px;
  position: relative;
}

.about-form h2 {
  margin: 0 0 8px;
  font-size: 1.2rem;
}

.close-x {
  margin-top: 8px;
}

.input-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}

.input-head h2 {
  margin: 0;
}

.btn-link {
  border: none;
  background: transparent;
  color: var(--teal);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 650;
  cursor: pointer;
  padding: 4px 2px;
  white-space: nowrap;
}

.btn-link:active {
  opacity: 0.75;
}

.collapsed-summary {
  display: block;
  width: 100%;
  margin: 0;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.92rem;
  text-align: left;
  cursor: pointer;
}

.collapsed-summary:hover,
.collapsed-summary:focus-visible {
  color: var(--teal-dark);
  outline: none;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

.btn.busy {
  position: relative;
}

.btn.busy::after {
  content: "";
  width: 1em;
  height: 1em;
  margin-left: 0.5em;
  border: 2px solid rgba(255,255,255,0.35);
  border-top-color: #fff;
  border-radius: 50%;
  display: inline-block;
  vertical-align: -0.15em;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@media (min-width: 480px) {
  .app { padding-top: 24px; }
}

.drive-time {
  margin: 12px 0 0;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--teal-dark);
}

.worth-why {
  margin: 8px 0 0;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--teal-dark);
  line-height: 1.35;
}

.card.compact {
  padding: 12px 14px 14px;
}

.card.compact h2 {
  font-size: 1rem;
}

.card.compact .input-body {
  display: none;
}

.card.compact .collapsed-summary {
  display: block;
}

.card.compact #btn-edit-stops {
  display: none !important;
}

textarea::placeholder {
  color: var(--muted);
  opacity: 0.72;
}

.examples-line {
  margin: 8px 0 0;
  font-size: 0.8rem;
  color: var(--muted);
  opacity: 0.9;
  line-height: 1.35;
}

.sample-chip {
  display: inline-flex;
  align-items: center;
  margin-top: 10px;
  border: 1px solid var(--line);
  background: var(--teal-soft);
  color: var(--teal-dark);
  font: inherit;
  font-size: 0.85rem;
  font-weight: 650;
  padding: 8px 12px;
  border-radius: 999px;
  cursor: pointer;
}

.sample-chip:active {
  transform: scale(0.98);
}

.sample-chip[hidden],
.examples-line[hidden] {
  display: none !important;
}

.plan-actions {
  margin-top: 14px;
}

.btn-maps {
  display: block;
  width: 100%;
  text-align: center;
  text-decoration: none;
  border-radius: 14px;
  padding: 14px 16px;
  font: inherit;
  font-size: 1.05rem;
  font-weight: 650;
  background: var(--teal);
  color: #fff;
  box-sizing: border-box;
}

.btn-maps:active {
  background: var(--teal-dark);
}

.btn-maps[hidden] {
  display: none !important;
}

.btn-clear-results {
  display: block;
  width: 100%;
  margin-top: 10px;
  box-sizing: border-box;
}


/* —— Confirm these places (ambiguous stops) —— */
.confirm-card .hint {
  margin-bottom: 14px;
}

.confirm-list {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.confirm-stop {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 12px 10px;
  background: #fafcfb;
}

.confirm-eyebrow {
  margin: 0 0 4px;
  font-size: 0.8rem;
  font-weight: 650;
  color: var(--muted);
}

.confirm-helper {
  margin: 0 0 10px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink);
}

.confirm-choices {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.confirm-escape {
  display: block;
  margin: 8px 2px 0;
  padding: 6px 2px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
  text-align: left;
  white-space: normal;
}

.confirm-escape:active {
  opacity: 0.75;
}

.confirm-choice {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  width: 100%;
  min-height: 44px;
  margin: 0;
  padding: 10px 12px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: #fff;
  cursor: pointer;
  text-align: left;
  font: inherit;
  color: var(--ink);
  box-sizing: border-box;
}

.confirm-choice:has(input:checked),
.confirm-choice.is-selected {
  border-color: var(--teal);
  background: var(--teal-soft);
}

.confirm-choice input {
  margin-top: 3px;
  flex-shrink: 0;
  accent-color: var(--teal);
  width: 18px;
  height: 18px;
}

.confirm-choice-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.confirm-choice-primary {
  font-weight: 650;
  font-size: 0.98rem;
  line-height: 1.25;
}

.confirm-choice-secondary {
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.3;
}

.confirm-choice-miles {
  font-size: 0.8rem;
  color: var(--muted);
  font-weight: 600;
}

.confirm-actions {
  margin-top: 16px;
}

.confirm-actions.sticky-plan {
  position: sticky;
  bottom: calc(8px + var(--safe-b));
  padding-top: 8px;
  padding-bottom: 2px;
  background: linear-gradient(to top, var(--surface) 70%, rgba(255,255,255,0));
  z-index: 2;
}

.confirm-actions .btn {
  margin-top: 0;
}

#confirm-card[hidden] {
  display: none !important;
}

.card.confirming #input-body,
.card.confirming .collapsed-summary {
  display: none !important;
}

/* Tap-to-talk mic (v20261001e) — near stops textarea */
.stops-wrap {
  position: relative;
}

.stops-wrap textarea {
  padding-right: 52px;
  display: block;
}

.mic-btn {
  position: absolute;
  right: 8px;
  bottom: 8px;
  width: 40px;
  height: 40px;
  z-index: 1;
  color: var(--teal);
  flex-shrink: 0;
}

.mic-btn:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 2px;
}

.mic-btn.is-listening,
.mic-btn[aria-pressed="true"] {
  background: var(--teal);
  border-color: var(--teal-dark);
  color: #fff;
  outline: 2px solid var(--teal-soft);
  outline-offset: 2px;
}

.mic-btn:disabled,
.mic-btn[aria-disabled="true"] {
  opacity: 0.45;
  cursor: not-allowed;
  color: var(--muted);
}

.mic-status {
  margin: 6px 0 0;
  font-size: 0.85rem;
  color: var(--muted);
}

.mic-status.is-listening {
  color: var(--teal-dark);
  font-weight: 650;
}

.mic-status.is-error {
  color: var(--rose);
  font-weight: 600;
}

.mic-status[hidden] {
  display: none !important;
}
