/* ADSB-TAK web preview. CSP is style-src 'self' — no inline style attributes. */
:root {
  --bg: #0b1a30; --panel: #12253f; --line: #1e3a5c; --ink: #e8f1fb;
  --dim: #8fb0d0; --accent: #7dd3fc; --hot: #facc15; --warn: #fb923c;
  --bad: #f87171; --ok: #4ade80; --water: #0a2744; --land: #1b3a2a;
  --sat-t: env(safe-area-inset-top, 0px);
  --sat-r: env(safe-area-inset-right, 0px);
  --sat-b: env(safe-area-inset-bottom, 0px);
  --sat-l: env(safe-area-inset-left, 0px);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--ink);
  font: 14px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  display: flex; flex-direction: column; min-height: 100%; min-height: 100dvh;
  overflow-x: clip;
}
.topbar {
  display: flex; gap: 14px; align-items: center; justify-content: space-between;
  padding: 12px 18px; background: var(--panel); border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
  padding-left: max(18px, var(--sat-l));
  padding-right: max(18px, var(--sat-r));
}
.brand { display: flex; gap: 12px; align-items: center; }
.brand img { width: 28px; height: 28px; }
.brand h1 { font-size: 16px; letter-spacing: .12em; margin: 0; color: var(--accent); }
.tag {
  font-size: 10px; letter-spacing: .14em; color: var(--hot);
  border: 1px solid var(--hot); border-radius: 99px; padding: 1px 8px;
  vertical-align: middle;
}
.ghost {
  background: #0e1f36; color: var(--ink); border: 1px solid var(--line);
  border-radius: 6px; padding: 6px 10px; font: inherit; cursor: pointer;
}
.ghost:hover { border-color: var(--accent); color: var(--accent); }
.help {
  margin: 0; padding: 12px 18px; background: #0e1f36; color: var(--dim);
  border-bottom: 1px solid var(--line); font-size: 13px; max-width: 92ch;
  padding-left: max(18px, var(--sat-l));
  padding-right: max(18px, var(--sat-r));
}
.help[hidden] { display: none !important; }
.help strong { color: var(--ink); }
.controls {
  display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap;
  padding: 10px 18px; background: var(--panel); border-bottom: 1px solid var(--line);
  padding-left: max(18px, var(--sat-l));
  padding-right: max(18px, var(--sat-r));
}
.field { display: flex; flex-direction: column; gap: 3px; }
.field label { color: var(--dim); font-size: 11px; letter-spacing: .08em; }
input, select, button {
  background: #0e1f36; color: var(--ink); border: 1px solid var(--line);
  border-radius: 6px; padding: 6px 9px; font: inherit; font-size: 13px;
}
button { cursor: pointer; border-color: var(--accent); color: var(--accent); }
button:hover { background: #16304f; }
button.primary { background: var(--accent); color: #08182c; font-weight: 700; }
input[type="range"] { width: min(220px, 100%); padding: 0; accent-color: var(--accent); }
.clock { color: var(--hot); font-size: 15px; letter-spacing: .06em; }
.status { color: var(--dim); font-size: 12px; }
main {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(280px, 380px);
  gap: 0; flex: 1; min-height: 0;
}
.mapwrap { position: relative; min-height: 0; height: 100%; background: var(--land); }
canvas.map { display: block; width: 100%; height: 100%; }
@media (min-height: 700px) {
  .mapwrap { min-height: 420px; }
}
@media (max-width: 880px) {
  main { grid-template-columns: 1fr; }
  .mapwrap {
    height: min(56svh, calc(100svh - 14rem));
    min-height: 220px;
  }
}
.legend {
  position: absolute; left: 12px; bottom: 12px;
  background: rgba(11, 26, 48, .86); border: 1px solid var(--line);
  border-radius: 8px; padding: 8px 10px; color: var(--dim); font-size: 11px;
}
.legend b { color: var(--ink); }
.panel {
  background: var(--panel); border-left: 1px solid var(--line);
  padding: 14px; overflow: auto; max-height: calc(100vh - 180px);
}
.panel h2 {
  font-size: 11px; letter-spacing: .16em; color: var(--dim); margin: 0 0 10px;
  text-transform: uppercase; font-weight: 600;
}
table { border-collapse: collapse; width: 100%; font-size: 12px; }
th {
  text-align: left; color: var(--dim); font-weight: 600; padding: 4px 6px;
  border-bottom: 1px solid var(--line);
}
td { padding: 4px 6px; border-bottom: 1px solid #18304d; }
tr.sel td { background: #16304f; color: var(--accent); }
tr:hover td { background: #16304f; cursor: pointer; }
.mono { font-variant-numeric: tabular-nums; }
pre.cot {
  background: #0e1f36; border: 1px solid var(--line); border-radius: 6px;
  padding: 8px; color: var(--dim); font-size: 11px; overflow: auto;
  white-space: pre-wrap;
}
.credit {
  color: var(--dim); font-size: 11px; padding: 10px 18px;
  border-top: 1px solid var(--line);
  padding-left: max(18px, var(--sat-l));
  padding-right: max(18px, var(--sat-r));
  padding-bottom: max(10px, var(--sat-b));
}

@media (max-width: 880px) {
  .panel {
    max-height: none;
    border-left: 0;
    border-top: 1px solid var(--line);
  }
}

@media (max-height: 540px) and (orientation: landscape) {
  /* Keep map + table side by side on a landscape phone. The 880px stack
     would otherwise put a 420px map under chrome taller than the screen. */
  body { overflow: hidden; }
  .topbar { padding: 4px 12px; gap: 10px;
    padding-left: max(12px, var(--sat-l)); padding-right: max(12px, var(--sat-r)); }
  .brand h1 { font-size: 14px; }
  .field label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .status { display: none; }
  .controls { padding: 4px 12px; gap: 8px; align-items: center;
    padding-left: max(12px, var(--sat-l)); padding-right: max(12px, var(--sat-r)); }
  .credit { display: none; }
  main {
    grid-template-columns: minmax(0, 1fr) minmax(200px, 32vw);
    flex: 1; min-height: 0;
  }
  .mapwrap { height: auto; min-height: 0; }
  canvas.map { min-height: 0; height: 100%; }
  .panel { max-height: none; height: 100%; padding: 8px; overflow: auto; }
  .legend { font-size: 9px; line-height: 1.25; padding: 4px 6px; left: 8px; bottom: 8px;
    max-width: min(280px, 48%); }
  input[type="range"] { width: min(180px, 28vw); }
}

@media (pointer: coarse) {
  button, .ghost { min-height: 40px; }
  input[type="range"] { min-height: 32px; }
}
