:root {
  /* Surfaces — light editorial (PNM Now) */
  --bg: #eef2f7;          /* page / stage behind the map */
  --bg-2: #f4f6f9;
  --panel: #ffffff;       /* sidebar */
  --panel-2: #f5f7fa;     /* cards, inputs */
  --line: #e6e9ee;
  --line-2: #d7dde5;
  /* Text */
  --text: #111827;        /* PNM Now near-black */
  --muted: #6b7280;
  --faint: #9ca3af;
  /* Brand */
  --accent: #111827;      /* primary ink (buttons, active states) */
  --accent-ink: #ffffff;  /* text on the ink */
  --danger: #e11d48;
  /* Map */
  --ocean: #ffffff;       /* the map disk reads as white "paper" on the grey page */
  --land: #e4e9f0;
  --land-stroke: #cfd7e1;
  --grat: #eaeef4;
  /* System */
  --radius: 12px;
  --radius-sm: 8px;
  --sidebar-w: 364px;
  --shadow: 0 16px 40px -16px rgba(17,24,39,0.22);
  --shadow-sm: 0 1px 3px rgba(17,24,39,0.08), 0 1px 2px rgba(17,24,39,0.04);
  --ring: 0 0 0 3px rgba(17,24,39,0.12);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-feature-settings: "cv02" 1, "cv11" 1, "ss01" 1;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow: hidden;
}
.route-dist, .stat-row .v, .v { font-variant-numeric: tabular-nums; }

/* Keyboard focus ring (mouse clicks don't trigger :focus-visible) */
a:focus-visible, button:focus-visible, input:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--text); outline-offset: 2px; border-radius: 6px;
}

#app { display: flex; height: 100vh; width: 100vw; }

/* ---------- Sidebar ---------- */
#sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  height: 100%;
  background: var(--panel);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  z-index: 5;
}

.brand {
  display: flex; align-items: center; gap: 12px;
  padding: 18px 22px 16px;
  border-bottom: 1px solid var(--line);
}
.logo { display: flex; color: var(--text); }
.brand-text h1 {
  margin: 0; font-size: 21px; font-weight: 800; letter-spacing: -0.5px; line-height: 1;
}
.brand-text p {
  margin: 4px 0 0; font-size: 11.5px; color: var(--muted); font-weight: 500;
}
.brand-text .byline { color: var(--text); font-weight: 700; text-decoration: none; border-bottom: 1.5px solid var(--line-2); }
.brand-text .byline:hover { border-bottom-color: var(--text); }

/* ---------- Global add box (top of sidebar) ---------- */
.add-block { padding: 14px 16px 2px; }
.global-search {
  display: flex; align-items: center; gap: 9px;
  background: var(--panel); border: 1px solid var(--line-2); border-radius: var(--radius);
  padding: 0 11px; box-shadow: var(--shadow-sm);
  transition: border-color .15s, box-shadow .15s;
}
.global-search:focus-within { border-color: var(--text); box-shadow: var(--ring); }
.global-search .search-icon { color: var(--faint); flex: none; transition: color .15s; }
.global-search:focus-within .search-icon { color: var(--text); }
.global-input {
  flex: 1; background: none; border: none; outline: none; min-width: 0;
  color: var(--text); font-family: inherit; font-size: 14px; font-weight: 500; padding: 11px 0;
}
.global-input::placeholder { color: var(--faint); font-weight: 500; }

