/* ============================================
   DESIGN TOKENS
   ============================================ */
:root {
  --ink:       #0a0a0f;
  --ink-soft:  #1a1a2e;
  --paper:     #f5f2eb;
  --cream:     #ede9df;
  --gold:      #c8a84b;
  --gold-pale: #e8d99a;
  --rust:      #c4613a;
  --teal:      #2a7a7a;
  --teal-pale: #4fa8a8;
  --blue-deep: #0f3460;
  --muted:     #888070;
  --divider:   rgba(10,10,15,0.12);
  --card-bg:   #ffffff;
  --shadow-sm: 0 2px 12px rgba(10,10,15,0.07);
  --shadow-md: 0 8px 40px rgba(10,10,15,0.13);
  --shadow-lg: 0 20px 80px rgba(10,10,15,0.18);
  --r:         6px;
  --r-lg:      14px;
  --trans:     0.22s cubic-bezier(0.4,0,0.2,1);
}

/* ============================================
   BASE
   ============================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: 'Syne', sans-serif;
  background: var(--paper);
  color: var(--ink);
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 70% 50% at 85% 10%, rgba(200,168,75,0.09) 0%, transparent 60%),
    radial-gradient(ellipse 50% 40% at 10% 80%, rgba(42,122,122,0.07) 0%, transparent 60%);
  pointer-events: none;
  z-index: 0;
}

/* Grain texture */
body::after {
  content: '';
  position: fixed;
  inset: -50%;
  width: 200%; height: 200%;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.03'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 1;
  opacity: 0.4;
}

/* ============================================
   NAV
   ============================================ */
nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 48px;
  background: rgba(245,242,235,0.88);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--divider);
}

.nav-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: inherit;
}

.nav-logo-icon {
  width: 36px; height: 36px;
  background: var(--ink);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--gold);
  font-size: 14px;
  flex-shrink: 0;
}

.nav-logo-text {
  font-family: 'DM Serif Display', serif;
  font-size: 22px;
  letter-spacing: -0.3px;
  color: var(--ink);
}

.nav-logo-text span {
  color: var(--gold);
}

.nav-links {
  display: flex;
  gap: 32px;
  list-style: none;
}

.nav-links a {
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  transition: color var(--trans);
}

.nav-links a:hover { color: var(--ink); }

.nav-badge {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  padding: 5px 14px;
  background: var(--ink);
  color: var(--gold);
  border-radius: 20px;
  letter-spacing: 0.05em;
}

/* ============================================
   HERO
   ============================================ */
.hero {
  position: relative;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 120px 48px 80px;
  z-index: 2;
  overflow: hidden;
}

.hero-grid-lines {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(10,10,15,0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(10,10,15,0.04) 1px, transparent 1px);
  background-size: 60px 60px;
  mask-image: radial-gradient(ellipse 80% 60% at 50% 50%, black 40%, transparent 100%);
}

.hero-inner {
  max-width: 1000px;
  width: 100%;
  text-align: center;
  position: relative;
}

.hero-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--rust);
  margin-bottom: 28px;
  padding: 8px 18px;
  background: rgba(196,97,58,0.08);
  border: 1px solid rgba(196,97,58,0.2);
  border-radius: 20px;
  animation: fadeSlideDown 0.8s ease both;
}

.hero-eyebrow i { font-size: 9px; }

.hero-title {
  font-family: 'DM Serif Display', serif;
  font-size: clamp(52px, 8vw, 96px);
  line-height: 1.0;
  letter-spacing: -2px;
  color: var(--ink);
  margin-bottom: 28px;
  animation: fadeSlideDown 0.8s 0.1s ease both;
}

.hero-title em {
  font-style: italic;
  color: var(--teal);
}

.hero-title .gold-line {
  display: block;
  color: var(--gold);
}

.hero-sub {
  font-size: 17px;
  font-weight: 400;
  color: var(--muted);
  max-width: 560px;
  margin: 0 auto 52px;
  line-height: 1.7;
  animation: fadeSlideDown 0.8s 0.2s ease both;
}

