:root {
  --google-blue: #1a73e8;
  --google-blue-dark: #1557b0;
  --google-blue-light: #4285f4;
  --apple-blue: #007aff;
  --waze-cyan: #33ccff;
  --waze-dark: #0099dd;
  --green: #34a853;
  --green-dark: #1e8e3e;
  --amber: #fbbc04;
  --red: #ea4335;
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-variant: #eef3f8;
  --outline: #d0d7de;
  --text: #0f172a;
  --muted: #64748b;
  --slate-900: #0f172a;
  --map-bg: #0b0e14;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: "Google Sans", "Inter", "Segoe UI", system-ui, sans-serif;
  background: #0a1220;
  color: var(--text);
}

.stage {
  min-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.phone {
  width: 390px;
  height: min(860px, calc(100vh - 24px));
  background: #111;
  border-radius: 36px;
  padding: 12px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.45);
  position: relative;
  display: flex;
}

.phone-notch {
  position: absolute;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  width: 120px;
  height: 18px;
  background: #000;
  border-radius: 12px;
  z-index: 5;
}

.app {
  height: 100%;
  width: 100%;
  background: var(--bg);
  border-radius: 28px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.topbar {
  padding: 28px 16px 10px;
  background: var(--surface);
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.06);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: linear-gradient(135deg, #1a73e8, #007aff);
  color: white;
  display: grid;
  place-items: center;
  font-size: 22px;
  font-weight: 800;
}
.brand h1 { margin: 0; font-size: 18px; letter-spacing: -0.2px; }
.brand p { margin: 2px 0 0; font-size: 12px; color: var(--muted); font-weight: 500; }

.top-actions { display: flex; gap: 2px; }
.icon-btn {
  position: relative;
  border: 0;
  background: transparent;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 16px;
}
.badge {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--google-blue);
  color: white;
  font-size: 10px;
  font-weight: 700;
  display: grid;
  place-items: center;
}

.scroll {
  flex: 1;
  overflow: auto;
  padding: 10px 16px 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.map-card {
  position: relative;
  flex-shrink: 0;
  border-radius: 20px;
  overflow: hidden;
  background: var(--map-bg);
  border: 1.5px solid #21262d;
  height: 220px;
  min-height: 220px;
}
#mapCanvas { width: 100%; height: 100%; display: block; }
.map-label {
  position: absolute;
  left: 10px;
  bottom: 8px;
  color: #94a3b8;
  font-size: 11px;
  font-weight: 600;
}

.chips {
  background: #eef3f8;
  border-radius: 16px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  cursor: pointer;
}
.priority-entry {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.priority-entry strong { display: block; font-size: 15px; }
.priority-entry p { margin: 3px 0 0; color: var(--muted); font-size: 12px; font-weight: 500; }
.priority-entry-action { color: var(--google-blue); font-weight: 800; font-size: 13px; flex-shrink: 0; }
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border-radius: 8px;
  padding: 5px 8px;
  font-size: 12px;
  font-weight: 700;
}
.chip.green { background: rgba(52, 168, 83, 0.18); color: var(--green-dark); }
.chip.red { background: rgba(234, 67, 53, 0.18); color: var(--red); }
.chip.blue { background: rgba(26, 115, 232, 0.18); color: var(--google-blue); }

.card {
  background: var(--surface);
  border-radius: 20px;
  padding: 16px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}
.card.soft { background: rgba(238, 243, 248, 0.7); }
.row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }

.priorities-dialog { max-height: 86vh; }
.priority-card {
  background: var(--surface-variant);
  border-radius: 16px;
  padding: 14px;
  margin: 0 0 10px;
}
.priority-head { align-items: flex-start; }
.priority-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.35;
}
.priority-round {
  margin: 8px 0 12px;
  padding: 12px 14px;
  background: var(--surface-variant);
  border-radius: 12px;
  font-weight: 600;
}
.slider-row { margin-top: 10px; }
.slider-row input[type="range"] {
  width: 100%;
  margin: 8px 0 0;
  accent-color: var(--google-blue);
  height: 28px;
}
.switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
}
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch-ui {
  width: 44px;
  height: 26px;
  border-radius: 999px;
  background: #cbd5e1;
  display: inline-block;
  position: relative;
}
.switch-ui::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.25);
  transition: transform 0.15s ease;
}
.switch input:checked + .switch-ui { background: var(--google-blue); }
.switch input:checked + .switch-ui::after { transform: translateX(18px); }
.metric-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 14px; }
.metric {
  background: var(--surface);
  border-radius: 12px;
  padding: 10px 4px;
  text-align: center;
}
.metric strong { display: block; font-size: 13px; }
.metric span { font-size: 10px; color: var(--muted); }

