:root {
  --bg: #ffffff;
  --panel-bg: #f7f8fa;
  --text: #14181f;
  --text-dim: #5a6472;
  --border: #dfe3e9;
  --accent: #1a5fd0;

  --ok: #12855a;
  --ok-bg: #e6f5ee;
  --warn: #9a6400;
  --warn-bg: #fdf3e0;
  --stop: #c0243c;
  --stop-bg: #fdecef;
  --unknown: #5a6472;
  --unknown-bg: #eef0f3;

  --panel-w: 400px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12161c;
    --panel-bg: #171c24;
    --text: #e8ecf2;
    --text-dim: #96a1b0;
    --border: #2a323d;
    --accent: #6ea8ff;

    --ok: #4ed6a0;
    --ok-bg: #102c22;
    --warn: #f2b854;
    --warn-bg: #2e2413;
    --stop: #ff7b91;
    --stop-bg: #331419;
    --unknown: #96a1b0;
    --unknown-bg: #1e242d;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

#app {
  display: flex;
  height: 100%;
}

/* ---------- Panel ---------- */

#panel {
  width: var(--panel-w);
  flex: none;
  display: flex;
  flex-direction: column;
  background: var(--panel-bg);
  border-right: 1px solid var(--border);
  overflow-y: auto;
}

#panel-header {
  padding: 20px 20px 12px;
}

#panel-header h1 {
  margin: 0;
  font-size: 20px;
  letter-spacing: -0.01em;
}

.tagline {
  margin: 2px 0 0;
  color: var(--text-dim);
  font-size: 13px;
}

#search-form {
  display: flex;
  gap: 8px;
  padding: 0 20px 12px;
}

#search {
  flex: 1;
  min-width: 0;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

#search:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
}

#search-form button {
  padding: 9px 16px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.hint {
  padding: 0 20px 20px;
  color: var(--text-dim);
  font-size: 13px;
}

#briefing {
  padding: 0 20px 20px;
  flex: 1;
}

#panel-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 11.5px;
  line-height: 1.5;
}

#panel-footer a { color: var(--accent); }

/* ---------- Verdict ---------- */

.verdict {
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 16px;
  border: 1px solid transparent;
}

.verdict h2 {
  margin: 0 0 4px;
  font-size: 17px;
  line-height: 1.3;
}

.verdict p {
  margin: 0;
  font-size: 13.5px;
}

.verdict.ok      { background: var(--ok-bg);      border-color: var(--ok);      color: var(--ok); }
.verdict.authorization_required { background: var(--warn-bg); border-color: var(--warn); color: var(--warn); }
.verdict.no_fly  { background: var(--stop-bg);    border-color: var(--stop);    color: var(--stop); }
.verdict.unknown { background: var(--unknown-bg); border-color: var(--unknown); color: var(--unknown); }

.altitude {
  text-align: center;
  padding: 16px;
  margin-bottom: 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
}

.altitude .num {
  display: block;
  font-size: 40px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.02em;
}

.altitude .unit {
  display: block;
  margin-top: 4px;
  color: var(--text-dim);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.altitude .note {
  display: block;
  margin-top: 8px;
  color: var(--text-dim);
  font-size: 12.5px;
}

.place {
  margin-bottom: 14px;
  font-size: 13px;
  color: var(--text-dim);
  word-break: break-word;
}

.section { margin-bottom: 16px; }

.section h3 {
  margin: 0 0 6px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
}

.section ul {
  margin: 0;
  padding-left: 18px;
  font-size: 13.5px;
}

.section li { margin-bottom: 5px; }

.section li.stop { color: var(--stop); font-weight: 600; }

.asof {
  color: var(--text-dim);
  font-size: 11.5px;
  border-top: 1px solid var(--border);
  padding-top: 10px;
}

.loading, .error {
  padding: 14px 0;
  font-size: 13.5px;
  color: var(--text-dim);
}

.error { color: var(--stop); }

/* ---------- Map ---------- */

#map-wrap { flex: 1; position: relative; }
#map { position: absolute; inset: 0; }

#legend {
  position: absolute;
  right: 12px;
  bottom: 24px;
  z-index: 500;
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 11px;
  color: var(--text);
  max-width: 260px;
}

.legend-title { font-weight: 600; margin-bottom: 6px; }

.legend-scale { display: flex; }

.legend-scale span {
  flex: 1;
  text-align: center;
  padding: 3px 0;
  color: #fff;
  font-size: 10px;
  font-weight: 600;
}

.legend-scale span[data-c="0"]   { background: #b3122e; }
.legend-scale span[data-c="50"]  { background: #d64524; }
.legend-scale span[data-c="100"] { background: #e8731a; }
.legend-scale span[data-c="150"] { background: #eda020; }
.legend-scale span[data-c="200"] { background: #d9c02a; color: #333; }
.legend-scale span[data-c="250"] { background: #a8c33a; color: #333; }
.legend-scale span[data-c="300"] { background: #6fb551; }
.legend-scale span[data-c="350"] { background: #35a06a; }
.legend-scale span[data-c="400"] { background: #12855a; }

.legend-note { margin-top: 6px; color: var(--text-dim); line-height: 1.4; }

#map-status {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 500;
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 12px;
  color: var(--text-dim);
}

/* ---------- Responsive ---------- */

@media (max-width: 820px) {
  #app { flex-direction: column-reverse; }
  #panel {
    width: 100%;
    max-height: 55%;
    border-right: 0;
    border-top: 1px solid var(--border);
  }
  #map-wrap { min-height: 45%; }
  #legend { bottom: 12px; right: 8px; max-width: 200px; }
}