.hero-cta {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 16px 36px;
  background: var(--ink);
  color: var(--gold);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  border: none;
  border-radius: var(--r);
  cursor: pointer;
  text-decoration: none;
  transition: transform var(--trans), box-shadow var(--trans), background var(--trans);
  animation: fadeSlideDown 0.8s 0.3s ease both;
}

.hero-cta:hover {
  background: var(--blue-deep);
  transform: translateY(-2px);
  box-shadow: 0 12px 40px rgba(10,10,15,0.2);
}

.hero-stats {
  display: flex;
  justify-content: center;
  gap: 56px;
  margin-top: 72px;
  padding-top: 48px;
  border-top: 1px solid var(--divider);
  animation: fadeSlideDown 0.8s 0.4s ease both;
}

.hero-stat-num {
  font-family: 'DM Serif Display', serif;
  font-size: 36px;
  color: var(--ink);
  display: block;
}

.hero-stat-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin-top: 4px;
  display: block;
}

/* ============================================
   SECTION STRUCTURE
   ============================================ */
section {
  position: relative;
  z-index: 2;
  padding: 80px 48px;
  max-width: 1200px;
  margin: 0 auto;
}

.section-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.section-label::after {
  content: '';
  flex: 1;
  max-width: 40px;
  height: 1px;
  background: var(--gold);
  opacity: 0.5;
}

.section-title {
  font-family: 'DM Serif Display', serif;
  font-size: clamp(32px, 4vw, 48px);
  letter-spacing: -1px;
  color: var(--ink);
  margin-bottom: 48px;
  line-height: 1.15;
}

/* ============================================
   ALGORITHM CARDS GRID
   ============================================ */
.algo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 2px;
  background: var(--divider);
  border: 1px solid var(--divider);
  border-radius: var(--r-lg);
  overflow: hidden;
  box-shadow: var(--shadow-md);
}

.algo-card {
  background: var(--card-bg);
  padding: 32px 36px;
  cursor: pointer;
  transition: background var(--trans);
  position: relative;
  overflow: hidden;
}

.algo-card::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--gold);
  transform: scaleY(0);
  transform-origin: bottom;
  transition: transform var(--trans);
}

.algo-card:hover { background: #fdfcf8; }
.algo-card:hover::before { transform: scaleY(1); }

.algo-card.active { background: #fdfcf8; }
.algo-card.active::before { transform: scaleY(1); background: var(--rust); }

.algo-icon-wrap {
  width: 44px; height: 44px;
  border-radius: var(--r);
  background: var(--paper);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
  color: var(--teal);
  margin-bottom: 18px;
  transition: background var(--trans), color var(--trans);
}

.algo-card:hover .algo-icon-wrap,
.algo-card.active .algo-icon-wrap {
  background: var(--ink);
  color: var(--gold);
}

.algo-name {
  font-family: 'DM Serif Display', serif;
  font-size: 19px;
  color: var(--ink);
  margin-bottom: 6px;
}

.algo-desc {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.6;
  margin-bottom: 18px;
}

.algo-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  padding: 3px 10px;
  border-radius: 20px;
  font-weight: 500;
  letter-spacing: 0.04em;
}

.tag-complexity {
  background: rgba(15,52,96,0.08);
  color: var(--blue-deep);
}

.tag-type {
  background: rgba(42,122,122,0.1);
  color: var(--teal);
}

/* ============================================
   MAIN PANEL / FORM
   ============================================ */
#optimizer-section {
  padding-top: 0;
}

.optimizer-wrapper {
  background: var(--card-bg);
  border: 1px solid var(--divider);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  display: grid;
  grid-template-columns: 320px 1fr;
  min-height: 620px;
}

/* Sidebar */
.optimizer-sidebar {
  background: var(--ink);
  padding: 36px 28px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sidebar-header {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.35);
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--r);
  border: none;
  background: transparent;
  color: rgba(255,255,255,0.55);
  font-family: 'Syne', sans-serif;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--trans);
  text-align: left;
  width: 100%;
}

