:root {
  color-scheme: light;
  --canvas: #f5f7fa;
  --paper: #fff;
  --ink: #152136;
  --muted: #53627a;
  --quiet: #637188;
  --line: #d9e1ec;
  --hairline: #e9edf4;
  --soft: #f6f8fc;
  --accent: #254cc0;
  --accent-deep: #213f9c;
  --accent-soft: #edf2ff;
  --focus: #3766db;
  --radius: 15px;
  --dock-height: 58px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Noto Sans CJK SC", "Microsoft YaHei", sans-serif;
  font-size: 15px;
  -webkit-text-size-adjust: 100%;
}

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

body {
  margin: 0;
  color: var(--ink);
  background: var(--canvas);
}

button, input, select { font: inherit; }
button, select, summary { -webkit-tap-highlight-color: transparent; }
button { color: inherit; cursor: pointer; }
summary { cursor: pointer; list-style: none; }
summary::-webkit-details-marker { display: none; }
button:disabled { cursor: default; opacity: .5; }
button:focus-visible, summary:focus-visible, select:focus-visible, input:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
}
[hidden] { display: none !important; }

h1, h2, h3, h4, p, dl, dd { margin: 0; }
ul { padding: 0; margin: 0; }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.icon-library {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.icon {
  width: 18px;
  height: 18px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.65;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
}

.page {
  max-width: 1860px;
  margin-inline: auto;
  padding-inline: clamp(24px, 3.2vw, 56px);
}

.topbar {
  min-height: clamp(76px, 9.1vh, 103px);
  display: flex;
  align-items: center;
  gap: 15px;
  margin-bottom: 13px;
  border-bottom: 1px solid #bec9da;
}

.brand {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 13px;
  margin-right: auto;
}

.brand h1 {
  color: var(--ink);
  font-size: clamp(27px, 2.85vw, 44px);
  font-weight: 770;
  line-height: 1.16;
  letter-spacing: -.048em;
}

.brand p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.brand-mark {
  width: clamp(33px, 3vw, 43px);
  height: auto;
  flex: none;
  fill: #17243a;
}

.brand-mark path {
  fill: none;
  stroke: #798cae;
  stroke-width: 1.3;
}

.brand-mark circle { fill: white; }

.control, .icon-button, .text-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  white-space: nowrap;
  line-height: 1.2;
}

.control {
  min-height: 36px;
  padding: 0 11px;
  border: 1px solid #cbd5e5;
  border-radius: 7px;
  color: var(--ink);
  background: #fff;
  font-size: 13px;
  font-weight: 630;
}

