:root {
  --ink: #16252b;
  --ink-soft: #40545b;
  --paper: #f2f0e8;
  --paper-strong: #fbfaf4;
  --line: rgba(22, 37, 43, 0.16);
  --accent: #e96f45;
  --cyan: #4db6b0;
  --shadow: 0 24px 70px rgba(15, 33, 39, 0.18);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #b7c4c1;
  color: var(--ink);
  font-family: "Avenir Next", "PingFang SC", "Microsoft YaHei", sans-serif;
}

button {
  font: inherit;
}

button:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 3px;
  box-shadow: 0 0 0 5px rgba(22, 37, 43, 0.5);
}

[hidden] {
  display: none !important;
}

.app-shell {
  position: relative;
  width: 100%;
  height: 100%;
  background:
    radial-gradient(circle at 76% 18%, rgba(255, 245, 205, 0.58), transparent 25%),
    linear-gradient(140deg, #90aaa9, #d4d5ca 58%, #a8b9b4);
}

.topbar {
  position: absolute;
  z-index: 30;
  top: 0;
  left: 0;
  right: 0;
  height: 72px;
  display: grid;
  grid-template-columns: minmax(280px, 1fr) auto minmax(280px, 1fr);
  align-items: center;
  padding: 0 24px;
  color: #f8f5e9;
  background: linear-gradient(180deg, rgba(13, 30, 35, 0.88), rgba(13, 30, 35, 0.42) 72%, transparent);
  pointer-events: none;
}

.brand,
.context,
.overview-button {
  pointer-events: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  position: relative;
  width: 38px;
  height: 38px;
  border: 1px solid rgba(255, 255, 255, 0.5);
  background:
    linear-gradient(90deg, transparent 48%, rgba(255, 255, 255, 0.24) 49%, rgba(255, 255, 255, 0.24) 51%, transparent 52%),
    linear-gradient(transparent 48%, rgba(255, 255, 255, 0.24) 49%, rgba(255, 255, 255, 0.24) 51%, transparent 52%);
}

.brand-mark::before,
.brand-mark::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  background: #f3b95f;
  box-shadow: 0 0 16px rgba(243, 185, 95, 0.8);
}

.brand-mark::before {
  width: 7px;
  height: 7px;
  top: 6px;
  right: 6px;
}

.brand-mark::after {
  width: 4px;
  height: 4px;
  left: 7px;
  bottom: 7px;
}

.brand-copy small,
.context small {
  display: block;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.2em;
  opacity: 0.68;
}

.brand-copy h1 {
  margin: 2px 0 0;
  font-family: "Songti SC", "STSong", serif;
  font-size: 19px;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.context {
  justify-self: center;
  min-width: 220px;
  text-align: center;
}

.context strong {
  display: block;
  margin-top: 4px;
  font-size: 12px;
  letter-spacing: 0.08em;
}

.overview-button {
  justify-self: end;
  min-width: 138px;
  padding: 10px 14px;
  border: 1px solid rgba(255, 255, 255, 0.42);
  color: #fff;
  background: rgba(7, 21, 25, 0.52);
  backdrop-filter: blur(12px);
  cursor: pointer;
  transition: border-color 180ms ease, background 180ms ease, transform 180ms ease;
}

.overview-button:hover {
  border-color: #f3b95f;
  background: rgba(7, 21, 25, 0.82);
  transform: translateY(-1px);
}

.scene-stage {
  position: absolute;
  inset: 0;
  overflow: clip;
  overflow-x: clip;
  overflow-y: clip;
}

.scene-root,
.scene-root canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
}

.scene-root canvas {
  touch-action: none;
}

.stage-grain {
  position: absolute;
  z-index: 3;
  inset: 0;
  pointer-events: none;
  opacity: 0.17;
  background:
    radial-gradient(circle at 20% 28%, rgba(255, 255, 255, 0.26) 0 0.7px, transparent 1px),
    radial-gradient(circle at 72% 64%, rgba(5, 24, 28, 0.24) 0 0.6px, transparent 1px);
  background-size: 7px 7px, 9px 9px;
  mix-blend-mode: overlay;
}

