/* SKY.TUTI.LT — 4D trajectory generator (Round 35).
   Self-contained: same design tokens as css/base.css / endlessatc.
   Map: self-hosted Leaflet + OpenStreetMap tiles (no Google Maps). */
:root {
  color-scheme: dark;
  --bg: #0b0e14;
  --bg2: #11151f;
  --panel: #141926;
  --panel2: #1a2032;
  --line: #232b40;
  --line2: #2e3854;
  --txt: #dbe4f3;
  --txt2: #8fa0bd;
  --txt3: #8494b3;
  --acc: #4da3ff;
  --acc2: #7fd4a8;
  --warn: #fbbf24;
  --bad: #ef4444;
  --radius: 10px;
  --shadow: 0 8px 30px rgba(0,0,0,.45);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
/* Author display rules (e.g. .rgrid{display:grid}) would otherwise beat the
   UA stylesheet's [hidden]{display:none} and leave stale panels visible. */
[hidden] { display: none !important; }
body {
  margin: 0; font-family: var(--font); font-size: 14px; line-height: 1.5;
  background: var(--bg); color: var(--txt);
  -webkit-tap-highlight-color: transparent;
}
button, input, select, output { font-family: inherit; }
a { color: var(--acc); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--acc); outline-offset: 2px; }

/* ── header / footer chrome (mirrors the site's sub-apps) ─────────────── */
header {
  display: flex; align-items: center; gap: 10px;
  padding: 10px clamp(12px, 3vw, 24px);
  background: var(--bg2); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 1000;
}
.brand { display: flex; align-items: center; gap: 7px; color: var(--txt);
         font-size: 15px; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand b { color: var(--acc); }
.brand .sep { color: var(--line2); }
.brand span:last-child { color: var(--txt2); }
.spacer { flex: 1; }
.hdr-note { color: var(--txt3); font-size: 12px; white-space: nowrap; }
footer {
  margin-top: 34px; padding: 18px clamp(12px, 3vw, 24px) 26px;
  border-top: 1px solid var(--line); background: var(--bg2);
  color: var(--txt3); font-size: 12.5px;
}
footer .nav { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 10px; }
footer .nav a { color: var(--txt2); }

main { max-width: 1160px; margin: 0 auto; padding: 0 clamp(12px, 3vw, 24px) 10px; }
h1 { font-size: clamp(1.45rem, 4.6vw, 2rem); margin: 22px 0 6px; }
.lede { color: var(--txt2); margin: 0 0 16px; max-width: 78ch; }
h2 { font-size: 15px; margin: 0 0 8px; color: var(--txt); letter-spacing: .02em; }

.banner {
  display: none; margin: 14px 0; padding: 12px 14px; border-radius: var(--radius);
  background: var(--panel); border: 1px solid var(--bad); color: var(--txt);
}
.banner.warn-show { display: block; }

/* ── route builder ────────────────────────────────────────────────────── */
.controls { margin: 0 0 12px; }
.routeline { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; }
.combo { position: relative; flex: 1 1 240px; min-width: 0; }
.combo label {
  display: block; color: var(--txt3); font-size: 11px; text-transform: uppercase;
  letter-spacing: .05em; margin-bottom: 4px;
}
.combo input {
  width: 100%; padding: 9px 12px; font-size: 14.5px;
  background: var(--panel); color: var(--txt);
  border: 1px solid var(--line2); border-radius: var(--radius);
}
.combo input::placeholder { color: var(--txt3); }
.ac-list {
  position: absolute; z-index: 1200; top: calc(100% + 4px); left: 0; right: 0;
  background: var(--panel2); border: 1px solid var(--line2); border-radius: var(--radius);
  box-shadow: var(--shadow); max-height: 288px; overflow: auto; display: none;
}
.ac-list.open { display: block; }
.ac-item { padding: 8px 11px; cursor: pointer; display: flex; gap: 8px; align-items: baseline; }
.ac-item:hover, .ac-item.sel { background: var(--panel); }
.ac-item .code { font-family: var(--mono); font-weight: 700; color: var(--acc);
                 min-width: 44px; font-size: 12.5px; }
.ac-item .nm { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ac-item .nm small { color: var(--txt3); }
.ac-empty { padding: 9px 12px; color: var(--txt3); font-size: 12.5px; }

.btn {
  padding: 8px 13px; border-radius: var(--radius); font-size: 13px; font-weight: 600;
  background: var(--panel2); color: var(--txt); border: 1px solid var(--line2);
  cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: var(--acc); color: var(--acc); }
.btn.warn:hover { border-color: var(--bad); color: var(--bad); }
.btn.icon { padding: 8px 12px; font-size: 15px; line-height: 1; margin-bottom: 1px; }
.btn.on { background: var(--acc); color: #06121f; border-color: var(--acc); }
.armgrp { display: flex; align-items: center; gap: 6px; margin-bottom: 1px; }
.arm-lbl { color: var(--txt3); font-size: 11px; text-transform: uppercase; letter-spacing: .05em; }
.armgrp .btn.arm { padding: 7px 11px; border-radius: 8px; font-size: 12.5px; }

/* ── map + results stage ──────────────────────────────────────────────── */
.stage {
  display: grid; grid-template-columns: minmax(0, 1.9fr) minmax(250px, 1fr);
  gap: 12px; align-items: stretch; margin: 0 0 12px;
}
#map {
  height: clamp(320px, 52vh, 560px); border-radius: var(--radius);
  border: 1px solid var(--line); background: #0a2e43; min-width: 0;
  z-index: 0;
}
.results {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 14px; min-width: 0;
}
.results h2 { display: flex; align-items: center; gap: 8px; }
.badge {
  font-size: 11px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase;
  padding: 2px 8px; border-radius: 999px; background: var(--bg2);
  border: 1px solid var(--acc2); color: var(--acc2);
}
.reshint { color: var(--txt3); font-size: 13px; padding: 6px 0 2px; }
.rgrid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(104px, 1fr));
  gap: 8px;
}
.cell { background: var(--bg2); border: 1px solid var(--line);
        border-radius: 8px; padding: 7px 10px; min-width: 0; }