.sidebar-btn i {
  width: 18px;
  font-size: 12px;
  color: var(--gold);
  opacity: 0.6;
  transition: opacity var(--trans);
  flex-shrink: 0;
}

.sidebar-btn:hover {
  background: rgba(255,255,255,0.07);
  color: rgba(255,255,255,0.9);
}

.sidebar-btn:hover i { opacity: 1; }

.sidebar-btn.active {
  background: rgba(200,168,75,0.15);
  color: #fff;
  border: 1px solid rgba(200,168,75,0.25);
}

.sidebar-btn.active i { opacity: 1; }

/* Main form area */
.optimizer-main {
  padding: 40px 48px;
  display: flex;
  flex-direction: column;
}

.form-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 32px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--divider);
}

.form-title {
  font-family: 'DM Serif Display', serif;
  font-size: 28px;
  letter-spacing: -0.5px;
  color: var(--ink);
}

.form-subtitle {
  font-size: 13px;
  color: var(--muted);
  margin-top: 4px;
}

.complexity-badge {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  padding: 6px 14px;
  border-radius: 4px;
  background: var(--paper);
  color: var(--teal);
  border: 1px solid rgba(42,122,122,0.2);
  white-space: nowrap;
  margin-top: 4px;
}

/* Form fields */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 24px;
}

.form-grid.single { grid-template-columns: 1fr; }
.form-grid.triple { grid-template-columns: 1fr 1fr 1fr; }

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.field input,
.field select {
  padding: 11px 16px;
  border: 1.5px solid var(--divider);
  border-radius: var(--r);
  font-family: 'Syne', sans-serif;
  font-size: 14px;
  font-weight: 500;
  color: var(--ink);
  background: var(--paper);
  transition: border-color var(--trans), box-shadow var(--trans);
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}

.field input:focus,
.field select:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(200,168,75,0.12);
  background: #fff;
}

.field input::placeholder { color: rgba(10,10,15,0.28); }

.field select {
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23888070' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}

.run-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 14px 32px;
  background: var(--ink);
  color: var(--gold);
  font-family: 'Syne', sans-serif;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  border: none;
  border-radius: var(--r);
  cursor: pointer;
  transition: all var(--trans);
  align-self: flex-start;
  margin-top: 4px;
}

.run-btn:hover {
  background: var(--blue-deep);
  transform: translateY(-1px);
  box-shadow: 0 8px 24px rgba(10,10,15,0.18);
}

.run-btn:active { transform: translateY(0); }

.run-btn.loading {
  pointer-events: none;
  opacity: 0.7;
}

.run-btn .spin {
  display: none;
  animation: spin 0.7s linear infinite;
}

.run-btn.loading .spin { display: inline-block; }
.run-btn.loading .btn-icon { display: none; }

/* ============================================
   RESULTS PANEL
   ============================================ */
.results-panel {
  margin-top: 32px;
  padding-top: 28px;
  border-top: 1px solid var(--divider);
  flex: 1;
}

.results-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px;
  color: var(--muted);
  gap: 12px;
}

.results-empty i {
  font-size: 32px;
  opacity: 0.25;
}

.results-empty p {
  font-size: 13px;
  opacity: 0.7;
  text-align: center;
}

/* Path result */
.result-card {
  background: var(--paper);
  border-radius: var(--r-lg);
  padding: 28px 32px;
  border: 1px solid var(--divider);
  animation: fadeIn 0.4s ease both;
}

.result-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 22px;
}

.result-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--teal);
}

.result-value-main {
  font-family: 'DM Serif Display', serif;
  font-size: 26px;
  color: var(--ink);
  letter-spacing: -0.5px;
}

.result-value-main .unit {
  font-family: 'Syne', sans-serif;
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
  margin-left: 4px;
}

/* Path route visualization */
.route-path {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0;
  margin-top: 16px;
}

.route-node {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
}

.route-code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 15px;
  font-weight: 500;
  padding: 8px 14px;
  background: var(--card-bg);
  border: 1.5px solid var(--divider);
  border-radius: var(--r);
  color: var(--ink);
  transition: all var(--trans);
  white-space: nowrap;
}

