/* NaviCrack — dark-only interface.
   Layout: icon rail (72) / panel (340) / chart viewer. */

:root {
  --rail: #171b24;
  --panel: #20252f;
  --raised: #2a303c;
  --raised-hi: #333a48;
  --viewer: #363c49;
  --line: #39404e;
  --line-soft: #2f3643;
  --text: #e6eaf2;
  --muted: #8d97aa;
  --dim: #6b748a;
  --accent: #3d82f7;
  --accent-soft: rgba(61, 130, 247, 0.16);
  --danger: #e0574f;
  --ok: #4fbd7e;

  --cat-sid: #e2599b;
  --cat-star: #4fbd7e;
  --cat-app: #e68a33;
  --cat-taxi: #4bb3d4;
  --cat-ref: #9a7ae8;

  --rail-w: 72px;
  --panel-w: 340px;

  --r-sm: 5px;
  --r-md: 8px;
  --r-lg: 12px;

  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --sans: "Barlow", system-ui, -apple-system, "Segoe UI", sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--panel);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

button,
input,
select {
  font: inherit;
  color: inherit;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-thumb {
  background: #434b5c;
  border: 3px solid transparent;
  background-clip: content-box;
  border-radius: 99px;
}

::-webkit-scrollbar-thumb:hover {
  background: #566076;
  background-clip: content-box;
}

::-webkit-scrollbar-track {
  background: transparent;
}

.icon {
  width: 20px;
  height: 20px;
  flex: none;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ---------------------------------------------------------------- shell */

/* Pinned rather than sized: iOS Safari resizes 100dvh as its toolbar slides,
   which pushed the bottom bar off screen. */
.app {
  position: fixed;
  inset: 0;
  display: grid;
  grid-template-columns: var(--rail-w) var(--panel-w) 1fr;
  overflow: hidden;
}

/* ----------------------------------------------------------------- rail */

.rail {
  grid-column: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 14px 0 10px;
  background: var(--rail);
  border-right: 1px solid var(--line-soft);
  z-index: 30;
}

.rail-brand {
  display: block;
  width: auto;
  height: 30px;
  margin-bottom: 14px;
}

.rail-btn {
  width: 60px;
  padding: 9px 2px 7px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  background: none;
  border: 0;
  border-radius: var(--r-md);
  color: var(--dim);
  cursor: pointer;
  transition: color 0.12s, background-color 0.12s;
}

.rail-btn span {
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.01em;
}

.rail-btn:hover:not(:disabled) {
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
}

.rail-btn[aria-current="true"] {
  color: var(--accent);
  background: var(--accent-soft);
}

.rail-btn:disabled {
  opacity: 0.35;
  cursor: default;
}

.rail-spacer {
  flex: 1;
}

.rail-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--raised-hi);
  color: var(--text);
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  cursor: pointer;
  display: grid;
  place-items: center;
}

.rail-avatar:hover {
  border-color: var(--accent);
}

/* -------------------------------------------------------------- account */

.account-pop {
  position: fixed;
  left: calc(var(--rail-w) + 8px);
  bottom: 12px;
  width: 232px;
  padding: 6px;
  background: var(--raised);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5);
  z-index: 60;
}

.account-pop[hidden] {
  display: none;
}

.account-id {
  padding: 8px 10px 10px;
  border-bottom: 1px solid var(--line-soft);
  margin-bottom: 6px;
}

.account-name {
  font-weight: 600;
  overflow-wrap: anywhere;
}

.account-role {
  display: inline-block;
  margin-top: 4px;
  padding: 1px 7px;
  border-radius: 99px;
  background: var(--accent-soft);
  color: #8fb6fd;
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.04em;
}

.account-pop a,
.account-pop button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  background: none;
  border: 0;
  border-radius: var(--r-sm);
  color: var(--text);
  font-size: 14px;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}

.account-pop a:hover,
.account-pop button:hover {
  background: var(--raised-hi);
}

/* display:flex above would otherwise beat the hidden attribute. */
.account-pop a[hidden],
.account-pop button[hidden] {
  display: none;
}

.account-pop .icon {
  width: 17px;
  height: 17px;
  color: var(--muted);
}

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

.panel {
  grid-column: 2;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--panel);
  border-right: 1px solid var(--line-soft);
}

.view {
  display: none;
  flex-direction: column;
  min-height: 0;
  flex: 1;
}

.view[data-active="true"] {
  display: flex;
}