/* ---------- Inline add (suggestions dropdown shared) ---------- */
.suggestions {
  list-style: none; margin: 10px 0 2px; padding: 5px;
  background: var(--panel); border: 1px solid var(--line-2);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-sm);
  max-height: 240px; overflow-y: auto;
}
.suggestions[hidden] { display: none; }
.suggestions li {
  display: flex; align-items: baseline; gap: 10px;
  padding: 8px 10px; border-radius: 6px; cursor: pointer; transition: background .1s;
}
.suggestions li.active, .suggestions li:hover { background: var(--panel-2); }
.sug-code { font-weight: 700; font-size: 13px; color: var(--text); min-width: 36px; letter-spacing: 0.3px; }
.sug-main { font-size: 13px; color: var(--text); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sug-sub { font-size: 11px; color: var(--muted); white-space: nowrap; }
.sug-empty { padding: 11px 10px; color: var(--muted); font-size: 13px; }

/* Inline stop input + "add" pill */
.stop-input {
  flex: 1 1 110px; min-width: 96px;
  background: var(--panel); border: 1px dashed var(--line-2); border-radius: 8px;
  color: var(--text); font-family: inherit; font-size: 13px; font-weight: 600; letter-spacing: 0.3px;
  padding: 5px 9px; outline: none; transition: border-color .14s, box-shadow .14s;
}
.stop-input::placeholder { color: var(--faint); font-weight: 500; letter-spacing: 0; }
.stop-input:focus { border-style: solid; border-color: var(--text); box-shadow: var(--ring); }
.add-stop {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; border-radius: 8px;
  background: transparent; border: 1px dashed var(--line-2); color: var(--muted);
  cursor: pointer; font-size: 16px; line-height: 1; font-family: inherit;
  transition: border-color .14s, color .14s;
}
.add-stop:hover { border-color: var(--text); color: var(--text); border-style: solid; }

/* "Add a route" button */
.add-route {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; margin-top: 2px; padding: 12px;
  background: transparent; border: 1px dashed var(--line-2); border-radius: var(--radius);
  color: var(--muted); font-family: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
  transition: border-color .15s, color .15s, background .15s;
}
.add-route:hover { border-color: var(--text); color: var(--text); background: var(--panel-2); }
.add-route .ar-plus { color: var(--text); font-size: 17px; line-height: 1; }

/* ---------- Routes ---------- */
.routes { flex: 1; overflow-y: auto; padding: 12px 16px 14px; }
.routes-bar { display: flex; justify-content: flex-end; padding: 0 2px 9px; }
.legs-toggle {
  display: inline-flex; align-items: center; gap: 6px;
  background: none; border: none; color: var(--muted); cursor: pointer;
  font-family: inherit; font-size: 11.5px; font-weight: 600; padding: 3px 4px; border-radius: 6px;
  transition: color .14s;
}
.legs-toggle:hover { color: var(--text); }
.legs-toggle svg { opacity: 0.8; }

/* Per-leg mileage breakdown */
.leg-miles {
  margin-top: 10px; padding-top: 9px; border-top: 1px dashed var(--line);
  display: flex; flex-direction: column; gap: 5px;
}
.leg-mile-row { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; font-size: 12px; }
.lm-pair { color: var(--muted); font-weight: 600; letter-spacing: 0.3px; }
.lm-right { display: inline-flex; align-items: baseline; white-space: nowrap; }
.lm-time { color: var(--muted); font-weight: 600; font-variant-numeric: tabular-nums; }
.lm-time:not(:empty)::after { content: "·"; color: var(--faint); font-weight: 400; margin: 0 6px; }
.lm-dist { color: var(--text); font-weight: 700; font-variant-numeric: tabular-nums; }
.route-card {
  position: relative;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 13px 13px 16px;
  margin-bottom: 10px; cursor: default; overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: border-color .16s, box-shadow .16s;
}
.route-card::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: var(--route-color, var(--text));
}
.route-card:hover { border-color: var(--line-2); }
.route-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.route-label { display: flex; align-items: center; gap: 8px; font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: 1.1px; font-weight: 700; }
.swatch { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.route-meta { display: flex; align-items: center; gap: 8px; }
.route-dist { font-size: 12px; color: var(--muted); }
.route-del { background: none; border: none; color: var(--faint); cursor: pointer; font-size: 16px; padding: 1px 5px; line-height: 1; border-radius: 6px; transition: color .12s, background .12s; }
.route-del:hover { color: var(--danger); background: rgba(225,29,72,0.1); }

.legs { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; }
.apt-chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--panel-2); border: 1px solid var(--line-2);
  border-radius: 8px; padding: 5px 7px 5px 10px;
  font-size: 13px; font-weight: 700; letter-spacing: 0.3px;
  transition: border-color .12s;
}
.apt-chip:hover { border-color: var(--faint); }
.apt-chip .x { color: var(--faint); cursor: pointer; font-weight: 700; font-size: 13px; transition: color .12s; }
.apt-chip .x:hover { color: var(--danger); }
.leg-arrow { color: var(--faint); font-size: 11px; }

