:root {
  --bg: #050a1a;
  --bg-elev: #0d1535;
  --bg-elev-2: #16204a;
  --text: #eaf0ff;
  --muted: #7888b8;
  --accent: #4dd6ff;
  --border: #1d2a52;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.55);
  --radius: 14px;
  --radius-sm: 10px;

  --c-climb: #4dd6ff;       /* electric cyan */
  --c-cruise: #5b8fff;      /* indigo blue */
  --c-descent: #a26dff;     /* electric violet */

  --smooth: #3df0c0;
  --smooth-bg: rgba(61, 240, 192, 0.18);
  --light: #9ce642;
  --light-bg: rgba(156, 230, 66, 0.20);
  --moderate: #ffbb3a;
  --moderate-bg: rgba(255, 187, 58, 0.22);
  --severe: #ff4d6e;
  --severe-bg: rgba(255, 77, 110, 0.22);
  --extreme: #c84cff;
  --extreme-bg: rgba(200, 76, 255, 0.22);
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Inter, system-ui, sans-serif;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}
body {
  background:
    radial-gradient(900px 700px at 88% -8%, rgba(77, 214, 255, 0.42) 0%, transparent 55%),
    radial-gradient(800px 600px at 0% 5%, rgba(91, 143, 255, 0.32) 0%, transparent 60%),
    radial-gradient(900px 800px at 50% 110%, rgba(162, 109, 255, 0.40) 0%, transparent 55%),
    radial-gradient(700px 500px at 5% 95%, rgba(61, 240, 192, 0.18) 0%, transparent 60%),
    linear-gradient(170deg, #050a1a 0%, #07112e 40%, #050a20 100%);
  background-attachment: fixed;
  min-height: 100dvh;
  padding-bottom: env(safe-area-inset-bottom);
}

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: rgba(5, 10, 26, 0.72); backdrop-filter: blur(12px);
  position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 8px; }
.logo {
  display: inline-block; transform: rotate(-25deg);
  font-size: 20px;
  background: linear-gradient(135deg, var(--c-climb), var(--c-cruise), var(--c-descent));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.title { font-weight: 700; letter-spacing: 0.2px; font-size: 16px; }
.accent {
  background: linear-gradient(135deg, var(--c-climb), var(--c-descent));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}

main { max-width: 720px; margin: 0 auto; padding: 12px 14px; display: grid; gap: 12px; }

.card {
  background: rgba(13, 21, 53, 0.85);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 14px;
  box-shadow: var(--shadow), inset 0 0 0 1px rgba(125, 167, 255, 0.04);
  backdrop-filter: blur(8px);
}
.card h2, .card h3 { margin: 0 0 10px 0; font-weight: 700; }
.card h2 { font-size: 17px; }
.card h3 { font-size: 15px; color: var(--muted); }

.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 10px;
}
.grid .full { grid-column: 1 / -1; }
.grid label {
  display: flex; flex-direction: column; gap: 3px;
  font-size: 12px; color: var(--muted);
}

input, select, textarea, button {
  font: inherit; color: inherit;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 11px;
  outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(77, 214, 255, 0.18); }
input[list] { text-transform: uppercase; }
textarea { resize: vertical; }

button {
  background: linear-gradient(135deg, var(--c-climb), var(--c-cruise));
  color: #050a1a; border: 0; font-weight: 700;
  cursor: pointer; transition: filter 0.15s, transform 0.1s, box-shadow 0.15s;
  box-shadow: 0 4px 18px rgba(77, 214, 255, 0.25);
}
button:hover { filter: brightness(1.08); }
button:active { transform: translateY(1px); }
button.ghost {
  background: transparent; color: var(--text);
  border: 1px solid var(--border); box-shadow: none;
}
button.ghost:hover { background: rgba(125, 167, 255, 0.06); }
button.wide { width: 100%; padding: 10px; }
.grid > button[type="submit"] { grid-column: 1 / -1; padding: 11px; }

.hint { color: var(--muted); font-size: 12px; margin: 6px 0 0; }
.hidden { display: none !important; }