.zone-pins {
  position: absolute;
  z-index: 12;
  inset: 0;
  pointer-events: none;
}

.zone-pin {
  --zone-color: #fff;
  position: absolute;
  min-width: 152px;
  padding: 10px 12px 9px;
  border: 1px solid color-mix(in srgb, var(--zone-color) 62%, white 18%);
  color: #f9fbf8;
  background: rgba(10, 27, 31, 0.78);
  box-shadow: 0 12px 28px rgba(4, 18, 21, 0.22);
  backdrop-filter: blur(10px);
  transform: translate(-50%, -50%);
  cursor: pointer;
  pointer-events: auto;
  transition: opacity 220ms ease, transform 220ms ease, background 220ms ease, border-color 220ms ease;
}

.zone-pin::before {
  content: "";
  position: absolute;
  left: -1px;
  top: -1px;
  bottom: -1px;
  width: 4px;
  background: var(--zone-color);
  box-shadow: 0 0 16px var(--zone-color);
}

.zone-pin small,
.zone-pin strong {
  display: block;
  text-align: left;
}

.zone-pin small {
  color: var(--zone-color);
  font-size: 8px;
  font-weight: 900;
  letter-spacing: 0.13em;
}

.zone-pin strong {
  margin-top: 3px;
  font-family: "Songti SC", "STSong", serif;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 0.08em;
}

.zone-pin:hover,
.zone-pin.is-hovered,
.zone-pin.is-selected {
  border-color: var(--zone-color);
  background: rgba(6, 22, 26, 0.94);
  transform: translate(-50%, -50%) translateY(-4px);
}

.app-shell[data-mode="zone-selected"] .zone-pin:not(.is-selected),
.app-shell[data-mode="task-selected"] .zone-pin:not(.is-selected),
.app-shell[data-mode="flight-playing"] .zone-pin:not(.is-selected),
.app-shell[data-mode="flight-complete"] .zone-pin:not(.is-selected) {
  opacity: 0.28;
}

.app-shell[data-mode="flight-playing"] .zone-pin,
.app-shell[data-mode="flight-complete"] .zone-pin {
  pointer-events: none;
}

.mission-profile-tags {
  position: absolute;
  z-index: 17;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.mission-profile-tag {
  --zone-color: #62b9a7;
  position: absolute;
  display: flex;
  align-items: center;
  gap: 6px;
  width: 148px;
  min-width: 0;
  min-height: 31px;
  padding: 6px 9px;
  border: 1px solid var(--zone-color);
  color: #fff;
  background: rgba(7, 24, 28, 0.9);
  box-shadow: 0 0 22px color-mix(in srgb, var(--zone-color) 55%, transparent);
  pointer-events: none;
}

.mission-profile-tag::after {
  content: "";
  position: absolute;
  left: var(--connector-x, 50%);
  top: 100%;
  width: 1px;
  height: 22px;
  background: var(--zone-color);
  box-shadow: 0 0 8px var(--zone-color);
  transform: translateX(-50%);
}

.mission-profile-tag i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--zone-color);
  box-shadow: 0 0 10px var(--zone-color);
}

