:root {
  color-scheme: light;
  --workspace: #c7d6e3;
  --workspace-deep: #9fb6c8;
  --surface: rgba(248, 251, 253, 0.96);
  --surface-solid: #f8fbfd;
  --surface-muted: #eaf0f4;
  --text: #10283c;
  --text-muted: #526c80;
  --line: rgba(42, 76, 101, 0.2);
  --line-strong: rgba(42, 76, 101, 0.38);
  --accent: #0879e8;
  --accent-soft: #dceeff;
  --live: #0879e8;
  --stale: #667f92;
  --shadow: 0 18px 44px rgba(20, 48, 70, 0.2);
  --bar-height: 64px;
  --radius-panel: 18px;
  font-family: Inter, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

:root[data-theme="night"] {
  color-scheme: dark;
  --workspace: #061525;
  --workspace-deep: #020b14;
  --surface: rgba(7, 25, 42, 0.94);
  --surface-solid: #081c2e;
  --surface-muted: #102c43;
  --text: #edf7fc;
  --text-muted: #9bb3c5;
  --line: rgba(143, 185, 211, 0.18);
  --line-strong: rgba(143, 185, 211, 0.34);
  --accent: #4fb4ff;
  --accent-soft: #103a59;
  --live: #75c8ff;
  --stale: #71889a;
  --shadow: 0 22px 54px rgba(0, 0, 0, 0.42);
}

* { box-sizing: border-box; }

html,
body {
  width: 100%;
  min-width: 0;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--workspace-deep);
  color: var(--text);
}

button,
a { -webkit-tap-highlight-color: transparent; }

button { font: inherit; }

button:focus-visible,
a:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}

.skip-link {
  position: fixed;
  z-index: 1000;
  top: 8px;
  left: 8px;
  transform: translateY(-140%);
  padding: 10px 14px;
  border-radius: 8px;
  background: var(--surface-solid);
  color: var(--text);
  font-weight: 700;
  text-decoration: none;
}

.skip-link:focus { transform: translateY(0); }

.adsb-shell {
  display: grid;
  grid-template-rows: var(--bar-height) minmax(0, 1fr);
  width: 100%;
  height: 100dvh;
  min-height: 0;
}

.product-bar {
  position: relative;
  z-index: 40;
  display: grid;
  grid-template-columns: minmax(150px, auto) 1fr auto;
  align-items: center;
  gap: clamp(16px, 2vw, 36px);
  min-width: 0;
  min-height: var(--bar-height);
  padding: 0 clamp(16px, 2vw, 40px);
  border-bottom: 1px solid rgba(117, 168, 201, 0.2);
  background: color-mix(in srgb, var(--theme-shell) 94%, transparent);
  box-shadow: 0 10px 32px rgba(0, 6, 12, 0.18);
  backdrop-filter: blur(18px) saturate(125%);
}

.product-mark {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  min-height: 44px;
  color: var(--pilotcb-white);
  text-decoration: none;
}

.product-mark-icon { display: block; width: 40px; height: 30px; object-fit: cover; object-position: center; }

.product-mark-copy { display: grid; line-height: 1; }
.product-mark-copy strong { font-size: 15px; letter-spacing: 0.18em; }
.product-mark-copy small { margin-top: 5px; color: var(--text-muted); font-size: 9px; font-weight: 800; letter-spacing: 0.34em; }

.product-nav {
  display: flex;
  align-items: stretch;
  justify-self: start;
  height: var(--bar-height);
}

.product-nav a {
  position: relative;
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 clamp(12px, 1.2vw, 22px);
  color: #9eb5ca;
  font-size: 13px;
  font-weight: 650;
  letter-spacing: 0.035em;
  text-decoration: none;
  white-space: nowrap;
}

.product-nav a:hover { color: var(--pilotcb-white); }
.product-nav a[data-pilotcb-account-link] { min-width: 5.25em; }
.product-nav a[aria-current="page"] { color: var(--pilotcb-white); }
.product-nav a[aria-current="page"]::after {
  content: "";
  position: absolute;
  right: 16px;
  bottom: 0;
  left: 16px;
  height: 3px;
  background: var(--accent);
}

