:root {
  color-scheme: dark;
  --bg: #0c0f14;
  --surface: #161b22;
  --surface-2: #1c222c;
  --line: rgba(255, 255, 255, 0.08);
  --text: #f3f5f8;
  --muted: #9aa3b5;
  --accent: #b11818;
  --accent-ink: #ffffff;
  --bar: #6d7c93;
  --space: 8px;
  --font: "Noto Sans KR", sans-serif;
  --mono: ui-monospace, "Cascadia Mono", "Segoe UI Mono", Consolas, monospace;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

body {
  margin: 0;
  background:
    radial-gradient(1000px 360px at 8% -12%, rgba(177, 24, 24, 0.14), transparent 55%),
    var(--bg);
  color: var(--text);
  font: 16px/1.5 var(--font);
}

body::before {
  content: "";
  display: block;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), transparent 72%);
}

main {
  max-width: 1120px;
  margin: 0 auto;
  padding: 24px 24px 48px;
}

h1, h2, p { margin: 0; }

a { color: #e07070; text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: #f3b4b4; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.mast {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px 24px;
  margin-bottom: 16px;
}

.eyebrow {
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.health {
  display: inline-block;
  margin-left: 4px;
  padding: 1px 8px;
  border-radius: 999px;
  background: #3a2a10;
  color: #f0d08c;
  font-weight: 600;
  letter-spacing: 0;
  white-space: nowrap;
}

.health.is-error {
  background: #3a1414;
  color: #f3b4b4;
}

h1 {
  margin-top: 8px;
  font-size: clamp(1.8rem, 3vw, 2.35rem);
  font-weight: 750;
  letter-spacing: -0.04em;
  line-height: 1.15;
}

.lede {
  margin-top: 8px;
  color: var(--muted);
  font-size: 15px;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
  margin-bottom: 26px;
}

.ranges {
  display: inline-flex;
  padding: 0;
  background: #10141b;
  border: 1px solid var(--line);
}

.ranges button {
  border: 0;
  background: transparent;
  color: #d5dbe6;
  padding: 4px 16px;
  font: inherit;
  font-size: 14px;
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease, transform 0.15s ease;
}

.ranges button:active {
  transform: scale(0.96);
}

.ranges button[aria-pressed="true"] {
  background: var(--surface);
  color: var(--text);
  font-weight: 700;
}

.period-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px;
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

.credit {
  margin: 24px 0 0;
  color: #6e7786;
  font-size: 12px;
}

.banner {
  margin: 0 0 16px;
  padding: 8px 16px;
  background: #2a1212;
  color: #f0d0d0;
  border: 0;
  border-radius: 12px;
}

.guide {
  max-width: 64ch;
  padding: 24px;
  background: var(--surface);
  border: 0;
  border-radius: 16px;
  color: #d5dbe6;
}

#board > .card { margin-bottom: 16px; }

.charts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.card, #sample-section {
  min-width: 0;
  background: var(--surface);
  border: 0;
  border-radius: 0;
  padding: 16px;
}

#sample-section { margin-top: 16px; }

.card-head, .section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px 16px;
  margin-bottom: 16px;
}

.section-head { align-items: center; }

h2 { font-size: 1.02rem; font-weight: 700; }

.card-note { color: var(--muted); font-size: 13px; }

.caution {
  margin: 0 0 16px;
  padding-left: 8px;
  border-left: 2px solid var(--accent);
  color: var(--muted);
  font-size: 13px;
}

.chart { position: relative; width: 100%; min-width: 0; }