.panel-head {
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--line-soft);
}

.panel-title {
  margin: 0 0 12px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--dim);
}

.panel-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding-bottom: 16px;
}

/* ---------------------------------------------------------------- input */

.field {
  position: relative;
  display: flex;
  align-items: center;
}

.field .icon {
  position: absolute;
  left: 11px;
  width: 17px;
  height: 17px;
  color: var(--dim);
  pointer-events: none;
}

.field input {
  width: 100%;
  padding: 9px 12px 9px 36px;
  background: var(--rail);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  color: var(--text);
}

.field input::placeholder {
  color: var(--dim);
}

.field input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.field input[type="search"]::-webkit-search-cancel-button {
  -webkit-appearance: none;
}

/* --------------------------------------------------------------- groups */

.group-label {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 9px 16px 7px;
  background: var(--panel);
  border-bottom: 1px solid var(--line-soft);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--dim);
}

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

.empty strong {
  display: block;
  margin-bottom: 4px;
  color: var(--text);
  font-weight: 600;
}

/* --------------------------------------------------------- airport rows */

.apt-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 9px 16px;
  background: none;
  border: 0;
  border-bottom: 1px solid var(--line-soft);
  text-align: left;
  cursor: pointer;
}

.apt-row:hover,
.apt-row[data-cursor="true"] {
  background: var(--raised);
}

.apt-row[aria-current="true"] {
  background: var(--accent-soft);
  box-shadow: inset 3px 0 0 var(--accent);
}

.apt-icao {
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.03em;
}

.apt-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13.5px;
  color: var(--muted);
}

/* -------------------------------------------------------- airport header */

.apt-head {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 16px 16px 14px;
  border-bottom: 1px solid var(--line-soft);
}

.apt-switch {
  flex: 1;
  min-width: 0;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 0 8px;
  padding: 4px 8px;
  margin: -4px -8px;
  background: none;
  border: 0;
  border-radius: var(--r-md);
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.apt-switch:hover {
  background: var(--raised);
}

.apt-switch-caret {
  grid-row: span 2;
  width: 18px;
  height: 18px;
  color: var(--dim);
}

.apt-switch:hover .apt-switch-caret {
  color: var(--text);
}

.apt-head-code {
  min-width: 0;
  font-family: var(--mono);
  font-size: 21px;
  font-weight: 500;
  letter-spacing: 0.02em;
  line-height: 1.2;
}

.apt-head-city {
  grid-column: 1;
  margin-top: 3px;
  font-size: 14px;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.star {
  flex: none;
  padding: 4px;
  background: none;
  border: 0;
  border-radius: var(--r-sm);
  color: var(--dim);
  cursor: pointer;
}

.star .icon {
  width: 21px;
  height: 21px;
}

.star:hover {
  color: var(--text);
}

.star[aria-pressed="true"] {
  color: #f0b429;
}

.star[aria-pressed="true"] .icon {
  fill: #f0b429;
}

/* ----------------------------------------------------------- chart chips */

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line-soft);
}

.chip {
  display: inline-flex;
  align-items: baseline;
  gap: 5px;
  padding: 3px 10px;
  background: none;
  border: 1px solid var(--line);
  border-radius: 99px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: 0.05em;
  cursor: pointer;
  transition: color 0.12s, border-color 0.12s, background-color 0.12s;
}

.chip-n {
  font-size: 10.5px;
  color: var(--dim);
}

.chip:hover:not(:disabled) {
  color: var(--text);
  border-color: var(--muted);
}

.chip:disabled {
  opacity: 0.3;
  cursor: default;
}

.chip[aria-pressed="true"] {
  color: var(--c);
  border-color: var(--c);
  background: color-mix(in srgb, var(--c) 16%, transparent);
}

.chip[aria-pressed="true"] .chip-n {
  color: inherit;
}

.chip-all {
  --c: var(--accent);
}
.chip-sid {
  --c: var(--cat-sid);
}
.chip-star {
  --c: var(--cat-star);
}
.chip-app {
  --c: var(--cat-app);
}
.chip-taxi {
  --c: var(--cat-taxi);
}
.chip-ref {
  --c: var(--cat-ref);
}

.chart-filter {
  padding: 12px 16px;
  border-bottom: 1px solid var(--line-soft);
}

/* ------------------------------------------------------------ chart rows */

.chart-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 8px 16px;
  background: none;
  border: 0;
  border-bottom: 1px solid var(--line-soft);
  border-left: 3px solid transparent;
  text-align: left;
  cursor: pointer;
}

