/* Market Atlas — light theme.
   Ink scale: #0E1726 (primary) · #475569 (secondary) · #8A94A6 (muted).
   Surfaces: white page, #F6F7F9 wells, #E6EAF0 hairlines. */
:root {
  --ink: #0E1726;
  --ink-2: #475569;
  --muted: #8A94A6;
  --line: #E6EAF0;
  --line-2: #D9DFE8;
  --well: #F6F7F9;
  --white: #FFFFFF;
  --accent: #0F766E;
  --radius: 18px;
  --shadow: 0 1px 2px rgba(15, 23, 38, .04), 0 8px 24px -12px rgba(15, 23, 38, .12);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--white); color: var(--ink); }
body {
  font: 14px/1.5 "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "cv11", "ss01";
  min-height: 100vh;
}
button, input, select { font: inherit; color: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.wrap { max-width: 1320px; margin: 0 auto; padding: 0 32px; }

/* ---------- header ---------- */
.top {
  max-width: 1320px; margin: 0 auto; padding: 22px 32px;
  display: flex; align-items: center; justify-content: space-between;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; letter-spacing: -0.01em; font-size: 15px; }
.top-right { display: flex; align-items: center; gap: 14px; font-size: 12.5px; }
.pill {
  display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 99px;
  background: var(--well); color: var(--ink-2); border: 1px solid var(--line);
}
.pill i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.pill.live i { background: #16A34A; box-shadow: 0 0 0 0 rgba(22,163,74,.5); animation: ping 2.2s infinite; }
.pill.preview i { background: #D97706; }
@keyframes ping { 70% { box-shadow: 0 0 0 8px rgba(22,163,74,0); } 100% { box-shadow: 0 0 0 0 rgba(22,163,74,0); } }

/* ---------- hero ---------- */
.hero {
  max-width: 1320px; margin: 0 auto; padding: 24px 32px 8px;
  display: grid; grid-template-columns: 1.25fr 1fr; gap: 28px 48px; align-items: end;
}
.eyebrow { margin: 0 0 14px; font-size: 11.5px; font-weight: 600; letter-spacing: .16em; text-transform: uppercase; color: var(--muted); }
h1 {
  margin: 0; font-family: "Fraunces", Georgia, serif; font-weight: 500;
  font-size: clamp(34px, 4.4vw, 56px); line-height: 1.04; letter-spacing: -0.02em;
}
h1 em { font-style: italic; color: var(--accent); font-weight: 400; }
.lede { margin: 18px 0 0; color: var(--ink-2); font-size: 15.5px; max-width: 58ch; }
.lede b { color: var(--ink); font-weight: 600; }

.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.stat { background: var(--white); padding: 18px 20px; }
.stat span { display: block; font-size: 11.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-weight: 500; }
.stat b { display: block; margin-top: 6px; font-family: "Fraunces", Georgia, serif; font-weight: 500; font-size: 30px; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }

.breadth { grid-column: 1 / -1; }
.breadth-bar { height: 8px; border-radius: 99px; overflow: hidden; display: flex; background: #F1D9CD; }
.breadth-bar i { display: block; height: 100%; width: 50%; background: var(--accent); transition: width .6s cubic-bezier(.2,.8,.2,1); }
.breadth-meta { display: flex; justify-content: space-between; margin-top: 10px; font-size: 12.5px; color: var(--ink-2); font-variant-numeric: tabular-nums; }

.banner {
  max-width: 1320px; margin: 16px auto 0; padding: 11px 16px; border-radius: 12px;
  background: #FFF7E6; border: 1px solid #F5D9A6; color: #7A4B00; font-size: 13px;
}
.banner { margin-left: auto; margin-right: auto; width: calc(100% - 64px); }

/* ---------- controls ---------- */
.controls {
  max-width: 1320px; margin: 28px auto 0; padding: 0 32px;
  display: flex; flex-wrap: wrap; gap: 12px; align-items: center;
}
.seg { display: inline-flex; background: var(--well); border: 1px solid var(--line); border-radius: 12px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button {
  background: none; border: 0; padding: 7px 12px; border-radius: 9px; cursor: pointer;
  color: var(--ink-2); font-size: 13px; font-weight: 500; white-space: nowrap; transition: background .15s, color .15s;
  display: inline-flex; align-items: center; gap: 6px;
}
.seg button:hover { color: var(--ink); }
.seg button[aria-pressed="true"] { background: var(--white); color: var(--ink); box-shadow: 0 1px 2px rgba(15,23,38,.08), 0 0 0 1px var(--line-2); }
.seg button .sw { width: 9px; height: 9px; border-radius: 3px; display: inline-block; }

.search {
  margin-left: auto; min-width: 240px; background: var(--white); border: 1px solid var(--line-2); border-radius: 12px; padding: 9px 14px; outline: none;
}
.search::placeholder { color: var(--muted); }
.search:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(15,118,110,.12); }

.switch { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; color: var(--ink-2); font-size: 13px; font-weight: 500; user-select: none; }
.switch input { display: none; }
.switch .track { width: 36px; height: 20px; border-radius: 99px; background: var(--line-2); position: relative; transition: background .2s; }
.switch .track i { position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: var(--white); box-shadow: 0 1px 2px rgba(0,0,0,.2); transition: transform .2s; }
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track i { transform: translateX(16px); }

.sub {
  max-width: 1320px; margin: 14px auto 0; padding: 0 32px;
  display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between;
}
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1px solid var(--line-2); background: var(--white); color: var(--ink-2); border-radius: 99px;
  padding: 5px 12px; cursor: pointer; font-size: 12.5px; font-weight: 500;
}
.chip:hover { color: var(--ink); border-color: #C3CCD9; }
.chip[aria-pressed="true"] { background: var(--ink); color: var(--white); border-color: var(--ink); }
.chip .n { opacity: .55; margin-left: 6px; font-variant-numeric: tabular-nums; }
.seg.small button { padding: 5px 10px; font-size: 12.5px; }

.caption { max-width: 1320px; margin: 16px auto 0; padding: 0 32px; color: var(--muted); font-size: 13px; min-height: 1.4em; }

/* ---------- stage ---------- */
.card {
  max-width: 1256px; margin: 10px auto 0; background: var(--white);
  border: 1px solid var(--line); border-radius: 22px; padding: 24px; box-shadow: var(--shadow); min-height: 520px;
}
.empty { color: var(--muted); padding: 80px 0; text-align: center; }
.loading { color: var(--muted); padding: 120px 0; text-align: center; font-size: 13px; }

/* map */
.map-wrap { position: relative; }
.map-wrap canvas { display: block; width: 100%; height: auto; cursor: crosshair; }
.legend { display: flex; align-items: center; gap: 12px; margin-top: 18px; font-size: 12px; color: var(--ink-2); font-variant-numeric: tabular-nums; flex-wrap: wrap; }
.legend .ramp { width: 240px; height: 10px; border-radius: 99px; }
.legend .sizes { margin-left: auto; display: flex; align-items: center; gap: 8px; color: var(--muted); }
.legend .sq { display: inline-block; background: #B8C0CC; border-radius: 2px; }

/* treemap + pack */
.tm { position: relative; width: 100%; }
.tm-cell {
  position: absolute; border-radius: 10px; padding: 10px 11px; overflow: hidden; cursor: pointer;
  display: flex; flex-direction: column; justify-content: space-between; transition: transform .2s, box-shadow .2s;
}
.tm-cell:hover { box-shadow: 0 0 0 2px var(--white), 0 0 0 3px var(--ink); z-index: 2; }
.tm-cell .nm { font-weight: 600; font-size: 13px; line-height: 1.2; }
.tm-cell .ct { font-size: 11px; opacity: .72; margin-top: 2px; }
.tm-cell .v { font-family: "Fraunces", Georgia, serif; font-size: 20px; font-weight: 500; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tm-cell .cap { font-size: 10.5px; opacity: .7; font-variant-numeric: tabular-nums; }
.tm-head { position: absolute; font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-2); font-weight: 600; pointer-events: none; white-space: nowrap; }
.tm-head span { color: var(--muted); font-weight: 500; margin-left: 8px; letter-spacing: .02em; text-transform: none; }

.pack { display: block; width: 100%; height: auto; }
.pack text { font-family: inherit; }

/* ranking */
.rank { display: grid; gap: 2px; }
.rank-row { display: grid; grid-template-columns: 240px 1fr 110px; align-items: center; gap: 16px; padding: 8px 10px; border-radius: 10px; }
.rank-row:hover { background: var(--well); }
.rank-row .meta b { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rank-row .meta small { color: var(--muted); font-size: 12px; }
.rank-track { position: relative; height: 18px; }
.rank-track::before { content: ""; position: absolute; left: 50%; top: -4px; bottom: -4px; width: 1px; background: var(--line-2); }
.rank-bar { position: absolute; top: 2px; bottom: 2px; border-radius: 5px; }
.rank-v { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; font-size: 14px; }

/* calendar */
.cal { display: grid; grid-template-columns: 210px repeat(12, minmax(48px, 1fr)); gap: 4px; align-items: center; font-variant-numeric: tabular-nums; }
.cal .hd { font-size: 11px; color: var(--muted); text-align: center; letter-spacing: .04em; text-transform: uppercase; padding-bottom: 6px; }
.cal .hd:first-child { text-align: left; }
.cal .g { grid-column: 1 / -1; font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-2); font-weight: 600; margin: 14px 0 4px; }
.cal .n { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-right: 8px; cursor: default; }
.cal .c { height: 30px; border-radius: 7px; display: flex; align-items: center; justify-content: center; font-size: 11.5px; font-weight: 600; }
.cal .c.na { background: var(--well); color: var(--muted); font-weight: 400; }

/* clock */
.clock-axis, .clock-row { display: grid; grid-template-columns: 230px 1fr; gap: 16px; align-items: center; }
.clock-axis { color: var(--muted); font-size: 11px; margin-bottom: 8px; }
.clock-axis .ticks { position: relative; height: 16px; }
.clock-axis .ticks span { position: absolute; transform: translateX(-50%); }
.clock-row { padding: 3px 6px; border-radius: 8px; }
.clock-row:hover { background: var(--well); }
.clock-row .meta { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 500; }
.clock-row .meta small { color: var(--muted); margin-left: 8px; font-weight: 400; font-size: 11.5px; }
.lane { position: relative; height: 16px; border-radius: 6px; background: var(--well); }
.lane::before { content: ""; position: absolute; inset: 0; background: repeating-linear-gradient(90deg, transparent 0 calc(100%/24 - 1px), #E6EAF0 calc(100%/24 - 1px) calc(100%/24)); border-radius: 6px; }
.sess { position: absolute; top: 0; bottom: 0; border-radius: 5px; }
.sess.closed { opacity: .35; }
.now { position: absolute; top: -6px; bottom: -6px; width: 2px; background: var(--ink); border-radius: 2px; z-index: 2; }
.clock-foot { margin-top: 18px; color: var(--muted); font-size: 12px; display: flex; gap: 22px; flex-wrap: wrap; }

/* quadrant */
.scatter { display: block; width: 100%; height: auto; }
.scatter text { fill: var(--muted); font-size: 11.5px; }
.scatter .q { font-size: 11px; letter-spacing: .14em; text-transform: uppercase; fill: #B3BCCA; font-weight: 600; }
.scatter .dot { cursor: pointer; transition: opacity .15s; }
.scatter .dot:hover { stroke: var(--ink) !important; stroke-width: 1.5; }
.scatter .lbl { fill: var(--ink); font-size: 11.5px; font-weight: 500; pointer-events: none; }

/* tooltip */
.tip {
  position: fixed; z-index: 50; pointer-events: none; width: 264px;
  background: var(--white); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px;
  box-shadow: 0 1px 2px rgba(15,23,38,.06), 0 18px 40px -12px rgba(15,23,38,.25);
}
.tip h4 { margin: 0; font-size: 14.5px; font-weight: 600; }
.tip .c { color: var(--muted); font-size: 12px; margin-top: 2px; }
.tip .big { font-family: "Fraunces", Georgia, serif; font-size: 26px; font-weight: 500; margin-top: 10px; font-variant-numeric: tabular-nums; }
.tip table { width: 100%; border-collapse: collapse; margin-top: 8px; font-size: 12.5px; font-variant-numeric: tabular-nums; }
.tip td { padding: 3px 0; color: var(--muted); border-top: 1px solid var(--line); }
.tip tr:first-child td { border-top: 0; }
.tip td:last-child { text-align: right; color: var(--ink); font-weight: 500; }
.tip .st { margin-top: 10px; font-size: 11.5px; color: var(--muted); }

/* buttons */
.ghost {
  background: var(--white); border: 1px solid var(--line-2); border-radius: 10px; padding: 7px 13px; cursor: pointer; color: var(--ink-2); font-size: 12.5px; font-weight: 500;
}
.ghost:hover { color: var(--ink); border-color: #C3CCD9; }

footer {
  max-width: 1320px; margin: 36px auto 0; padding: 22px 32px 40px; border-top: 1px solid var(--line);
  display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; color: var(--muted); font-size: 12px;
}
footer span { max-width: 80ch; }

@media (max-width: 960px) {
  .hero { grid-template-columns: 1fr; padding: 20px 20px 4px; }
  .top, .controls, .sub, .caption, footer { padding-left: 20px; padding-right: 20px; }
  .search { margin-left: 0; min-width: 0; flex: 1; }
  .card { margin-left: 12px; margin-right: 12px; padding: 16px; }
  .rank-row { grid-template-columns: 130px 1fr 80px; }
  .clock-axis, .clock-row { grid-template-columns: 120px 1fr; }
  .cal { grid-template-columns: 130px repeat(12, minmax(34px, 1fr)); }
}