.mission-profile-tag span {
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.mission-profile-tag b {
  color: var(--zone-color);
  font-size: 8px;
  letter-spacing: 0.08em;
}

.overview-key {
  position: absolute;
  z-index: 10;
  left: 24px;
  bottom: 24px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 13px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  color: rgba(247, 249, 244, 0.9);
  background: rgba(8, 24, 28, 0.66);
  backdrop-filter: blur(10px);
  pointer-events: none;
}

.overview-key .mouse {
  width: 17px;
  height: 24px;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 9px;
  position: relative;
}

.overview-key .mouse::after {
  content: "";
  position: absolute;
  width: 2px;
  height: 5px;
  left: 7px;
  top: 4px;
  background: #f3b95f;
}

.overview-key small {
  display: block;
  font-size: 8px;
  font-weight: 900;
  letter-spacing: 0.14em;
  opacity: 0.62;
}

.overview-key strong {
  display: block;
  margin-top: 2px;
  font-size: 10px;
  font-weight: 600;
}

.fleet-status {
  position: absolute;
  z-index: 11;
  right: 24px;
  bottom: 24px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 13px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: rgba(247, 249, 244, 0.92);
  background: rgba(8, 24, 28, 0.68);
  backdrop-filter: blur(10px);
  pointer-events: none;
  transition: right 320ms ease, bottom 320ms ease;
}

.fleet-pulse {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #62b9a7;
  box-shadow: 0 0 0 0 rgba(98, 185, 167, 0.6);
  animation: fleet-pulse 1.8s ease-out infinite;
}

@keyframes fleet-pulse {
  70% { box-shadow: 0 0 0 8px rgba(98, 185, 167, 0); }
}

.fleet-status small,
.fleet-status strong {
  display: block;
}

.fleet-status small {
  color: #8fd5ca;
  font-size: 8px;
  font-weight: 900;
  letter-spacing: 0.14em;
}

.fleet-status strong {
  margin-top: 2px;
  font-size: 10px;
  font-weight: 650;
}

.app-shell:not([data-mode="overview"]) .fleet-status {
  right: 408px;
}

.task-panel {
  position: absolute;
  z-index: 20;
  top: 88px;
  right: 20px;
  bottom: 22px;
  width: min(370px, calc(100vw - 40px));
  display: flex;
  flex-direction: column;
  border: 1px solid rgba(255, 255, 255, 0.55);
  background: rgba(244, 242, 234, 0.93);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
  transform: translateX(calc(100% + 30px));
  opacity: 0;
  pointer-events: none;
  transition: transform 420ms cubic-bezier(0.22, 1, 0.36, 1), opacity 220ms ease;
}

.task-panel.is-visible {
  transform: translateX(0);
  opacity: 1;
  pointer-events: auto;
}

.task-panel::before {
  content: "";
  position: absolute;
  top: -1px;
  left: -1px;
  bottom: -1px;
  width: 5px;
  background: var(--zone-color, var(--cyan));
}

.panel-head {
  padding: 23px 22px 17px 26px;
  border-bottom: 1px solid var(--line);
}

.panel-kicker {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--ink-soft);
  font-size: 8px;
  font-weight: 900;
  letter-spacing: 0.16em;
}

.panel-kicker span:last-child {
  color: var(--zone-color, var(--accent));
}

.panel-head h2 {
  margin: 8px 0 0;
  font-family: "Songti SC", "STSong", serif;
  font-size: 30px;
  font-weight: 500;
  letter-spacing: 0.06em;
}

.panel-head p {
  margin: 7px 0 0;
  color: var(--ink-soft);
  font-size: 11px;
  line-height: 1.65;
}

.task-list {
  flex: 1 1 auto;
  display: grid;
  align-content: start;
  gap: 10px;
  min-height: 0;
  padding: 14px 14px 18px 18px;
  overflow: auto;
}

.task-card {
  position: relative;
  width: 100%;
  padding: 15px 16px 14px;
  border: 1px solid rgba(22, 37, 43, 0.15);
  color: var(--ink);
  background: rgba(255, 255, 255, 0.78);
  text-align: left;
  cursor: pointer;
  transition: border-color 180ms ease, box-shadow 180ms ease, transform 180ms ease, opacity 180ms ease;
}

.task-card::after {
  content: "↗";
  position: absolute;
  right: 15px;
  top: 14px;
  color: var(--zone-color, var(--accent));
  font-size: 16px;
}

