/* Inter for Latin text and figures (tabular digits for times); Chinese falls back to the system font */
@font-face {
  font-family: "Inter";
  src: url("fonts/inter.woff2") format("woff2");
  font-weight: 400 800;
  font-display: swap;
}

/* ---------- Design tokens ---------- */
/* Same neutrals and heavy outlines as Interchange; colour is kept for state (live, cancelled) and categories */
:root {
  --bg: #ffffff;
  --surface: #ffffff;
  --fill: #f5f5f7;
  --text: #1d1d1f;
  --muted: #6e6e73;
  --faint: #a1a1a6;
  --line: #d2d2d7;
  --live: #12a150;
  --live-soft: #e3f6ea;
  --bad: #e5484d;
  --radius: 16px;
  --stroke: 2.5px;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --c-charter: #7c3aed;
  --c-maint: #0a84ff;
  --c-rare: #f5a524;
  --c-livery: #e5484d;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  font-feature-settings: "tnum" 1, "cv11" 1;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  /* A faint engineering grid behind everything */
  background-image:
    linear-gradient(to right, rgba(0, 0, 0, 0.035) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(0, 0, 0, 0.035) 1px, transparent 1px);
  background-size: 24px 24px;
}
button { font: inherit; color: inherit; cursor: pointer; }
button:focus-visible { outline: 3px solid rgba(29, 29, 31, 0.35); outline-offset: 2px; }
[hidden] { display: none !important; }

.app {
  max-width: 1120px;
  margin: 0 auto;
  padding: 40px 20px 56px;
}

/* ---------- Header ---------- */
.top {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  margin-bottom: 20px;
  animation: rise 0.5s var(--ease) backwards;
}
.code {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.18em;
  color: var(--muted);
}
.code span { color: var(--faint); margin: 0 4px; }
h1 {
  margin: 4px 0 0;
  font-size: 34px;
  font-weight: 800;
  letter-spacing: -0.01em;
}
.clock { text-align: right; }
.clock-time {
  font-size: 30px;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.clock-zone {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.16em;
  color: var(--muted);
}

/* ---------- Status strip ---------- */
.status {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border: var(--stroke) solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
  margin-bottom: 16px;
  animation: rise 0.5s 0.05s var(--ease) backwards;
}
.stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px 16px;
}
.stat + .stat { border-left: 1.5px solid var(--line); }
.stat-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--muted);
}
.stat-value {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 17px;
  font-weight: 700;
}
.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--live);
  box-shadow: 0 0 0 0 rgba(18, 161, 80, 0.5);
  animation: pulse 2s infinite;
}
.dot.stale { background: var(--faint); animation: none; }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(18, 161, 80, 0.45); }
  70% { box-shadow: 0 0 0 8px rgba(18, 161, 80, 0); }
  100% { box-shadow: 0 0 0 0 rgba(18, 161, 80, 0); }
}
.error {
  margin: 0 0 16px;
  padding: 10px 14px;
  border: var(--stroke) solid var(--bad);
  border-radius: 12px;
  color: var(--bad);
  font-size: 14px;
  font-weight: 600;
}

/* ---------- Date and category switches ---------- */
.dates, .filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
  animation: rise 0.5s 0.1s var(--ease) backwards;
}
.filters { margin-bottom: 20px; }
.seg {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 16px;
  border: var(--stroke) solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  font-size: 14px;
  font-weight: 700;
  transition: border-color 0.2s, background 0.2s, color 0.2s, transform 0.15s var(--ease);
}
.seg:hover { border-color: var(--muted); }
.seg:active { transform: scale(0.96); }
.seg[aria-pressed="true"] { border-color: var(--text); background: var(--text); color: #fff; }
.seg .n {
  min-width: 22px;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--fill);
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}
.seg[aria-pressed="true"] .n { background: rgba(255, 255, 255, 0.18); color: #fff; }
.seg .sw { width: 8px; height: 8px; border-radius: 2px; }
.seg small { font-weight: 600; color: var(--muted); }
.seg[aria-pressed="true"] small { color: rgba(255, 255, 255, 0.7); }

/* ---------- Boards ---------- */
.board {
  border: var(--stroke) solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  margin-bottom: 20px;
  overflow: hidden;
  animation: rise 0.5s 0.15s var(--ease) backwards;
}
.board-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px;
  border-bottom: var(--stroke) solid var(--line);
}
.board-head h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 800;
  display: flex;
  align-items: baseline;
  gap: 10px;
}
.board-head h2 span {
  font-size: 11px;
  letter-spacing: 0.18em;
  color: var(--faint);
}
.count {
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
}