.route-node:first-child .route-code,
.route-node:last-child .route-code {
  background: var(--ink);
  color: var(--gold);
  border-color: var(--ink);
}

.route-arrow {
  color: var(--gold);
  font-size: 11px;
  padding: 0 6px;
  opacity: 0.8;
}

/* List result (BFS, Budget, etc.) */
.result-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.result-list-item {
  display: flex;
  flex-direction: column;
  padding: 12px 14px;
  background: var(--card-bg);
  border-radius: var(--r);
  border: 1px solid var(--divider);
  font-size: 12px;
  gap: 3px;
}

.result-list-item .airport-code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 14px;
  font-weight: 500;
  color: var(--ink);
}

.result-list-item .airport-cost {
  color: var(--teal);
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
}

/* K-paths result */
.k-paths-list { display: flex; flex-direction: column; gap: 10px; margin-top: 8px; }

.k-path-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 18px;
  background: var(--card-bg);
  border-radius: var(--r);
  border: 1px solid var(--divider);
  animation: fadeIn 0.3s ease both;
}

.k-path-rank {
  font-family: 'DM Serif Display', serif;
  font-size: 22px;
  color: var(--gold);
  width: 28px;
  flex-shrink: 0;
  line-height: 1;
}

.k-path-route {
  flex: 1;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: var(--ink);
  letter-spacing: 0.03em;
}

.k-path-cost {
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  font-weight: 500;
  color: var(--teal);
  white-space: nowrap;
}

/* MST result */
.mst-list { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }

.mst-edge {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: var(--card-bg);
  border-radius: var(--r);
  border: 1px solid var(--divider);
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: var(--ink);
}

.mst-edge-cost { color: var(--gold); font-weight: 500; }

/* SCC result */
.scc-list { display: flex; flex-direction: column; gap: 10px; margin-top: 8px; }

.scc-group {
  padding: 14px 18px;
  background: var(--card-bg);
  border-radius: var(--r);
  border: 1px solid var(--divider);
}

.scc-group-header {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
}

.scc-nodes {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.scc-node {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  padding: 4px 10px;
  background: var(--paper);
  border-radius: 4px;
  color: var(--ink);
  border: 1px solid var(--divider);
}

/* Error state */
.result-error {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  background: rgba(196,97,58,0.08);
  border: 1px solid rgba(196,97,58,0.2);
  border-radius: var(--r);
  color: var(--rust);
  font-size: 13px;
  animation: fadeIn 0.4s ease both;
}

/* ============================================
   ABOUT SECTION
   ============================================ */
#about-section {
  border-top: 1px solid var(--divider);
  margin-top: 40px;
}

.about-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 24px;
}

.about-card {
  padding: 28px 30px;
  background: var(--card-bg);
  border-radius: var(--r-lg);
  border: 1px solid var(--divider);
  transition: box-shadow var(--trans);
}

.about-card:hover { box-shadow: var(--shadow-md); }

.about-card-icon {
  font-size: 20px;
  color: var(--gold);
  margin-bottom: 16px;
}

.about-card-title {
  font-family: 'DM Serif Display', serif;
  font-size: 18px;
  color: var(--ink);
  margin-bottom: 8px;
}

.about-card-text {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.65;
}

/* ============================================
   FOOTER
   ============================================ */
footer {
  position: relative;
  z-index: 2;
  border-top: 1px solid var(--divider);
  padding: 32px 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 40px;
}

.footer-left {
  font-size: 13px;
  color: var(--muted);
}

.footer-left strong {
  font-family: 'DM Serif Display', serif;
  color: var(--ink);
  font-size: 15px;
}

.footer-right {
  display: flex;
  gap: 16px;
}

.footer-tag {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  padding: 5px 12px;
  border-radius: 4px;
  border: 1px solid var(--divider);
  color: var(--muted);
  letter-spacing: 0.06em;
}

/* ============================================
   LIVE MAP
   ============================================ */
.map-section {
  padding: 0 48px 80px;
  position: relative;
  z-index: 2;
  max-width: 1200px;
  margin: 0 auto;
}