/* Route suggestions (live ADS-B-derived city pairs for the entered flight) */
#route-suggestions {
  display: flex; flex-direction: column; gap: 6px;
  padding: 8px 10px;
  background: rgba(76, 194, 255, 0.06);
  border: 1px solid rgba(76, 194, 255, 0.25);
  border-radius: var(--radius-sm);
}
#route-suggestions .suggest-head {
  font-size: 11px; font-weight: 700; color: var(--c-cruise);
  letter-spacing: 0.4px; text-transform: uppercase;
}
.suggestion {
  text-align: left;
  padding: 8px 10px;
  background: rgba(13, 21, 53, 0.85);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  box-shadow: none;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.1s;
}
.suggestion:hover { border-color: var(--c-cruise); }
.suggestion .pair { font-size: 14px; font-weight: 700;
  background: linear-gradient(135deg, var(--c-climb), var(--c-cruise), var(--c-descent));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.suggestion .names { display: block; color: var(--muted); font-size: 11px;
  font-weight: 400; margin-top: 2px; }

/* Flight view top bar with back arrow */
.flight-top {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: -2px;
}
.back-arrow {
  background: rgba(125, 167, 255, 0.08);
  color: var(--text); border: 1px solid var(--border);
  width: 36px; height: 36px;
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: 18px; font-weight: 600;
  cursor: pointer; box-shadow: none;
}
.back-arrow:hover { background: rgba(125, 167, 255, 0.16); }

/* Flight header — compact */
.flight-header { padding: 12px 14px; }
.route-row { display: flex; align-items: center; gap: 10px; }
.airport { flex: 0 0 auto; text-align: center; }
.airport .iata {
  font-size: 24px; font-weight: 800; letter-spacing: 1px;
  background: linear-gradient(135deg, var(--c-climb), var(--c-descent));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.airport .name { color: var(--muted); font-size: 11px; max-width: 86px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.route-arrow { flex: 1; text-align: center; color: var(--c-cruise); }
.route-arrow .line { display: block; width: 100%; max-width: 180px;
  margin: 4px auto; height: 2px; background: linear-gradient(90deg,
    transparent, var(--c-climb), var(--c-cruise), var(--c-descent), transparent); }
.route-meta { font-size: 11px; color: var(--muted); }

.badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  background: rgba(22, 32, 74, 0.6); border: 1px solid var(--border);
  padding: 3px 9px; border-radius: 999px; font-size: 11px; color: var(--muted);
}
.badge.warn { color: var(--moderate); border-color: rgba(255, 187, 58, 0.4); background: rgba(255, 187, 58, 0.10); }
.badge.alert { color: var(--severe); border-color: rgba(255, 77, 110, 0.4); background: rgba(255, 77, 110, 0.10); }
.badge.ok { color: var(--smooth); border-color: rgba(61, 240, 192, 0.3); background: rgba(61, 240, 192, 0.10); }

.live {
  margin-top: 8px; padding: 6px 10px;
  background: rgba(22, 32, 74, 0.5); border-radius: var(--radius-sm);
  font-size: 12px; color: var(--muted);
}
.live .dot {
  display: inline-block; width: 7px; height: 7px; border-radius: 50%;
  background: var(--smooth); margin-right: 5px;
  box-shadow: 0 0 0 0 rgba(61, 240, 192, 0.6);
  animation: pulse 1.6s infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(61, 240, 192, 0.55); }
  70% { box-shadow: 0 0 0 9px rgba(61, 240, 192, 0); }
  100% { box-shadow: 0 0 0 0 rgba(61, 240, 192, 0); }
}

/* Three compact phase cards — climb (up-slope), cruise (flat), descent (down-slope) */
.phases { display: grid; gap: 8px; }
.phase {
  background: rgba(13, 21, 53, 0.85);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 14px 14px;
  position: relative;
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
}
.phase::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  border-radius: var(--radius) 0 0 var(--radius);
}
.phase.climb::before   { background: var(--c-climb); }
.phase.cruise::before  { background: var(--c-cruise); }
.phase.descent::before { background: var(--c-descent); }

.phase-head {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-bottom: 2px;
}
.phase-name { font-size: 11px; font-weight: 800; letter-spacing: 0.8px; }
.phase.climb   .phase-name { color: var(--c-climb); }
.phase.cruise  .phase-name { color: var(--c-cruise); }
.phase.descent .phase-name { color: var(--c-descent); }
.phase-meta { font-size: 10px; color: var(--muted); }

.phase.climb   .profile { color: var(--c-climb); }
.phase.cruise  .profile { color: var(--c-cruise); }
.phase.descent .profile { color: var(--c-descent); }

.profile {
  position: relative;
  height: 130px;
  margin: 32px 2px 6px;
  overflow: visible;
}
.profile-line {
  position: absolute; inset: 0; width: 100%; height: 100%;
  pointer-events: none;
  filter: drop-shadow(0 0 8px rgba(77, 214, 255, 0.30));
}
.profile-line line, .profile-line path {
  stroke: currentColor; stroke-width: 2.5;
  stroke-linecap: round; stroke-linejoin: round;
  stroke-dasharray: 1, 7;
  fill: none;
  opacity: 0.9;
}
.profile-dots { position: absolute; inset: 0; pointer-events: none; }

/* Live plane indicator — small silhouette that moves along the active phase line */
.plane {
  position: absolute;
  left: var(--x); top: var(--y);
  width: 80px; height: 80px;
  transform: translate(-50%, -50%) rotate(var(--rot, 90deg));
  color: #fff;
  opacity: 0.5;
  filter: drop-shadow(0 0 10px var(--accent)) drop-shadow(0 0 20px var(--accent));
  pointer-events: none;
  z-index: 5;
  transition: left 1.2s ease, top 1.2s ease;
}
.plane svg { width: 100%; height: 100%; display: block; }

