:root { --accent: #5a6e9c; }
  body { overflow-x: hidden; }
  .wrap { max-width: 1240px; margin: 0 auto; padding: 0 28px; }

  header.hero { padding: 56px 0 28px; border-bottom: 1px solid var(--ink); }
  .nav-back { font-size: 13px; color: var(--ink-soft); margin-bottom: 18px; }
  .nav-back a { color: var(--ink); text-decoration: underline; text-decoration-color: rgba(27,34,55,0.3); }
  .eyebrow { font-size: 12px; letter-spacing: 0.24em; text-transform: uppercase; color: var(--ink-soft); margin-bottom: 16px; }
  header.hero h1 {
    font-size: clamp(40px, 6vw, 72px);
    font-weight: 800; letter-spacing: -0.025em; line-height: 1.02;
    margin: 0 0 16px;
  }
  header.hero h1 .col { display: inline-block; padding: 0 8px; background: var(--ink); color: var(--bg); }
  header.hero p.lede {
    font-size: 18px; max-width: 720px;
    color: var(--ink-soft); line-height: 1.5; margin: 0;
  }
  header.hero p.lede b { color: var(--ink); }

  /* VIEW TABS */
  .tabs {
    display: flex; flex-wrap: wrap;
    border-bottom: 1px solid var(--ink);
    margin-top: 28px;
  }
  .tab {
    background: transparent;
    border: none;
    border-right: 1px solid var(--rule);
    color: var(--ink-soft);
    font-family: inherit;
    font-size: 13px; font-weight: 700;
    letter-spacing: 0.02em;
    padding: 14px 22px;
    cursor: pointer;
    position: relative;
    transition: all .12s;
  }
  .tab:hover { color: var(--ink); background: rgba(27,34,55,0.04); }
  .tab.active {
    color: var(--ink);
    background: var(--bg);
  }
  .tab.active::after {
    content: ''; position: absolute;
    left: 0; right: 0; bottom: -1px; height: 3px;
    background: var(--accent);
  }
  .tab .tab-num {
    font-size: 10px; letter-spacing: 0.18em;
    color: var(--ink-soft);
    margin-right: 6px;
  }
  .tab.active .tab-num { color: var(--accent); }

  /* CONTROLS */
  .controls {
    padding: 22px 0 18px;
    display: flex; flex-wrap: wrap; gap: 14px 22px;
    align-items: flex-end;
    border-bottom: 1px solid var(--rule);
  }
  .ctrl { display: flex; flex-direction: column; gap: 4px; }
  .ctrl label.tag {
    font-size: 10px; letter-spacing: 0.18em; text-transform: uppercase;
    color: var(--ink-soft); font-weight: 700;
  }
  .ctrl select, .ctrl input[type=text] {
    background: var(--bg); border: 1px solid var(--ink);
    color: var(--ink);
    font-family: inherit; font-size: 14px; font-weight: 600;
    padding: 7px 10px; min-width: 180px;
    cursor: pointer;
  }
  .ctrl input[type=text] { font-weight: 500; min-width: 200px; }
  .ctrl .toggle {
    display: inline-flex; align-items: center; gap: 6px;
    font-size: 12px; cursor: pointer;
    padding: 6px 0;
    white-space: nowrap;
  }
  .ctrl .toggle input { accent-color: var(--accent); }
  .controls .ctrl.hidden { display: none; }

  /* CHART CARD */
  .chart-card {
    background: var(--bg);
    border-left: 1px solid var(--ink);
    border-right: 1px solid var(--ink);
    border-bottom: 1px solid var(--ink);
    position: relative;
  }
  .chart-wrap { position: relative; padding: 8px 18px 8px 8px; }
  #chart { display: block; width: 100%; height: 580px; }
  #chart .axis line, #chart .axis path { stroke: var(--ink); stroke-width: 1; fill: none; }
  #chart .grid line { stroke: rgba(27,34,55,0.08); stroke-width: 1; }
  #chart .median line { stroke: rgba(27,34,55,0.45); stroke-width: 1; stroke-dasharray: 3 3; }
  #chart .median text { font-size: 10px; fill: var(--ink-soft); font-weight: 600; }
  #chart .axis text {
    font-family: 'Pretendard', sans-serif;
    font-size: 11px; fill: var(--ink-soft);
  }
  #chart .axis-title {
    font-family: 'Pretendard', sans-serif;
    font-size: 12px; font-weight: 700; fill: var(--ink);
    letter-spacing: 0.01em;
  }
  #chart circle.dot {
    stroke: rgba(27,34,55,0.5); stroke-width: 1;
    cursor: pointer;
    transition: stroke-width .15s, opacity .15s, cx .9s linear, cy .9s linear, r .9s linear;
  }
  #chart circle.dot.dim { opacity: 0.12; }
  #chart circle.dot.match,
  #chart circle.dot.pinned,
  #chart circle.dot.hover { stroke: var(--ink); stroke-width: 2.5; }
  #chart circle.sido-mean {
    stroke: var(--ink); stroke-width: 2; fill-opacity: 0.95;
  }
  #chart text.label {
    font-size: 11px; font-weight: 700; fill: var(--ink);
    pointer-events: none;
    paint-order: stroke;
    stroke: var(--bg); stroke-width: 3.5;
  }
  #chart text.label-outlier {
    font-size: 10px; font-weight: 600; fill: var(--ink-soft);
  }
  #chart text.sido-label {
    font-size: 10px; font-weight: 700; fill: var(--ink);
    pointer-events: none;
    paint-order: stroke; stroke: var(--bg); stroke-width: 3;
  }
  /* Ranks bars */
  #chart rect.bar { cursor: pointer; transition: opacity .15s; }
  #chart rect.bar.dim { opacity: 0.15; }
  #chart text.bar-label { font-size: 10px; fill: var(--ink); font-weight: 600; }
  #chart text.bar-value { font-size: 10px; fill: var(--ink-soft); font-variant-numeric: tabular-nums; }
  /* Correlation matrix */
  #chart rect.corr-cell { transition: opacity .15s; }
  #chart rect.corr-cell:hover { stroke: var(--ink); stroke-width: 1.5; }
  /* Timeline */
  #chart polyline.tl-line { cursor: pointer; transition: opacity .12s, stroke-width .12s; }
  #chart polyline.tl-line.dim { opacity: 0.08 !important; }
  #chart polyline.tl-line.match { opacity: 1 !important; stroke-width: 2.5 !important; }

  /* TOOLTIP */
  #tooltip {
    position: absolute;
    background: var(--ink); color: var(--bg);
    padding: 10px 13px;
    font-size: 12px; line-height: 1.55;
    pointer-events: none;
    opacity: 0; transition: opacity .12s;
    z-index: 30;
    max-width: 240px;
    box-shadow: 0 4px 14px rgba(0,0,0,0.2);
  }
  #tooltip.show { opacity: 1; }
  #tooltip .ttl { font-size: 14px; font-weight: 700; margin-bottom: 2px; }
  #tooltip .sub { font-size: 11px; color: rgba(245,239,228,0.7); margin-bottom: 7px; }
  #tooltip .row { display: flex; justify-content: space-between; gap: 14px; font-variant-numeric: tabular-nums; }
  #tooltip .row .k { color: rgba(245,239,228,0.6); }
  #tooltip .row .v { font-weight: 700; }

  /* LEGEND */
  .legend-row {
    padding: 18px 0 8px;
    display: flex; flex-wrap: wrap; gap: 8px 10px;
    align-items: center;
    font-size: 12px;
  }
  .legend-row .lab {
    font-size: 10px; letter-spacing: 0.18em; text-transform: uppercase;
    color: var(--ink-soft); font-weight: 700;
    margin-right: 6px;
  }
  .sido-chip {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 4px 10px;
    border: 1px solid var(--ink);
    background: var(--bg);
    font-size: 12px; font-weight: 600;
    cursor: pointer;
    user-select: none;
    transition: all .12s;
  }
  .sido-chip .swatch { width: 10px; height: 10px; border: 1px solid rgba(27,34,55,0.3); }
  .sido-chip .swatch.tier-t1 { outline: 2px solid var(--ink); outline-offset: 1px; }
  .sido-chip .swatch.tier-t2 { border-width: 2px; }
  .sido-chip.off { opacity: 0.35; background: transparent; }
  .sido-chip:hover { background: rgba(27,34,55,0.05); }
  .region-label {
    font-size: 10px; letter-spacing: 0.18em; text-transform: uppercase;
    color: var(--ink); font-weight: 700;
    padding: 4px 8px 4px 8px;
    margin-left: 4px;
    border-left: 2px solid var(--ink);
    display: inline-flex; align-items: center;
    cursor: pointer;
    user-select: none;
    transition: opacity .12s;
  }
  .region-label:first-of-type { margin-left: 0; }
  .region-label:hover { color: var(--ink-soft); }
  .region-label.off { opacity: 0.35; }

  /* INSIGHTS */
  .insight {
    margin-top: 22px;
    padding: 18px 22px;
    background: var(--bg2);
    border-left: 4px solid var(--accent);
    font-size: 14px;
    line-height: 1.6;
  }
  .insight b { font-variant-numeric: tabular-nums; }
  .insight em { color: var(--accent); font-style: normal; font-weight: 700; }

  /* PRESETS */
  .presets { padding: 20px 0 4px; display: flex; flex-wrap: wrap; gap: 8px; }
  .preset-chip {
    background: transparent;
    border: 1px dashed var(--ink);
    color: var(--ink);
    font-family: inherit;
    font-size: 12px; font-weight: 600;
    padding: 6px 12px;
    cursor: pointer;
    transition: all .12s;
  }
  .preset-chip:hover { background: var(--ink); color: var(--bg); border-style: solid; }
  .presets.hidden, .legend-row.hidden { display: none; }

  /* SOURCES */
  footer { padding: 56px 0 80px; border-top: 1px solid var(--ink); color: var(--ink-soft); font-size: 13px; line-height: 1.6; }
  footer h3 { font-size: 11px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--ink-soft); font-weight: 700; margin: 0 0 14px; }

  @media (max-width: 720px) {
    .wrap { padding: 0 16px; }
    #chart { height: 460px; }
    .ctrl select, .ctrl input[type=text] { min-width: 0; width: 100%; font-size: 13px; padding: 6px 8px; }
    .ctrl { flex: 1 1 calc(50% - 10px); min-width: 130px; }
    .ctrl.c-q { flex: 1 1 100%; }
    .ctrl.c-log .toggle, .ctrl.c-overlay .toggle { font-size: 11px; }
    header.hero { padding: 36px 0 20px; }
    header.hero h1 { font-size: clamp(32px, 9vw, 56px); }
    .tab { padding: 10px 12px; font-size: 12px; flex: 1 1 50%; text-align: center; }
    .tab .tab-num { display: none; }
    .src-toggle { font-size: 11px; padding: 6px 10px; bottom: 8px; }
    #shareBtn { right: 8px !important; left: auto !important; bottom: 8px !important; }
  }

  /* src-toggle 3종 (데이터 출처·PNG·공유) — viewport 고정 */
  .src-toggle {
    position: fixed !important;
    z-index: 500;
  }
  #srcToggle { left: 14px; bottom: 14px; }
  #downloadBtn { right: 96px; bottom: 14px; left: auto; }
  #shareBtn { right: 14px; bottom: 14px; left: auto; }
  @media (max-width: 720px) {
    .src-toggle { font-size: 11px !important; padding: 6px 10px !important; }
    #downloadBtn { right: 84px !important; bottom: 8px !important; }
    #shareBtn { right: 8px !important; left: auto !important; bottom: 8px !important; }
    #srcToggle { left: 8px !important; bottom: 8px !important; }
  }
    .presets { gap: 6px; padding: 12px 0 4px; }
    .preset-chip { font-size: 11px; padding: 5px 9px; }
    .sido-chip { font-size: 11px; padding: 3px 8px; }
    .region-label { font-size: 9px; padding: 3px 6px; }
    .legend-row { gap: 5px 6px; padding: 12px 0 6px; }
    .insight { font-size: 13px; padding: 14px 16px; }
    /* Distribution: 권역 라벨 자리 확보 */
  }
  @media (max-width: 480px) {
    #chart { height: 380px; }
    header.hero h1 { font-size: clamp(28px, 10vw, 44px); }
    header.hero p.lede { font-size: 15px; }
    .meta-row { gap: 14px; }
  }