.empty { padding: 16px 0; color: var(--muted); }
.empty.is-error { color: #f3b4b4; }

.cloud { display: block; width: 100%; height: auto; }
.cloud text, .cloud-extra span { cursor: pointer; user-select: none; -webkit-user-select: none; }
.cloud.is-hot text { opacity: 0.38; }
.cloud.is-hot text.is-on, .cloud-extra span.is-on { opacity: 1; }
.cloud-extra { margin: 8px 0 0; font-size: 13px; font-weight: 700; }
.cloud-extra span { margin-right: 8px; }
.chart-note { margin: 8px 0 0; color: var(--muted); font-size: 13px; }
button.chart-note {
  display: block;
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
}
.can-open { cursor: pointer; }
.chart-note.can-open,
.cols li.can-open .col-name,
.waffle-legend li.can-open .waffle-name {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}
.members {
  height: 0;
  margin-top: 0;
  overflow: hidden;
  opacity: 0;
  transform: translateY(-8px);
  transition: height 0.45s cubic-bezier(0.22, 0.61, 0.36, 1), opacity 0.35s ease, margin-top 0.45s cubic-bezier(0.22, 0.61, 0.36, 1), transform 0.45s cubic-bezier(0.22, 0.61, 0.36, 1);
}
.members.is-open {
  margin-top: 8px;
  opacity: 1;
  transform: none;
}
.members ol {
  margin: 0;
  padding: 8px;
  list-style: none;
  display: grid;
  gap: 8px;
  max-height: 240px;
  overflow: auto;
  background: var(--surface-2);
  border-radius: 8px;
}
.members li {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 13px;
}
.members span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.members b { flex: none; font-variant-numeric: tabular-nums; }
#chart-tags .members { margin-left: 20px; margin-right: 20px; }
#chart-tags .members ol { border-radius: 0; }

.card:has(#chart-filetype),
.card:has(#chart-downloads) {
  display: flex;
  flex-direction: column;
}
#chart-downloads {
  flex: 1;
  display: flex;
  flex-direction: column;
}
#chart-filetype {
  flex: 1;
  display: flex;
  flex-direction: column;
}
#chart-filetype .members { margin-left: 20px; margin-right: 20px; }
#chart-filetype .members ol { border-radius: 0; }

/* Donut on the left, legend on the right: same proportions as the tag waffle next to it. */
.pie {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-left: 20px;
  padding-right: 20px;
}
.donut { display: block; flex: none; width: 220px; height: 220px; overflow: visible; }
.donut text {
  font-family: var(--font);
  font-weight: 700;
  pointer-events: none;
}
.donut path { transition: opacity 0.15s ease; }
.donut.is-hot g:not(.is-on) path { opacity: 0.35; }
.donut g.can-open { cursor: pointer; }

.pie-lines {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}
.pie-line {
  fill: none;
  stroke-width: 1;
  stroke-opacity: 0.55;
  stroke-linejoin: round;
  shape-rendering: geometricPrecision;
  transition: stroke-opacity 0.15s ease;
}
.pie-lines.is-hot .pie-line { stroke-opacity: 0.15; }
.pie-lines.is-hot .pie-line.is-on { stroke-opacity: 1; stroke-width: 1.5; }

