:root {
  --bg: #050c12;
  --surface: #0b1721;
  --surface-raised: #101f2b;
  --surface-hover: #172936;
  --line: #263a47;
  --line-strong: #3b5360;
  --text: #f0f5f5;
  --text-soft: #c8d5d8;
  --muted: #8fa4ad;
  --muted-strong: #aebfc5;
  --accent: #e9b65e;
  --accent-strong: #ffd184;
  --accent-ink: #241a08;
  --origin: #70c3d7;
  --danger: #ff8f7f;
  --focus: #8dd9e7;
  --topbar-height: 68px;
  --panel-width: 376px;
  --radius-sm: 8px;
  --radius-md: 14px;
  --shadow-stage: inset 0 0 100px rgba(0, 0, 0, 0.36);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
}

body {
  min-width: 320px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button,
select {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
select:focus-visible {
  outline: 3px solid rgba(141, 217, 231, 0.52);
  outline-offset: 2px;
}

button:disabled,
select:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.app-shell {
  display: grid;
  grid-template-rows: var(--topbar-height) minmax(0, 1fr);
  min-height: 100vh;
  min-height: 100dvh;
}

.topbar {
  position: relative;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-width: 0;
  padding: 0 20px;
  border-bottom: 1px solid var(--line);
  background: #08131c;
}

.brand,
.topbar-actions,
.toolbar-button,
.utc-readout {
  display: flex;
  align-items: center;
}

.brand {
  min-width: 0;
  gap: 12px;
}

.brand-mark {
  display: grid;
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  color: var(--origin);
}

.brand-mark svg {
  width: 25px;
  height: 25px;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.35;
}

.brand-copy {
  display: flex;
  min-width: 0;
  flex-direction: column;
}

.brand-copy h1 {
  margin: 0;
  color: var(--text);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.01em;
  line-height: 1.25;
}

.brand-copy span {
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.025em;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar-actions {
  gap: 8px;
}

.utc-readout {
  min-height: 44px;
  margin-right: 8px;
  gap: 8px;
  color: var(--muted-strong);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #5dc3a5;
  box-shadow: 0 0 0 4px rgba(93, 195, 165, 0.1);
}

.toolbar-button {
  min-height: 44px;
  gap: 8px;
  padding: 0 13px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-soft);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  transition: background-color 180ms ease, border-color 180ms ease, color 180ms ease;
}

.toolbar-button:hover {
  border-color: var(--line);
  background: var(--surface-raised);
  color: var(--text);
}

.toolbar-button[aria-pressed="true"] {
  border-color: rgba(112, 195, 215, 0.42);
  background: rgba(112, 195, 215, 0.12);
  color: #a5dfeb;
}

.earth-mode-button[data-mode="live"] {
  border-color: rgba(112, 195, 215, 0.38);
  background: rgba(112, 195, 215, 0.09);
  color: #a5dfeb;
}

.earth-mode-button[data-mode="day"] {
  border-color: rgba(233, 182, 94, 0.42);
  background: rgba(233, 182, 94, 0.1);
  color: var(--accent-strong);
}

.earth-mode-button[data-mode="night"] {
  border-color: rgba(135, 158, 220, 0.42);
  background: rgba(135, 158, 220, 0.1);
  color: #b7c8f4;
}

.toolbar-button svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.7;
}

.workspace {
  display: grid;
  min-width: 0;
  min-height: 0;
  grid-template-columns: var(--panel-width) minmax(0, 1fr);
}

.route-panel {
  position: relative;
  z-index: 10;
  min-width: 0;
  min-height: 0;
  overflow-y: auto;
  padding: 26px 26px 34px;
  border-right: 1px solid var(--line);
  background: var(--surface);
}

.panel-intro {
  padding-bottom: 23px;
  border-bottom: 1px solid var(--line);
}

.section-index {
  margin: 0 0 9px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.09em;
}

.panel-intro h2 {
  max-width: 19ch;
  margin: 0;
  color: var(--text);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.34;
}

.panel-intro > p:last-child {
  max-width: 34ch;
  margin: 11px 0 0;
  color: var(--muted-strong);
  font-size: 13px;
  line-height: 1.65;
}

.route-form {
  display: flex;
  flex-direction: column;
  padding: 23px 0 20px;
  border-bottom: 1px solid var(--line);
}

.field-group {
  display: grid;
  gap: 8px;
}

.field-group label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted-strong);
  font-size: 12px;
  font-weight: 650;
}