.map-container {
  background: var(--ink);
  border-radius: var(--r-lg);
  overflow: hidden;
  position: relative;
  border: 1px solid rgba(255,255,255,0.06);
  box-shadow: var(--shadow-lg);
}

.map-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 28px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.map-title {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.4);
  display: flex;
  align-items: center;
  gap: 8px;
}

.map-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--teal-pale);
  box-shadow: 0 0 8px var(--teal-pale);
}

.map-legend {
  display: flex;
  gap: 20px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  color: rgba(255,255,255,0.35);
}

.legend-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
}

canvas#worldMap {
  display: block;
  width: 100%;
  height: 400px;
  position: relative;
  z-index: 1;
}

/* ============================================
   SCROLLBAR
   ============================================ */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--divider); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }

/* ============================================
   ANIMATIONS
   ============================================ */
@keyframes fadeSlideDown {
  from { opacity: 0; transform: translateY(-16px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.5; transform: scale(0.8); }
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 900px) {
  nav { padding: 16px 24px; }
  .nav-links { display: none; }
  .hero { padding: 100px 24px 60px; }
  .hero-stats { gap: 32px; }
  section { padding: 60px 24px; }
  .optimizer-wrapper { grid-template-columns: 1fr; }
  .optimizer-sidebar { flex-direction: row; flex-wrap: wrap; gap: 8px; padding: 20px; }
  .sidebar-btn { width: auto; }
  .optimizer-main { padding: 28px 24px; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid.triple { grid-template-columns: 1fr 1fr; }
  .about-grid { grid-template-columns: 1fr; }
  footer { flex-direction: column; gap: 16px; align-items: flex-start; }
  .map-section { padding: 0 24px 60px; }
}

/* ============================================
   CURRENCY BAR
   ============================================ */
.currency-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 14px 20px 0;
  flex-wrap: wrap;
}

.currency-bar-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.35);
  margin-right: 4px;
  white-space: nowrap;
}

.currency-btn {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  padding: 5px 11px;
  border-radius: 4px;
  border: 1px solid rgba(255,255,255,0.1);
  background: transparent;
  color: rgba(255,255,255,0.45);
  cursor: pointer;
  transition: all var(--trans);
  letter-spacing: 0.04em;
}

.currency-btn:hover {
  background: rgba(255,255,255,0.08);
  color: rgba(255,255,255,0.9);
}

.currency-btn.active {
  background: rgba(200,168,75,0.18);
  border-color: rgba(200,168,75,0.4);
  color: var(--gold);
}

/* ============================================
   ROUTE NAMES (full airport labels below path)
   ============================================ */
.route-names {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.6;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--divider);
  font-family: 'JetBrains Mono', monospace;
  word-break: break-word;
}

/* ============================================
   MAP TOOLTIP
   ============================================ */
#map-tooltip {
  position: absolute;
  pointer-events: none;
  background: rgba(10,10,15,0.92);
  color: var(--gold);
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  font-weight: 500;
  padding: 7px 12px;
  border-radius: 5px;
  border: 1px solid rgba(200,168,75,0.3);
  letter-spacing: 0.06em;
  white-space: nowrap;
  line-height: 1.5;
  opacity: 0;
  transition: opacity 0.1s ease;
  z-index: 10;
  backdrop-filter: blur(8px);
}

#map-tooltip strong {
  color: #fff;
  font-weight: 600;
}

.map-container { position: relative; }

/* ============================================
   ALGO GRID — 2 cards per row (all screen sizes)
   ============================================ */
.algo-grid {
  grid-template-columns: repeat(2, 1fr);
}

@media (max-width: 700px) {
  .algo-grid { grid-template-columns: 1fr; }
}

/* ============================================
   SIDEBAR — scrollable when content overflows
   ============================================ */
.optimizer-sidebar {
  overflow-y: auto;
  max-height: 800px;
}

/* ============================================
   MAP RESET BAR BUTTON HOVER
   ============================================ */