.product-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.provider-status {
  max-width: 220px;
  overflow: hidden;
  color: #9eb5ca;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.provider-status[data-state="live"] { color: var(--live); }
.provider-status[data-state="stale"] { color: #b7782f; }
.provider-status[data-state="unavailable"] { color: #9eb5ca; }
.provider-status[data-state="qa"] { color: #b7782f; }

.bar-button,
.feed-button,
.map-refresh,
.icon-button,
.inactive-action,
.traffic-list-item {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 10px;
  cursor: pointer;
  transition: background-color 180ms ease, border-color 180ms ease, color 180ms ease, opacity 180ms ease;
}

.bar-button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0 12px;
  border-color: rgba(117, 168, 201, 0.28);
  background: rgba(8, 32, 53, 0.84);
  color: var(--pilotcb-white);
  font-size: 12px;
  font-weight: 700;
}

.bar-button:hover { border-color: rgba(126, 197, 239, 0.58); background: rgba(12, 49, 80, 0.94); }
.icon-button:hover { border-color: var(--line-strong); background: var(--accent-soft); }

.bar-button svg,
.map-refresh svg,
.icon-button svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.feed-button {
  padding: 0 16px;
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.03em;
}

.feed-button:hover { filter: brightness(1.08); }

.map-workspace {
  position: relative;
  min-width: 0;
  min-height: 0;
  isolation: isolate;
  overflow: hidden;
  background: var(--workspace);
}

.adsb-map {
  position: absolute;
  z-index: 0;
  inset: 0;
}

.workspace-title-block {
  position: absolute;
  z-index: 12;
  top: clamp(14px, 2vw, 28px);
  left: clamp(14px, 2vw, 32px);
  min-width: 210px;
  padding: 14px 16px 13px;
  border: 1px solid var(--line-strong);
  border-left: 3px solid var(--accent);
  border-radius: 4px 14px 14px 4px;
  background: var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.workspace-title-block p,
.panel-heading p,
.sheet-heading p {
  margin: 0 0 5px;
  color: var(--text-muted);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.workspace-title-block h1,
.panel-heading h2,
.sheet-heading h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.025em;
}

.workspace-readout {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 11px;
  color: var(--text-muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

.live-indicator {
  width: 7px;
  height: 7px;
  border: 2px solid var(--surface-solid);
  border-radius: 50%;
  background: var(--stale);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--stale) 42%, transparent);
}
body[data-traffic-state="live"] .live-indicator { background: var(--live); box-shadow: 0 0 0 2px color-mix(in srgb, var(--live) 42%, transparent); }
body[data-traffic-state="stale"] .live-indicator { background: #b7782f; box-shadow: 0 0 0 2px rgba(183, 120, 47, 0.28); }

.map-refresh {
  position: absolute;
  z-index: 12;
  top: clamp(14px, 2vw, 28px);
  right: clamp(60px, 5vw, 78px);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 13px;
  background: var(--surface);
  box-shadow: 0 9px 24px rgba(0, 0, 0, 0.18);
  color: var(--text);
  font-size: 11px;
  font-weight: 750;
  backdrop-filter: blur(10px);
}

.map-refresh:disabled { cursor: wait; opacity: 0.64; }

.map-state {
  position: absolute;
  z-index: 11;
  top: 50%;
  left: 50%;
  display: flex;
  align-items: stretch;
  gap: 14px;
  width: min(420px, calc(100% - 32px));
  padding: 14px 16px;
  transform: translate(-50%, -50%);
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.map-state[hidden] { display: none; }
.map-state-rule { width: 3px; border-radius: 2px; background: var(--accent); }
.map-state[data-state="error"] .map-state-rule { background: #d98c3b; }
.map-state[data-state="stale"] .map-state-rule { background: #b7782f; }
.map-state strong { display: block; font-size: 13px; }
.map-state span:not(.map-state-rule) { display: block; margin-top: 4px; color: var(--text-muted); font-size: 11px; line-height: 1.45; }

.basemap-state {
  position: absolute;
  z-index: 11;
  bottom: 58px;
  left: 12px;
  display: grid;
  gap: 2px;
  max-width: min(330px, calc(100% - 24px));
  padding: 8px 10px;
  border: 1px solid var(--line-strong);
  border-left: 3px solid #d98c3b;
  border-radius: 7px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.basemap-state[hidden] { display: none; }
.basemap-state strong { font-size: 10px; letter-spacing: 0.04em; text-transform: uppercase; }
.basemap-state span { color: var(--text-muted); font-size: 9px; }

.aircraft-panel {
  position: absolute;
  z-index: 20;
  top: clamp(84px, 13vh, 144px);
  right: clamp(14px, 2vw, 32px);
  width: min(390px, calc(100% - 28px));
  max-height: calc(100% - clamp(160px, 25vh, 240px));
  overflow: auto;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-panel);
  background: var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.aircraft-panel[hidden] { display: none; }

.panel-heading,
.sheet-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 18px 14px;
  border-bottom: 1px solid var(--line);
}

.panel-heading h2 { font-size: 26px; font-variant-numeric: tabular-nums; }
.panel-heading span { display: inline-block; margin-top: 7px; color: var(--text-muted); font-size: 10px; font-weight: 800; letter-spacing: 0.09em; }
.panel-heading span[data-freshness="live"] { color: var(--live); }

.icon-button {
  display: grid;
  flex: 0 0 44px;
  width: 44px;
  padding: 0;
  place-items: center;
  background: transparent;
  color: var(--text);
}

.aircraft-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin: 0;
  padding: 6px 18px 18px;
}

.aircraft-field {
  min-width: 0;
  padding: 12px 8px 10px 0;
  border-bottom: 1px solid var(--line);
}

.aircraft-field:nth-last-child(-n + 2) { border-bottom: 0; }
.aircraft-field dt { margin-bottom: 5px; color: var(--text-muted); font-size: 9px; font-weight: 750; letter-spacing: 0.08em; text-transform: uppercase; }
.aircraft-field dd { margin: 0; overflow-wrap: anywhere; font-size: 12px; font-variant-numeric: tabular-nums; font-weight: 650; line-height: 1.35; }

.map-legend {
  position: absolute;
  z-index: 10;
  right: clamp(14px, 2vw, 32px);
  bottom: 48px;
  display: flex;
  gap: 16px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text-muted);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.14);
  font-size: 10px;
  font-weight: 700;
  backdrop-filter: blur(10px);
}

.map-legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend-shape { display: inline-block; width: 8px; height: 12px; clip-path: polygon(50% 0, 100% 100%, 50% 73%, 0 100%); background: var(--live); }
.legend-shape--stale { background: var(--stale); }
.legend-shape--selected { background: var(--accent); filter: drop-shadow(0 0 2px var(--text)); }

.data-attribution {
  display: block;
  position: absolute;
  z-index: 10;
  bottom: 29px;
  left: 12px;
  max-width: min(70vw, 720px);
  margin: 0;
  padding: 3px 6px;
  border-radius: 4px;
  background: color-mix(in srgb, var(--surface-solid) 86%, transparent);
  color: var(--text-muted);
  font-size: 9px;
}
.data-attribution a { color: inherit; }
.maplibregl-ctrl-attrib-inner { white-space: normal; overflow-wrap: anywhere; }

.sheet {
  position: fixed;
  z-index: 100;
  top: calc(var(--bar-height) + 14px);
  right: 14px;
  width: min(410px, calc(100% - 28px));
  max-height: calc(100dvh - var(--bar-height) - 28px);
  overflow: auto;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-panel);
  background: var(--surface-solid);
  box-shadow: var(--shadow);
}

.sheet[hidden] { display: none; }
.sheet-intro { margin: 0; padding: 14px 18px; color: var(--text-muted); font-size: 12px; line-height: 1.5; }

.traffic-list {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0 10px 12px;
  list-style: none;
}

.traffic-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  width: 100%;
  padding: 10px 12px;
  background: var(--surface-muted);
  color: var(--text);
  text-align: left;
}

.traffic-list-item:hover,
.traffic-list-item[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); }
.traffic-list-item span:first-child { display: grid; gap: 3px; }
.traffic-list-item strong { font-size: 12px; }
.traffic-list-item small { color: var(--text-muted); font-size: 9px; letter-spacing: 0.06em; }
.traffic-list-alt { flex: 0 0 auto; font-size: 11px; font-variant-numeric: tabular-nums; font-weight: 750; }
.traffic-list-empty { padding: 20px 12px; color: var(--text-muted); font-size: 12px; text-align: center; }

.development-notice {
  display: grid;
  gap: 4px;
  margin: 16px 18px;
  padding: 12px 14px;
  border-left: 3px solid #d98c3b;
  background: var(--surface-muted);
}

.development-notice strong { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; }
.development-notice span { color: var(--text-muted); font-size: 11px; line-height: 1.45; }

.feed-steps { display: grid; gap: 0; margin: 0; padding: 0 18px; list-style: none; }
.feed-steps li { display: grid; grid-template-columns: 34px 1fr; gap: 12px; padding: 13px 0; border-bottom: 1px solid var(--line); }
.feed-steps li > span { color: var(--accent); font-size: 10px; font-weight: 850; letter-spacing: 0.08em; }
.feed-steps strong { font-size: 12px; }
.feed-steps p { margin: 4px 0 0; color: var(--text-muted); font-size: 11px; line-height: 1.45; }
.inactive-action { width: calc(100% - 36px); margin: 18px; background: var(--surface-muted); color: var(--text-muted); cursor: not-allowed; opacity: 0.68; font-size: 12px; font-weight: 750; }

.maplibregl-ctrl-top-right { top: 72px; right: clamp(6px, 0.6vw, 12px); }
.maplibregl-ctrl-group { overflow: hidden; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--surface-solid); box-shadow: 0 7px 20px rgba(0, 0, 0, 0.16); }
.maplibregl-ctrl-group button { width: 44px; height: 44px; }
.maplibregl-ctrl-group button + button { border-top-color: var(--line); }
.maplibregl-ctrl button .maplibregl-ctrl-icon { filter: none; }
:root[data-theme="night"] .maplibregl-ctrl button .maplibregl-ctrl-icon { filter: invert(1) brightness(1.6); }
.maplibregl-ctrl-attrib { color: #1f3445; font-size: 9px; }
.maplibregl-ctrl-attrib a { color: #164f78; }
.maplibregl-ctrl-bottom-left { bottom: 5px; }
.maplibregl-ctrl-bottom-right { bottom: 24px; }
.maplibregl-ctrl-scale { border-color: var(--text-muted); background: color-mix(in srgb, var(--surface-solid) 82%, transparent); color: var(--text); font-size: 9px; }

@media (max-width: 1050px) {
  .provider-status { display: none; }
  .product-bar { grid-template-columns: auto 1fr auto; gap: 10px; }
  .product-nav { justify-self: center; }
}

@media (max-width: 760px) {
  :root { --bar-height: 58px; }
  .product-bar { grid-template-columns: auto minmax(0, 1fr) auto; gap: 4px; padding: 0 6px; }
  .product-mark { gap: 5px; }
  .product-mark-icon { width: 32px; height: 24px; }
  .product-mark-copy strong { font-size: 11px; letter-spacing: 0.12em; }
  .product-nav { display: flex; justify-self: center; height: var(--bar-height); }
  .product-nav a { min-height: 44px; padding: 0 7px; font-size: 10px; letter-spacing: 0; }
  .product-nav a[aria-current="page"]::after { right: 6px; left: 6px; }
  .product-actions { justify-self: end; }
  .bar-button { width: 44px; padding: 0; justify-content: center; }
  .bar-button span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .feed-button { padding: 0 12px; font-size: 10px; }
  .workspace-title-block { top: 12px; left: 12px; min-width: 184px; padding: 11px 13px; }
  .workspace-title-block h1 { font-size: 17px; }
  .workspace-readout { margin-top: 7px; }
  .map-refresh { top: 84px; right: 8px; width: 44px; padding: 0; justify-content: center; }
  .map-refresh span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .maplibregl-ctrl-top-right { top: 130px; right: 8px; }
  .map-legend { right: 8px; bottom: 36px; gap: 10px; max-width: calc(100% - 16px); font-size: 9px; }
  .data-attribution { bottom: 29px; left: 7px; max-width: calc(100% - 14px); white-space: normal; overflow-wrap: anywhere; }
  .basemap-state { bottom: 58px; left: 8px; }
  .aircraft-panel {
    top: auto;
    right: 8px;
    bottom: 34px;
    left: 8px;
    width: auto;
    max-height: min(58dvh, 470px);
    border-radius: 18px 18px 10px 10px;
  }
  .panel-heading { padding: 15px 15px 12px; }
  .panel-heading h2 { font-size: 22px; }
  .aircraft-fields { padding: 4px 15px 14px; }
  .sheet {
    top: auto;
    right: 8px;
    bottom: 8px;
    left: 8px;
    width: auto;
    max-height: calc(100dvh - var(--bar-height) - 16px);
    border-radius: 20px 20px 12px 12px;
  }
  .maplibregl-ctrl-bottom-left { bottom: 5px; }
}

@media (min-width: 761px) and (max-width: 820px) {
  .data-attribution { bottom: 29px; left: 7px; max-width: calc(100% - 14px); white-space: normal; overflow-wrap: anywhere; }
  .maplibregl-ctrl-bottom-left { bottom: 5px; }
}

@media (max-width: 430px) {
  .feed-button { max-width: 92px; line-height: 1.1; }
  .map-legend span:nth-child(2) { display: none; }
  .aircraft-field { padding-right: 6px; }
}

@media (min-width: 2560px) {
  .workspace-title-block { left: 44px; top: 36px; }
  .map-refresh { top: 36px; right: 92px; }
  .aircraft-panel { right: 44px; width: 410px; }
  .map-legend { right: 44px; }
}

@media (max-width: 620px) {
  :root { --bar-height: 100px; }
  .product-bar { grid-template-columns: minmax(0, 1fr) auto; grid-template-rows: 52px 44px; }
  .product-mark { grid-column: 1; grid-row: 1; }
  .product-actions { grid-column: 2; grid-row: 1; }
  .product-bar .product-nav { grid-column: 1 / -1; grid-row: 2; width: 100%; height: 44px; justify-content: space-between; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; }
}