.pill {
  border-radius: 12px;
  padding: 7px 12px;
  font-size: 12px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.pill.green { background: rgba(52, 168, 83, 0.15); color: var(--green-dark); border: 1px solid rgba(52, 168, 83, 0.4); }
.pill.blue { background: rgba(26, 115, 232, 0.12); color: var(--google-blue); border: 1px solid rgba(26, 115, 232, 0.35); }

.actions { display: flex; gap: 8px; margin: 12px 0; }
button.primary, button.secondary, button.ghost {
  border: 0;
  border-radius: 14px;
  height: 48px;
  font-weight: 700;
  cursor: pointer;
}
button.primary { background: var(--google-blue); color: white; flex: 1.3; }
button.secondary {
  flex: 1.4;
  background: rgba(51, 204, 255, 0.12);
  color: var(--google-blue);
  border: 1.5px solid rgba(26, 115, 232, 0.5);
}
button.ghost {
  width: 48px;
  background: var(--surface-variant);
  color: var(--text);
}
button.linkish { background: transparent; border: 0; color: var(--google-blue); font-weight: 700; cursor: pointer; }
button:disabled { opacity: 0.45; cursor: not-allowed; }

.switch {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--surface-variant);
  border-radius: 12px;
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}
.switch input { accent-color: var(--green); }