.pie-legend {
  flex: 0 0 auto;
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  grid-template-columns: 8px minmax(0, max-content) max-content max-content;
  justify-content: start;
  width: max-content;
  column-gap: 8px;
  row-gap: 8px;
}
.pie-legend li {
  display: grid;
  grid-template-columns: subgrid;
  grid-column: 1 / -1;
  align-items: center;
  min-width: 0;
  font-size: 13px;
  transition: opacity 0.15s ease;
}
.pie-legend.is-hot li:not(.is-on) { opacity: 0.45; }
.pie-pct {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.pie-legend .waffle-value { font-weight: 500; }
.pie-legend li.can-open .waffle-name {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.ranks {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: 1.6rem minmax(0, max-content) minmax(48px, 1fr) max-content;
  column-gap: 8px;
  row-gap: 8px;
}

.rank-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rank-value {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  text-align: right;
}

.rank-track {
  position: relative;
  display: block;
  height: 8px;
  overflow: hidden;
  background: #222833;
  border-radius: 99px;
}

.rank-fill {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  animation: grow 0.55s ease forwards;
}

/* The columns fill the card (its height comes from the 시그니처 card next to it); the
   track keeps the old 128px as its minimum. */
.cols {
  flex: 1;
  display: flex;
  align-items: stretch;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.cols li {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
  transition: opacity 0.2s ease;
}
.cols.is-hot li:not(.is-on) { opacity: 0.35; }
.cols li.is-on .col-value { color: var(--text); }
.col-short { display: none; }

.col-value {
  color: var(--muted);
  font-size: 12px;
  line-height: 16px;
  font-variant-numeric: tabular-nums;
}

.col-track {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  width: min(100%, 24px);
  flex: 1 1 auto;
  min-height: 128px;
  max-height: 320px;
  background: #222833;
  border-radius: 4px 4px 0 0;
}

.col-bar {
  display: block;
  width: 100%;
  height: 0;
  border-radius: inherit;
  animation: rise 0.55s ease forwards;
}

.col-name {
  width: 100%;
  overflow: hidden;
  color: var(--text);
  font-size: 12px;
  line-height: 16px;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.waffle {
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  gap: 16px;
  padding-left: 20px;
  padding-right: 20px;
}

.waffle-grid {
  display: grid;
  grid-template-columns: repeat(10, minmax(0, 1fr));
  grid-template-rows: repeat(10, minmax(0, 1fr));
  gap: 4px;
  flex: none;
  min-width: 0;
  min-height: 0;
}

.waffle-cell {
  display: block;
  min-width: 0;
  min-height: 0;
  border-radius: 5px;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.waffle-grid.is-hot .waffle-cell { opacity: 0.22; transform: scale(0.86); }
.waffle-grid.is-hot .waffle-cell.is-on { opacity: 1; transform: scale(1.06); }
.waffle-legend li { transition: opacity 0.2s ease; }
.waffle-legend.is-hot li:not(.is-on) { opacity: 0.45; }

.waffle-legend {
  flex: 0 0 auto;
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  grid-template-columns: 8px minmax(0, max-content) max-content;
  justify-content: start;
  width: max-content;
  column-gap: 8px;
  row-gap: 8px;
}

.waffle-legend li {
  display: grid;
  grid-template-columns: subgrid;
  grid-column: 1 / -1;
  align-items: center;
  min-width: 0;
  font-size: 13px;
}

.waffle-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.waffle-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.waffle-value {
  color: var(--muted);
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.country-layout {
  display: grid;
  grid-template-columns: minmax(240px, 320px) minmax(0, 1fr);
  gap: 16px;
  align-items: center;
}

#chart-country-list {
  width: auto;
  margin-left: 20px;
  max-height: 336px;
  overflow: auto;
  padding-right: 8px;
  scrollbar-width: none;
}
#chart-country-list::-webkit-scrollbar {
  display: none;
}

.ranks li {
  display: grid;
  grid-template-columns: subgrid;
  grid-column: 1 / -1;
  align-items: center;
  font-size: 13px;
}

.rank-index {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11px;
}

.note {
  margin-top: 16px;
  color: var(--muted);
  font-size: 13px;
}

.map { min-height: 220px; }
.map:has(.empty) { min-height: 0; }

.filter {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.filter-icon {
  position: absolute;
  left: 12px;
  width: 16px;
  height: 16px;
  color: var(--muted);
  pointer-events: none;
}

.filter input {
  width: min(100%, 280px);
  padding: 8px 16px 8px 36px;
  background: #10141b;
  color: var(--text);
  border: 0;
  outline: 2px solid transparent;
  outline-offset: 4px;
  font: inherit;
  font-size: 14px;
  transition: outline-color 0.2s ease, outline-offset 0.2s ease;
}

.filter input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.table-wrap { overflow-x: auto; }

.table-wrap table {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
  font-size: 14px;
}

.table-wrap th:nth-child(1),
.table-wrap td:nth-child(1) { width: 7rem; }
.table-wrap th:nth-child(2),
.table-wrap td:nth-child(2) { width: 9.5rem; }
.table-wrap th:nth-child(3),
.table-wrap td:nth-child(3) { width: 5.5rem; }
.table-wrap th:nth-child(4),
.table-wrap td:nth-child(4) { width: 6.5rem; }
.table-wrap th:nth-child(5),
.table-wrap td:nth-child(5) { width: 5.25rem; }

.table-wrap th,
.table-wrap td {
  text-align: left;
  padding: 8px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  white-space: nowrap;
}

.table-wrap th {
  position: sticky;
  top: 0;
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.table-wrap tbody tr { position: relative; }
.table-wrap tbody tr:hover td { background: rgba(177, 24, 24, 0.1); }

.table-wrap th:last-child,
.table-wrap td:last-child { width: 100%; }

.hash-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-width: 0;
  font-family: var(--mono);
  font-size: 12.5px;
}

.row-link {
  min-width: 0;
  flex: 1 1 auto;
}

.hash-text {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row-link::after {
  content: "";
  position: absolute;
  inset: 0;
}

.copy {
  position: relative;
  z-index: 1;
  flex: none;
  margin-left: auto;
  border: 1px solid var(--line);
  background: transparent;
  color: #d5dbe6;
  padding: 0 8px;
  font: 12px/1.4 var(--font);
  cursor: pointer;
}

.copy:hover { border-color: var(--accent); color: var(--text); }

@keyframes grow { to { width: var(--w); } }
@keyframes rise { to { height: var(--h); } }

body.is-loading .chart {
  color: transparent;
  background: linear-gradient(90deg, #1c222c 25%, #2a3342 37%, #1c222c 63%);
  background-size: 400% 100%;
  border-radius: 8px;
  animation: shimmer 1.3s ease infinite;
}

body.is-loading .chart { min-height: 220px; }

@keyframes shimmer {
  0% { background-position: 100% 0; }
  100% { background-position: 0 0; }
}

@media (prefers-reduced-motion: reduce) {
  .rank-fill {
    animation: none;
    width: var(--w);
  }
  .col-bar {
    animation: none;
    height: var(--h);
  }
  body.is-loading .chart { animation: none; }
  .waffle-cell,
  .waffle-legend li,
  .cols li,
  .pie-legend li,
  .pie-line,
  .donut path { transition: none; }
}

@media (max-width: 800px) {
  .charts { grid-template-columns: 1fr; }
  /* Stacked cards have no neighbour to borrow height from, so give the bars room. */
  .col-track { min-height: 200px; }
  .country-layout { grid-template-columns: 1fr; }
  #chart-country-list { max-height: none; margin-left: 0; }
  .table-wrap { overflow: visible; }
  .table-wrap table { table-layout: auto; }
  .table-wrap th:nth-child(n),
  .table-wrap td:nth-child(n) { width: auto; }
  .table-wrap table,
  .table-wrap tbody,
  .table-wrap tr,
  .table-wrap td { display: block; }
  .table-wrap thead { display: none; }
  .table-wrap tbody tr {
    margin-bottom: 8px;
    padding: 8px 16px;
    background: var(--surface-2);
    border-radius: 0;
  }
  .table-wrap td {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 0;
    border: 0;
    white-space: normal;
    text-align: right;
  }
  .table-wrap td::before {
    content: attr(data-label);
    color: var(--muted);
    text-align: left;
    flex: none;
  }
  .hash-actions { width: auto; flex: 1; min-width: 0; justify-content: flex-end; }
  .table-wrap tr.is-empty td { display: block; text-align: left; }
  .table-wrap tr.is-empty td::before { content: none; }
}

@media (max-width: 640px) {
  main { padding: 16px 16px 48px; }
  .waffle, .pie { gap: 8px; }
  #chart-country .role-legend { translate: 0 24px; }
}

@media (max-width: 520px) {
  .cols { gap: 4px; }
  .col-full { display: none; }
  .col-short { display: inline; }
  .waffle {
    justify-content: space-between;
    gap: 20px;
    padding-left: 0;
    padding-right: 0;
  }
  #chart-tags .members { margin-left: 0; margin-right: 0; }
  .pie { padding-left: 0; padding-right: 0; }
  #chart-filetype .members { margin-left: 0; margin-right: 0; }
}

/* Very narrow phones: donut on top, legend underneath in two compact columns. */
@media (max-width: 359px) {
  .pie { flex-direction: column; align-items: stretch; gap: 12px; }
  .pie-lines { display: none; }
  .donut { align-self: center; }
  .pie-legend {
    width: auto;
    grid-template-columns: repeat(2, 8px minmax(0, 1fr) max-content max-content);
    column-gap: 6px;
  }
  .pie-legend li:nth-child(odd) { grid-column: 1 / 5; }
  .pie-legend li:nth-child(even) { grid-column: 5 / 9; }
}
