.demo-workbench {
  --panel2: #202d3c;
  --text: #e8edf3;
  --dim: #a6b5c4;
  --blue: #a3cae8;
  --warm: #e6a57d;
  --r: 12px;
  color-scheme: dark;
  background: #11161e;
  color: var(--text);
  --panel: #171f2a;
  --line: #304153;
  --muted: #b2c1d0;
}
@scope (.demo-workbench) {
  * {
    box-sizing: border-box;
  }
  button,
  input,
  select {
    font: inherit;
    color: inherit;
  }
  button,
  select {
    cursor: pointer;
  }
  button {
    background: #202d3c;
    border: 1px solid #3a4b5d;
    border-radius: 8px;
    padding: 9px 12px;
    font-weight: 600;
  }
  button:hover {
    background: #2b3b4d;
  }
  button:disabled {
    opacity: 0.45;
    cursor: not-allowed;
  }
  button[aria-pressed="true"],
  button.active {
    background: #304a61;
    border-color: #7292af;
    color: #e9f7ff;
  }
  button.primary {
    background: var(--blue);
    color: #152230;
    border-color: var(--blue);
  }
  button.flat {
    background: transparent;
    border-color: transparent;
    color: var(--blue);
    padding: 6px;
  }
  a {
    color: var(--blue);
  }
  button:focus-visible,
  input:focus-visible,
  select:focus-visible,
  [tabindex]:focus-visible {
    outline: 2px solid #accdea;
    outline-offset: 3px;
  }
  input,
  select {
    width: 100%;
    background: #111923;
    border: 1px solid #344455;
    border-radius: 7px;
    padding: 9px 10px;
    min-height: 38px;
  }
  label {
    display: block;
    font-size: 11px;
    color: #c1cedb;
    font-weight: 650;
    margin: 0 0 5px;
  }
  small,
  .muted {
    color: var(--muted);
  }
  small {
    font-size: 11px;
  }
  h1,
  h2,
  h3,
  p {
    margin: 0;
  }
  h1 {
    font-size: 23px;
    letter-spacing: -0.65px;
    font-weight: 720;
  }
  h2 {
    font-size: 14px;
    letter-spacing: -0.1px;
  }
  h3 {
    font-size: 12px;
    font-weight: 650;
  }

  .heading {
    display: flex;
    justify-content: space-between;
    align-items: end;
    margin-bottom: 14px;
    gap: 12px;
  }
  .kicker {
    color: var(--blue);
    font-size: 10px;
    font-weight: 750;
    letter-spacing: 1.4px;
    text-transform: uppercase;
    margin-bottom: 4px;
  }
  .heading p {
    font-size: 12px;
    color: var(--muted);
    margin-top: 4px;
  }
  .source-tag {
    border: 1px solid #435367;
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 11px;
    color: #cbd8e4;
    text-align: right;
    max-width: 370px;
  }
  .demo-tag {
    border-color: #805a40;
    color: #f4c9a9;
    background: #36271e;
  }
  .demo-grid {
    display: grid;
    grid-template-columns: 230px minmax(245px, 300px) minmax(0, 1fr);
    gap: 12px;
    align-items: start;
  }
  .panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--r);
    overflow: hidden;
  }
  .pad {
    padding: 15px;
  }
  .filters {
    display: flex;
    flex-direction: column;
    gap: 13px;
  }
  .row {
    display: flex;
    align-items: center;
    gap: 7px;
  }
  .between {
    justify-content: space-between;
  }
  .search {
    display: flex;
    gap: 5px;
  }
  .search button {
    padding: 8px 11px;
  }
  .filter-block {
    padding-top: 12px;
    border-top: 1px solid var(--line);
  }
  .pair {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 7px;
  }
  .filter-btns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 7px;
  }
  .filter-note {
    font-size: 11px;
    color: var(--muted);
    margin-top: 6px;
    line-height: 1.5;
  }
  .total {
    border: 1px solid var(--line);
    background: #111b26;
    border-radius: 10px;
    padding: 12px;
  }
  .total-num {
    font-size: 33px;
    letter-spacing: -1.3px;
    font-weight: 730;
    color: var(--warm);
    line-height: 1.2;
    margin: 5px 0;
  }
  .section-title {
    font-size: 11px;
    color: #abbccc;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 700;
  }
  .stack {
    display: flex;
    flex-direction: column;
    gap: 10px;
  }
  .statshead {
    padding: 12px 14px;
  }
  .statshead h2 {
    font-size: 13px;
  }
  .statshead p {
    font-size: 11px;
    color: var(--muted);
    margin-top: 3px;
  }
  .chart-card {
    padding: 12px 13px;
  }
  .chart-card h3 {
    font-size: 12px;
    color: #d9e4ee;
    margin-bottom: 10px;
  }
  .bars {
    display: flex;
    flex-direction: column;
    gap: 9px;
  }
  .bar-row .bar-label {
    font-size: 11px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 7px;
    margin-bottom: 4px;
  }
  .bar-label span:first-child {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .bar-label b {
    font-size: 11px;
    font-weight: 650;
  }
  .track {
    height: 5px;
    border-radius: 5px;
    background: #293746;
    overflow: hidden;
  }
  .track i {
    display: block;
    height: 100%;
    background: var(--blue);
    border-radius: 5px;
  }
  .bar-row:nth-child(even) .track i {
    background: #7497b4;
  }
  .na {
    font-size: 11px;
    color: var(--dim);
    line-height: 1.45;
    padding: 4px 0;
  }
  .chart-mini {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }
  .chart-mini .chart-card {
    min-width: 0;
  }
  .chart-mini .bar-label {
    font-size: 10px;
  }
  .chart-mini h3 {
    font-size: 11px;
  }
  .series svg {
    width: 100%;
    height: auto;
    display: block;
  }
  .series-head button {
    padding: 3px 7px;
    font-size: 10px;
  }
  .map-panel {
    position: sticky;
    top: 10px;
    min-width: 0;
  }
  .map-top {
    padding: 12px 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
  }
  .map-top p {
    color: var(--muted);
    font-size: 11px;
    margin-top: 2px;
  }
  .map-tools {
    display: flex;
    gap: 5px;
    flex-wrap: wrap;
  }
  .map-tools button {
    font-size: 11px;
    padding: 7px 9px;
  }
  .map-stage {
    position: relative;
    height: clamp(490px, calc(100vh - 270px), 820px);
    background: #111b25;
    overflow: hidden;
    touch-action: none;
  }
  .map-stage svg#atlas {
    width: 100%;
    height: 100%;
    display: block;
    cursor: grab;
    touch-action: none;
    user-select: none;
  }
  .map-stage svg#atlas.dragging {
    cursor: grabbing;
  }
  .map-stage canvas {
    position: absolute;
    inset: 0;
    pointer-events: none;
    width: 100%;
    height: 100%;
    mix-blend-mode: screen;
  }
  .map-stage .overlay {
    position: absolute;
    inset: 0;
    pointer-events: none;
  }
  .map-stage .overlay > * {
    pointer-events: auto;
  }
  .zoom {
    position: absolute;
    top: 13px;
    left: 13px;
    display: flex;
    flex-direction: column;
    gap: 5px;
  }
  .zoom button {
    width: 36px;
    height: 36px;
    padding: 0;
    font-size: 20px;
    box-shadow: 0 2px 8px #0005;
    background: #182431ee;
  }
  .zoom button:hover {
    background: #30455a;
  }
  .zoom button.home {
    font-size: 18px;
  }
  .layer-info {
    position: absolute;
    top: 13px;
    right: 13px;
    padding: 8px 10px;
    background: #152330ed;
    border: 1px solid #3a4d60;
    border-radius: 8px;
    text-align: right;
    max-width: 70%;
    font-size: 11px;
  }
  .layer-info strong {
    display: block;
    color: #eef5fc;
  }
  .layer-info small {
    font-size: 10px;
  }
  .map-legend {
    position: absolute;
    bottom: 25px;
    left: 13px;
    padding: 10px 12px;
    background: #14202deb;
    border: 1px solid #3a4b5b;
    border-radius: 9px;
    width: 176px;
    font-size: 10px;
    color: #c4d2de;
  }
  .gradient {
    height: 8px;
    margin: 6px 0 4px;
    border-radius: 5px;
    background: linear-gradient(
      90deg,
      #31549a,
      #518ba4,
      #c1af67,
      #dc8550,
      #d95150
    );
  }
  .attribution {
    position: absolute;
    bottom: 2px;
    right: 4px;
    background: #101923c9;
    color: #b5c4d2;
    padding: 1px 5px;
    font-size: 9px;
  }
  .map-popup {
    position: absolute;
    right: 13px;
    bottom: 28px;
    width: min(255px, calc(100% - 26px));
    background: #172431f5;
    border: 1px solid #4c6174;
    border-radius: 12px;
    padding: 13px;
    box-shadow: 0 10px 28px #0008;
  }
  .map-popup h3 {
    font-size: 14px;
    margin: 5px 0 9px;
  }
  .map-popup .kv {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    border-top: 1px solid #334556;
    padding: 6px 0;
    font-size: 11px;
  }
  .map-popup .kv span:first-child {
    color: var(--muted);
  }
  .map-popup .kv span:last-child {
    text-align: right;
  }
  .map-popup button {
    padding: 3px 7px;
    font-size: 13px;
  }
  .map-footer {
    padding: 11px 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    font-size: 11px;
    color: var(--muted);
  }
  .map-footer label {
    margin: 0;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
  }
  .map-footer input {
    width: 15px;
    min-height: 15px;
    margin: 0;
  }
  .map-footer button {
    font-size: 11px;
    padding: 6px 9px;
  }
  .notice {
    padding: 11px 13px;
    border-top: 1px solid var(--line);
    font-size: 11px;
    color: #b2c1d0;
    background: #141d28;
  }

  .hidden,
  [hidden] {
    display: none !important;
  }

  .marker {
    cursor: pointer;
  }
  .marker:hover {
    stroke: #fff;
    stroke-width: 2;
  }
  .demo-road {
    stroke: #5d7080;
    fill: none;
    stroke-linecap: round;
    stroke-linejoin: round;
  }
  .demo-block {
    fill: #1d2d36;
    stroke: #30414b;
    stroke-width: 1;
  }
  .map-panel:fullscreen {
    display: flex;
    flex-direction: column;
    border-radius: 0;
    position: static;
    background: var(--panel);
  }
  .map-panel:fullscreen .map-stage {
    height: auto;
    flex: 1;
  }

  .toggle-filters {
    display: none;
  }
  .search-status {
    font-size: 11px;
    color: var(--muted);
    margin-top: 4px;
  }
  .results {
    display: flex;
    flex-direction: column;
    gap: 5px;
    margin-top: 5px;
  }
  .results button {
    text-align: left;
    font-size: 11px;
    padding: 7px;
  }
  .icon {
    display: inline-block;
    width: 16px;
    height: 16px;
    vertical-align: middle;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.7;
    stroke-linecap: round;
    stroke-linejoin: round;
  }
  .empty-map {
    position: absolute;
    top: 45%;
    left: 50%;
    transform: translate(-50%, -50%);
    padding: 10px 13px;
    background: #172331df;
    border-radius: 8px;
    font-size: 12px;
    pointer-events: none !important;
    text-align: center;
    max-width: 75%;
  }
  .guide {
    display: flex;
    gap: 5px;
    align-items: center;
    margin-top: 8px;
  }
  .guide span {
    flex: 1;
    text-align: center;
    border: 1px solid var(--line);
    border-radius: 5px;
    padding: 4px 2px;
    font-size: 10px;
    color: #9eb0c0;
  }
  .guide span.active {
    border-color: #9abbd4;
    color: #f2f7fc;
    background: #2b4054;
  }

  .map-stage svg text {
    pointer-events: none;
  }
  .map-label {
    paint-order: stroke;
    stroke: #13212b;
    stroke-width: 2px;
    stroke-linejoin: round;
    vector-effect: non-scaling-stroke;
  }
  @media (max-width: 1150px) {
    .demo-grid {
      grid-template-columns: 218px minmax(0, 1fr);
    }
    .stats {
      grid-column: 1/-1;
      grid-row: 2;
      display: grid;
      grid-template-columns: repeat(3, minmax(0, 1fr));
      align-items: start;
    }
    .statshead {
      grid-column: 1/-1;
    }
    .map-panel {
      grid-column: 2;
      grid-row: 1;
    }
    .map-stage {
      height: 640px;
    }
    .series {
      grid-column: span 2;
    }
  }
  @media (max-width: 700px) {
    .heading {
      display: block;
    }
    .source-tag {
      text-align: left;
      margin-top: 8px;
      max-width: none;
    }
    .demo-grid {
      display: flex;
      flex-direction: column;
      gap: 9px;
    }
    .demo-grid > * {
      width: 100%;
    }
    .filters {
      gap: 9px;
    }
    .toggle-filters {
      display: block;
    }
    .filter-content.collapsed {
      display: none;
    }
    .map-panel {
      position: static;
      order: 1;
    }
    .stats {
      order: 2;
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 8px;
    }
    .chart-card {
      padding: 11px;
    }
    .series {
      grid-column: 1/-1;
    }
    .chart-mini {
      grid-column: 1/-1;
    }
    .map-stage {
      height: 490px;
    }
    .map-top {
      padding: 10px;
    }
    .map-tools button {
      font-size: 10px;
      padding: 6px 8px;
    }
    .map-legend {
      bottom: 22px;
      width: 135px;
      font-size: 9px;
      padding: 8px;
    }
    .map-popup {
      bottom: 25px;
    }
    .layer-info {
      max-width: 74%;
      font-size: 10px;
    }

    .statshead {
      grid-column: 1/-1;
    }
  }

  @media (min-width: 1151px) {
    .heading {
      margin-bottom: 11px;
    }
    .map-stage {
      height: clamp(465px, calc(100vh - 340px), 790px);
    }
    .filters {
      gap: 10px;
    }
    .filters.pad {
      padding: 12px;
    }
    .filters input,
    .filters select {
      min-height: 34px;
      padding: 6px 8px;
    }
    .filters .filter-block {
      padding-top: 8px;
    }
    .filters .filter-block > div[style] {
      margin-top: 8px !important;
    }
    .filters label {
      margin-bottom: 4px;
    }
    .filter-note {
      margin-top: 4px;
    }
    .statshead {
      padding: 10px 12px;
    }
    .chart-card {
      padding: 10px 12px;
    }
    .chart-card h3 {
      margin-bottom: 8px;
    }
    .bars {
      gap: 6px;
    }
    .bar-label {
      margin-bottom: 3px !important;
    }
    .track {
      height: 4px;
    }
    .stack {
      gap: 8px;
    }
    .total {
      padding: 9px 11px;
    }
    .total-num {
      font-size: 29px;
      margin: 3px 0;
    }
    .map-top {
      padding: 10px 12px;
    }
    .map-footer {
      padding: 8px 12px;
    }
    .notice {
      padding: 9px 12px;
    }
    .map-panel:fullscreen .map-stage {
      height: auto;
      flex: 1;
    }
  }
}