.map-reset-bar button:hover {
  background: rgba(255,255,255,0.13) !important;
  color: rgba(255,255,255,0.9) !important;
  border-color: rgba(255,255,255,0.22) !important;
}

/* ============================================
   AVIATION DECORATIVE ELEMENTS
   ============================================ */
/* Map panning cursor */
canvas#worldMap.panning {
  cursor: grabbing !important;
}

canvas#worldMap.pan-ready {
  cursor: grab;
}

/* SEE ON MAP BUTTON */
.see-on-map-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 16px;
  padding: 10px 22px;
  background: transparent;
  border: 1.5px solid var(--teal);
  border-radius: var(--r);
  color: var(--teal);
  font-family: 'Syne', sans-serif;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all var(--trans);
  animation: fadeIn 0.4s 0.15s ease both;
}

.see-on-map-btn i { font-size: 11px; }

.see-on-map-btn:hover {
  background: var(--teal);
  color: #fff;
  box-shadow: 0 4px 18px rgba(42,122,122,0.28);
  transform: translateY(-1px);
}

.see-on-map-btn:active { transform: translateY(0); }

/* Dotted flight trail on algo cards */
.algo-card::after {
  content: '';
  position: absolute;
  bottom: 12px;
  right: 16px;
  width: 48px;
  height: 3px;
  background: repeating-linear-gradient(
    to right,
    var(--gold) 0, var(--gold) 4px,
    transparent 4px, transparent 8px
  );
  opacity: 0;
  transition: opacity var(--trans);
  border-radius: 2px;
}

.algo-card:hover::after,
.algo-card.active::after {
  opacity: 0.35;
}

/* Radar pulse on the live dot */
@keyframes radar-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(79,168,168,0.6), 0 0 8px var(--teal-pale); }
  70%  { box-shadow: 0 0 0 10px rgba(79,168,168,0), 0 0 8px var(--teal-pale); }
  100% { box-shadow: 0 0 0 0 rgba(79,168,168,0), 0 0 8px var(--teal-pale); }
}

.map-dot { animation: radar-pulse 2s ease-out infinite; }

/* Runway-style dotted divider before map */
.map-section::before {
  content: '';
  display: block;
  height: 1px;
  margin-bottom: 32px;
  background: repeating-linear-gradient(
    to right,
    transparent 0, transparent 8px,
    var(--divider) 8px, var(--divider) 16px
  );
}

/* Footer runway line */
footer {
  position: relative;
}
footer::before {
  content: '';
  position: absolute;
  top: 0; left: 48px; right: 48px;
  height: 1px;
  background: repeating-linear-gradient(
    to right,
    var(--gold) 0, var(--gold) 12px,
    transparent 12px, transparent 24px
  );
  opacity: 0.15;
}

/* Hero subtle plane decoration */
.hero-plane-deco {
  position: absolute;
  right: 7%;
  top: 32%;
  opacity: 0.04;
  font-size: 110px;
  color: var(--ink);
  transform: rotate(-22deg);
  pointer-events: none;
  z-index: 0;
}

/* SVG flight path curves in hero */
.hero-flight-svg {
  position: absolute;
  inset: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  z-index: 0;
  opacity: 0.07;
}

/* ============================================
   CUSTOM AIRPORT AUTOCOMPLETE DROPDOWN
   ============================================ */
.airport-dropdown {
  position: absolute;
  top: calc(100% + 2px);
  left: 0; right: 0;
  background: #fff;
  border: 1.5px solid var(--gold);
  border-radius: var(--r);
  box-shadow: 0 8px 32px rgba(10,10,15,0.14);
  z-index: 200;
  max-height: 220px;
  overflow-y: auto;
  font-family: 'Syne', sans-serif;
}

.airport-dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  cursor: pointer;
  transition: background 0.12s ease;
  border-bottom: 1px solid var(--divider);
}

.airport-dropdown-item:last-child {
  border-bottom: none;
}

.airport-dropdown-item:hover,
.airport-dropdown-item.highlighted {
  background: rgba(200,168,75,0.08);
}

.airport-dropdown-code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  min-width: 36px;
}

