:root {
  color-scheme: light;
  --page: #f7fbff;
  --ink: #071832;
  --ink-soft: #203454;
  --muted: #64748b;
  --line: rgba(76, 96, 130, 0.18);
  --surface: rgba(255, 255, 255, 0.86);
  --surface-solid: #ffffff;
  --surface-blue: #eef7ff;
  --blue: #0572ff;
  --blue-deep: #0055d9;
  --cyan: #20c5e8;
  --green: #0ba879;
  --warning: #a16000;
  --danger: #c2410c;
  --shadow: 0 22px 60px rgba(22, 49, 91, 0.13);
  --soft-shadow: 0 12px 32px rgba(22, 49, 91, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--page);
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) calc(78px + env(safe-area-inset-bottom))
    env(safe-area-inset-left);
  background:
    linear-gradient(180deg, rgba(232, 245, 255, 0.8), rgba(247, 251, 255, 0) 360px),
    var(--page);
  color: var(--ink);
  font-family:
    -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", "Microsoft YaHei",
    sans-serif;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

a {
  color: inherit;
  text-decoration: none;
}

.app-bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    linear-gradient(120deg, rgba(5, 114, 255, 0.08), transparent 38%),
    radial-gradient(circle at 85% 12%, rgba(32, 197, 232, 0.16), transparent 28rem),
    radial-gradient(circle at 12% 72%, rgba(75, 141, 255, 0.08), transparent 24rem);
}

.app-bg::after {
  content: "";
  position: absolute;
  top: 116px;
  right: 9vw;
  width: min(480px, 58vw);
  aspect-ratio: 2 / 1;
  opacity: 0.2;
  background:
    linear-gradient(rgba(5, 114, 255, 0.24) 1px, transparent 1px),
    linear-gradient(90deg, rgba(5, 114, 255, 0.24) 1px, transparent 1px);
  background-size: 24px 24px;
  mask-image: radial-gradient(ellipse, black 22%, transparent 72%);
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 28px;
  align-items: center;
  min-height: 72px;
  padding: 12px max(24px, calc((100vw - 1440px) / 2 + 24px));
  border-bottom: 1px solid rgba(76, 96, 130, 0.13);
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(24px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  font-size: 22px;
  font-weight: 900;
  color: var(--ink);
}

.brand img {
  width: 38px;
  height: 38px;
}

.desktop-nav {
  display: flex;
  justify-content: center;
  gap: 8px;
}

.desktop-nav a {
  border-radius: 999px;
  color: var(--muted);
  padding: 10px 15px;
  font-size: 14px;
  font-weight: 760;
}

.desktop-nav a.active,
.desktop-nav a:hover {
  background: #edf6ff;
  color: var(--blue);
}

.header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.status-chip {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--muted);
  padding: 0 14px;
  font-size: 13px;
  font-weight: 760;
  box-shadow: var(--soft-shadow);
}

.status-chip.good {
  border-color: rgba(11, 168, 121, 0.24);
  color: var(--green);
}

.status-chip.warn {
  border-color: rgba(245, 158, 11, 0.26);
  color: var(--warning);
}

.icon-button {
  display: none;
  width: 42px;
  height: 42px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.7);
}

.icon-button span {
  display: block;
  width: 18px;
  height: 2px;
  border-radius: 999px;
  background: var(--ink-soft);
}

.icon-button span + span {
  margin-top: 5px;
}

.page-shell {
  width: min(1220px, calc(100vw - 32px));
  margin: 34px auto 0;
}

.hero {
  display: flex;
  min-height: 144px;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 8px 7vw 24px;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--blue);
  font-size: 14px;
  font-weight: 900;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  max-width: 760px;
  margin-bottom: 12px;
  font-size: clamp(32px, 4vw, 48px);
  font-weight: 930;
  line-height: 1.06;
  letter-spacing: 0;
}

.hero-copy {
  max-width: 680px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.65;
}

.hero-plane {
  display: grid;
  width: 98px;
  height: 98px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid rgba(5, 114, 255, 0.12);
  border-radius: 999px;
  background: linear-gradient(145deg, #ffffff, #e9f6ff);
  color: var(--blue);
  font-size: 44px;
  box-shadow: var(--soft-shadow);
}

.search-card,
.filters-panel,
.results-panel,
.notice-row {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: blur(24px);
}

.search-card {
  position: relative;
  padding: 22px;
}

.search-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}