.task-card:hover {
  border-color: var(--zone-color, var(--accent));
  box-shadow: 0 12px 32px rgba(31, 51, 57, 0.12);
  transform: translateY(-2px);
}

.task-card.is-selected {
  border-color: var(--zone-color, var(--accent));
  background: #fff;
  box-shadow: inset 4px 0 0 var(--zone-color, var(--accent)), 0 12px 32px rgba(31, 51, 57, 0.14);
}

.task-card.is-dimmed {
  opacity: 0.36;
}

.task-card:disabled {
  cursor: default;
  transform: none;
}

.task-card .task-department {
  color: var(--zone-color, var(--accent));
  font-size: 8px;
  font-weight: 900;
  letter-spacing: 0.14em;
}

.task-card h3 {
  margin: 6px 26px 10px 0;
  font-family: "Songti SC", "STSong", serif;
  font-size: 19px;
  font-weight: 600;
}

.task-meta {
  display: grid;
  grid-template-columns: 1.25fr 0.65fr 0.7fr;
  gap: 6px;
  margin: 0;
}

.task-meta div {
  min-width: 0;
}

.task-meta dt {
  color: #718087;
  font-size: 8px;
}

.task-meta dd {
  margin: 3px 0 0;
  overflow: hidden;
  color: #23383e;
  font-size: 9px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.task-card p {
  margin: 11px 0 0;
  padding-top: 10px;
  border-top: 1px solid rgba(22, 37, 43, 0.1);
  color: #4f6167;
  font-size: 10px;
  line-height: 1.55;
}

.mission-roster {
  display: grid;
  gap: 4px;
  margin-top: 10px;
  padding-top: 9px;
  border-top: 1px solid rgba(22, 37, 43, 0.1);
}

.mission-profile-row {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr) auto;
  align-items: center;
  gap: 7px;
  min-height: 25px;
  padding: 4px 7px 4px 5px;
  color: #263b40;
  background: rgba(34, 56, 62, 0.055);
}

.mission-profile-index {
  color: var(--zone-color, var(--accent));
  font-size: 8px;
  font-weight: 900;
  letter-spacing: 0.08em;
}

.mission-profile-copy {
  min-width: 0;
}

.mission-profile-copy b,
.mission-profile-copy small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mission-profile-copy b {
  font-size: 9px;
  font-weight: 850;
}

.mission-profile-copy small {
  margin-top: 1px;
  color: #718087;
  font-size: 7px;
  font-weight: 700;
}

.mission-profile-altitude {
  color: var(--zone-color, var(--accent));
  font-size: 9px;
  font-style: normal;
  font-weight: 900;
}

.mission-hud {
  position: absolute;
  z-index: 18;
  left: 50%;
  top: 86px;
  width: min(420px, calc(100vw - 430px));
  min-width: 310px;
  padding: 12px 14px 11px;
  border: 1px solid rgba(255, 255, 255, 0.46);
  color: #f7f7ef;
  background: rgba(7, 24, 28, 0.8);
  box-shadow: 0 15px 42px rgba(3, 17, 20, 0.25);
  backdrop-filter: blur(12px);
  transform: translateX(-50%);
}

.mission-hud-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.mission-hud-head small {
  color: var(--zone-color, #f3b95f);
  font-size: 8px;
  font-weight: 900;
  letter-spacing: 0.14em;
}

.mission-hud-head strong {
  font-size: 11px;
  font-weight: 700;
}

.mission-progress {
  position: relative;
  height: 3px;
  margin-top: 10px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.18);
}