.dot {
  position: absolute;
  left: var(--x); top: var(--y);
  transform: translate(-50%, -50%);
  width: 30px; height: 30px;
  border-radius: 50%;
  border: 2px solid currentColor;
  background: var(--state-bg, var(--bg-elev-2));
  color: var(--state-color, var(--muted));
  font-weight: 800; font-size: 12px;
  cursor: pointer; pointer-events: auto;
  display: grid; place-items: center;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.45),
              0 0 0 0 var(--state-color, transparent);
  transition: transform 0.15s ease, box-shadow 0.2s;
  padding: 0;
}
.dot:hover, .dot:focus-visible {
  transform: translate(-50%, -50%) scale(1.18);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.55),
              0 0 0 4px rgba(77, 214, 255, 0.20);
  outline: none;
}
.dot .num { color: var(--text); font-size: 11px; font-weight: 800; line-height: 1; }
.dot .state-label {
  position: absolute; bottom: calc(100% + 4px); left: 50%;
  transform: translateX(-50%);
  font-size: 9px; font-weight: 800;
  color: var(--state-color);
  letter-spacing: 0.5px; text-transform: uppercase;
  white-space: nowrap; line-height: 1;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.7), 0 0 12px var(--state-color);
  pointer-events: none;
}
.dot.smooth   { --state-color: var(--smooth);   --state-bg: var(--smooth-bg); }
.dot.light    { --state-color: var(--light);    --state-bg: var(--light-bg); }
.dot.moderate { --state-color: var(--moderate); --state-bg: var(--moderate-bg); }
.dot.severe   { --state-color: var(--severe);   --state-bg: var(--severe-bg); animation: shimmer 2s infinite; }
.dot.extreme  { --state-color: var(--extreme);  --state-bg: var(--extreme-bg); animation: shimmer 1.4s infinite; }
@keyframes shimmer {
  0%, 100% { box-shadow: 0 4px 14px rgba(0,0,0,0.45), 0 0 0 0 var(--state-color); }
  50%      { box-shadow: 0 4px 14px rgba(0,0,0,0.45), 0 0 0 5px transparent; }
}
.dot .count {
  position: absolute; top: -3px; right: -3px;
  background: var(--accent); color: #050a1a;
  font-size: 9px; font-weight: 800;
  padding: 1px 4px; border-radius: 999px;
  min-width: 14px; text-align: center;
  border: 2px solid var(--bg-elev);
}

/* Modal */
.modal { border: none; border-radius: var(--radius); padding: 0;
  background: transparent; max-width: 480px; width: 92vw; }
.modal::backdrop { background: rgba(0, 0, 0, 0.65); backdrop-filter: blur(4px); }
.modal form {
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; color: var(--text);
}
.modal form h3 { margin: 0 0 8px; font-size: 16px; }
.modal form label { display: block; margin: 8px 0; font-size: 12px; color: var(--muted); }
.modal form label > select, .modal form label > textarea, .modal form label > input {
  display: block; width: 100%; margin-top: 4px; color: var(--text);
}
.rate-buttons { display: grid; grid-template-columns: repeat(2, 1fr); gap: 7px; margin: 10px 0; }
.rate-buttons button {
  text-align: left; padding: 9px 11px; background: var(--bg-elev-2);
  color: var(--text); border: 1px solid var(--border);
  border-radius: var(--radius-sm); font-weight: 700;
  box-shadow: none;
}
.rate-buttons button strong { display: block; font-size: 13px; }
.rate-buttons button small { display: block; color: var(--muted); font-weight: 400; font-size: 11px; margin-top: 2px; }
.rate-buttons button.smooth   { border-color: rgba(61, 240, 192, 0.6);  background: rgba(61, 240, 192, 0.10); grid-column: 1 / -1; }
.rate-buttons button.light    { border-color: rgba(156, 230, 66, 0.6);  background: rgba(156, 230, 66, 0.10); }
.rate-buttons button.moderate { border-color: rgba(255, 187, 58, 0.6);  background: rgba(255, 187, 58, 0.10); }
.rate-buttons button.severe   { border-color: rgba(255, 77, 110, 0.6);  background: rgba(255, 77, 110, 0.10); }
.rate-buttons button.extreme  { border-color: rgba(200, 76, 255, 0.6);  background: rgba(200, 76, 255, 0.10); }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.dlg-actions button { padding: 8px 14px; }

#defs-body .def {
  border-top: 1px solid var(--border); padding: 9px 0;
}
#defs-body .def:first-child { border-top: 0; }
#defs-body h4 { margin: 0 0 3px; font-size: 13px; }
#defs-body p { margin: 3px 0; font-size: 12px; color: var(--muted); }

@media (max-width: 420px) {
  .airport .name { display: none; }
  .airport .iata { font-size: 22px; }
  main { padding: 10px 12px; gap: 10px; }
  .profile { height: 110px; margin: 28px 2px 4px; }
  .dot { width: 26px; height: 26px; font-size: 10px; }
  .dot .num { font-size: 10px; }
  .plane { width: 64px; height: 64px; }
  .phase { padding: 6px 12px 12px; }
}