.control .icon { width: 17px; height: 17px; }
.control:hover, details[open] > .control { border-color: #afbdcf; background: #f1f5fb; }

.source-button {
  color: #354864;
  background: transparent;
  border-color: #c6d0e0;
}

.icon-button, .text-button {
  padding: 0;
  border: 0;
  background: transparent;
}
.icon-button { border-radius: 7px; color: var(--quiet); }
.icon-button:hover { background: var(--soft); color: var(--ink); }

.text-button {
  min-height: 29px;
  color: var(--accent-deep);
  font-size: 12px;
  font-weight: 640;
}
.text-button:hover { text-decoration: underline; text-underline-offset: 4px; }
.text-button .icon { width: 15px; height: 15px; }

.square { width: 36px; height: 36px; padding: 0; }

.scope {
  display: flex;
  align-items: center;
  white-space: nowrap;
  gap: 14px;
  flex: none;
  padding: 0 7px 0 0;
  color: var(--muted);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.scope strong {
  border-left: 1px solid #cbd5e5;
  padding-left: 14px;
  color: var(--ink);
  font-weight: 650;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) clamp(285px, 25vw, 398px);
  gap: 12px;
  height: clamp(460px, calc(100svh - 138px), 990px);
}

.surface {
  min-width: 0;
  min-height: 0;
  border: 1px solid #cdd8e8;
  border-radius: var(--radius);
  background: var(--paper);
}

.chart-card {
  position: relative;
  display: flex;
  flex-direction: column;
}

.chart-header, .chart-footer {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.chart-header {
  align-items: flex-start;
  padding: 16px 17px 9px 20px;
}
.chart-heading { min-width: 0; }
.chart-heading h2 { font-size: 21px; font-weight: 725; line-height: 1.3; letter-spacing: -.045em; }
.chart-heading p { margin-top: 5px; color: var(--muted); font-size: 12px; line-height: 1.5; }
.chart-actions { display: flex; align-items: center; gap: 12px; }
.chart-tools { display: flex; align-items: center; gap: 5px; }

.view-presets {
  display: flex;
  gap: 2px;
  padding: 2px;
  border: 1px solid #d6dfed;
  border-radius: 8px;
  background: #f5f7fb;
}

.view-button {
  min-height: 30px;
  padding: 0 9px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 660;
  white-space: nowrap;
}

.view-button:hover { color: var(--accent-deep); background: #e9effc; }
.view-button[aria-pressed="true"] { border-color: #d5e0fa; background: #fff; color: var(--accent-deep); }

.chart {
  flex: 1 1 0;
  min-width: 0;
  min-height: 230px;
  position: relative;
}

.load-error {
  padding: 20px;
  color: var(--muted);
}

.chart-footer { padding: 3px 19px 10px; }

.legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 15px;
  list-style: none;
  color: var(--muted);
  font-size: 11px;
}

.legend li { display: flex; align-items: center; gap: 6px; white-space: nowrap; }

.marker {
  display: inline-block;
  width: 10px;
  height: 10px;
  flex: none;
  border: 1.6px solid currentColor;
  color: #566a87;
}

.marker.sample { border-radius: 50%; background: currentColor; }
.marker.national { border-radius: 1px; background: currentColor; transform: rotate(45deg) scale(.85); }
.marker.domestic { border-radius: 50%; }
.marker.job { border-radius: 1px; }
.marker.public {
  width: 12px;
  height: 11px;
  border: none;
  clip-path: polygon(50% 0, 100% 100%, 0 100%);
  background: currentColor;
  position: relative;
}
.marker.public::after {
  content: "";
  position: absolute;
  inset: 3px 3px 1.6px;
  clip-path: polygon(50% 0, 100% 100%, 0 100%);
  background: var(--marker-bg, #fff);
}

.reference-line {
  width: 18px;
  border-bottom: 1.6px dashed #647b9c;
}

.popover { position: relative; }

.popover-body {
  z-index: 8;
  position: absolute;
  right: 0;
  width: max-content;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--paper);
  box-shadow: 0 8px 22px #2437541b;
}

.layers {
  top: calc(100% + 7px);
  min-width: 184px;
  padding: 13px;
}

.layer-label { display: grid; gap: 6px; color: var(--muted); font-size: 12px; }

.layer-label select {
  width: 100%;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  background: var(--paper);
}

.check-field {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 12px;
  font-size: 12px;
}
.check-field input { accent-color: var(--accent); margin: 0; width: 16px; height: 16px; }

.group-legend {
  bottom: calc(100% + 6px);
  max-width: min(410px, calc(100vw - 54px));
  max-height: min(440px, calc(92dvh - 140px));
  overflow: auto;
  padding: 13px 14px;
}

.legend-family + .legend-family { margin-top: 12px; border-top: 1px solid var(--hairline); padding-top: 10px; }
.legend-family h3 { margin-bottom: 6px; color: var(--muted); font-size: 12px; font-weight: 600; }
.legend-groups { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 3px 9px; }
.legend-group {
  min-height: 31px;
  display: flex;
  text-align: left;
  align-items: center;
  gap: 6px;
  padding: 0 5px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  font-size: 11px;
}
.legend-group:hover { background: var(--soft); }
.legend-group .marker { width: 8px; height: 8px; }

.inspector { display: flex; flex-direction: column; overflow: hidden; }
.inspector-header {
  flex: none;
  display: flex;
  align-items: center;
  gap: 10px;
  padding-inline: 15px;
  border-bottom: 1px solid var(--line);
}

.mode-bar { display: flex; gap: 9px; }
.mode-button {
  position: relative;
  min-height: 52px;
  padding: 0 12px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 15px;
  font-weight: 650;
}
.mode-button:hover { color: var(--accent-deep); }
.mode-button[aria-pressed="true"] { color: var(--accent-deep); }
.mode-button[aria-pressed="true"]::after {
  content: "";
  position: absolute;
  inset: auto 2px 0;
  height: 2px;
  border-radius: 2px 2px 0 0;
  background: var(--accent);
}

.inspector-content {
  min-height: 0;
  flex: 1;
  overflow: auto;
  overscroll-behavior-y: contain;
}

.search-panel { padding: 15px 14px 12px; }
.search-panel.below-detail { padding-top: 14px; border-top: 1px solid var(--hairline); }

.search-field {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  border: 1px solid #cbd6e8;
  border-radius: 8px;
  padding-inline: 11px 7px;
  color: var(--quiet);
  background: var(--soft);
}

.search-field:focus-within {
  border-color: var(--focus);
  box-shadow: 0 0 0 2px #3766db30;
}

.search-field input {
  min-width: 0;
  width: 100%;
  min-height: 40px;
  padding: 0 3px;
  outline: 0;
  border: 0;
  color: var(--ink);
  background: transparent;
  line-height: 1.25;
  font-size: 14px;
}
.search-field input:focus-visible { outline: none; }
.search-field input::placeholder { color: var(--quiet); opacity: 1; }

.filters { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; margin-top: 9px; }

.filter-field {
  position: relative;
  display: flex;
  align-items: center;
}
.filter-field select {
  appearance: none;
  width: 100%;
  min-height: 38px;
  padding: 5px 24px 5px 9px;
  border: 1px solid #ccd7e8;
  border-radius: 7px;
  background: var(--paper);
  color: #30415c;
  font-size: 12px;
  font-weight: 590;
  text-overflow: ellipsis;
  cursor: pointer;
}
.filter-field .icon {
  width: 15px;
  height: 15px;
  position: absolute;
  right: 7px;
  color: var(--quiet);
}

.result-caption {
  padding: 0 15px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 25px;
  color: var(--quiet);
  border-top: 1px solid var(--hairline);
  background: var(--soft);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.results { list-style: none; padding: 0 13px; }
.result { border-bottom: 1px solid var(--hairline); }
.result:last-child { border-bottom: 0; }

.result-button {
  --marker-bg: #fff;
  width: 100%;
  min-height: 54px;
  display: grid;
  grid-template-columns: 12px minmax(0, 1fr) 16px;
  align-items: center;
  gap: 9px;
  padding: 6px 4px;
  border: 0;
  background: var(--marker-bg);
  text-align: left;
  border-radius: 6px;
}
.result-button:hover { --marker-bg: #f3f6fd; }
.result-button[aria-pressed="true"] { --marker-bg: #edf2ff; }
.result-button .icon { width: 16px; height: 16px; color: #637693; }
.result-button[aria-pressed="true"] .icon { color: var(--accent); }

.result-info { min-width: 0; display: block; }
.result-name, .result-category { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.result-name { font-size: 14px; font-weight: 680; line-height: 1.4; }
.result-category { margin-top: 2px; color: var(--muted); font-size: 11px; line-height: 1.4; }

.empty-results {
  padding: 18px 15px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.point-detail, .compare-panel { padding: 11px 14px 14px; }

.back-button { margin-bottom: 10px; }
.back-button .icon { margin-left: -3px; }

.detail-title { display: flex; align-items: flex-start; gap: 9px; }
.detail-title .marker { margin-top: .51em; width: 12px; height: 12px; }
.detail-title h3 { font-weight: 750; font-size: 22px; line-height: 1.32; letter-spacing: -.035em; }
.category { color: var(--muted); font-size: 12px; line-height: 1.5; margin-top: 5px; }

.metrics {
  display: grid;
  grid-template-columns: minmax(0, .7fr) minmax(0, 1.3fr);
  gap: 7px;
  padding: 12px 10px;
  margin-top: 15px;
  background: #f3f6fc;
  border: 1px solid #e5ebf7;
  border-radius: 8px;
}
.metric { min-width: 0; }
.metric + .metric { border-left: 1px solid #dfe7f5; padding-left: 9px; }
.metric-label, .metric-unit { color: var(--muted); font-weight: 540; font-size: 11px; line-height: 1.4; }
.metric-value {
  margin: 3px 0 2px;
  font-size: clamp(18px, 1.55vw, 26px);
  font-weight: 735;
  letter-spacing: -.035em;
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
  overflow-wrap: anywhere;
}
.metric-value.long-number { font-size: clamp(15px, 1.24vw, 20px); }

.point-detail h4 { margin-top: 16px; font-size: 13px; }
.ranges { margin-top: 5px; }
.range-row {
  display: flex;
  justify-content: space-between;
  gap: 7px;
  padding: 6px 0;
  border-bottom: 1px solid var(--hairline);
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}
.range-row dd { color: var(--ink); text-align: right; font-variant-numeric: tabular-nums; }
.range-hint { margin-top: 6px; color: var(--quiet); font-size: 11px; line-height: 1.5; }

.feature-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 5px 8px;
  margin-top: 13px;
}
.primary { color: white; border-color: var(--accent); background: var(--accent); }
.primary:hover { color: white; border-color: var(--accent-deep); background: var(--accent-deep); }

.compare-panel { border-bottom: 1px solid var(--hairline); }
.compare-hint { color: var(--muted); font-size: 12px; line-height: 1.45; margin-bottom: 9px; }
.compare-slot {
  position: relative;
  min-height: 48px;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 5px 6px;
  margin-top: 5px;
  border: 1px dashed #c4d1e5;
  border-radius: 8px;
  background: #fcfdff;
}
.compare-slot.filled {
  border-style: solid;
  background: var(--paper);
}

.slot-badge {
  width: 23px;
  height: 23px;
  display: inline-grid;
  place-content: center;
  border-radius: 6px;
  border: 1px solid var(--point-color, #cbd7eb);
  color: var(--ink);
  background: #f3f6fd;
  font-size: 11px;
  font-weight: 750;
  flex: none;
}

.slot-empty {
  display: flex;
  align-items: center;
  gap: 7px;
  width: 100%;
  min-height: 32px;
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--muted);
  text-align: left;
  font-size: 12px;
}
.slot-empty:hover { color: var(--accent); }
.slot-point { display: grid; gap: 2px; min-width: 0; flex: 1; }
.slot-point strong { color: var(--ink); font-size: 12px; line-height: 1.4; }
.slot-point span { color: var(--muted); font-size: 10px; line-height: 1.35; font-variant-numeric: tabular-nums; }
.slot-remove { width: 28px; min-height: 32px; flex: none; }
.slot-remove .icon { width: 15px; height: 15px; }

.difference { margin-top: 9px; }
.difference-header { display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.difference-header h3 { font-size: 13px; font-weight: 690; }
.difference .metrics { margin-top: 2px; }
.comparison-actions { justify-content: space-between; margin-top: 9px; }

.status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 11px 1px 13px;
  color: var(--muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.mobile-hint, .dock, .sheet-handle, .sheet-close { display: none; }

.sources-dialog {
  width: min(630px, calc(100% - 28px));
  max-height: min(745px, calc(100dvh - 28px));
  padding: 0;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--paper);
  box-shadow: 0 16px 58px #16274631;
  overscroll-behavior: contain;
}
.sources-dialog::backdrop { background: #19273f60; }
.dialog-top {
  position: sticky;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px 19px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--paper);
}
.dialog-top h2 { font-size: 21px; letter-spacing: -.04em; }
.dialog-body { padding: 17px 19px 21px; }
.dialog-lead { font-size: 14px; line-height: 1.65; }
.reference-note {
  margin-top: 12px;
  padding: 10px;
  border: 1px solid #e2eaf8;
  border-radius: 8px;
  background: #f4f7fd;
  font-size: 13px;
  line-height: 1.65;
}
.reference-note h3 { font-size: 13px; }
.reference-note p { padding-top: 3px; color: var(--muted); }
.notes {
  list-style: none;
  padding-top: 10px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}
.notes li { padding-block: 8px; }
.notes li + li { border-top: 1px solid var(--hairline); }

@media (max-width: 880px) {
  .page { padding: 0 14px calc(var(--dock-height) + env(safe-area-inset-bottom)); }
  .topbar {
    min-height: 73px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 5px 6px;
    padding-block: 11px 8px;
    margin-bottom: 9px;
  }
  .brand { gap: 8px; }
  .brand h1 { font-size: clamp(23px, 5.55vw, 31px); white-space: nowrap; }
  .brand p { margin-top: 2px; font-size: 10px; white-space: nowrap; }
  .brand-mark { width: 28px; }
  .source-button { min-height: 36px; grid-area: 1 / 2; padding-inline: 6px; font-size: 11px; gap: 4px; }
  .source-button .icon { width: 15px; height: 15px; }
  .scope { grid-area: 2 / 1; font-size: 10px; gap: 8px; }
  .scope strong { padding-left: 8px; }
  .workspace {
    display: block;
    height: max(350px, calc(100svh - 178px - env(safe-area-inset-bottom)));
  }
  .chart-card { height: 100%; border-radius: 12px; }
  .chart-header { gap: 6px; padding: 9px 8px 5px 10px; }
  .chart-heading h2 { font-size: 15px; line-height: 1.35; }
  .chart-heading p { margin-top: 2px; font-size: 10px; }
  .chart-actions { gap: 5px; }
  .chart-tools { gap: 3px; }
  .chart-tools .control { min-height: 38px; height: 38px; }
  .chart-tools .square { width: 30px; }
  .chart-tools .icon { width: 15px; height: 15px; }
  .view-button { min-height: 32px; padding-inline: 6px; font-size: 11px; }
  .chart-footer { padding: 2px 9px 5px 10px; gap: 4px; }
  .legend { gap: 4px 9px; font-size: 9px; }
  .legend li { gap: 4px; }
  .legend .legend-detail { display: none; }
  .legend .marker { width: 7px; height: 7px; }
  .reference-line { width: 12px; }
  .group-menu .text-button { font-size: 10px; }
  .group-menu .icon { width: 12px; height: 12px; }
  .status { padding-top: 7px; padding-bottom: 6px; font-size: 10px; }
  .desktop-hint { display: none; }
  .mobile-hint { display: inline; }
  .dock {
    position: fixed;
    z-index: 12;
    inset: auto 0 0;
    display: flex;
    justify-content: center;
    gap: 8px;
    min-height: calc(var(--dock-height) + env(safe-area-inset-bottom));
    padding: 6px 14px calc(6px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--line);
    background: var(--paper);
  }
  .dock button {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    flex: 1;
    max-width: 350px;
    min-width: 0;
    padding: 0 8px;
    border: 1px solid transparent;
    border-radius: 9px;
    background: transparent;
    color: var(--muted);
    font-size: 13px;
    font-weight: 655;
  }
  .dock button[aria-expanded="true"] {
    border-color: #dfe7fd;
    background: var(--accent-soft);
    color: var(--accent-deep);
  }
  .dock-count {
    min-width: 23px;
    min-height: 19px;
    display: inline-grid;
    place-items: center;
    padding: 0 4px;
    border: 1px solid #d8e3fa;
    border-radius: 6px;
    background: var(--accent-soft);
    color: var(--accent-deep);
    font-size: 10px;
  }
  .inspector {
    display: none;
    position: fixed;
    z-index: 11;
    inset: auto 0 calc(var(--dock-height) + env(safe-area-inset-bottom));
    max-height: min(63dvh, 515px);
    margin-inline: auto;
    width: min(100%, 580px);
    border-radius: 15px 15px 0 0;
    box-shadow: 0 -10px 35px #17274525;
  }
  .inspector[data-open="true"] { display: flex; }
  .inspector-header { justify-content: space-between; padding-inline: 13px; }
  .sheet-handle {
    display: block;
    width: 29px;
    height: 3px;
    margin: 7px auto 0;
    border-radius: 2px;
    background: #c7d1e1;
  }
  .sheet-close { display: inline-flex; }
  .mode-button { min-height: 44px; }
  .search-panel { padding-block: 9px 7px; }
  .search-field input { font-size: 16px; }
  .filters { margin-top: 6px; }
  .result-button { min-height: 48px; }
  .point-detail, .compare-panel { padding-top: 8px; }
  .detail-title h3 { font-size: 20px; }
  .metric-value { font-size: clamp(18px, 5vw, 23px); }
  .metric-value.long-number { font-size: clamp(16px, 4.1vw, 20px); }
}

@media (max-width: 475px) {
  .chart-header { display: grid; }
  .chart-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 6px; }
  .chart-actions { justify-content: space-between; }
  .chart-tools { gap: 5px; }
  .chart-tools .square { width: 40px; height: 42px; }
  .view-button { min-height: 36px; padding-inline: 10px; font-size: 12px; }
}

@media (max-width: 355px) {
  .page { padding-inline: 9px; }
  .brand h1 { font-size: 21px; }
  .chart-heading p { font-size: 9px; }
  .legend { gap: 4px 6px; }
}
