:root {
  color-scheme: light;
  --ink: #18363d;
  --muted: #4e656c;
  --accent: #216c73;
  --line: #cbd9d7;
  --paper: #fafbf7;
  color: var(--ink);
  background: #f4f6f2;
  font: 14px/1.5 "Segoe UI", "Microsoft YaHei", sans-serif;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(circle at 1px 1px, #38716c15 .65px, transparent .95px) 0 0 / 12px 12px, #f4f6f2;
}
a { color: inherit; text-decoration: none; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
header {
  display: flex;
  align-items: center;
  gap: 32px;
  min-height: 60px;
  padding-inline: clamp(16px, 4vw, 60px);
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}
nav, .heading, .toolbar, .legend, .map-readout { display: flex; align-items: center; flex-wrap: wrap; }
header nav { gap: 4px; }
header nav a { padding: 7px 12px; border-radius: 6px; color: var(--muted); font-weight: 600; }
header nav a:hover, header nav a[aria-current] { background: #e2eeea; color: #15575c; }
.brand { display: inline-flex; align-items: center; gap: 9px; font-size: 18px; font-weight: 700; }
.brand::before {
  content: "";
  width: 23px; height: 23px; border-radius: 4px;
  background: linear-gradient(90deg, #37767a 48%, transparent 48% 54%, #9dbfbb 54%) top / 100% 57% no-repeat,
              linear-gradient(90deg, #75a6a3 67%, transparent 67% 73%, #37767a 73%) bottom / 100% 37% no-repeat;
}
main { width: min(1540px, 100%); margin: auto; padding: 0 clamp(12px, 3.2vw, 48px) 24px; }
.heading, .toolbar { justify-content: space-between; gap: 12px; }
.heading { position: relative; isolation: isolate; padding: clamp(20px, 3vw, 38px) 2px 22px; }
.heading::before, #stage.stock-detail::after {
  content: ""; position: absolute; inset: 0 0 0 auto; width: 47%; pointer-events: none;
  background: url("atlas-contours.png") no-repeat right center / cover;
  mask-image: linear-gradient(90deg, transparent, #000 58%);
}
.heading::before { z-index: -1; opacity: .66; }
h1 { margin: 0; font-size: clamp(26px, 3vw, 40px); line-height: 1.2; letter-spacing: -.035em; }
.heading p { margin: 7px 0 0; color: var(--muted); font-variant-numeric: tabular-nums; }
button, select {
  max-width: 100%; padding: 7px 12px; border: 1px solid #b3c6c5; border-radius: 7px;
  background: #fff; color: var(--ink); font: inherit; cursor: pointer;
}
button:enabled:hover, select:enabled:hover { border-color: var(--accent); }
#refresh { background: #e5efeb; color: #194f54; font-weight: 650; }
#refresh:disabled { opacity: .7; cursor: wait; }
.atlas {
  overflow: hidden; background: var(--paper); border: 1px solid var(--line);
  border-radius: 14px; box-shadow: 0 6px 22px #24473f0c;
}
.toolbar, .map-readout { padding: 10px 16px; min-height: 46px; }
#path { gap: 5px; }
#path button { padding: 2px 4px; border: 0; background: transparent; color: var(--accent); }
#path button:disabled { color: var(--ink); font-weight: 650; cursor: default; }
#path button + button::before { content: "›"; margin-right: 8px; color: #678080; }
#stage { position: relative; height: clamp(290px, 55vh, 660px); background: #edf2ec; }
#stage.stock-detail::after { opacity: .55; }
#map { width: 100%; height: 100%; display: block; cursor: zoom-in; }
#message { position: absolute; inset: 0; display: grid; place-items: center; padding: 20px; text-align: center; background: #edf2ec; color: var(--muted); }
.map-readout { gap: 6px 14px; border-top: 1px solid var(--line); }
#metrics { color: #435c64; font: 13px/1.6 Consolas, "Microsoft YaHei", monospace; }
#selectionCard {
  position: absolute; z-index: 1; bottom: 14px; left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; justify-content: space-between; gap: 18px;
  width: min(550px, calc(100% - 24px)); padding: 13px 16px;
  background: var(--paper); border: 1px solid #9cb4ae; border-radius: 10px; box-shadow: 0 4px 18px #224d432b;
}
#selectionCard strong, #selectionCard small { display: block; }
#selectionCard strong { font-size: 18px; }
#selectionCard small { color: var(--muted); margin-top: 2px; }
.selection-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.selection-actions a { padding: 9px 12px; border-radius: 6px; font-weight: 650; color: #245356; background: #e3eeea; }
.selection-actions #research { background: #206269; color: #fff; }
.selection-actions a:hover, #mapLesson:hover { text-decoration: underline; }
.legend { gap: 8px 24px; padding: 9px 16px; border-top: 1px solid var(--line); background: #f0f4f0; color: #395259; font-size: 13px; }
.legend i { display: inline-block; width: 12px; height: 12px; margin: 0 4px 0 6px; border-radius: 3px; vertical-align: -1px; box-shadow: inset 0 0 0 1px #19383d29; }
.up { background: #e6a49b; } .flat { background: #b7c7ce; } .down { background: #9ec7b8; }
.legend .ramp { width: 44px; margin-left: 0; background: linear-gradient(90deg, #95a9b3, #d7dfe4); }
.note, footer { margin: 8px 2px 0; color: var(--muted); font-size: 12px; line-height: 1.6; }
#mapLesson { color: #225e67; text-decoration: underline; text-underline-offset: 3px; }
body.embedded { min-height: 0; background: var(--paper); }
.embedded > header, .embedded main > .heading, .embedded main > .note, .embedded main > footer { display: none; }
.embedded main { padding: 0; }
.embedded .atlas { border: 0; border-radius: 0; box-shadow: none; }
.embedded #stage { height: calc(100vh - 150px); min-height: 125px; }
.embedded .toolbar, .embedded .map-readout { padding: 6px 10px; min-height: 36px; gap: 3px 10px; }
.embedded .legend { padding: 5px 10px; font-size: 11px; }
@media (max-width: 600px) {
  header { flex-wrap: wrap; gap: 2px 12px; padding: 8px 12px; }
  header nav { gap: 0; }
  header nav a { padding: 7px 6px; font-size: 12px; }
  .heading { align-items: flex-start; flex-wrap: nowrap; }
  .heading p { font-size: 12px; }
  #refresh { flex-shrink: 0; }
  .toolbar, .map-readout, .legend { padding-inline: 10px; }
  #stage { height: 48svh; min-height: 285px; }
  .map-readout span { flex-basis: 100%; }
  .legend { gap: 4px 10px; font-size: 12px; }
  #selectionCard { flex-wrap: wrap; gap: 8px; }
  #selectionCard strong { font-size: 16px; }
  .selection-actions a { padding: 8px 10px; }
}