.endpoint-code {
  display: inline-grid;
  width: 20px;
  height: 20px;
  place-items: center;
  border: 1px solid rgba(112, 195, 215, 0.5);
  border-radius: 50%;
  color: var(--origin);
  font-size: 10px;
  font-weight: 800;
}

.endpoint-code-destination {
  border-color: rgba(233, 182, 94, 0.58);
  color: var(--accent);
}

.field-group select {
  width: 100%;
  height: 50px;
  padding: 0 42px 0 13px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  appearance: none;
  background-color: var(--surface-raised);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23aebfc5' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m7 10 5 5 5-5'/%3E%3C/svg%3E");
  background-position: right 13px center;
  background-repeat: no-repeat;
  color: var(--text);
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  transition: border-color 180ms ease, background-color 180ms ease;
}

.field-group select:hover {
  border-color: #536b78;
  background-color: var(--surface-hover);
}

.swap-button {
  display: flex;
  align-self: flex-end;
  min-height: 44px;
  align-items: center;
  gap: 6px;
  margin: 2px 2px 2px 0;
  padding: 0 8px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted-strong);
  cursor: pointer;
  font-size: 12px;
  font-weight: 650;
  transition: background-color 180ms ease, color 180ms ease;
}

.swap-button:hover {
  background: var(--surface-raised);
  color: var(--text);
}

.swap-button svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.7;
}

.flight-button {
  display: flex;
  width: 100%;
  min-height: 50px;
  align-items: center;
  justify-content: center;
  gap: 9px;
  margin-top: 18px;
  padding: 0 18px;
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: var(--accent-ink);
  cursor: pointer;
  font-size: 14px;
  font-weight: 800;
  transition: background-color 180ms ease, border-color 180ms ease, transform 120ms ease;
}

.flight-button:hover {
  border-color: var(--accent-strong);
  background: var(--accent-strong);
}

.flight-button:active {
  transform: translateY(1px);
}

.flight-button.is-flying {
  border-color: var(--line-strong);
  background: var(--surface-raised);
  color: var(--text);
}

.flight-button svg {
  width: 19px;
  height: 19px;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.65;
}

.flight-progress {
  height: 2px;
  margin-top: 9px;
  overflow: hidden;
  background: var(--line);
  opacity: 0;
  transition: opacity 180ms ease;
}

.flight-progress.is-visible {
  opacity: 1;
}

.flight-progress span {
  display: block;
  width: 0;
  height: 100%;
  background: var(--accent);
  transition: width 80ms linear;
}

.quick-routes,
.route-data,
.local-time-section {
  padding-top: 20px;
}

.quick-routes h3,
.route-data h3,
.local-time-section h3 {
  margin: 0;
  color: var(--text-soft);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.025em;
}

.quick-route-list {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 11px;
}

.quick-route-button {
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--muted-strong);
  cursor: pointer;
  font-size: 12px;
  font-weight: 650;
  transition: border-color 180ms ease, background-color 180ms ease, color 180ms ease;
}

.quick-route-button:hover,
.quick-route-button[aria-pressed="true"] {
  border-color: rgba(233, 182, 94, 0.55);
  background: rgba(233, 182, 94, 0.08);
  color: var(--accent-strong);
}

.section-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding-bottom: 10px;
}

.section-heading > span {
  color: var(--muted);
  font-size: 10px;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  border-top: 1px solid var(--line);
  border-left: 1px solid var(--line);
}

.metric {
  min-width: 0;
  min-height: 76px;
  padding: 13px 12px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.025em;
}

