.am4 {
  --am4-bg: #EDF0F3; --am4-surface: #FFFFFF; --am4-field: #F6F8FA; --am4-ink: #101D27; --am4-muted: #54636F;
  --am4-line: #CBD3DA; --am4-accent: #0A6C8C; --am4-accent-ink: #FFFFFF; --am4-stop: #A85408; --am4-ok: #17704A;
  --am4-bad: #B3261E; --am4-ocean: #E4EEF4; --am4-land: #C3D1DB; --am4-border: #6C8498; --am4-city: #34505F;
  --am4-shadow: 0 1px 2px rgba(16, 29, 39, .08), 0 10px 28px rgba(16, 29, 39, .12);
  --am4-f-display: "Barlow Semi Condensed", "Arial Narrow", system-ui, sans-serif;
  --am4-f-body: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --am4-f-mono: "IBM Plex Mono", ui-monospace, Menlo, Consolas, monospace;
}

/* AM4 Stopover Finder: widget styles.
   Everything is scoped under .am4 and prefixed am4-, so it cannot restyle (or be restyled by) a host site's theme.
   Layout: one narrow column worksheet. Settings and inputs on top, the flight-plan result below it. */

.am4, .am4 *, .am4 *::before, .am4 *::after { box-sizing: border-box; }
.am4 {
  max-width: 880px; margin: 0 auto; padding: 20px;
  display: flex; flex-direction: column; gap: 20px;
  background: var(--am4-bg); color: var(--am4-ink);
  font-family: var(--am4-f-body); font-size: 16px; line-height: 1.5; text-align: left;
  border-radius: 12px;
  container-type: inline-size; container-name: am4;
}
.am4 p, .am4 h1, .am4 h2, .am4 h3, .am4 dl, .am4 dt, .am4 dd, .am4 ul, .am4 li, .am4 fieldset, .am4 legend {
  margin: 0; padding: 0; border: 0; text-transform: none; letter-spacing: normal; font-style: normal;
}
.am4 a { color: var(--am4-accent); }

.am4 .am4-kicker { font-family: var(--am4-f-display); font-weight: 600; font-size: 14px; letter-spacing: .14em; text-transform: uppercase; color: var(--am4-accent); }
.am4 .am4-title { font-family: var(--am4-f-display); font-weight: 700; font-size: clamp(34px, 6vw, 48px); line-height: 1.05; margin: 4px 0 8px; color: var(--am4-ink); text-wrap: balance; }
.am4 .am4-lede { max-width: 62ch; color: var(--am4-muted); }

.am4 .am4-panel { background: var(--am4-surface); border: 1px solid var(--am4-line); border-radius: 10px; padding: 20px; }
.am4 .am4-form { display: flex; flex-direction: column; gap: 18px; }

/* segmented switches */
.am4 .am4-group { min-width: 0; }
.am4 .am4-group legend {
  float: none; width: auto; margin-bottom: 8px;
  font-family: var(--am4-f-display); font-weight: 600; font-size: 14px; letter-spacing: .1em; text-transform: uppercase; color: var(--am4-muted);
}
.am4 .am4-segs { display: inline-flex; border: 1px solid var(--am4-line); border-radius: 8px; overflow: hidden; }
.am4 .am4-seg { position: relative; display: block; margin: 0; padding: 0; cursor: pointer; }
.am4 .am4-seg input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.am4 .am4-seg span {
  display: block; padding: 9px 22px; min-width: 110px; text-align: center;
  font-family: var(--am4-f-display); font-weight: 600; font-size: 18px; line-height: 1.4; letter-spacing: .02em;
  background: var(--am4-field); color: var(--am4-ink);
}
.am4 .am4-seg + .am4-seg span { border-left: 1px solid var(--am4-line); }
.am4 .am4-seg input:checked + span { background: var(--am4-accent); color: var(--am4-accent-ink); }
.am4 .am4-seg input:focus-visible + span { outline: 3px solid var(--am4-ink); outline-offset: -3px; }
.am4 .am4-help { margin-top: 10px; font-size: 14px; color: var(--am4-muted); max-width: 70ch; }