/* ---------- Empty state ---------- */
.empty { padding: 6px 4px 14px; color: var(--muted); }
.empty-title { font-size: 14px; color: var(--text); margin: 0 0 3px; font-weight: 700; }
.empty-sub { font-size: 12.5px; margin: 0 0 13px; line-height: 1.4; }
.examples { display: flex; flex-direction: column; gap: 8px; }
.chip-example {
  text-align: left; background: var(--panel); border: 1px solid var(--line-2);
  color: var(--text); border-radius: var(--radius-sm); padding: 10px 13px; font-size: 13px; font-weight: 600; cursor: pointer;
  box-shadow: var(--shadow-sm); transition: border-color .14s, transform .05s, background .14s;
}
.chip-example:hover { border-color: var(--text); background: var(--panel-2); }
.chip-example:active { transform: translateY(1px); }

/* ---------- Stats ---------- */
.stats { padding: 14px 18px 6px; border-top: 1px solid var(--line); }
.stat-row { display: flex; align-items: baseline; justify-content: space-between; padding: 5px 0; }
.stat-row .k { font-size: 12px; color: var(--muted); }
.stat-row .v { font-size: 14px; font-weight: 700; }
.stat-row.total { padding-bottom: 8px; }
.stat-row.total .k { color: var(--text); }
.stat-row.total .v { font-size: 22px; font-weight: 800; letter-spacing: -0.5px; color: var(--text); }
.stat-sub { font-size: 11px; color: var(--faint); margin-top: 4px; display: flex; align-items: center; gap: 6px; }
.mini-spin {
  width: 9px; height: 9px; border-radius: 50%; flex: none;
  border: 1.5px solid var(--line-2); border-top-color: var(--text);
  display: inline-block; animation: spin .7s linear infinite;
}

/* ---------- Earn calculator: launch button ---------- */
.earn-mount { padding: 0 18px; }
.earn-launch {
  display: flex; align-items: center; gap: 9px; width: 100%;
  margin-top: 12px; padding: 11px 13px;
  background: var(--panel-2); border: 1px solid var(--line-2); border-radius: var(--radius);
  color: var(--text); font-family: inherit; font-size: 13px; font-weight: 700; cursor: pointer;
  box-shadow: var(--shadow-sm); transition: border-color .14s, background .14s, transform .05s;
}
.earn-launch:hover { border-color: var(--text); background: var(--panel); }
.earn-launch:active { transform: translateY(1px); }
.earn-launch svg { color: var(--muted); flex: none; }
.earn-launch span { flex: 1; text-align: left; }
.earn-launch .earn-launch-arrow { color: var(--faint); }
.earn-launch:hover svg { color: var(--text); }

/* ---------- Earn calculator: modal ---------- */
.earn-modal { position: fixed; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center; }
.earn-modal[hidden] { display: none; }
.earn-backdrop { position: absolute; inset: 0; background: rgba(17,24,39,0.34); backdrop-filter: blur(2px); animation: earnFade .18s ease; }
@keyframes earnFade { from { opacity: 0; } to { opacity: 1; } }
@keyframes earnPop { from { opacity: 0; transform: translateY(8px) scale(.985); } to { opacity: 1; transform: none; } }
.earn-dialog {
  position: relative; width: 460px; max-width: calc(100vw - 32px); max-height: calc(100vh - 48px);
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--panel); border: 1px solid var(--line-2); border-radius: 16px;
  box-shadow: var(--shadow); animation: earnPop .2s cubic-bezier(.2,.8,.2,1);
}
.earn-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  padding: 18px 20px 14px; border-bottom: 1px solid var(--line);
}
.earn-head-text h2 { margin: 0; font-size: 17px; font-weight: 800; letter-spacing: -0.4px; }
.earn-head-text p { margin: 3px 0 0; font-size: 12px; color: var(--muted); }
.earn-close {
  flex: none; width: 30px; height: 30px; border-radius: 8px; margin: -4px -4px 0 0;
  display: flex; align-items: center; justify-content: center;
  background: none; border: none; color: var(--faint); cursor: pointer; transition: color .14s, background .14s;
}
.earn-close:hover { color: var(--text); background: var(--panel-2); }
.earn-body { padding: 16px 20px 20px; overflow-y: auto; }
.earn-field { margin-bottom: 14px; }
.earn-field > label {
  display: block; margin-bottom: 6px;
  font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; color: var(--muted);
}
.earn-row2 { display: flex; gap: 12px; }
.earn-row2 .earn-field { flex: 1; min-width: 0; margin-bottom: 14px; }