.chart-row:hover,
.chart-row[data-cursor="true"] {
  background: var(--raised);
}

.chart-row[aria-current="true"] {
  background: var(--accent-soft);
  border-left-color: var(--accent);
}

.chart-row-text {
  flex: 1;
  min-width: 0;
}

.chart-row-name {
  font-size: 13.5px;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.chart-row-code {
  margin-top: 2px;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 500;
  color: var(--c, var(--muted));
}

.chart-row[aria-current="true"] .chart-row-code {
  color: #a9c6fc;
}

/* --------------------------------------------------------------- viewer */

.viewer {
  grid-column: 3;
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--viewer);
}

.viewer-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px 8px 16px;
  background: var(--rail);
  border-bottom: 1px solid var(--line-soft);
}

.viewer-title {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: baseline;
  gap: 10px;
  overflow: hidden;
}

.viewer-title-code {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 500;
  color: var(--accent);
}

.viewer-title-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
  color: var(--muted);
}

.tools {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: none;
}

.tool {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  background: none;
  border: 0;
  border-radius: var(--r-md);
  color: var(--muted);
  cursor: pointer;
  text-decoration: none;
  transition: color 0.12s, background-color 0.12s;
}

.tool:hover:not(:disabled) {
  color: var(--text);
  background: rgba(255, 255, 255, 0.07);
}

.tool:disabled {
  opacity: 0.3;
  cursor: default;
}

/* display:grid above would otherwise beat the hidden attribute. */
.tool[hidden] {
  display: none;
}

.tool-sep {
  width: 1px;
  height: 20px;
  margin: 0 5px;
  background: var(--line);
}

.stage {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  cursor: grab;
  touch-action: none;
}

.stage.is-panning {
  cursor: grabbing;
}

.stage img {
  position: absolute;
  top: 0;
  left: 0;
  transform-origin: 0 0;
  user-select: none;
  -webkit-user-drag: none;
  background: #fff;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.45);
}

.stage-empty {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 24px;
  text-align: center;
  color: var(--dim);
}

.stage-empty[hidden] {
  display: none;
}

.stage-empty .icon {
  width: 42px;
  height: 42px;
  stroke-width: 1.1;
}

.stage-empty p {
  margin: 0;
  max-width: 34ch;
  font-size: 14px;
}

.zoom-badge {
  position: absolute;
  right: 14px;
  bottom: 14px;
  padding: 3px 9px;
  background: rgba(23, 27, 36, 0.86);
  border: 1px solid var(--line);
  border-radius: 99px;
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--muted);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.25s;
}

.zoom-badge.is-shown {
  opacity: 1;
}

/* -------------------------------------------------------------- spinner */