/* inputs */
.am4 .am4-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 20px; }
.am4 .am4-field { min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.am4 .am4-field.am4-wide { grid-column: 1 / -1; }
.am4 .am4-field label {
  display: block; margin: 0; padding: 0;
  font-family: var(--am4-f-display); font-weight: 600; font-size: 14px; line-height: 1.4; letter-spacing: .1em; text-transform: uppercase; color: var(--am4-muted);
}
.am4 .am4-combo { position: relative; }
.am4 .am4-combo input[type="text"] {
  display: block; width: 100%; max-width: none; height: 46px; margin: 0; padding: 0 12px;
  font: 500 16px/1 var(--am4-f-mono); color: var(--am4-ink); background: var(--am4-field);
  border: 1px solid var(--am4-line); border-radius: 8px; box-shadow: none; appearance: none; -webkit-appearance: none;
}
.am4 .am4-combo input[type="text"]::placeholder { color: var(--am4-muted); opacity: .8; font-weight: 400; }
.am4 .am4-combo input[type="text"]:focus-visible { outline: 3px solid var(--am4-accent); outline-offset: 1px; border-color: var(--am4-accent); }
.am4 .am4-combo input[type="text"][aria-invalid="true"] { border-color: var(--am4-bad); }

.am4 .am4-list {
  position: absolute; z-index: 20; left: 0; right: 0; top: calc(100% + 4px);
  margin: 0; padding: 4px; list-style: none; max-height: 340px; overflow-y: auto;
  background: var(--am4-surface); border: 1px solid var(--am4-line); border-radius: 8px; box-shadow: var(--am4-shadow);
}
.am4 .am4-list[hidden] { display: none; }
.am4 .am4-opt {
  display: grid; grid-template-columns: 64px minmax(0, 1fr) auto; gap: 12px; align-items: center;
  margin: 0; padding: 8px 10px; border-radius: 6px; cursor: pointer; list-style: none;
}
.am4 .am4-opt[aria-selected="true"] { background: color-mix(in srgb, var(--am4-accent) 16%, transparent); }
.am4 .am4-opt.am4-dim .am4-o-name, .am4 .am4-opt.am4-dim .am4-o-code { opacity: .6; }
.am4 .am4-o-code { display: flex; flex-direction: column; font-family: var(--am4-f-mono); line-height: 1.25; min-width: 0; overflow-wrap: anywhere; }
.am4 .am4-o-code b { font-weight: 600; font-size: 15px; }
.am4 .am4-o-code i { font-style: normal; font-size: 12px; color: var(--am4-muted); }
.am4 .am4-o-main { display: flex; flex-direction: column; min-width: 0; }
.am4 .am4-o-name { font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.am4 .am4-o-sub { font-size: 13px; color: var(--am4-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.am4 .am4-o-sub em { font-style: normal; color: var(--am4-bad); }
.am4 .am4-o-side { font-family: var(--am4-f-mono); font-size: 13px; color: var(--am4-muted); text-align: right; white-space: nowrap; line-height: 1.35; }

.am4 .am4-meta { min-height: 1.4em; font-size: 14px; color: var(--am4-muted); }
.am4 .am4-meta.am4-err, .am4 .am4-meta .am4-warn { color: var(--am4-bad); }

.am4 .am4-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 18px; }
.am4 .am4-go {
  height: 48px; margin: 0; padding: 0 28px; border: 0; border-radius: 8px; cursor: pointer;
  background: var(--am4-accent); color: var(--am4-accent-ink); box-shadow: none;
  font-family: var(--am4-f-display); font-weight: 700; font-size: 19px; line-height: 1; letter-spacing: .04em; text-transform: uppercase;
}
.am4 .am4-go:hover { filter: brightness(1.08); }
.am4 .am4-go:focus-visible { outline: 3px solid var(--am4-ink); outline-offset: 2px; }

/* load status: shown until the script has started, or if it fails */
.am4 .am4-status { padding: 10px 14px; border-radius: 8px; font-size: 14px; background: var(--am4-surface); border: 1px solid var(--am4-line); color: var(--am4-muted); }
.am4 .am4-status[hidden] { display: none; }
.am4 .am4-status.am4-bad { color: var(--am4-bad); border-color: var(--am4-bad); }

/* result */
.am4 #am4-result:empty { display: none; }
.am4 .am4-card { background: var(--am4-surface); border: 1px solid var(--am4-line); border-radius: 10px; padding: 22px 20px; display: flex; flex-direction: column; gap: 22px; }
.am4 .am4-verdict { display: flex; flex-direction: column; gap: 8px; }
.am4 .am4-tag {
  align-self: flex-start; padding: 3px 10px; border-radius: 999px;
  font-family: var(--am4-f-display); font-weight: 600; font-size: 13px; line-height: 1.5; letter-spacing: .12em; text-transform: uppercase;
}
.am4 .am4-tag.am4-t-stop { color: var(--am4-stop); background: color-mix(in srgb, var(--am4-stop) 15%, transparent); }
.am4 .am4-tag.am4-t-ok { color: var(--am4-ok); background: color-mix(in srgb, var(--am4-ok) 15%, transparent); }
.am4 .am4-tag.am4-t-bad { color: var(--am4-bad); background: color-mix(in srgb, var(--am4-bad) 14%, transparent); }
.am4 .am4-route {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 14px;
  font-family: var(--am4-f-display); font-weight: 700; font-size: clamp(34px, 7vw, 52px); line-height: 1.05; letter-spacing: .02em; color: var(--am4-ink);
}
.am4 .am4-route i { font-style: normal; font-weight: 500; color: var(--am4-muted); }
.am4 .am4-route .am4-via { color: var(--am4-stop); }
.am4 .am4-plain { font-family: var(--am4-f-display); font-weight: 700; font-size: 28px; line-height: 1.15; color: var(--am4-ink); text-wrap: balance; }
.am4 .am4-sum { max-width: 68ch; }

/* route line: leg widths follow leg distance */
.am4 .am4-viz { display: flex; align-items: flex-start; padding: 6px 2px 2px; }
.am4 .am4-node { flex: none; width: 58px; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.am4 .am4-node .am4-code { font: 600 18px/26px var(--am4-f-mono); }
.am4 .am4-node .am4-dot {
  width: 14px; height: 14px; border-radius: 50%; background: var(--am4-accent);
  border: 3px solid var(--am4-surface); box-shadow: 0 0 0 2px var(--am4-accent);
}
.am4 .am4-node.am4-n-stop .am4-dot { background: var(--am4-stop); box-shadow: 0 0 0 2px var(--am4-stop); }
.am4 .am4-node.am4-n-stop .am4-code { color: var(--am4-stop); }
.am4 .am4-leg { flex: 1 1 0; min-width: 110px; margin: 38px -2px 0; padding-top: 8px; text-align: center; border-top: 2px solid var(--am4-accent); }
.am4 .am4-leg .am4-len { display: block; font: 500 15px/1.35 var(--am4-f-mono); }
.am4 .am4-leg .am4-pct { display: block; font-size: 12px; color: var(--am4-muted); }

/* round route map */
.am4 .am4-map { position: relative; width: 100%; max-width: 640px; aspect-ratio: 1 / 1; margin: 0 auto; background: var(--am4-ocean); border: 1px solid var(--am4-line); border-radius: 50%; overflow: hidden; }
.am4 .am4-map svg.am4-base { position: absolute; left: 0; top: 0; display: block; max-width: none; }
.am4 .am4-land { fill: var(--am4-land); stroke: none; }
.am4 .am4-border { fill: none; stroke: var(--am4-border); stroke-width: .8px; stroke-linejoin: round; }
.am4 .am4-city { fill: var(--am4-city); }
.am4 .am4-arc-case { fill: none; stroke: var(--am4-surface); stroke-width: 6px; stroke-linecap: round; stroke-linejoin: round; opacity: .85; }
.am4 .am4-arc { fill: none; stroke: var(--am4-accent); stroke-width: 2.8px; stroke-linecap: round; stroke-linejoin: round; }
.am4 .am4-pin { position: absolute; width: 0; height: 0; }
.am4 .am4-pin .am4-pd {
  position: absolute; left: -6.5px; top: -6.5px; width: 13px; height: 13px; border-radius: 50%;
  background: var(--am4-accent); border: 2px solid var(--am4-surface); box-shadow: 0 0 0 1.5px var(--am4-accent);
}
.am4 .am4-pin.am4-stop .am4-pd { background: var(--am4-stop); box-shadow: 0 0 0 1.5px var(--am4-stop); }
.am4 .am4-lab {
  position: absolute; padding: 1px 6px; border-radius: 5px; white-space: nowrap;
  background: color-mix(in srgb, var(--am4-surface) 90%, transparent);
  font: 600 13px/20px var(--am4-f-mono); color: var(--am4-ink);
}
.am4 .am4-lab.am4-stop { color: var(--am4-stop); }
.am4 .am4-legl {
  position: absolute; padding: 0 8px; border-radius: 999px; white-space: nowrap;
  background: var(--am4-surface); border: 1px solid var(--am4-accent);
  font: 500 12px/20px var(--am4-f-mono); color: var(--am4-ink);
}

/* figures */
.am4 .am4-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 16px 24px; padding-top: 18px; border-top: 1px solid var(--am4-line); }
.am4 .am4-stat { min-width: 0; }
.am4 .am4-stat dt { font-family: var(--am4-f-display); font-weight: 600; font-size: 13px; letter-spacing: .1em; text-transform: uppercase; color: var(--am4-muted); }
.am4 .am4-stat dd { margin: 2px 0 0; font: 500 21px/1.25 var(--am4-f-mono); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.am4 .am4-stat dd.am4-stopc { color: var(--am4-stop); }

.am4 .am4-h3 { font-family: var(--am4-f-display); font-weight: 600; font-size: 20px; line-height: 1.3; letter-spacing: .02em; color: var(--am4-ink); }
.am4 .am4-scroll { overflow-x: auto; }
.am4 .am4-table { width: 100%; margin: 0; border-collapse: collapse; border-spacing: 0; border: 0; font-size: 15px; background: transparent; }
.am4 .am4-table caption {
  caption-side: top; text-align: left; padding: 0 0 8px; color: var(--am4-ink);
  font-family: var(--am4-f-display); font-weight: 600; font-size: 20px; line-height: 1.3; letter-spacing: .02em;
}
.am4 .am4-table th {
  text-align: left; padding: 8px 12px 8px 0; background: transparent; border: 0; border-bottom: 1px solid var(--am4-line);
  font-family: var(--am4-f-display); font-weight: 600; font-size: 13px; line-height: 1.3; letter-spacing: .1em; text-transform: uppercase; color: var(--am4-muted); vertical-align: bottom;
}
.am4 .am4-table td { padding: 10px 12px 10px 0; background: transparent; border: 0; border-bottom: 1px solid var(--am4-line); vertical-align: top; color: var(--am4-ink); }
.am4 .am4-table tbody tr, .am4 .am4-table tbody tr:nth-child(odd), .am4 .am4-table tbody tr:nth-child(even) { background: transparent; }
.am4 .am4-table tbody tr:last-child td { border-bottom: 0; }
.am4 .am4-table th.am4-num, .am4 .am4-table td.am4-num { text-align: right; font-variant-numeric: tabular-nums; }
.am4 .am4-table td.am4-num { white-space: nowrap; }
.am4 .am4-table td.am4-hm { font-family: var(--am4-f-mono); font-weight: 500; }
.am4 .am4-mono { font-family: var(--am4-f-mono); font-weight: 500; white-space: nowrap; }
.am4 .am4-okt { color: var(--am4-ok); font-size: 13px; margin-left: 6px; }
.am4 .am4-fine { margin-top: -10px; font-size: 13px; color: var(--am4-muted); max-width: 72ch; }
.am4 .am4-foot { font-size: 13px; color: var(--am4-muted); max-width: 72ch; }

@container am4 (max-width: 480px) { .am4 .am4-opt-name-sub, .am4 .am4-lab small { display: none; } }
@container am4 (max-width: 640px) {
  .am4 .am4-grid { grid-template-columns: 1fr; }
  .am4 .am4-panel, .am4 .am4-card { padding: 16px; }
  .am4 .am4-opt { grid-template-columns: 56px minmax(0, 1fr) auto; gap: 10px; }
  .am4 .am4-go { width: 100%; }
  .am4 .am4-viz { flex-direction: column; align-items: flex-start; }
  .am4 .am4-node { flex-direction: row; width: auto; gap: 14px; align-items: center; }
  .am4 .am4-node .am4-code { order: 2; }
  .am4 .am4-leg {
    flex: none !important; min-width: 0; margin: 0 0 0 6px; padding: 14px 0 14px 20px;
    border-top: 0; border-left: 2px solid var(--am4-accent); text-align: left;
  }
}
@media (prefers-reduced-motion: reduce) { .am4 * { transition: none !important; scroll-behavior: auto !important; } }

/* flight-time table: the five figure columns share the width equally */
.am4 .am4-times { table-layout: fixed; min-width: 720px; }
.am4 .am4-times col.am4-c-eng { width: 22%; }
.am4 .am4-times col.am4-c-n { width: 13%; }
.am4 .am4-times th { white-space: normal; vertical-align: bottom; }
.am4 .am4-times td:first-child { overflow-wrap: anywhere; }

.am4 .am4-dem { table-layout: fixed; min-width: 520px; }
.am4 .am4-dem col.am4-c-eng { width: 22%; }
.am4 .am4-dem col.am4-c-n { width: 15.6%; }
.am4 .am4-dem td.am4-num { font-family: var(--am4-f-mono); }

/* aircraft photo and its credit */
.am4 .am4-photo { margin: 0; display: flex; flex-direction: column; align-items: stretch; gap: 8px; width: 100%; }
.am4 .am4-photo[hidden] { display: none; }
.am4 .am4-photo img { display: block; width: 100%; height: auto; border-radius: 8px; background: var(--am4-field); }
.am4 .am4-photo figcaption { width: 100%; font-size: 12px; line-height: 1.4; color: var(--am4-muted); overflow-wrap: anywhere; }
.am4 .am4-photo .am4-acinfo { margin: 0 0 4px; font-size: 13px; color: var(--am4-text, inherit); }
.am4 .am4-photo .am4-credit { display: block; }