/* Columns: time, flight, route, aircraft, stand, livery */
.cols, .row {
  display: grid;
  grid-template-columns: 112px 1.35fr 1.2fr 1.5fr 64px 1.2fr;
  gap: 16px;
  padding: 0 18px;
}
.cols {
  padding-top: 10px;
  padding-bottom: 10px;
  background: var(--fill);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--muted);
}
.row {
  padding-top: 14px;
  padding-bottom: 14px;
  border-top: 1.5px solid var(--fill);
  align-items: start;
  animation: row-in 0.4s var(--ease) backwards;
}
.row:first-child { border-top: none; }
.row.cancelled > :not(.t) { opacity: 0.45; }
@keyframes row-in { from { opacity: 0; transform: translateY(6px); } }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }

.t-main { font-size: 20px; font-weight: 700; line-height: 1.2; }
.t-day { font-size: 12px; font-weight: 600; color: var(--muted); }
.t-sub { font-size: 13px; font-weight: 600; color: var(--muted); }
.t-sub.est { color: var(--c-maint); }
.t-sub.act { color: var(--live); }
.row.cancelled .t-main { text-decoration: line-through; color: var(--faint); }
.t-sub.cx { color: var(--bad); }

.fn { font-size: 17px; font-weight: 800; letter-spacing: 0.01em; }
.airline { font-size: 13px; color: var(--muted); }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 1px 8px;
  border: 1.5px solid currentColor;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
}
.tag.charter { color: var(--c-charter); }
.tag.maint, .tag.test, .tag.ferry { color: var(--c-maint); }
.tag.rare { color: #b7791f; }
.tag.livery { color: var(--c-livery); }
.tag.live { color: var(--live); background: var(--live-soft); border-color: transparent; }
.tag.live .dot { width: 6px; height: 6px; }

.route { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.ap {
  padding: 2px 7px;
  border-radius: 6px;
  background: var(--fill);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.06em;
}
.ap.home { background: var(--text); color: #fff; }
.arrow { color: var(--faint); font-size: 13px; }

.type { font-size: 14px; font-weight: 600; }
.reg {
  display: inline-block;
  margin-top: 3px;
  padding: 1px 7px;
  border: 1.5px solid var(--line);
  border-radius: 6px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
}
.pending { font-size: 12px; font-weight: 600; color: var(--muted); margin-top: 3px; }

.stand { font-size: 17px; font-weight: 800; }
.empty-cell { color: var(--faint); }

.livery-en { font-size: 14px; font-weight: 700; }
.livery-zh { font-size: 13px; color: var(--muted); }

.empty {
  padding: 28px 18px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}

/* Conflicts */
.conflict {
  padding: 12px 18px;
  border-top: 1.5px solid var(--fill);
  font-size: 14px;
}
.conflict:first-child { border-top: none; }
.conflict b { font-weight: 800; }
.conflict .src { color: var(--muted); }

.foot {
  margin-top: 28px;
  font-size: 12px;
  color: var(--muted);
  text-align: center;
}
.foot p { margin: 4px 0; }

/* ---------- Narrow screens: each flight becomes a card ---------- */
@media (max-width: 820px) {
  .app { padding: 24px 14px 40px; }
  h1 { font-size: 26px; }
  .clock-time { font-size: 22px; }
  .stat { padding: 10px 12px; }
  .stat-value { font-size: 15px; }
  .cols { display: none; }
  .row {
    grid-template-columns: 84px 1fr;
    grid-template-areas:
      "t f"
      "t r"
      "t a"
      "t s";
    gap: 6px 14px;
  }
  .row > .t { grid-area: t; }
  .row > .f { grid-area: f; }
  .row > .r { grid-area: r; }
  .row > .a { grid-area: a; }
  .row > .sl { grid-area: s; display: flex; flex-wrap: wrap; gap: 4px 14px; align-items: baseline; }
  .row > .s, .row > .l { display: none; }
  .sl .stand { font-size: 14px; }
  .sl .stand::before { content: "停机位 "; font-size: 12px; font-weight: 600; color: var(--muted); }
  .t-main { font-size: 18px; }
}
@media (min-width: 821px) {
  .row > .sl { display: none; }
}