.cell .k { color: var(--txt3); font-size: 10.5px; text-transform: uppercase;
           letter-spacing: .05em; white-space: nowrap; }
.cell .v { font-weight: 700; font-variant-numeric: tabular-nums; font-size: 14.5px;
           white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cell .v small { color: var(--txt3); font-weight: 400; font-size: 11px; }

/* Leaflet overrides to sit inside the dark theme */
.leaflet-container { font: 12px/1.4 var(--font); }
.leaflet-tooltip.ap-tip {
  background: var(--panel2); border: 1px solid var(--line2); color: var(--txt);
  box-shadow: var(--shadow); border-radius: 7px; padding: 4px 8px; font-size: 12px;
}
.leaflet-tooltip.ap-tip::before { display: none; }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: var(--panel2); color: var(--txt); }
.leaflet-control-attribution { background: rgba(11,14,20,.75) !important; color: var(--txt3) !important; }
.leaflet-control-attribution a { color: var(--txt2) !important; }
.leaflet-bar a { background: var(--panel2) !important; color: var(--txt) !important;
                 border-color: var(--line2) !important; }
.leaflet-bar a:hover { background: var(--panel) !important; }

/* ── vertical profile card ────────────────────────────────────────────── */
.profileCard {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 14px 14px; margin: 0 0 12px;
}
.phead { display: flex; align-items: center; justify-content: space-between; gap: 10px;
         flex-wrap: wrap; margin-bottom: 6px; }
.phead h2 { margin: 0; }
#profile { width: 100%; height: 240px; display: block; border-radius: 8px;
           background: #0d1220; border: 1px solid var(--line); cursor: crosshair; touch-action: none; }
.ptrow { display: flex; align-items: center; gap: 12px; margin-top: 10px; flex-wrap: wrap; }
.ptrow label { color: var(--txt3); font-size: 12px; text-transform: uppercase;
               letter-spacing: .05em; white-space: nowrap; }
.ptrow input[type=range] { flex: 1 1 200px; accent-color: var(--acc); min-width: 0; }
.ptrow output { font-family: var(--mono); color: var(--acc); font-weight: 700;
                min-width: 52px; text-align: right; }
.ptimes { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-top: 12px; }
.tfield label { display: block; color: var(--txt3); font-size: 11px; text-transform: uppercase;
                letter-spacing: .05em; margin-bottom: 4px; }
.tfield input {
  padding: 7px 10px; background: var(--panel2); color: var(--txt);
  border: 1px solid var(--line2); border-radius: 8px; font-size: 13px;
  color-scheme: dark;
}
.tnote { color: var(--txt3); font-size: 12px; margin: 0 0 4px; flex: 1 1 200px; min-width: 0; }

details.setup { background: var(--panel); border: 1px solid var(--line);
                border-radius: var(--radius); margin: 0 0 16px; }
details.setup summary { cursor: pointer; padding: 10px 14px; color: var(--acc2);
                        font-weight: 600; list-style-position: inside; }
details.setup p { margin: 0; padding: 0 14px 12px; color: var(--txt2); max-width: none; }

/* ── responsive ───────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .stage { grid-template-columns: 1fr; }
  #map { height: clamp(300px, 48vh, 460px); }
}
@media (max-width: 560px) {
  .hdr-note { display: none; }
  .routeline { gap: 8px; }
  .combo { flex: 1 1 100%; }
  .btn.icon { flex: 0 0 auto; }
  .armgrp { width: 100%; }
  .rgrid { grid-template-columns: repeat(auto-fit, minmax(90px, 1fr)); }
  #profile { height: 210px; }
}