.demo-workbench {
  max-width: 1900px;
  padding: 1rem clamp(0.65rem, 1.2vw, 1.4rem) 1.5rem;
}

:root[data-theme="light"] .demo-workbench {
  background: var(--bg);
  color: var(--ink);
  --panel: #fff;
  --line: #a9bcc7;
  --muted: #435863;
  --blue: #376585;
  --warm: #934523;
  --dim: #435863;
}
:root[data-theme="light"] .demo-workbench :is(.total, .notice) {
  background: #eaf0f4;
  color: #172c37;
}
:root[data-theme="light"]
  .demo-workbench
  :is(.section-title, .chart-card h3, label, .guide span) {
  color: #243c4b;
}
:root[data-theme="light"] .demo-workbench .guide .active {
  color: #fff;
}
:root[data-theme="light"] .demo-workbench input:not([type="checkbox"]),
:root[data-theme="light"] .demo-workbench select {
  background: #fff;
  color: #172c37;
  color-scheme: light;
}
:root[data-theme="light"] .demo-workbench button {
  background: #dbe7f0;
  color: #172c37;
}
:root[data-theme="light"] .demo-workbench .zoom button {
  background: #182431;
  color: #fff;
}
:root[data-theme="light"] .demo-workbench :is(.layer-info, .map-popup) small,
:root[data-theme="light"]
  .demo-workbench
  .map-popup
  :is(.kv, .kv span:first-child, .filter-note, h3) {
  color: #dbe7f0;
}
:root[data-theme="light"] .demo-workbench .series svg text {
  fill: #435863;
}