.spinner {
  width: 22px;
  height: 22px;
  margin: 28px auto;
  border: 2px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.stage .spinner {
  position: absolute;
  top: 50%;
  left: 50%;
  margin: -11px 0 0 -11px;
}

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

/* ------------------------------------------------------------ auth pages */

.auth {
  display: grid;
  grid-template-columns: 1fr 1fr;
  min-height: 100dvh;
  background: var(--rail);
}

.auth-aside {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 48px;
  overflow: hidden;
  background:
    radial-gradient(900px 560px at 18% 108%, rgba(61, 130, 247, 0.3), transparent 62%),
    radial-gradient(700px 480px at 92% -8%, rgba(79, 189, 126, 0.14), transparent 60%),
    #11141c;
  border-right: 1px solid var(--line-soft);
}

/* Compass rose: the aside's one piece of decoration. */
.auth-rose {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 150%;
  max-width: 760px;
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  color: rgba(141, 151, 170, 0.14);
  pointer-events: none;
}

.auth-rose svg {
  width: 100%;
  height: 100%;
  display: block;
}

.auth-brand {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 19px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

/* Height-driven: the mark is wider than it is tall, so a square box
   would park it below the wordmark's centre line. */
.auth-brand-mark {
  display: block;
  width: auto;
  height: 30px;
}

.auth-pitch {
  position: relative;
  max-width: 17ch;
  margin: 0;
  font-size: clamp(30px, 3.4vw, 46px);
  font-weight: 600;
  line-height: 1.08;
  letter-spacing: -0.02em;
}

.auth-meta {
  position: relative;
  margin: 0;
  font-family: var(--mono);
  font-size: 11.5px;
  letter-spacing: 0.06em;
  color: var(--dim);
}

.auth-main {
  display: grid;
  place-items: center;
  padding: 48px 32px;
  background: var(--panel);
}

.auth-card {
  width: 100%;
  max-width: 352px;
}

.auth-card h1 {
  margin: 0 0 6px;
  font-size: 25px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.auth-lede {
  margin: 0 0 26px;
  color: var(--muted);
  font-size: 14.5px;
}

.auth-card form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.auth-field label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
}

.auth-field input {
  width: 100%;
  padding: 11px 13px;
  background: var(--rail);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  color: var(--text);
}

.auth-field input::placeholder {
  color: var(--dim);
}

.auth-field input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.auth-hint {
  margin: 6px 0 0;
  font-size: 12.5px;
  color: var(--dim);
}

.btn-primary {
  margin-top: 4px;
  padding: 11px 16px;
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: var(--r-md);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.12s;
}

.btn-primary:hover {
  background: #336fd8;
  border-color: #336fd8;
}

.alert {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  margin: 0 0 18px;
  padding: 10px 12px;
  background: rgba(224, 87, 79, 0.12);
  border: 1px solid rgba(224, 87, 79, 0.4);
  border-radius: var(--r-md);
  color: #f3a8a3;
  font-size: 13.5px;
}

.alert .icon {
  width: 17px;
  height: 17px;
  margin-top: 1px;
  flex: none;
}

.auth-foot {
  margin: 26px 0 0;
  padding-top: 18px;
  border-top: 1px solid var(--line-soft);
  color: var(--dim);
  font-size: 12.5px;
}

.auth-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 18px;
  color: var(--muted);
  font-size: 13.5px;
  text-decoration: none;
}

.auth-back:hover {
  color: var(--text);
}

.auth-back .icon {
  width: 15px;
  height: 15px;
}

/* ---------------------------------------------------------- responsive */

@media (max-width: 1180px) {
  :root {
    --panel-w: 300px;
  }
}

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

  .auth-aside {
    padding: 28px 24px 32px;
    border-right: 0;
    border-bottom: 1px solid var(--line-soft);
  }

  .auth-rose,
  .auth-meta {
    display: none;
  }

  .auth-pitch {
    margin-top: 24px;
    font-size: 27px;
    max-width: none;
  }

  .auth-main {
    padding: 36px 24px 56px;
    place-items: start center;
  }
}

/* Phone / small tablet: rail docks to the bottom, panel becomes a sheet
   over the viewer, and only one of the two is visible at a time. */
@media (max-width: 820px) {
  .app {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr auto;
  }

  .rail {
    grid-column: 1;
    grid-row: 2;
    flex-direction: row;
    justify-content: space-around;
    align-items: center;
    gap: 0;
    padding: 4px 6px calc(4px + env(safe-area-inset-bottom));
    border-right: 0;
    border-top: 1px solid var(--line-soft);
    box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.45);
  }

  /* Clear the status bar and the browser's floating toolbar. */
  .panel-head,
  .apt-head {
    padding-top: calc(14px + env(safe-area-inset-top));
  }

  .viewer-bar {
    padding-top: calc(8px + env(safe-area-inset-top));
  }

  .panel-body {
    padding-bottom: 28px;
  }

  .rail-brand,
  .rail-spacer {
    display: none;
  }

  .rail-btn {
    width: auto;
    flex: 1;
    max-width: 92px;
    padding: 6px 2px;
  }

  .account-pop {
    left: 10px;
    right: 10px;
    bottom: calc(66px + env(safe-area-inset-bottom));
    width: auto;
  }

  .panel,
  .viewer {
    grid-column: 1;
    grid-row: 1;
    min-height: 0;
  }

  .panel {
    z-index: 10;
    border-right: 0;
  }

  .viewer {
    z-index: 5;
  }

  /* data-mobile on .app says which pane wins. */
  .app[data-mobile="viewer"] .panel {
    display: none;
  }

  .app[data-mobile="panel"] .viewer {
    display: none;
  }

  .viewer-title-name {
    display: none;
  }

  .tool {
    width: 40px;
    height: 40px;
  }

  .apt-row,
  .chart-row {
    padding-top: 11px;
    padding-bottom: 11px;
  }
}

@media (max-width: 820px) {
  .only-wide {
    display: none !important;
  }
}

@media (min-width: 821px) {
  .only-narrow {
    display: none !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