.metric strong {
  display: block;
  overflow: hidden;
  margin-top: 5px;
  color: var(--text);
  font-size: 16px;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.015em;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.local-time-section {
  padding-bottom: 8px;
}

.clock-table {
  margin-top: 10px;
  border-top: 1px solid var(--line);
}

.clock-row {
  display: grid;
  min-height: 63px;
  align-items: center;
  grid-template-columns: 10px minmax(0, 1fr) auto;
  gap: 11px;
  border-bottom: 1px solid var(--line);
}

.clock-marker {
  width: 7px;
  height: 7px;
  border-radius: 50%;
}

.clock-marker-origin {
  background: var(--origin);
  box-shadow: 0 0 0 4px rgba(112, 195, 215, 0.09);
}

.clock-marker-destination {
  background: var(--accent);
  box-shadow: 0 0 0 4px rgba(233, 182, 94, 0.09);
}

.clock-place {
  display: flex;
  min-width: 0;
  flex-direction: column;
}

.clock-place strong {
  overflow: hidden;
  color: var(--text-soft);
  font-size: 13px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.clock-place span {
  color: var(--muted);
  font-size: 10px;
}

.clock-row time {
  color: var(--text);
  font-size: 19px;
  font-variant-numeric: tabular-nums;
  font-weight: 650;
  letter-spacing: 0.015em;
}

.globe-stage {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  isolation: isolate;
  background: radial-gradient(circle at 55% 44%, #10293a 0%, #07131c 43%, #03080d 100%);
  box-shadow: var(--shadow-stage);
}

.globe-stage::after {
  position: absolute;
  z-index: 2;
  right: 0;
  bottom: 0;
  left: 0;
  height: 18%;
  background: linear-gradient(to bottom, transparent, rgba(3, 8, 13, 0.5));
  content: "";
  pointer-events: none;
}

#globeViz,
#globeViz > div,
#globeViz canvas {
  width: 100%;
  height: 100%;
}

#globeViz {
  position: absolute;
  inset: 0;
  z-index: 1;
  cursor: grab;
}

#globeViz:active {
  cursor: grabbing;
}

#globeViz canvas {
  display: block;
  outline: none;
}

.scene-tooltip {
  max-width: 240px;
  padding: 9px 11px !important;
  border: 1px solid var(--line-strong) !important;
  border-radius: 7px !important;
  background: #0b1721 !important;
  color: var(--text) !important;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28) !important;
  font-family: inherit !important;
  font-size: 12px !important;
}

.globe-tooltip strong,
.globe-tooltip span {
  display: block;
}

.globe-tooltip span {
  margin-top: 2px;
  color: var(--muted-strong);
  font-size: 10px;
}

.route-hud {
  position: absolute;
  z-index: 4;
  top: 22px;
  right: 22px;
  display: flex;
  min-width: 190px;
  flex-direction: column;
  padding: 13px 15px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: rgba(8, 19, 28, 0.92);
  pointer-events: none;
}

.route-hud > span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 650;
  letter-spacing: 0.06em;
}

.route-hud strong {
  max-width: 34ch;
  margin-top: 3px;
  overflow: hidden;
  color: var(--text);
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.route-hud small {
  margin-top: 2px;
  color: var(--accent);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.earth-status {
  position: absolute;
  z-index: 4;
  top: 104px;
  right: 22px;
  display: flex;
  min-height: 44px;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border: 1px solid rgba(59, 83, 96, 0.72);
  border-radius: var(--radius-sm);
  background: rgba(8, 19, 28, 0.88);
  pointer-events: none;
}

.earth-status-marker {
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px rgba(112, 195, 215, 0.12);
}

.earth-status > div {
  display: flex;
  min-width: 0;
  flex-direction: column;
}

.earth-status strong {
  color: var(--text-soft);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.35;
}

.earth-status small {
  margin-top: 1px;
  color: var(--muted);
  font-size: 9px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.025em;
  line-height: 1.35;
}

.interaction-hint {
  position: absolute;
  z-index: 4;
  bottom: 19px;
  left: 20px;
  display: flex;
  min-height: 40px;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  border: 1px solid rgba(59, 83, 96, 0.72);
  border-radius: var(--radius-sm);
  background: rgba(8, 19, 28, 0.9);
  color: var(--muted-strong);
  font-size: 11px;
  pointer-events: none;
}

.interaction-hint svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.6;
}

.loading-state,
.error-state {
  position: absolute;
  z-index: 8;
  inset: 0;
  display: grid;
  place-content: center;
  background: #07131c;
}

.loading-state {
  gap: 14px;
  transition: opacity 220ms ease, visibility 220ms ease;
}

.loading-state.is-hidden {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
}

.loading-copy {
  display: flex;
  min-width: 210px;
  flex-direction: column;
}

.loading-copy span {
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
}

.loading-copy small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
}

.loading-line {
  position: relative;
  width: 210px;
  height: 3px;
  overflow: hidden;
  background: var(--line);
}

.loading-line::after {
  position: absolute;
  inset: 0;
  width: 40%;
  background: var(--origin);
  content: "";
  animation: loading-line 1.15s ease-in-out infinite;
}