/* Segmented controls (programs, distance source) stretch full width */
.earn-seg { display: flex; width: 100%; }
.earn-seg button { flex: 1; padding: 8px 6px; white-space: nowrap; }
.earn-seg button:disabled { opacity: .45; cursor: not-allowed; }
.earn-seg button:disabled:hover { color: var(--muted); }

/* Selects */
.earn-selwrap { position: relative; }
.earn-selwrap::after {
  content: ""; position: absolute; right: 12px; top: 50%; width: 8px; height: 8px; margin-top: -5px;
  border-right: 1.6px solid var(--muted); border-bottom: 1.6px solid var(--muted);
  transform: rotate(45deg); pointer-events: none;
}
.earn-select {
  width: 100%; appearance: none; -webkit-appearance: none;
  background: var(--panel); border: 1px solid var(--line-2); border-radius: var(--radius-sm);
  color: var(--text); font-family: inherit; font-size: 13px; font-weight: 600;
  padding: 10px 32px 10px 12px; cursor: pointer; box-shadow: var(--shadow-sm);
  transition: border-color .14s, box-shadow .14s;
}
.earn-select:focus { outline: none; border-color: var(--text); box-shadow: var(--ring); }

/* Elite-status field: a note where no tier bonus applies (United on partner flights) */
.earn-tier-note {
  padding: 9px 11px; font-size: 11.5px; line-height: 1.4; color: var(--muted);
  background: var(--panel-2); border: 1px dashed var(--line-2); border-radius: var(--radius-sm);
}

/* Manual distance input */
.earn-manual { display: flex; align-items: center; gap: 9px; margin-bottom: 10px; }
.earn-miles {
  width: 130px; background: var(--panel); border: 1px solid var(--line-2); border-radius: var(--radius-sm);
  color: var(--text); font-family: inherit; font-size: 14px; font-weight: 700; padding: 9px 11px; outline: none;
  font-variant-numeric: tabular-nums; transition: border-color .14s, box-shadow .14s;
}
.earn-miles:focus { border-color: var(--text); box-shadow: var(--ring); }
.earn-manual-suf { font-size: 12.5px; color: var(--muted); font-weight: 500; }
.earn-distempty {
  padding: 11px 12px; margin-bottom: 2px; color: var(--muted); font-size: 12.5px; font-weight: 500;
  background: var(--panel-2); border: 1px dashed var(--line-2); border-radius: var(--radius-sm);
}

