* { box-sizing: border-box; }

/* Let the hidden attribute win over display rules further down. */
[hidden] { display: none !important; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  display: grid;
  grid-template-columns: 340px 1fr;
  font: 14px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: #1c2126;
  background: #f6f7f8;
}

#panel {
  overflow-y: auto;
  padding: 14px 16px 18px;
  border-right: 1px solid #d9dde1;
  background: #fff;
}

main {
  position: relative;
  min-width: 0;
}

#map {
  position: absolute;
  inset: 0;
  background: #fff;
}

/* The basemap is drawn above the turbulence image: greyed out so it doesn't
   shift the turbulence colors, and multiplied so only its lines and labels
   darken what's underneath. */
.leaflet-base-pane {
  mix-blend-mode: multiply;
  filter: grayscale(1) contrast(0.9) brightness(1.08);
}

/* CARTO's map is pale to begin with, so it needs no lightening. Its country
   borders are a faint pink that all but vanishes in grey; strengthening the
   colors first makes them come out darker. */
.leaflet-base-pane.carto {
  filter: saturate(8) grayscale(1);
}

/* ---------- form ---------- */
#flight-form {
  display: flex;
  gap: 8px;
}

#flight-input {
  flex: 1;
  min-width: 0;
  padding: 8px 10px;
  font: inherit;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border: 1px solid #b9c0c7;
  border-radius: 6px;
}

#flight-input::placeholder {
  font-weight: 400;
  letter-spacing: 0;
  text-transform: none;
}

button {
  padding: 8px 14px;
  font: inherit;
  font-weight: 600;
  color: #fff;
  background: #1f4e79;
  border: 0;
  border-radius: 6px;
  cursor: pointer;
}

button:hover { background: #173b5c; }
button:disabled { background: #8a99a8; cursor: default; }

.message {
  margin: 10px 0 0;
  padding: 8px 10px;
  border-radius: 6px;
  background: #fff4e5;
  border: 1px solid #f0c98a;
}

.notice {
  margin: 0;
  padding: 10px 12px;
  border-radius: 6px;
  background: #f1f4f6;
  border: 1px solid #d9dde1;
}

/* ---------- sections ---------- */
section {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid #e6e9ec;
}

h2 {
  margin: 0 0 8px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: #5c6670;
}

.title {
  font-size: 20px;
  font-weight: 700;
}

.row { margin: 2px 0; }
.dim { color: #66717c; }
.small { font-size: 12px; }
p { margin: 6px 0 0; }

.stale { color: #b45309; font-weight: 600; }

/* ---------- now ---------- */
.now {
  display: flex;
  align-items: center;
  gap: 10px;
}

.chip {
  display: inline-block;
  padding: 6px 14px;
  font-size: 20px;
  font-weight: 700;
  border-radius: 8px;
  border: 1px solid rgba(0, 0, 0, 0.18);
  background: #eef1f3;
}

.cat-0 { background: #e9f6f1; color: #14532d; }
.cat-1 { background: #ccff99; color: #1c2126; }
.cat-2 { background: #f4d600; color: #1c2126; }
.cat-3 { background: #ff5b00; color: #fff; }
.cat-4 { background: #8e0000; color: #fff; }
.cat-none { background: #eef1f3; color: #66717c; }

.tag {
  display: inline-block;
  padding: 0 6px;
  font-weight: 700;
  border-radius: 4px;
  border: 1px solid rgba(0, 0, 0, 0.15);
}

/* ---------- ahead strip ---------- */
#strip, #legend-bar {
  display: block;
  width: 100%;
  border: 1px solid #aab2ba;
  border-radius: 4px;
}

#strip { height: 34px; }
#legend-bar { height: 14px; margin-top: 10px; }

.axis {
  position: relative;
  height: 16px;
  font-size: 11px;
  color: #66717c;
}

.axis span {
  position: absolute;
  top: 2px;
  transform: translateX(-50%);
  white-space: nowrap;
}

.axis span:first-child { transform: none; }
.axis span.end { transform: translateX(-100%); }

/* ---------- layer + legend ---------- */
select {
  width: 100%;
  padding: 6px 8px;
  font: inherit;
  border: 1px solid #b9c0c7;
  border-radius: 6px;
  background: #fff;
}

.legend-labels {
  position: relative;
  height: 30px;
  font-size: 11px;
}

.legend-labels span {
  position: absolute;
  top: 0;
  padding-left: 3px;
  border-left: 1px solid #1c2126;
  line-height: 1.25;
  white-space: nowrap;
}

footer {
  margin-top: 18px;
  padding-top: 12px;
  border-top: 1px solid #e6e9ec;
}

footer a { color: inherit; }

/* ---------- map furniture ---------- */
#recenter {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 1000;
  padding: 6px 12px;
  color: #1c2126;
  background: #fff;
  border: 1px solid #aab2ba;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
}

#recenter:hover { background: #f0f2f4; }

.plane-icon { background: none; border: 0; }
.plane-icon svg {
  display: block;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.45));
  transform-origin: 50% 50%;
}

.tick-label {
  background: none;
  border: 0;
  font-size: 11px;
  font-weight: 700;
  color: #1c2126;
  white-space: nowrap;
  text-shadow: 0 0 3px #fff, 0 0 3px #fff, 0 0 3px #fff;
}

.airport-label {
  background: none;
  border: 0;
  font-size: 12px;
  font-weight: 700;
  color: #1c2126;
  text-shadow: 0 0 3px #fff, 0 0 3px #fff, 0 0 3px #fff;
}

.leaflet-container { font: inherit; }
/* The credits are a long line; keep them small so they cover little of a phone's map. */
.leaflet-control-attribution { font-size: 11px; }

/* ---------- narrow screens: panel on top ---------- */
@media (max-width: 760px) {
  body {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(50vh, 1fr);
  }
  #panel {
    border-right: 0;
    border-bottom: 1px solid #d9dde1;
    max-height: 50vh;
    padding: 10px 12px 12px;
  }
  section {
    margin-top: 10px;
    padding-top: 10px;
  }
  .title { font-size: 17px; }
  /* Keep the essentials above the fold; the rest scrolls. */
  #ahead-note { display: none; }
}