.mission-progress span {
  display: block;
  width: 0;
  height: 100%;
  background: var(--zone-color, #f3b95f);
  box-shadow: 0 0 14px var(--zone-color, #f3b95f);
  transition: width 80ms linear;
}

.mission-controls {
  position: absolute;
  z-index: 22;
  right: 392px;
  bottom: 24px;
  display: flex;
  gap: 8px;
}

.mission-controls button {
  min-width: 116px;
  padding: 11px 14px;
  border: 1px solid rgba(255, 255, 255, 0.42);
  color: #f8f7f0;
  background: rgba(8, 24, 28, 0.78);
  box-shadow: 0 10px 28px rgba(3, 17, 20, 0.2);
  cursor: pointer;
  backdrop-filter: blur(12px);
}

.mission-controls button:first-child {
  border-color: var(--zone-color, #f3b95f);
  color: #17282d;
  background: var(--zone-color, #f3b95f);
}

.mission-controls button:hover {
  transform: translateY(-1px);
}

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

.loading-fallback {
  position: absolute;
  z-index: 50;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  color: #fff;
  background: #173039;
  text-align: center;
}

.loading-fallback strong {
  display: block;
  font-family: "Songti SC", "STSong", serif;
  font-size: 26px;
  font-weight: 500;
}

.loading-fallback span {
  display: block;
  margin-top: 8px;
  color: rgba(255, 255, 255, 0.65);
  font-size: 11px;
}

@media (max-width: 1120px) {
  .topbar {
    grid-template-columns: 1fr auto;
  }

  .context {
    display: none;
  }

  .task-panel {
    width: 344px;
  }

  .mission-controls {
    right: 366px;
  }

  .app-shell:not([data-mode="overview"]) .fleet-status {
    right: 382px;
  }

  .mission-hud {
    left: 33%;
    width: 330px;
  }
}

@media (max-width: 860px) {
  .topbar {
    height: 64px;
    padding: 0 14px;
  }

  .brand-copy small {
    display: none;
  }

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

  .overview-button {
    min-width: 118px;
    padding: 9px 10px;
    font-size: 11px;
  }

  .zone-pin {
    min-width: 116px;
    padding: 8px 9px 7px;
  }

  .zone-pin strong {
    font-size: 14px;
  }

  .mission-profile-tag {
    width: 128px;
    padding: 5px 7px;
  }

  .mission-profile-tag span {
    font-size: 8px;
  }

  .task-panel {
    top: auto;
    left: 10px;
    right: 10px;
    bottom: 10px;
    width: auto;
    height: min(44vh, 390px);
    transform: translateY(calc(100% + 20px));
  }

  .task-panel.is-visible {
    transform: translateY(0);
  }

  .panel-head {
    padding: 14px 16px 10px 20px;
  }

  .panel-head h2 {
    margin-top: 4px;
    font-size: 22px;
  }

  .panel-head p {
    display: none;
  }

  .task-list {
    grid-template-columns: 1fr 1fr;
    padding: 9px 9px 12px 14px;
  }

  .task-card {
    padding: 11px 12px;
  }

  .task-card h3 {
    margin-bottom: 7px;
    font-size: 16px;
  }

  .task-meta {
    grid-template-columns: 1fr 1fr;
  }

  .task-meta div:first-child {
    grid-column: 1 / -1;
  }

  .task-card p {
    display: none;
  }

  .mission-hud {
    top: 72px;
    left: 50%;
    width: calc(100vw - 24px);
    min-width: 0;
  }

  .mission-controls {
    right: 18px;
    bottom: calc(min(44vh, 390px) + 18px);
  }

  .fleet-status,
  .app-shell:not([data-mode="overview"]) .fleet-status {
    right: 12px;
    bottom: 12px;
  }

  .app-shell:not([data-mode="overview"]) .fleet-status {
    bottom: calc(min(44vh, 390px) + 18px);
  }

  .overview-key {
    left: 12px;
    bottom: 12px;
  }
}

@media (max-width: 560px) {
  .brand-mark {
    width: 32px;
    height: 32px;
  }

  .zone-pin {
    min-width: 96px;
  }

  .zone-pin small {
    display: none;
  }

  .task-list {
    grid-template-columns: 1fr;
  }

  .mission-controls {
    left: 12px;
    right: 12px;
  }

  .mission-controls button {
    flex: 1;
    min-width: 0;
  }
}

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