:root {
  --bg: #0f1115;
  --panel: #181b22;
  --panel-2: #1f2330;
  --line: #2a2f3d;
  --text: #e6e8ee;
  --text-dim: #9098ad;
  --accent: #ff4d6d;
  --accent-2: #4d8cff;
  --female: #ff5e8e;
  --male: #4d8cff;
  --neutral: #b39ddb;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Sans", "Yu Gothic", "Helvetica Neue", Arial, sans-serif; }
body { min-height: 100vh; }

.topbar {
  display: flex; align-items: flex-end; justify-content: space-between;
  padding: 20px 32px 16px; gap: 20px;
  background: linear-gradient(180deg, #14171f 0%, #0f1115 100%);
  border-bottom: 1px solid var(--line);
}
.topbar .title h1 { margin: 0; font-size: 26px; letter-spacing: 0.02em; }
.topbar .title h1 .sub { color: var(--accent); font-size: 18px; margin-left: 8px; }
.topbar .title .source { margin: 6px 0 0; color: var(--text-dim); font-size: 11px; line-height: 1.5; }

.search-wrap { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
#searchBox { width: 260px; padding: 9px 12px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); color: var(--text); font-size: 13px; }
#searchBox:focus { outline: none; border-color: var(--accent-2); }
.search-wrap select { padding: 9px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); color: var(--text); font-size: 12px; cursor: pointer; }
.search-wrap select:focus { outline: none; border-color: var(--accent-2); }
#resetFilters { padding: 9px 14px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel-2); color: var(--text-dim); cursor: pointer; font-size: 12px; }
#resetFilters:hover { color: var(--text); border-color: var(--accent); }

.media-tag { display: inline-block; padding: 2px 7px; border-radius: 4px; font-size: 10px; background: rgba(77,140,255,0.15); color: var(--accent-2); white-space: nowrap; }
.tp-tag { display: inline-block; padding: 2px 7px; border-radius: 4px; font-size: 10px; background: rgba(255,94,142,0.12); color: #ff8eaf; white-space: nowrap; }

.tabs { display: flex; gap: 2px; padding: 0 24px; background: #0f1115; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tab { padding: 12px 18px; border: none; background: transparent; color: var(--text-dim); cursor: pointer; font-size: 13px; border-bottom: 2px solid transparent; white-space: nowrap; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); border-bottom-color: var(--accent); }

main { padding: 18px 24px 60px; }
.view { display: none; }
.view.active { display: block; }

.map-header { margin-bottom: 12px; }
.map-header h2 { margin: 0 0 6px; font-size: 20px; }
.map-header p { margin: 0; color: var(--text-dim); font-size: 12px; line-height: 1.5; }
.map-header p small { display: block; margin-top: 4px; color: #6b738a; }

.plot { width: 100%; height: calc(100vh - 240px); min-height: 600px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 6px; }
.plot.empty { display: flex; align-items: center; justify-content: center; color: var(--text-dim); font-size: 14px; }

.filter-row { display: flex; gap: 16px; margin-bottom: 10px; padding: 10px 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; }
.filter-row label { display: flex; align-items: center; gap: 6px; color: var(--text-dim); font-size: 12px; }
.filter-row select { background: var(--panel-2); color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: 5px 8px; font-size: 12px; }

table#rankTable { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; font-size: 12px; }
#rankTable th, #rankTable td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; }
#rankTable th { background: var(--panel-2); cursor: pointer; user-select: none; font-weight: 600; color: var(--text-dim); position: sticky; top: 0; }
#rankTable th:hover { color: var(--text); }
#rankTable th.sorted-asc::after { content: " ▲"; color: var(--accent); }
#rankTable th.sorted-desc::after { content: " ▼"; color: var(--accent); }
#rankTable tbody tr:hover { background: rgba(77, 140, 255, 0.05); }
#rankTable td.num { text-align: right; font-variant-numeric: tabular-nums; }

.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(380px, 1fr)); gap: 16px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 18px; }
.card .card-rank { display: inline-block; padding: 4px 10px; background: var(--accent); color: white; border-radius: 4px; font-weight: 700; font-size: 12px; }
.card h3 { margin: 10px 0 12px; font-size: 18px; }
.card .pyramid { display: flex; flex-direction: column; gap: 3px; margin: 12px 0; }
.card .pyramid .row { display: grid; grid-template-columns: 40px 1fr 1fr 40px; align-items: center; gap: 4px; font-size: 10px; color: var(--text-dim); }
.card .pyramid .bar-male { background: var(--male); height: 14px; border-radius: 2px 0 0 2px; justify-self: end; }
.card .pyramid .bar-female { background: var(--female); height: 14px; border-radius: 0 2px 2px 0; justify-self: start; }
.card .pyramid .axis { text-align: center; color: var(--text-dim); font-size: 9px; margin-top: 2px; }
.card .meta { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 14px; margin-top: 10px; font-size: 11px; }
.card .meta .k { color: var(--text-dim); }
.card .meta .v { color: var(--text); font-weight: 600; }
.card .gender-split { display: flex; height: 8px; border-radius: 4px; overflow: hidden; margin: 6px 0; }
.card .gender-split .m { background: var(--male); }
.card .gender-split .f { background: var(--female); }
.card .badge { display: inline-block; padding: 2px 7px; border-radius: 4px; font-size: 10px; background: rgba(255,77,109,0.15); color: var(--accent); margin-right: 4px; }

.about { max-width: 760px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 24px 28px; line-height: 1.7; }
.about h2 { margin-top: 0; }
.about h3 { color: var(--accent); margin: 22px 0 8px; font-size: 15px; }
.about ul { padding-left: 22px; }
.about li { margin: 4px 0; color: var(--text); }
.about li b { color: var(--accent-2); }