@keyframes loading-line {
  0% { transform: translateX(-115%); }
  100% { transform: translateX(290%); }
}

.error-state {
  max-width: none;
  padding: 32px;
  text-align: center;
}

.error-state[hidden] {
  display: none;
}

.error-state svg {
  width: 34px;
  height: 34px;
  margin: 0 auto 12px;
  stroke: var(--danger);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.5;
}

.error-state h2 {
  margin: 0;
  font-size: 18px;
}

.error-state p {
  max-width: 38ch;
  margin: 8px auto 18px;
  color: var(--muted-strong);
  font-size: 13px;
}

.error-state button {
  min-height: 44px;
  padding: 0 18px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-raised);
  color: var(--text);
  cursor: pointer;
  font-weight: 700;
}

.mobile-planner-button {
  display: none;
}

.toast {
  position: fixed;
  z-index: 10020;
  left: 50%;
  bottom: 22px;
  max-width: min(420px, calc(100vw - 32px));
  min-height: 42px;
  padding: 10px 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: #12212b;
  color: var(--text-soft);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.34);
  font-size: 12px;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 12px);
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.noscript-message {
  position: fixed;
  z-index: 10050;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 32px;
  background: var(--bg);
  color: var(--text);
  text-align: center;
}

@media (min-width: 1440px) {
  :root {
    --panel-width: 400px;
  }

  .route-panel {
    padding-right: 30px;
    padding-left: 30px;
  }
}

@media (max-width: 900px) {
  :root {
    --panel-width: 340px;
  }

  .route-panel {
    padding-right: 20px;
    padding-left: 20px;
  }

  .toolbar-button span,
  .utc-readout {
    display: none;
  }

  .toolbar-button {
    width: 44px;
    justify-content: center;
    padding: 0;
    border-color: var(--line);
  }
}

@media (max-width: 720px) {
  body {
    overflow-x: hidden;
    overflow-y: auto;
  }

  .app-shell {
    display: block;
    min-height: 100dvh;
  }

  .topbar {
    position: sticky;
    top: 0;
    height: 60px;
    padding: 0 12px;
  }

  .brand-mark {
    width: 34px;
    height: 34px;
  }

  .brand-copy h1 {
    font-size: 15px;
  }

  .brand-copy span {
    display: none;
  }

  .topbar-actions {
    gap: 6px;
  }

  .toolbar-button {
    width: 44px;
    min-height: 44px;
  }

  .workspace {
    display: flex;
    min-height: auto;
    flex-direction: column;
  }

  .globe-stage {
    order: 1;
    height: min(58dvh, 560px);
    min-height: 390px;
  }

  .route-panel {
    order: 2;
    width: 100%;
    min-height: auto;
    overflow: visible;
    padding: 25px 20px calc(42px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--line);
    border-right: 0;
  }

  .panel-intro h2 {
    max-width: 24ch;
    font-size: 21px;
  }

  .route-hud {
    top: 14px;
    right: 14px;
    left: 14px;
    min-width: 0;
    padding: 10px 12px;
  }

  .earth-status {
    top: 88px;
    right: 14px;
    padding: 7px 10px;
  }

  .interaction-hint {
    right: 14px;
    bottom: 70px;
    left: 14px;
    justify-content: center;
    overflow: hidden;
    white-space: nowrap;
  }

  .mobile-planner-button {
    position: absolute;
    z-index: 5;
    right: 14px;
    bottom: 14px;
    left: 14px;
    display: flex;
    min-height: 46px;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 1px solid var(--accent);
    border-radius: var(--radius-sm);
    background: var(--accent);
    color: var(--accent-ink);
    cursor: pointer;
    font-size: 13px;
    font-weight: 800;
  }

  .mobile-planner-button svg {
    width: 17px;
    height: 17px;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 1.8;
  }

  .toast {
    bottom: calc(18px + env(safe-area-inset-bottom));
  }
}

@media (max-width: 420px) {
  .globe-stage {
    height: 54dvh;
    min-height: 360px;
  }

  .route-panel {
    padding-right: 16px;
    padding-left: 16px;
  }

  .route-hud strong {
    max-width: 26ch;
  }

  .interaction-hint span {
    font-size: 10px;
  }
}

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

@media (prefers-contrast: more) {
  :root {
    --line: #526875;
    --line-strong: #78909b;
    --muted: #b9c7cc;
    --muted-strong: #d2dde0;
  }
}