.stop {
  display: flex;
  gap: 12px;
  align-items: center;
  background: rgba(238, 243, 248, 0.85);
  border-radius: 14px;
  padding: 12px;
  margin-bottom: 8px;
}
.stop.start { border: 1.5px solid var(--google-blue); }
.seq {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  color: white;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 13px;
  background: var(--google-blue-light);
}
.seq.start { background: var(--google-blue); }
.seq.end { background: var(--red); }
.stop-info { flex: 1; min-width: 0; cursor: pointer; }
.stop-info strong, .stop-info p { margin: 0; }
.stop-info p { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.meta { color: var(--google-blue); font-size: 12px; font-weight: 600; margin-top: 4px; }
.done strong { text-decoration: line-through; color: #94a3b8; }
.start-tag {
  display: inline-block;
  margin-left: 6px;
  background: rgba(26, 115, 232, 0.15);
  color: var(--google-blue);
  font-size: 10px;
  font-weight: 800;
  padding: 2px 5px;
  border-radius: 6px;
  vertical-align: middle;
}
.stop-actions button {
  width: 28px;
  height: 28px;
  border: 0;
  background: transparent;
  cursor: pointer;
  color: var(--muted);
}

.launch {
  background: rgba(26, 115, 232, 0.08);
  border: 1.2px solid rgba(26, 115, 232, 0.4);
  border-radius: 16px;
  padding: 16px;
  display: flex;
  gap: 14px;
  align-items: center;
  cursor: pointer;
}
.launch-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: rgba(26, 115, 232, 0.2);
  display: grid;
  place-items: center;
  color: var(--google-blue);
  font-size: 20px;
}
.launch h3, .launch p { margin: 0; }
.launch p { color: var(--muted); font-size: 13px; }

.export-bar {
  background: var(--surface);
  border-radius: 24px 24px 0 0;
  padding: 14px 16px 18px;
  box-shadow: 0 -8px 24px rgba(15, 23, 42, 0.08);
}
.export-title { font-weight: 800; font-size: 14px; }
.export-hint { margin: 4px 0 10px; color: var(--muted); font-size: 12px; line-height: 1.35; }
.export-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.export-grid button { height: 46px; flex: none; border-radius: 14px; width: 100%; }
.export-grid button.tesla { color: #e31937; border-color: rgba(227, 25, 55, 0.45); }
.export-row { display: flex; gap: 8px; margin-top: 10px; justify-content: flex-end; }
.export-row button.secondary { height: 46px; flex: 1; border-radius: 14px; }
.export-row button.ghost { height: 46px; border-radius: 14px; }

.welcome {
  background: var(--surface);
  border-radius: 20px;
  padding: 18px 16px 16px;
  border: 1.5px solid #d6e3f5;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
}
.welcome h2 { margin: 0 0 8px; font-size: 20px; }
.welcome > p { margin: 0 0 12px; color: var(--muted); font-size: 14px; line-height: 1.45; }
.welcome-steps {
  margin: 0 0 16px;
  padding-left: 20px;
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  font-weight: 600;
}
.welcome-steps li { margin: 0 0 8px; }
.keep-moving {
  background: rgba(30, 142, 62, 0.10);
  border-radius: 16px;
  padding: 14px;
}
.keep-moving strong { color: var(--green-dark); display: block; font-size: 14px; }
.keep-moving p { margin: 4px 0 0; color: var(--muted); font-size: 12px; line-height: 1.4; }

.backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 20;
}
.sheet, .dialog {
  background: white;
  width: min(390px, 100%);
  border-radius: 24px 24px 0 0;
  padding: 20px;
  max-height: 86vh;
  overflow: auto;
}
.dialog {
  align-self: center;
  border-radius: 24px;
  margin: 16px;
  max-height: 80vh;
}
.search-card {
  background: var(--surface);
  border-radius: 20px;
  padding: 18px 16px 16px;
  margin-top: 4px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
  border: 1.5px solid #d6e3f5;
}
.search-card h2 {
  margin: 0 0 6px;
  font-size: 16px;
}
.search-card .hint, .hint {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}
.field, .search {
  width: 100%;
  border: 2px solid #9bb8e0;
  border-radius: 16px;
  padding: 16px 16px;
  font-size: 17px;
  background: #f8fbff;
}
.search.large {
  min-height: 62px;
  font-size: 18px;
  padding: 18px 16px;
  margin: 4px 0 14px;
}
.search-results {
  margin-top: 8px;
}
.search-status {
  color: var(--muted);
  font-size: 13px;
  margin: 8px 0;
}
.empty-search {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.4;
  padding: 12px 2px 4px;
}

.mode-card {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}
.mode-option {
  border: 1.5px solid var(--outline);
  background: var(--surface);
  border-radius: 16px;
  padding: 14px 14px;
  text-align: left;
  cursor: pointer;
  width: 100%;
  height: auto;
  font-weight: 700;
}
.mode-option strong { display: block; font-size: 15px; }
.mode-option span {
  display: block;
  margin-top: 4px;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  line-height: 1.35;
}
.mode-option.active {
  border-color: var(--google-blue);
  background: rgba(26, 115, 232, 0.08);
  color: var(--google-blue);
}
.mode-option.active.efficient {
  border-color: var(--green-dark);
  background: rgba(52, 168, 83, 0.12);
  color: var(--green-dark);
}
.result {
  padding: 12px;
  border-radius: 12px;
  background: rgba(238, 243, 248, 0.7);
  margin-bottom: 8px;
  cursor: pointer;
}
.suggest { display: flex; gap: 8px; overflow: auto; padding-bottom: 4px; }
.suggest button {
  border: 1px solid var(--outline);
  background: white;
  border-radius: 16px;
  padding: 6px 10px;
  white-space: nowrap;
  cursor: pointer;
}

.compare-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.compare-col {
  border-radius: 16px;
  padding: 12px;
  background: var(--surface-variant);
  text-align: center;
}
.compare-col.rec { border: 1.5px solid var(--google-blue); }

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  background: #111827;
  color: white;
  padding: 10px 16px;
  border-radius: 12px;
  z-index: 30;
  font-size: 13px;
}
.hidden { display: none !important; }

@media (max-width: 480px) {
  .stage {
    padding: 0;
    min-height: 100dvh;
    align-items: stretch;
  }
  .phone {
    width: 100%;
    height: 100dvh;
    border-radius: 0;
    padding: 0;
    box-shadow: none;
  }
  .phone-notch { display: none; }
  .app { border-radius: 0; }
}