.field {
  display: block;
}

.field-wide {
  grid-column: span 2;
}

.field span,
.section-label {
  display: block;
  margin-bottom: 8px;
  color: #263a59;
  font-size: 13px;
  font-weight: 850;
}

.field small {
  color: var(--muted);
  font-weight: 700;
}

.nights-inputs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.nights-inputs label {
  position: relative;
  display: block;
}

.nights-inputs input {
  padding-right: 48px;
}

.nights-inputs small {
  position: absolute;
  right: 12px;
  bottom: 14px;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 820;
  pointer-events: none;
}

input,
select {
  width: 100%;
  min-height: 48px;
  border: 1px solid rgba(76, 96, 130, 0.2);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  color: var(--ink);
  outline: none;
  padding: 11px 13px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

input:focus,
select:focus {
  border-color: rgba(5, 114, 255, 0.72);
  box-shadow: 0 0 0 4px rgba(5, 114, 255, 0.12);
}

.segmented {
  display: grid;
  gap: 4px;
  overflow: hidden;
  border: 1px solid rgba(76, 96, 130, 0.2);
  border-radius: 8px;
  background: rgba(118, 132, 160, 0.12);
  padding: 4px;
}

.segmented.three {
  grid-template-columns: repeat(3, 1fr);
}

.segmented.four {
  grid-template-columns: repeat(4, 1fr);
}

.segmented label,
.source-grid label {
  position: relative;
  min-width: 0;
}

.segmented input,
.source-grid input {
  position: absolute;
  inset: 0;
  opacity: 0;
}

.segmented span {
  display: grid;
  min-height: 39px;
  margin: 0;
  place-items: center;
  border-radius: 6px;
  color: var(--ink-soft);
  font-size: 14px;
  font-weight: 820;
}

.segmented input:checked + span {
  background: var(--surface-solid);
  color: var(--blue);
  box-shadow: 0 4px 14px rgba(22, 49, 91, 0.12);
}

.chips-preview {
  display: flex;
  min-height: 30px;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.chip {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  border: 1px solid rgba(5, 114, 255, 0.16);
  border-radius: 999px;
  background: #edf6ff;
  color: #1d4f92;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 820;
}

.chip.muted {
  border-color: rgba(100, 116, 139, 0.18);
  background: #f4f7fb;
  color: var(--muted);
}

.check-tile {
  display: flex;
  min-height: 48px;
  align-items: center;
  gap: 12px;
  align-self: end;
  border: 1px solid rgba(76, 96, 130, 0.18);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.74);
  padding: 0 14px;
  color: var(--ink-soft);
  font-weight: 830;
}

.check-tile input {
  width: 22px;
  min-height: 22px;
  accent-color: var(--blue);
}

.source-mode {
  margin-top: 18px;
}

.source-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.source-card,
.source-summary {
  display: block;
  min-height: 78px;
  border: 1px solid rgba(76, 96, 130, 0.18);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
  padding: 14px;
  transition:
    border-color 0.2s ease,
    transform 0.2s ease,
    box-shadow 0.2s ease;
}

.source-card strong,
.source-card small,
.source-summary strong,
.source-summary small {
  display: block;
}

.source-card strong,
.source-summary strong {
  color: var(--ink);
  font-size: 15px;
  font-weight: 880;
}

.source-card small,
.source-summary small {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.source-grid input:checked + .source-card {
  border-color: rgba(5, 114, 255, 0.72);
  background: linear-gradient(180deg, #ffffff, #edf6ff);
  box-shadow: 0 12px 26px rgba(5, 114, 255, 0.13);
}

.source-summary {
  background: linear-gradient(180deg, #ffffff, #edf6ff);
  border-color: rgba(5, 114, 255, 0.34);
}

.source-grid label:hover .source-card {
  transform: translateY(-1px);
}

.inline-note,
.mini-note {
  border: 1px solid rgba(5, 114, 255, 0.16);
  border-radius: 8px;
  background: rgba(237, 246, 255, 0.86);
  color: #29527f;
  line-height: 1.55;
}

.inline-note {
  margin-top: 16px;
  padding: 12px 14px;
  font-size: 14px;
}

.primary-action {
  display: inline-flex;
  min-height: 52px;
  align-items: center;
  justify-content: center;
  margin-top: 18px;
  border: 0;
  border-radius: 8px;
  background: linear-gradient(135deg, #16b7ff, var(--blue));
  color: #fff;
  padding: 0 30px;
  font-size: 16px;
  font-weight: 900;
  box-shadow: 0 18px 34px rgba(5, 114, 255, 0.26);
}

.primary-action::before {
  content: "⌕";
  margin-right: 10px;
  font-size: 24px;
  line-height: 1;
}

.primary-action:hover {
  background: linear-gradient(135deg, #0aa7f5, var(--blue-deep));
}

.primary-action:disabled {
  cursor: wait;
  opacity: 0.72;
}

.suggest-popover {
  position: absolute;
  z-index: 40;
  overflow: hidden;
  max-height: min(360px, 64vh);
  border: 1px solid rgba(76, 96, 130, 0.18);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 22px 48px rgba(22, 49, 91, 0.18);
  backdrop-filter: blur(20px);
}

.suggest-option {
  display: flex;
  width: 100%;
  min-height: 58px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 0;
  border-bottom: 1px solid rgba(76, 96, 130, 0.1);
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  padding: 10px 13px;
  text-align: left;
}

.suggest-option:last-child {
  border-bottom: 0;
}

.suggest-option:hover {
  background: #edf6ff;
}

.suggest-option strong,
.suggest-option small {
  display: block;
}

.suggest-option strong {
  font-size: 15px;
  font-weight: 880;
}

.suggest-option small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.suggest-option em {
  flex: 0 0 auto;
  color: var(--blue);
  font-size: 12px;
  font-style: normal;
  font-weight: 900;
}

.notice-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  overflow: hidden;
  margin-top: 18px;
  background: rgba(76, 96, 130, 0.12);
}

.notice-row p {
  margin: 0;
  background: rgba(255, 255, 255, 0.72);
  color: #365274;
  padding: 15px 18px;
  font-size: 14px;
  line-height: 1.55;
}

.results-layout {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 22px;
  margin-top: 22px;
}

.filters-panel {
  align-self: start;
  padding: 18px;
}

.panel-head,
.results-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.panel-head strong {
  font-size: 16px;
}

.panel-head button,
#clearFilters {
  border: 0;
  background: transparent;
  color: var(--blue);
  padding: 0;
  font-size: 13px;
  font-weight: 820;
}

.filter-list {
  display: grid;
  gap: 10px;
  margin: 18px 0;
}

.filter-pill {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(76, 96, 130, 0.12);
  color: var(--muted);
  padding-bottom: 10px;
  font-size: 13px;
}

.filter-pill strong {
  color: var(--ink-soft);
}

.mini-note {
  padding: 12px;
  font-size: 13px;
}

.results-panel {
  padding: 20px;
}

.results-head {
  align-items: flex-start;
  margin-bottom: 16px;
}

.results-head h2 {
  margin-bottom: 6px;
  font-size: 24px;
  font-weight: 930;
}

.results-head p {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.5;
}

#sortSelect {
  width: auto;
  min-width: 150px;
  min-height: 40px;
}

.message {
  border: 1px dashed rgba(76, 96, 130, 0.22);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.58);
  color: var(--muted);
  padding: 28px 16px;
  text-align: center;
  line-height: 1.55;
}

.api-key-action {
  display: grid;
  gap: 12px;
  justify-items: center;
}

.api-key-action strong {
  color: var(--ink);
  font-size: 16px;
}

.api-key-action span {
  max-width: 680px;
  color: var(--muted);
  line-height: 1.55;
}

.api-key-action button {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  padding: 0 18px;
  background: linear-gradient(135deg, var(--blue), #18b6ff);
  color: #fff;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 12px 26px rgba(5, 114, 255, 0.22);
}

.message.error {
  border-color: rgba(194, 65, 12, 0.24);
  background: #fff5f0;
  color: var(--danger);
}

.result-list {
  display: grid;
  gap: 12px;
}

.result-card {
  display: grid;
  grid-template-columns: 120px 1fr 210px 36px;
  gap: 18px;
  align-items: center;
  border: 1px solid rgba(76, 96, 130, 0.13);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.86);
  padding: 16px;
  box-shadow: 0 10px 28px rgba(22, 49, 91, 0.07);
}

.price-block strong {
  display: block;
  color: var(--ink);
  font-size: 28px;
  font-weight: 960;
  line-height: 1;
}

.price-block span {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
}

.route-block {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 14px;
  align-items: center;
}

.airport-code {
  display: block;
  font-size: 22px;
  font-weight: 950;
}

.airport-name {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.route-mid {
  min-width: 76px;
  color: var(--ink-soft);
  text-align: center;
  font-size: 12px;
  font-weight: 850;
}

.route-mid::before {
  content: "✈";
  display: block;
  margin-bottom: 5px;
  color: var(--blue);
  font-size: 22px;
}

.meta-block {
  display: grid;
  gap: 6px;
  color: #35506d;
  font-size: 13px;
  line-height: 1.35;
}

.airline-line {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
  font-weight: 860;
}

.airline-badge {
  display: inline-grid;
  min-width: 36px;
  height: 28px;
  place-items: center;
  border-radius: 7px;
  background: #edf6ff;
  color: var(--blue);
  font-size: 12px;
  font-weight: 950;
}

.source-tag {
  display: inline-flex;
  width: fit-content;
  border-radius: 999px;
  background: #e9fbf4;
  color: var(--green);
  padding: 5px 9px;
  font-size: 12px;
  font-weight: 880;
}

.open-result {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border: 1px solid rgba(76, 96, 130, 0.16);
  border-radius: 8px;
  color: var(--blue);
  font-size: 24px;
}

.source-details {
  display: grid;
  gap: 8px;
  margin-top: 16px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.bottom-nav {
  display: none;
}

@media (max-width: 980px) {
  body {
    padding-bottom: calc(86px + env(safe-area-inset-bottom));
  }

  .app-header {
    grid-template-columns: 1fr auto;
    min-height: 64px;
    padding: 10px 18px;
  }

  .desktop-nav,
  .status-chip {
    display: none;
  }

  .icon-button {
    display: grid;
  }

  .brand {
    font-size: 23px;
  }

  .brand img {
    width: 34px;
    height: 34px;
  }

  .page-shell {
    width: min(100vw - 24px, 760px);
    margin-top: 16px;
  }

  .hero {
    min-height: auto;
    padding: 12px 4px 18px;
  }

  .hero-plane {
    display: none;
  }

  h1 {
    font-size: 29px;
  }

  .hero-copy {
    font-size: 15px;
  }

  .search-card {
    padding: 16px;
  }

  .search-grid,
  .source-grid,
  .notice-row,
  .results-layout {
    grid-template-columns: 1fr;
  }

  .field-wide {
    grid-column: auto;
  }

  .source-grid {
    grid-template-columns: 1fr 1fr;
  }

  .primary-action {
    position: sticky;
    bottom: calc(78px + env(safe-area-inset-bottom));
    z-index: 10;
    width: 100%;
  }

  .filters-panel {
    display: none;
  }

  .results-panel {
    padding: 14px;
  }

  .results-head {
    align-items: stretch;
    flex-direction: column;
  }

  #sortSelect {
    width: 100%;
  }

  .result-card {
    grid-template-columns: 1fr;
    gap: 14px;
    padding: 14px;
  }

  .price-block {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
  }

  .price-block strong {
    font-size: 30px;
  }

  .route-block {
    grid-template-columns: 1fr 58px 1fr;
  }

  .airport-code {
    font-size: 20px;
  }

  .open-result {
    width: 100%;
    height: 40px;
    font-size: 18px;
  }

  .bottom-nav {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 30;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    border-top: 1px solid rgba(76, 96, 130, 0.14);
    background: rgba(255, 255, 255, 0.9);
    padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
    backdrop-filter: blur(22px);
  }

  .bottom-nav a {
    display: grid;
    min-height: 46px;
    place-items: center;
    border-radius: 8px;
    color: #52677f;
    font-size: 12px;
    font-weight: 820;
  }

  .bottom-nav a.active {
    background: #edf6ff;
    color: var(--blue);
  }
}

@media (max-width: 420px) {
  .page-shell {
    width: calc(100vw - 18px);
  }

  .brand span {
    font-size: 21px;
  }

  h1 {
    font-size: 27px;
  }

  .segmented span,
  .source-card strong {
    font-size: 13px;
  }

  .source-card {
    min-height: 86px;
    padding: 12px;
  }

  .route-block {
    gap: 8px;
  }

  .airport-name {
    font-size: 12px;
  }
}
