.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; }
.field label, .seg legend { font-size: 12px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; }
input[type=text], select {
  width: 100%; font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; min-height: 44px;
}
.points { display: flex; align-items: center; gap: 8px; }
.points-fields { flex: 1; min-width: 0; }
.combo { position: relative; }
.suggestions {
  position: absolute; z-index: 20; left: 0; right: 0; top: calc(100% + 4px);
  margin: 0; padding: 4px; list-style: none; max-height: 260px; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow);
}
.suggestions li { padding: 9px 10px; border-radius: 8px; cursor: pointer; font-size: 14px; }
.suggestions li[aria-selected=true], .suggestions li:hover { background: var(--surface-2); }
.suggestions li.empty { color: var(--text-muted); cursor: default; }
.link-btn {
  align-self: flex-start; background: none; border: 0; padding: 4px 0; font: inherit; font-size: 13px;
  color: var(--accent); cursor: pointer; text-decoration: underline;
}
.icon-btn {
  flex: none; width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); cursor: pointer; display: grid; place-items: center;
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn:active { transform: translateY(1px); }
.link-btn:hover { text-decoration-thickness: 2px; }
.link-btn:disabled { opacity: .6; cursor: progress; }
.hint { margin: 0 0 12px; font-size: 12.5px; color: var(--text-muted); }
.controls { display: flex; gap: 12px; align-items: flex-end; margin-bottom: 14px; flex-wrap: wrap; }
.controls .period { flex: 1; min-width: 150px; margin: 0; }
.seg { border: 0; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 4px; }
.seg legend { padding: 0; margin-bottom: 4px; float: left; width: 100%; }
.seg { display: block; }
.seg label { display: inline-block; position: relative; }
.seg > label:first-of-type span { border-radius: 10px 0 0 10px; }
.seg > label:not(:first-of-type):not(:last-of-type) span { border-radius: 0; margin-left: -1px; }
.seg > label:last-of-type span { border-radius: 0 10px 10px 0; margin-left: -1px; }
.seg span {
  display: inline-block; min-height: 44px; line-height: 42px; padding: 0 16px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface); font-size: 14px;
}
.seg input { position: absolute; inset: 0; opacity: 0; margin: 0; pointer-events: none; }
.seg input:checked + span { background: var(--btn-bg); color: var(--btn-fg); border-color: var(--btn-bg); font-weight: 600; }
.seg input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 2px; position: relative; z-index: 1; }
.primary {
  width: 100%; min-height: 48px; border: 0; border-radius: 999px; font: inherit; font-weight: 700;
  background: var(--btn-bg); color: var(--btn-fg); cursor: pointer;
}
.primary { display: flex; align-items: center; justify-content: center; gap: 8px; transition: filter .12s, transform .05s; }
.primary:hover:not(:disabled) { filter: brightness(1.08); }
.primary:active:not(:disabled) { transform: translateY(1px); }
.primary:disabled { opacity: .7; cursor: progress; }
.primary .spinner { border-color: color-mix(in srgb, var(--btn-fg) 35%, transparent); border-top-color: var(--btn-fg); }
.status { min-height: 1.4em; margin: 10px 0 0; font-size: 13px; color: var(--text-muted); }
.error { margin: 10px 0 0; padding: 10px 12px; border-radius: 10px; background: var(--error-bg); color: var(--error-text); font-size: 14px; }
.section-title { font-size: 14px; margin: 16px 0 8px; }
.cards { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.cards > li { --line: var(--accent); }
.cards > li[data-line=rapida] { --line: var(--line-rapida); }
.cards > li[data-line=equilibrada] { --line: var(--line-equilibrada); }
.cards > li[data-line=segura] { --line: var(--line-segura); }
.card {
  display: block; width: 100%; text-align: left; font: inherit; color: inherit; cursor: pointer;
  background: var(--surface); border: 2px solid var(--border); border-radius: var(--radius); padding: 12px;
}
@media (hover: hover) { .card:hover { border-color: var(--text-muted); } }
.card[aria-pressed=true] { border-color: var(--line); background: color-mix(in srgb, var(--line) var(--line-tint), var(--surface)); }
.card-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.card-line { display: flex; align-items: center; gap: 8px; min-width: 0; }
.line-num {
  flex: none; display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%;
  background: var(--line); color: var(--line-fg); font-size: 12px; font-weight: 800; line-height: 1;
}
.card-label { font-weight: 700; }
.card-metrics { margin: 6px 0 2px; font-size: 20px; font-weight: 800; letter-spacing: -.01em; }
.card-metrics small { font-size: 13px; font-weight: 500; color: var(--text-muted); margin-left: 6px; }
.card-vs, .card-cats { font-size: 13px; color: var(--text-muted); margin: 2px 0 0; }
.badge { font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 999px; white-space: nowrap; }
.badge.baixo { background: var(--badge-baixo-bg); color: var(--badge-baixo-fg); }
.badge.moderado { background: var(--badge-moderado-bg); color: var(--badge-moderado-fg); }
.badge.alto { background: var(--badge-alto-bg); color: var(--badge-alto-fg); }
.badge.muito-alto { background: var(--badge-muito-bg); color: var(--badge-muito-fg); }
.toggle-row { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--border); }
.switch { display: flex; align-items: center; gap: 10px; cursor: pointer; min-height: 44px; position: relative; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; }
.switch-track { width: 42px; height: 24px; border-radius: 12px; background: var(--border); position: relative; flex: none; transition: background .15s; }
.switch-track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch input:checked + .switch-track { background: var(--accent); }
.switch input:checked + .switch-track::after { transform: translateX(18px); }
.switch input:focus-visible + .switch-track { outline: 3px solid var(--focus); outline-offset: 2px; }
.legend { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.legend-bar { flex: 1; height: 8px; border-radius: 4px; background: linear-gradient(90deg, var(--risk-0), var(--risk-1), var(--risk-2), var(--risk-3)); }
.pin { width: 22px; height: 22px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 1px 6px rgba(0,0,0,.5); cursor: grab; }
.pin.origin { background: #0455a1; }
.pin.dest { background: #c0262d; }
.pin.via { background: #7b3fc4; }
.via-combo { display: flex; align-items: center; gap: 8px; }
.via-combo input { flex: 1; min-width: 0; }
.via-remove { font-size: 22px; line-height: 1; }
.via-field[hidden], .via-field + .link-btn[hidden] { display: none; }
.hint[hidden] { display: none; }

/* ---- exposição por período ---- */
.periods { margin-top: 10px; }
.periods h3 { margin: 0 0 4px; font-size: 14px; }
.periods ul { list-style: none; margin: 0; padding: 0; }
.period-row { display: grid; grid-template-columns: 80px 1fr auto; align-items: center; gap: 8px; min-height: 28px; font-size: 13px; padding: 2px 6px; border-radius: 8px; }
.period-row.current { background: var(--surface); box-shadow: inset 3px 0 0 var(--line, var(--accent)); font-weight: 600; }
.period-bar { height: 8px; border-radius: 4px; background: var(--border); overflow: hidden; }
.period-bar > span { display: block; height: 100%; border-radius: 4px; background: var(--line, var(--accent)); }
.period-val { text-align: right; white-space: nowrap; color: var(--text-muted); font-size: 12.5px; }
.period-val b { color: var(--text); font-weight: 700; margin-right: 4px; }
@media (max-width: 400px) { .period-row { grid-template-columns: 72px 1fr auto; gap: 6px; } }
.maplibregl-ctrl-attrib { font-size: 10px; }

/* ---- Fase 2 ---- */
.server-banner {
  flex: none; display: flex; align-items: center; gap: 10px; margin: 8px var(--gutter) 0; padding: 9px 12px;
  border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); font-size: 13px;
}
.server-banner.failed { background: var(--error-bg); color: var(--error-text); border-color: transparent; }
.server-banner .link-btn { padding: 0; margin-left: auto; white-space: nowrap; }
.spinner {
  flex: none; width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--border); border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}
.server-banner.failed .spinner { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 3s; } }

.recents { margin: 0 0 12px; padding: 8px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); }
.recents-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.recents-head h2 { margin: 0; font-size: 12px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; }
.recents-head .link-btn { padding: 2px 0; }
.recents-list { list-style: none; margin: 4px 0 0; padding: 0; }
.recent {
  display: block; width: 100%; text-align: left; font: inherit; color: inherit; cursor: pointer; min-height: 44px;
  background: none; border: 0; border-radius: 8px; padding: 6px 8px;
}
.recent:hover { background: var(--surface); }
.recent-route { display: block; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recent-meta { display: block; font-size: 12px; color: var(--text-muted); }

li:has(> .card-extra) > .card { border-bottom: 0; border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
.card-extra {
  border: 2px solid var(--line); border-top: 1px solid var(--border); border-radius: 0 0 var(--radius) var(--radius);
  background: color-mix(in srgb, var(--line) var(--line-tint), var(--surface)); padding: 10px 12px 12px;
}
.card-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.btn-sm {
  flex: 1; min-height: 44px; padding: 0 14px; border-radius: 999px; font: inherit; font-weight: 600; cursor: pointer;
  background: transparent; color: var(--text); border: 1.5px solid var(--text-muted);
}
.btn-sm:hover { background: var(--surface); }
.btn-sm:active { transform: translateY(1px); }
.btn-sm.primary-sm { flex-basis: 100%; }
.btn-sm.primary-sm, .btn-sm.primary-sm:hover { background: var(--btn-bg); color: var(--btn-fg); border-color: var(--btn-bg); }
.btn-sm.primary-sm:hover { filter: brightness(1.25); }
.steps { margin-top: 10px; }
.steps summary { cursor: pointer; font-weight: 600; font-size: 14px; min-height: 36px; display: flex; align-items: center; }
.steps-list { list-style: none; margin: 4px 0 0; padding: 0; max-height: 300px; overflow-y: auto; }
/* passo a passo como estações: linha vertical na cor do perfil, círculos nas paradas */
.step {
  position: relative; display: flex; align-items: flex-start; gap: 10px; width: 100%; text-align: left; font: inherit; color: inherit; cursor: pointer;
  min-height: 44px; padding: 12px 8px 12px 38px; background: none; border: 0; border-radius: 8px;
}
.step::before { content: ""; position: absolute; left: 13px; top: 0; bottom: 0; width: 6px; background: var(--line); }
li:first-child > .step::before { top: 22px; }
li:last-child > .step::before { bottom: auto; height: 22px; }
li:only-child > .step::before { display: none; }
.step::after {
  content: ""; position: absolute; left: 16px; top: 22px; width: 12px; height: 12px; box-sizing: border-box;
  transform: translate(-50%, -50%); border-radius: 50%; background: var(--surface); border: 3px solid var(--line);
}
li:first-child > .step::after, li:last-child > .step::after { width: 18px; height: 18px; border-width: 4px; }
li:last-child > .step::after { border-color: var(--text); }
.step:hover { background: color-mix(in srgb, var(--line) 10%, transparent); }
.step.current { background: color-mix(in srgb, var(--line) 16%, transparent); font-weight: 700; }
.step-text { flex: 1; min-width: 0; font-size: 14px; }
.step-dist { flex: none; font-size: 12.5px; color: var(--text-muted); white-space: nowrap; }

.snack {
  position: fixed; z-index: 60; left: 50%; top: 16px; transform: translateX(-50%); max-width: calc(100% - 32px);
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 999px; font-size: 14px; box-shadow: var(--shadow);
}

/* Navegação */
.nav-banner {
  position: absolute; z-index: 4; top: 8px; left: 8px; right: 8px; max-width: 560px; margin: 0 auto;
  background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow);
  overflow: hidden;
}
.nav-main { display: flex; align-items: center; gap: 12px; padding: 10px 12px; }
.nav-icon { flex: none; width: 52px; height: 52px; border-radius: 12px; background: var(--accent); color: var(--accent-contrast); display: grid; place-items: center; }
.nav-info { flex: 1; min-width: 0; }
.nav-dist { font-size: 22px; font-weight: 800; line-height: 1.1; }
.nav-text { font-size: 15px; font-weight: 600; }
.nav-sub { font-size: 12.5px; color: var(--text-muted); overflow-wrap: anywhere; }
.nav-btns { flex: none; display: flex; flex-direction: column; gap: 6px; }
.nav-btn {
  min-height: 36px; padding: 0 12px; border-radius: 999px; font: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
  background: var(--surface-2); color: var(--text); border: 1px solid var(--border);
}
.nav-btn:hover { background: var(--bg); }
.nav-btn.nav-primary { background: var(--btn-bg); color: var(--btn-fg); border-color: var(--btn-bg); border-radius: 999px; }
.nav-exit { color: var(--error-text); }
.nav-off { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 12px; background: var(--error-bg); color: var(--error-text); font-weight: 600; }
.nav-banner.is-off .nav-icon { background: var(--risk-3); }
.nav-banner.is-arrived .nav-icon { background: var(--risk-0); }
.nav-notice { padding: 6px 12px; font-size: 13px; background: var(--badge-moderado-bg); color: var(--badge-moderado-fg); }
.navigating .map-toast { display: none !important; }

.user-dot { width: 44px; height: 44px; display: grid; place-items: center; pointer-events: none; }
.user-core { grid-area: 1 / 1; width: 18px; height: 18px; border-radius: 50%; background: #1a73e8; border: 3px solid #fff; box-shadow: 0 0 0 2px rgba(26,115,232,.35), 0 1px 6px rgba(0,0,0,.5); }
.user-heading {
  grid-area: 1 / 1; width: 0; height: 0; display: none; align-self: start; justify-self: center;
  border-left: 8px solid transparent; border-right: 8px solid transparent; border-bottom: 14px solid #1a73e8; opacity: .85;
}
.user-dot.has-heading .user-heading { display: block; }
.step-dot { width: 16px; height: 16px; border-radius: 50%; background: var(--accent); border: 3px solid #fff; box-shadow: 0 1px 6px rgba(0,0,0,.5); }

/* ---- navegação: voz e ETA ---- */
.nav-btn[aria-pressed="false"] { color: var(--text-muted); }
.nav-btn[hidden] { display: none; }
@media (max-width: 400px) {
  .nav-main { gap: 8px; padding: 8px; }
  .nav-icon { width: 44px; height: 44px; }
  .nav-btn { padding: 0 8px; font-size: 12px; white-space: nowrap; }
}