/* Per-leg airline + fare-class blocks */
.earn-segments { display: flex; flex-direction: column; gap: 10px; }
.earn-legcfg { border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--panel-2); padding: 10px 11px; }
.earn-legcfg-manual { border: none; background: none; padding: 0; }
.earn-legcfg-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.earn-legcfg-pair { font-size: 12.5px; font-weight: 700; letter-spacing: .2px; color: var(--text); }
.earn-euro-tag {
  display: inline-block; margin-left: 7px; padding: 1px 6px; font-size: 9.5px; font-weight: 700;
  letter-spacing: .4px; text-transform: uppercase; color: var(--muted); vertical-align: middle;
  background: var(--panel-2); border: 1px solid var(--line-2); border-radius: 999px;
}
.earn-legcfg-right { display: inline-flex; align-items: baseline; gap: 8px; white-space: nowrap; }
.earn-legcfg-mi { font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.earn-legcfg-earned { font-size: 13.5px; font-weight: 800; color: var(--text); font-variant-numeric: tabular-nums; }
.earn-legcfg-earned.is-zero, .earn-legcfg-earned.is-rev { color: var(--faint); font-weight: 700; }
.earn-legcfg-controls { display: flex; gap: 8px; }
.earn-legcfg-controls .earn-selwrap { min-width: 0; }
.earn-selwrap-air { flex: 1 1 44%; }
.earn-selwrap-class { flex: 1 1 56%; }
.earn-legcfg .earn-select { padding-top: 9px; padding-bottom: 9px; }
.earn-revnote {
  flex: 1 1 56%; display: flex; align-items: center; padding: 8px 11px; line-height: 1.3;
  font-size: 11.5px; font-weight: 600; color: var(--muted);
  background: var(--panel); border: 1px dashed var(--line-2); border-radius: var(--radius-sm);
}

/* Result */
.earn-result { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.earn-total { display: flex; align-items: baseline; gap: 8px; }
.earn-total-num { font-size: 40px; font-weight: 800; letter-spacing: -1.5px; line-height: 1; color: var(--text); font-variant-numeric: tabular-nums; }
.earn-total-unit { font-size: 13px; font-weight: 700; color: var(--muted); }
.earn-none-title { font-size: 16px; font-weight: 800; letter-spacing: -0.3px; color: var(--text); }
.earn-total-sub { margin-top: 6px; font-size: 13px; color: var(--muted); }
.earn-total-sub strong { color: var(--text); font-weight: 700; }
.earn-elite-note { margin-top: 5px; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.earn-elite-note strong { color: var(--text); font-weight: 700; }

/* Status currency (American Loyalty Points, United PQP) — a secondary stat under the total */
.earn-status-row { margin-top: 13px; display: flex; align-items: baseline; gap: 7px; }
.earn-status-num { font-size: 23px; font-weight: 800; letter-spacing: -0.8px; line-height: 1; color: var(--text); font-variant-numeric: tabular-nums; }
.earn-status-unit { font-size: 12px; font-weight: 700; color: var(--muted); }
.earn-status-foot { margin-top: 6px; font-size: 11px; line-height: 1.5; color: var(--faint); }
/* Delta MQDs: revenue-based, not distance-estimable — a plain callout instead of a number */
.earn-status-note {
  margin-top: 13px; padding: 10px 12px; font-size: 11.5px; line-height: 1.5; color: var(--muted);
  background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius-sm);
}
.earn-status-note strong { color: var(--text); font-weight: 700; }

/* Partner-specific notes (revenue-based partners, route restrictions, etc.) */
.earn-partner-notes { margin-top: 13px; display: flex; flex-direction: column; gap: 7px; }
.earn-partner-note { font-size: 11.5px; line-height: 1.45; color: var(--muted); }
.earn-partner-note strong { color: var(--text); font-weight: 700; }
.earn-partner-note.is-rev {
  padding: 10px 12px; color: var(--text);
  background: rgba(225,29,72,0.06); border: 1px solid rgba(225,29,72,0.18); border-radius: var(--radius-sm);
}
.earn-partner-note.is-rev strong { color: var(--danger); }
.earn-partner-note a { color: var(--muted); font-weight: 700; text-decoration: none; border-bottom: 1px solid var(--line-2); white-space: nowrap; }
.earn-partner-note a:hover { color: var(--text); border-bottom-color: var(--text); }

.earn-caveat { margin-top: 14px; padding-top: 12px; border-top: 1px dashed var(--line); font-size: 11px; line-height: 1.5; color: var(--faint); }
.earn-caveat strong { color: var(--muted); font-weight: 700; }
.earn-caveat a { color: var(--muted); font-weight: 700; text-decoration: none; border-bottom: 1px solid var(--line-2); white-space: nowrap; }
.earn-caveat a:hover { color: var(--text); border-bottom-color: var(--text); }
.earn-verified { display: block; margin-top: 7px; font-size: 10.5px; letter-spacing: .3px; text-transform: uppercase; font-weight: 700; color: var(--faint); }

/* ---------- Footer + Subscribe ---------- */
.side-footer { display: flex; flex-direction: column; gap: 12px; padding: 14px 16px; border-top: 1px solid var(--line); }
.promo {
  display: flex; align-items: center; gap: 12px;
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 12px 13px;
}
.promo-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.promo-text strong { font-size: 12.5px; font-weight: 800; letter-spacing: -0.2px; }
.promo-text span { font-size: 11.5px; color: var(--muted); line-height: 1.35; }
.footer-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.footer-legal { display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 2px; font-size: 11px; }
.footer-legal a {
  display: inline-flex; align-items: center; gap: 5px;
  color: var(--faint); text-decoration: none; font-weight: 600; letter-spacing: 0.2px;
  padding: 4px 8px; border-radius: 7px; transition: color .14s, background .14s;
}
.footer-legal a:hover { color: var(--text); background: var(--panel-2); }
.footer-legal a svg { opacity: 0.65; transition: opacity .14s; }
.footer-legal a:hover svg { opacity: 1; }
.footer-legal .sep { width: 3px; height: 3px; border-radius: 50%; background: var(--line-2); flex: none; }
.footer-copy { text-align: center; font-size: 10.5px; color: var(--faint); margin-top: 1px; letter-spacing: 0.2px; }

/* ---------- Buttons / segmented ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  border: 1px solid var(--line-2); background: var(--panel); color: var(--text);
  border-radius: var(--radius-sm); padding: 8px 13px; font-size: 13px; font-weight: 600; cursor: pointer;
  font-family: inherit; transition: border-color .14s, background .14s, color .14s; box-shadow: var(--shadow-sm);
}
.btn:hover { border-color: var(--text); }
.btn.subtle { color: var(--muted); box-shadow: none; }
.btn.subtle:hover { color: var(--text); }

.btn-primary {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--accent); color: var(--accent-ink);
  border: 1px solid var(--accent); border-radius: var(--radius-sm);
  padding: 9px 16px; font-size: 13px; font-weight: 700; cursor: pointer; white-space: nowrap;
  font-family: inherit; text-decoration: none; transition: opacity .14s, transform .05s;
}
.btn-primary:hover { opacity: 0.88; }
.btn-primary:active { transform: translateY(1px); }

.seg { display: inline-flex; background: var(--panel); border: 1px solid var(--line-2); border-radius: var(--radius-sm); padding: 3px; gap: 2px; box-shadow: var(--shadow-sm); }
.seg button {
  border: none; background: none; color: var(--muted); cursor: pointer;
  padding: 6px 12px; font-size: 12.5px; font-weight: 700; border-radius: 6px; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center; font-family: inherit;
  transition: color .14s, background .14s;
}
.seg button:hover { color: var(--text); }
.seg button.active { background: var(--accent); color: var(--accent-ink); }
.view-toggle button { padding: 8px 11px; }

.icon-btn {
  width: 36px; height: 36px; border-radius: 10px;
  border: 1px solid var(--line-2); background: var(--panel);
  color: var(--text); cursor: pointer; font-size: 19px; line-height: 1;
  display: flex; align-items: center; justify-content: center; box-shadow: var(--shadow-sm);
  transition: border-color .14s, color .14s;
}
.icon-btn:hover { border-color: var(--text); }
.icon-btn.ghost { width: auto; height: auto; border: none; background: none; padding: 2px 4px; font-size: 18px; color: var(--faint); box-shadow: none; }
.icon-btn.ghost:hover { color: var(--text); }

/* ---------- Stage / map ---------- */
#stage {
  position: relative; flex: 1; height: 100%; overflow: hidden;
  background:
    radial-gradient(1200px 700px at 70% -12%, #ffffff 0%, transparent 55%),
    var(--bg);
}
#map { width: 100%; height: 100%; display: block; cursor: grab; }
#map:active { cursor: grabbing; }

.map-controls { position: absolute; z-index: 6; display: flex; gap: 8px; }
.map-controls.top-right { top: 18px; right: 18px; align-items: center; }
.map-controls.bottom-right { right: 18px; bottom: 18px; flex-direction: column; }

.loading {
  position: absolute; top: 18px; left: 50%; transform: translateX(-50%);
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--panel); border: 1px solid var(--line-2); color: var(--muted);
  padding: 8px 15px; border-radius: 22px; font-size: 12.5px; z-index: 7; box-shadow: var(--shadow-sm);
}
.loading::before {
  content: ""; width: 11px; height: 11px; border-radius: 50%;
  border: 2px solid var(--line-2); border-top-color: var(--text); animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading.hidden { opacity: 0; pointer-events: none; transition: opacity .45s; }

.tooltip {
  position: absolute; z-index: 20; pointer-events: none;
  background: var(--panel); border: 1px solid var(--line-2);
  border-radius: 10px; padding: 9px 12px; box-shadow: var(--shadow);
  font-size: 12.5px; max-width: 250px; transform: translate(-50%, calc(-100% - 14px));
}
.tooltip .t-code { font-weight: 800; color: var(--text); margin-right: 6px; letter-spacing: 0.3px; }
.tooltip .t-name { color: var(--text); }
.tooltip .t-sub { color: var(--muted); font-size: 11.5px; margin-top: 3px; }

/* ---------- Map SVG element styles ---------- */
.sphere { fill: var(--ocean); }
.graticule { fill: none; stroke: var(--grat); stroke-width: 0.6; }
.land { fill: var(--land); stroke: var(--land-stroke); stroke-width: 0.6; }
.route-arc { fill: none; stroke-linecap: round; opacity: 0.95; transition: opacity .25s; }
.route-arc.dim { opacity: 0.16; }
.apt-dot { stroke: #ffffff; stroke-width: 1.5; cursor: pointer; }
.apt-halo { opacity: 0.18; pointer-events: none; }
.apt-label {
  fill: var(--text); font-size: 11px; font-weight: 700; letter-spacing: 0.3px;
  paint-order: stroke; stroke: #ffffff; stroke-width: 3.5px; stroke-linejoin: round; pointer-events: none;
}

/* ---------- Toast ---------- */
.toast {
  position: absolute; bottom: 20px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--accent); color: var(--accent-ink); font-weight: 700; font-size: 13px;
  padding: 10px 18px; border-radius: 22px; z-index: 40; opacity: 0;
  transition: opacity .25s, transform .25s; box-shadow: var(--shadow);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- Scrollbars ---------- */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 6px; }
::-webkit-scrollbar-thumb:hover { background: var(--faint); }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- Responsive ---------- */
@media (max-width: 760px) {
  /* Map fixed on top; the whole sidebar scrolls as one unit beneath it. */
  #app { flex-direction: column-reverse; height: 100vh; height: 100dvh; }
  #stage { flex: none; height: 42vh; height: 42dvh; min-height: 250px; }
  #sidebar {
    width: 100%; min-width: 0; flex: 1 1 auto; height: auto; min-height: 0;
    border-right: none; border-top: 1px solid var(--line);
    overflow-y: auto; -webkit-overflow-scrolling: touch;
  }
  .routes { flex: none; overflow: visible; padding-bottom: 4px; }

  .brand { padding: 14px 16px 12px; }
  .add-block { padding: 14px 14px 2px; }
  .routes { padding: 12px 14px 4px; }
  .stats { padding: 14px 16px 6px; }
  .side-footer { padding: 13px 14px calc(14px + env(safe-area-inset-bottom)); }

  /* 16px inputs stop iOS from zooming the page on focus */
  .global-input, .stop-input { font-size: 16px; }
  .global-input { padding: 12px 0; }

  /* Bigger, comfier tap targets on the map */
  .icon-btn { width: 42px; height: 42px; border-radius: 11px; }
  .map-controls { gap: 9px; }
  .map-controls.top-right { top: 12px; right: 12px; }
  .map-controls.bottom-right { right: 12px; bottom: 12px; }
  .view-toggle button { padding: 9px 12px; }

  .legs-toggle { padding: 6px 6px; font-size: 12px; }
  .suggestions { max-height: 260px; }

  /* Earn calculator becomes a bottom sheet on phones */
  .earn-mount { padding: 0 14px; }
  .earn-modal { align-items: flex-end; }
  .earn-dialog {
    width: 100%; max-width: 100%; max-height: 92vh; max-height: 92dvh;
    border-radius: 18px 18px 0 0; border-bottom: none;
    animation: earnSheet .22s cubic-bezier(.2,.8,.2,1);
    padding-bottom: env(safe-area-inset-bottom);
  }
  @keyframes earnSheet { from { transform: translateY(100%); } to { transform: none; } }
  .earn-legcfg-controls { flex-direction: column; gap: 8px; }
  .earn-selwrap-air, .earn-selwrap-class, .earn-revnote { flex: 1 1 auto; }
  .earn-select { font-size: 16px; }  /* stop iOS zoom-on-focus */
  .earn-miles { font-size: 16px; }
  .earn-total-num { font-size: 34px; }
}
