/* FlightDeck CLT pilot. Follows the FlightDeck design system (DESIGN.md in
   FlightDeckWeb and flightdeck-app): black canvas, #161616 cards, white as
   the one accent, Inter at 400/600/800, 0.5px hairlines, colour only for
   meaning. Token values match FlightDeckWeb/src/app/tokens.css. */

@font-face {
  font-family: "Inter";
  src: url("/static/fonts/Inter.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

:root {
  --base: #000;
  --elevated: #0c0c0c;
  --surface: #161616;
  --surface-alt: #1c1c1c;
  --surface-hover: #232325;
  --selected: rgb(255 255 255 / 14%);
  --track: rgb(255 255 255 / 6%);
  --glass-strong: rgb(22 22 22 / 94%);
  --scrim: rgb(0 0 0 / 60%);

  --primary: #fff;
  --secondary: #8e8e93;
  --tertiary: #78787e;
  --accent: #f2f2f2;
  --on-accent: #000;

  --hairline: 0.5px;
  --border: #2c2c2e;
  --border-card: rgb(255 255 255 / 6%);
  --selection-edge: rgb(255 255 255 / 20%);

  --green: #34c759;
  --orange: #ff9f0a;
  --red: #ff3b30;
  --blue: #0a84ff;
  --green-tint: rgb(52 199 89 / 14%);
  --orange-tint: rgb(255 159 10 / 14%);
  --red-tint: rgb(255 59 48 / 14%);
  --blue-tint: rgb(10 132 255 / 14%);

  --font-ui: Inter, -apple-system, "Segoe UI", Arial, sans-serif;
  --micro: 11px;
  --meta: 12px;
  --label: 13px;
  --body: 15px;
  --strong: 17px;
  --title: 22px;
  --display: 28px;
  --hero: 34px;

  --radius-segment: 10px;
  --radius-control: 14px;
  --radius-card: 22px;

  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  color-scheme: dark;
}
@media (prefers-contrast: more) {
  :root { --secondary: #a1a1a6; --red: #ff6165; }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--base);
  color: var(--primary);
  font: 400 var(--body) / 1.5 var(--font-ui);
  font-feature-settings: "cv11", "ss03";
  -webkit-font-smoothing: antialiased;
}
body.drawer-open { overflow: hidden; }

a { color: inherit; text-underline-offset: 3px; text-decoration-thickness: var(--hairline); }
h1 { font-size: var(--display); font-weight: 800; letter-spacing: -0.02em; line-height: 1.15; margin: 0 0 12px; }
h2 { font-size: var(--strong); font-weight: 600; letter-spacing: -0.01em; line-height: 1.3; margin: 32px 0 12px; }
h3 { font-size: var(--body); font-weight: 600; margin: 16px 0 4px; }
p { margin: 0 0 8px; }
time, .numeric, .count, .board-when, .row-end, .badge { font-variant-numeric: tabular-nums; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }

.muted { color: var(--secondary); }
.small { font-size: var(--label); }
.strong { font-weight: 600; }
.spacer { flex: 1; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* ---------- frame ---------- */

.top {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 32px;
  height: 56px;
  padding: 0 24px;
  background: var(--base);
  border-bottom: var(--hairline) solid var(--border);
}
.brand { font-size: var(--strong); font-weight: 800; letter-spacing: -0.01em; text-decoration: none; white-space: nowrap; }
.brand-sub { font-weight: 600; color: var(--secondary); margin-left: 4px; }
.nav { display: flex; gap: 4px; flex: 1; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.nav-link {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 12px;
  border-radius: var(--radius-segment);
  font-size: var(--label);
  font-weight: 600;
  color: var(--secondary);
  text-decoration: none;
  white-space: nowrap;
}
.nav-link:hover { color: var(--primary); }
.nav-link[aria-current="page"] { color: var(--primary); background: var(--selected); }
.who { display: flex; align-items: center; gap: 16px; }
.who .nav-link { padding: 0; background: none; }
.nav-account { display: none; }

.main { width: 100%; max-width: 960px; margin: 0 auto; padding: 32px 24px 48px; flex: 1; }
.main.narrow { max-width: 400px; padding-top: 64px; }
.foot { width: 100%; max-width: 960px; margin: 0 auto; padding: 24px; color: var(--tertiary); font-size: var(--meta); }
.foot p { margin: 0; max-width: 64ch; }

/* ---------- controls ---------- */

label { display: flex; flex-direction: column; gap: 8px; font-size: var(--label); font-weight: 600; color: var(--secondary); }
input, select, textarea {
  font: inherit;
  font-size: var(--body);
  color: var(--primary);
  background: var(--surface);
  border: var(--hairline) solid var(--border-card);
  border-radius: var(--radius-control);
  padding: 0 12px;
  min-height: 44px;
  transition: border-color 120ms var(--ease), background 120ms var(--ease);
}
textarea { padding: 12px; resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--selection-edge); background: var(--surface-alt); }
input:focus-visible, select:focus-visible, textarea:focus-visible { box-shadow: 0 0 0 3px rgb(255 255 255 / 10%); }
input::placeholder, textarea::placeholder { color: var(--tertiary); }
input[type="checkbox"], input[type="radio"] { min-height: 0; width: 20px; height: 20px; margin: 0; accent-color: var(--accent); }

button {
  font: inherit;
  font-size: var(--label);
  font-weight: 600;
  color: var(--primary);
  background: var(--surface-alt);
  border: var(--hairline) solid var(--border-card);
  border-radius: var(--radius-control);
  min-height: 40px;
  padding: 0 16px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 120ms var(--ease), transform 120ms var(--ease);
}
button:hover { background: var(--surface-hover); }
button:active { transform: scale(0.97); }
button:disabled { opacity: 0.4; cursor: default; transform: none; }
button.primary { background: var(--accent); color: var(--on-accent); border-color: transparent; }
button.primary:hover { background: #fff; }
button.danger { color: var(--red); }
.text-button, .link-button { min-height: 32px; padding: 0; border: 0; background: none; color: var(--secondary); }
.text-button:hover, .link-button:hover { background: none; color: var(--primary); }
.icon-button { width: 36px; min-height: 36px; padding: 0; border-radius: 50%; color: var(--secondary); font-size: var(--strong); line-height: 1; }
.icon-button:hover { color: var(--primary); }
.inline { display: inline; }
.wide-button { width: 100%; min-height: 48px; margin-top: 16px; background: var(--surface); border-radius: var(--radius-control); }

/* The only tab style, as in the FlightDeck apps. */
.segmented { display: inline-flex; gap: 4px; padding: 4px; border-radius: var(--radius-control); background: var(--track); }
.segmented button { min-height: 32px; padding: 0 12px; border: 0; border-radius: var(--radius-segment); background: transparent; color: var(--secondary); }
.segmented button:hover { background: transparent; color: var(--primary); }
.segmented button[aria-pressed="true"], .segmented button[aria-selected="true"] { background: var(--selected); color: var(--primary); }
.segmented .count { margin-left: 6px; font-weight: 400; color: var(--tertiary); }
.segmented [aria-selected="true"] .count { color: var(--secondary); }

.badge, .tag {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--surface-alt);
  color: var(--secondary);
  font-size: var(--micro);
  font-weight: 600;
  white-space: nowrap;
}
.badge-red { background: var(--red-tint); color: var(--red); }
.badge-orange { background: var(--orange-tint); color: var(--orange); }
.badge-blue { background: var(--blue-tint); color: var(--blue); }
.badge-white { background: var(--accent); color: var(--on-accent); }

.card { background: var(--surface); border: var(--hairline) solid var(--border-card); border-radius: var(--radius-card); padding: 16px; }

.stack { display: flex; flex-direction: column; gap: 16px; }
.stack > h2 { margin: 16px 0 0; }
.stack > button { min-height: 44px; }
.check { flex-direction: row; align-items: center; gap: 12px; min-height: 44px; font-size: var(--body); font-weight: 400; color: var(--primary); }
.group { margin: 0; padding: 4px 16px 8px; border: var(--hairline) solid var(--border-card); border-radius: var(--radius-card); background: var(--surface); display: flex; flex-direction: column; }
.group legend { float: left; width: 100%; padding: 12px 0 4px; font-size: var(--label); font-weight: 600; color: var(--secondary); }
.group .check + .check { border-top: var(--hairline) solid var(--border-card); }
.group button { align-self: flex-start; margin: 8px 0; }
.group > p { margin: 4px 0 0; }
.code-input { font-size: var(--title); font-weight: 600; letter-spacing: 0.3em; font-variant-numeric: tabular-nums; max-width: 220px; }
.secret { font-size: var(--label); line-height: 1.6; font-variant-numeric: tabular-nums; background: var(--elevated); border-radius: var(--radius-control); padding: 12px; overflow-wrap: anywhere; }
pre.secret { white-space: pre-wrap; margin: 8px 0; font-family: var(--font-ui); }
.qr { width: 200px; height: 200px; border-radius: var(--radius-control); }

.notice { padding: 12px 16px; border-radius: var(--radius-control); background: var(--surface); margin: 0 0 16px; }
.notice-error { background: var(--red-tint); }
.notice-ok { background: var(--green-tint); }
.callout { background: var(--surface); border: var(--hairline) solid var(--border-card); border-radius: var(--radius-card); padding: 16px; margin: 0 0 24px; }

/* ---------- Now ---------- */

.hero-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.hero h1 { font-size: var(--hero); letter-spacing: -0.03em; margin: 0; }
.lede { margin: 4px 0 0; font-size: var(--label); color: var(--secondary); }
.lede a { color: var(--secondary); }
.status { margin: 16px 0 0; }
.status p { margin: 0; }
.outage { margin: 0 0 24px; padding: 12px 16px; border-radius: var(--radius-control); background: var(--red-tint); color: var(--primary); }
.permission { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin: 24px 0 0; padding: 12px 12px 12px 16px; border-radius: var(--radius-control); background: var(--surface); border: var(--hairline) solid var(--border-card); }
.permission p { margin: 0; }

.alerts { display: flex; flex-direction: column; gap: 12px; margin-top: 24px; }
.alerts:empty { display: none; }
.alert.flash { animation: flash 1.2s var(--ease) 1; }
@keyframes flash { from { border-color: var(--selection-edge); background: var(--surface-hover); } to { border-color: var(--border-card); background: var(--surface); } }
.alert-top { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 8px; margin-bottom: 12px; }
.alert-top time, .alert-top .ago { white-space: nowrap; }
.alert-top time { font-size: var(--label); font-weight: 600; }
.alert-top .ago { font-size: var(--meta); color: var(--tertiary); }
.alert-ident { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 16px; }
.callsign {
  font: inherit;
  font-size: var(--display);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.15;
  color: var(--primary);
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 4px;
  background: none;
}
button.callsign:hover { background: none; text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 5px; }
button.callsign:active { transform: none; }
.callsign-sm { font-size: var(--title); letter-spacing: -0.015em; }
.alert-route { font-size: var(--strong); font-weight: 600; letter-spacing: -0.01em; }
.flight-meta { display: flex; flex-wrap: wrap; gap: 4px 16px; margin: 4px 0 0; font-size: var(--label); color: var(--secondary); }
.alert-line { margin: 0; font-weight: 600; }
.alert-actions { display: flex; align-items: center; gap: 16px; margin-top: 16px; }
.earlier { margin-top: 16px; border-top: var(--hairline) solid var(--border-card); }
.plans { margin-top: 8px; }
.plans summary { cursor: pointer; font-size: var(--label); font-weight: 600; color: var(--secondary); }
.plan-label { margin: 12px 0 0; font-size: var(--meta); color: var(--tertiary); }

/* Original ACARS text, as the FlightDeck apps show it: Inter, 13, tabular. */
.msg {
  margin: 12px 0 0;
  font-family: var(--font-ui);
  font-size: var(--label);
  line-height: 1.6;
  font-variant-numeric: tabular-nums;
  color: var(--primary);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  max-height: 24em;
  overflow-y: auto;
}
.msg mark { color: inherit; font-weight: 600; border-radius: 4px; padding: 0 2px; background: var(--selected); }
.msg .mark-red { background: var(--red-tint); color: var(--red); }
.msg .mark-orange { background: var(--orange-tint); color: var(--orange); }
.msg .mark-blue { background: var(--blue-tint); color: var(--blue); }

.rows > * + * { border-top: var(--hairline) solid var(--border-card); }
.card.rows { padding-top: 0; padding-bottom: 0; }
.hold-row { display: grid; grid-template-columns: minmax(88px, auto) minmax(0, 1fr) auto; align-items: center; gap: 12px; min-height: 48px; }
.alert .rows { margin-top: 12px; border-top: var(--hairline) solid var(--border-card); }
.row-main { display: flex; flex-direction: column; min-width: 0; }
.row-title { font: inherit; font-size: var(--body); font-weight: 600; color: var(--primary); text-align: left; min-height: 0; padding: 0; border: 0; background: none; }
button.row-title:hover { background: none; text-decoration: underline; }
.row-sub { font-size: var(--meta); color: var(--secondary); }
.row-end { font-size: var(--label); font-weight: 600; color: var(--secondary); text-align: right; }
.dismissed-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 56px; padding: 8px 0; }

.fold > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 48px;
  padding: 0 16px;
  border-radius: var(--radius-control);
  background: var(--surface);
  border: var(--hairline) solid var(--border-card);
  font-weight: 600;
  cursor: pointer;
  list-style: none;
}
.fold > summary::-webkit-details-marker { display: none; }
.fold > summary:hover { background: var(--surface-alt); }
.fold-body { display: flex; flex-direction: column; gap: 12px; margin-top: 12px; }

/* ---------- flight board ---------- */

.flights { margin-top: 48px; }
.section-head { display: flex; align-items: center; flex-wrap: wrap; gap: 12px 16px; margin-bottom: 16px; }
.section-head h2 { margin: 0; font-size: var(--title); font-weight: 800; letter-spacing: -0.015em; }
.h-note { margin-left: 8px; font-size: var(--label); font-weight: 400; letter-spacing: 0; color: var(--secondary); }
.filter { margin-left: auto; width: 280px; }
.board { border-bottom: var(--hairline) solid var(--border); }
.board-row {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 56px;
  padding: 8px 0;
  border: 0;
  border-top: var(--hairline) solid var(--border);
  border-radius: 0;
  background: none;
  text-align: left;
  font-weight: 400;
}
.board-row:hover { background: none; }
.board-row:active { transform: none; }
.board-row:hover .board-when, .board-row:hover .board-route.none { color: var(--primary); }
.board-flight { display: flex; flex-direction: column; min-width: 0; }
.board-route { font-size: var(--body); font-weight: 600; }
.board-route.none { font-weight: 400; color: var(--secondary); }
.board-when { font-size: var(--label); font-weight: 600; color: var(--secondary); }
.board-badges { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 4px; }
.empty-line { color: var(--secondary); margin: 16px 0; }

/* ---------- flight panel ---------- */

.drawer { position: fixed; inset: 0; z-index: 30; }
.drawer-backdrop { position: absolute; inset: 0; background: var(--scrim); }
.drawer-panel { position: absolute; top: 0; right: 0; bottom: 0; width: min(560px, 100%); display: flex; flex-direction: column; background: var(--base); border-left: var(--hairline) solid var(--border); }
.drawer-head { display: flex; align-items: center; gap: 12px; padding: 20px 20px 4px; }
.drawer-head h2 { flex: 1; margin: 0; font-size: var(--display); font-weight: 800; letter-spacing: -0.02em; line-height: 1.15; }
.drawer-body { flex: 1; overflow-y: auto; padding: 0 20px 40px; }
.flight-route { margin: 0; font-size: var(--title); font-weight: 800; letter-spacing: -0.015em; }
.flight-head { padding-bottom: 16px; }
.timeline { border-bottom: var(--hairline) solid var(--border); }
.msg-item { padding: 12px 0; border-top: var(--hairline) solid var(--border); }
.msg-head { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.msg-head time { font-size: var(--label); font-weight: 600; }
.msg-head > span:not(.badge) { font-size: var(--meta); color: var(--tertiary); }
.msg-item .msg { margin-top: 8px; }
.earlier .msg-item:first-child { border-top: 0; }
.drawer-foot { margin: 16px 0 0; }

/* ---------- toasts ---------- */

.toasts { position: fixed; right: 24px; bottom: 24px; z-index: 40; display: flex; flex-direction: column; gap: 12px; width: min(360px, calc(100% - 32px)); }
.toast {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  border-radius: var(--radius-card);
  background: var(--glass-strong);
  -webkit-backdrop-filter: blur(20px) saturate(140%);
  backdrop-filter: blur(20px) saturate(140%);
  border: var(--hairline) solid rgb(255 255 255 / 10%);
  box-shadow: 0 12px 40px rgb(0 0 0 / 55%);
  animation: toast-in 300ms var(--ease);
}
.toast-text { display: flex; flex-direction: column; gap: 4px; }
.toast-text strong { font-size: var(--body); font-weight: 600; }
.toast-text span { font-size: var(--label); color: var(--secondary); }
.toast-actions { display: flex; align-items: center; gap: 16px; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- Search and reading pages ---------- */

.page-head { margin-bottom: 24px; }
.page-head p { margin: 0; color: var(--secondary); max-width: 64ch; }
.search-row { display: flex; align-items: flex-end; flex-wrap: wrap; gap: 12px; margin-bottom: 12px; }
.search-row .grow { flex: 1; min-width: 240px; }
.search-row button { min-height: 44px; }
.list { display: flex; flex-direction: column; gap: 12px; margin-top: 16px; }
.result .msg-item { margin-top: 12px; padding-bottom: 0; border-top: var(--hairline) solid var(--border-card); }
.empty .row-sub { margin: 4px 0 0; }

.prose { max-width: 64ch; }
.prose ul { padding-left: 20px; }
.prose li { margin-bottom: 8px; }
.rules { display: grid; grid-template-columns: max-content 1fr; gap: 12px 24px; margin: 16px 0; }
.rules dt { font-weight: 600; }
.rules dd { margin: 0; font-size: var(--label); color: var(--secondary); }
.rules dd .strong { color: var(--primary); }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 12px 32px; margin: 16px 0 32px; }
.facts dt { color: var(--secondary); }
.facts dd { margin: 0; }

.table { display: block; overflow-x: auto; width: 100%; border-collapse: collapse; margin: 0 0 16px; font-size: var(--label); }
.table th { text-align: left; padding: 0 16px 8px 0; font-weight: 600; color: var(--secondary); white-space: nowrap; border-bottom: var(--hairline) solid var(--border); }
.table td { padding: 12px 16px 12px 0; vertical-align: top; border-bottom: var(--hairline) solid var(--border); }
.table.compact td { padding: 8px 16px 8px 0; font-size: var(--meta); }
.table .actions { display: flex; flex-wrap: wrap; gap: 8px; }
.table .actions button { min-height: 32px; padding: 0 12px; border-radius: var(--radius-segment); }
.row-form { display: flex; align-items: flex-end; flex-wrap: wrap; gap: 12px; }
.row-form button { min-height: 44px; }
.invite-form { max-width: 640px; }

/* ---------- compact (wall screens) ---------- */

body.compact .main { padding-top: 16px; }
body.compact .alerts { gap: 8px; }
body.compact .card { padding: 12px; }
body.compact .board-row { min-height: 44px; padding: 4px 0; }
body.compact .flights { margin-top: 32px; }

/* ---------- narrow screens ---------- */

@media (max-width: 760px) {
  .top { flex-wrap: wrap; height: auto; gap: 8px 16px; padding: 12px 20px 8px; }
  .nav { order: 3; flex-basis: 100%; margin: 0 -12px; }
  .who { margin-left: auto; }
  .who .nav-link { display: none; }
  .nav-account { display: inline-flex; }
  .main { padding: 20px 20px 40px; }
  .foot { padding: 20px; }
  .hero h1 { font-size: var(--display); }
  .section-head .segmented { max-width: 100%; overflow-x: auto; scrollbar-width: none; }
  .filter { margin-left: 0; width: 100%; }
  .board-row { grid-template-columns: 96px minmax(0, 1fr) auto; }
  .alert-actions { flex-wrap: wrap; }
  .drawer-head, .drawer-body { padding-left: 16px; padding-right: 16px; }
  .rules { grid-template-columns: 1fr; gap: 4px; }
  .rules dd { margin-bottom: 12px; }
  input, select, textarea { font-size: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