.airport-dropdown-name {
  font-size: 12px;
  color: var(--muted);
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.airport-dropdown-match {
  color: var(--teal);
  font-weight: 700;
}

.field { position: relative; }

/* ============================================
   SAME-AIRPORT WARNING
   ============================================ */
.same-airport-warning {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: rgba(196,97,58,0.08);
  border: 1px solid rgba(196,97,58,0.25);
  border-radius: var(--r);
  color: var(--rust);
  font-size: 12px;
  font-weight: 600;
  margin-top: 10px;
  animation: fadeIn 0.25s ease both;
}

.same-airport-warning i {
  font-size: 12px;
  flex-shrink: 0;
}

/* Warning sits above run btn — give it bottom margin */
.same-airport-warning {
  margin-bottom: 12px;
}

/* Disabled run button state */
.run-btn:disabled {
  opacity: 0.45;
  pointer-events: none;
  cursor: not-allowed;
}

/* ============================================
   COMPLEXITY TOOLTIP
   ============================================ */
.complexity-badge {
  cursor: help;
  position: relative;
  transition: background var(--trans), border-color var(--trans);
}

.complexity-badge:hover {
  background: rgba(42,122,122,0.1);
  border-color: var(--teal);
}

.complexity-tip {
  display: none;
  position: absolute;
  z-index: 9999;
  width: 360px;
  max-width: calc(100vw - 24px);
  background: var(--paper);
  border: 1.5px solid rgba(42,122,122,0.4);
  border-radius: var(--r);
  box-shadow: 0 8px 32px rgba(10,10,15,0.14), 0 0 0 1px rgba(200,168,75,0.08);
  font-family: 'Syne', sans-serif;
  pointer-events: none;
  animation: fadeIn 0.18s ease both;
}

/* Arrow pointing DOWN (tooltip is above badge) */
.complexity-tip[data-arrow="down"]::after {
  content: '';
  position: absolute;
  bottom: -8px;
  left: 50%;
  transform: translateX(-50%);
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-top: 8px solid rgba(42,122,122,0.4);
}
.complexity-tip[data-arrow="down"]::before {
  content: '';
  position: absolute;
  bottom: -6px;
  left: 50%;
  transform: translateX(-50%);
  border-left: 7px solid transparent;
  border-right: 7px solid transparent;
  border-top: 7px solid var(--paper);
  z-index: 1;
}

/* Arrow pointing UP (tooltip is below badge) */
.complexity-tip[data-arrow="up"]::after {
  content: '';
  position: absolute;
  top: -8px;
  left: 50%;
  transform: translateX(-50%);
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-bottom: 8px solid rgba(42,122,122,0.4);
}
.complexity-tip[data-arrow="up"]::before {
  content: '';
  position: absolute;
  top: -6px;
  left: 50%;
  transform: translateX(-50%);
  border-left: 7px solid transparent;
  border-right: 7px solid transparent;
  border-bottom: 7px solid var(--paper);
  z-index: 1;
}

.complexity-tip-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px 10px;
  border-bottom: 1px solid var(--divider);
}

.complexity-tip-formula {
  font-family: 'JetBrains Mono', monospace;
  font-size: 14px;
  font-weight: 700;
  color: var(--teal);
}

.complexity-tip-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.complexity-tip-body {
  padding: 12px 16px 14px;
  font-size: 12.5px;
  line-height: 1.65;
  color: var(--ink);
}

.complexity-tip-body b {
  color: var(--teal);
  font-weight: 700;
}

.complexity-tip-body em {
  color: #a07a1a;
  font-style: normal;
  font-weight: 600;
}

/* ============================================
   ALGO TIP — hint box inside algorithm forms
   ============================================ */
.algo-tip {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  background: rgba(42,122,122,0.07);
  border: 1px solid rgba(42,122,122,0.18);
  border-radius: var(--r);
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
  margin-bottom: 20px;
}

.algo-tip i {
  color: var(--teal);
  font-size: 12px;
  margin-top: 1px;
  flex-shrink: 0;
}

.algo-tip strong { color: var(--teal); }
