:root {
  --bg: #0a0d12;
  --surface: #111720;
  --surface-2: #161e28;
  --surface-3: #1c2632;
  --line: #232e3a;
  --line-strong: #33404f;
  --text: #e9eff6;
  --muted: #8b98a8;
  --muted-2: #7d8a99;
  --accent: #e2b714;
  --accent-2: #f6d64a;
  --accent-soft: rgba(226, 183, 20, 0.1);
  --danger: #ff6b6b;
  --ok: #4ade80;
  --warn: #f0b429;
  --radius: 14px;
  --radius-sm: 10px;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
}

body {
  min-height: 100vh;
  background:
    radial-gradient(760px 340px at 50% -10%, rgba(226, 183, 20, 0.1), transparent 70%),
    var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  color: var(--accent-2);
}

code {
  font-family: var(--font-mono);
  font-size: 0.92em;
  color: #cfd8e3;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 1px 5px;
}

.wrap {
  max-width: 1240px;
  margin: 0 auto;
  padding: 18px 20px 56px;
}

/* ---------- top bar ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 56px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--text);
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.brand::before {
  width: 8px;
  height: 8px;
  content: "";
  border-radius: 2px;
  background: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.brand span {
  color: var(--muted);
  font-weight: 600;
}

.tag {
  padding: 4px 9px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
}

/* ---------- home / upload ---------- */

.home {
  max-width: 760px;
  margin: 0 auto;
  padding: 28px 0 40px;
}

.intro {
  margin-bottom: 22px;
}

.kicker,
.eyebrow {
  margin: 0 0 10px;
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.intro h1 {
  margin: 0 0 10px;
  font-size: clamp(24px, 3.4vw, 32px);
  line-height: 1.18;
  letter-spacing: -0.02em;
}

.intro-text {
  max-width: 62ch;
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.65;
}

.status-line {
  margin-top: 14px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 10px;
  color: var(--muted);
  font-size: 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
}

.status-pill .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--muted);
}

.status-pill.ok .dot {
  background: var(--ok);
  box-shadow: 0 0 0 3px rgba(74, 222, 128, 0.12);
}

.status-pill.warn .dot {
  background: var(--warn);
  box-shadow: 0 0 0 3px rgba(240, 180, 41, 0.12);
}

.alert {
  margin: 0 0 16px;
  padding: 11px 13px;
  color: var(--text);
  font-size: 13px;
  line-height: 1.55;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.alert.error {
  border-color: rgba(255, 107, 107, 0.4);
  background: rgba(255, 107, 107, 0.08);
}

.alert.subtle {
  margin-top: 14px;
  color: var(--muted);
}

.upload-panel {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.22);
}

.file-drop {
  position: relative;
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  min-height: 84px;
  padding: 14px 16px;
  cursor: pointer;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.018), transparent);
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.file-drop:hover,
.file-drop.drag {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.file-drop:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(226, 183, 20, 0.12);
}

.file-drop.has-file {
  border-style: solid;
  border-color: var(--line-strong);
}

.file-drop input[type="file"] {
  position: absolute;
  inset: 0;
  cursor: pointer;
  opacity: 0;
}

.file-badge {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  border: 1px solid rgba(226, 183, 20, 0.22);
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
}

.file-copy {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.file-title {
  overflow: hidden;
  font-size: 14px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-hint {
  color: var(--muted-2);
  font-size: 12px;
}

.file-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 34px;
  padding: 0 12px;
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface-2);
}

.file-drop:hover .file-action {
  color: var(--accent);
  border-color: var(--accent);
}

.upload-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 2px 0;
}

.upload-note {
  color: var(--muted-2);
  font-size: 12px;
}

/* ---------- buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 17px;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  border: 1px solid transparent;
  border-radius: 9px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.05s ease;
}

.btn:active {
  transform: translateY(1px);
}

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

.btn.primary {
  color: #171307;
  background: var(--accent);
}

.btn.primary:hover {
  background: var(--accent-2);
}

.btn.ghost {
  color: var(--text);
  border-color: var(--line);
  background: transparent;
}

.btn.ghost:hover {
  border-color: var(--line-strong);
}

.btn:disabled {
  cursor: wait;
  opacity: 0.75;
}

.btn.is-loading::before {
  width: 13px;
  height: 13px;
  content: "";
  border: 2px solid rgba(0, 0, 0, 0.25);
  border-top-color: #171307;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

/* ---------- result ---------- */

.result-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding: 30px 0 22px;
}

.result-head h1 {
  margin: 0 0 8px;
  font-size: clamp(24px, 4vw, 34px);
  line-height: 1.15;
  letter-spacing: -0.02em;
  overflow-wrap: anywhere;
}

.lead {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.65;
}

.lead strong {
  color: var(--text);
}

.head-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
}

.cards {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
  margin: 8px 0 26px;
}

.card {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}

.card .k {
  color: var(--muted);
  font-size: 11px;
}

.card .v {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.card .v.small {
  font-size: 15px;
  line-height: 1.35;
}

.card .v small {
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}

.card .s {
  color: var(--muted-2);
  font-size: 11px;
}

.region-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-bottom: 12px;
}

.region-label {
  margin-right: 4px;
  color: var(--muted-2);
  font-family: var(--font-mono);
  font-size: 10px;
}

.region-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 9px;
  color: var(--text);
  font: inherit;
  font-size: 11px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: var(--region-bg, var(--surface));
  cursor: pointer;
  transition: border-color 0.15s ease;
}

.region-chip b {
  color: var(--region-color, var(--text));
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.region-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--region-color, var(--muted));
}

.region-chip:hover {
  color: var(--text);
  border-color: var(--region-color, var(--line-strong));
}

.region-chip.is-active {
  color: #171307;
  border-color: var(--accent);
  background: var(--accent);
}

.region-chip.is-active b {
  color: #171307;
}

.region-chip.is-active .region-dot {
  background: #171307;
}

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

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
  margin-bottom: 12px;
}

#boss-search {
  flex: 0 1 340px;
  min-width: 200px;
  padding: 9px 12px;
  color: var(--text);
  font: inherit;
  font-size: 13px;
  border: 1px solid var(--line);
  border-radius: 9px;
  outline: none;
  background: var(--surface);
}

#boss-search::placeholder {
  color: var(--muted-2);
}

#boss-search:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(226, 183, 20, 0.12);
}

.check {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
  user-select: none;
}

.check input {
  accent-color: var(--accent);
}

/* ---------- boss grid ---------- */

.boss-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.boss-grid.has-open {
  align-items: start;
}

.boss-grid.hide-ids .boss-id {
  display: none;
}

.boss-card {
  display: flex;
  flex-direction: column;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  transition: border-color 0.15s ease, background 0.15s ease;
}

.boss-card:hover {
  border-color: var(--line-strong);
}

.boss-card[open] {
  border-color: var(--line-strong);
}

summary.boss-summary,
.boss-summary.static {
  display: flex;
  flex: 1;
  flex-direction: column;
}

summary.boss-summary {
  list-style: none;
  cursor: pointer;
}

summary.boss-summary::-webkit-details-marker {
  display: none;
}

summary.boss-summary:focus-visible {
  border-radius: var(--radius-sm);
  outline: 2px solid var(--accent-2);
  outline-offset: 4px;
}

.boss-summary.static {
  cursor: default;
}

.boss-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.boss-avatar-wrap {
  flex: 0 0 auto;
  width: 48px;
  height: 48px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-2);
}

.boss-avatar {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
}

.boss-avatar.placeholder {
  display: grid;
  place-items: center;
  color: var(--accent);
  font-size: 17px;
  font-weight: 700;
  background: var(--accent-soft);
}

.boss-title {
  flex: 1;
  min-width: 0;
}

.boss-name {
  font-size: 14px;
  font-weight: 700;
  line-height: 1.3;
}

.boss-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
  margin-top: 4px;
}

.region-tag {
  flex: 0 0 auto;
  padding: 1px 6px;
  color: var(--region-color, var(--muted));
  font-size: 10px;
  white-space: nowrap;
  border: 1px solid transparent;
  border-radius: 999px;
  background: var(--region-bg, var(--surface-2));
}

.region-slate {
  --region-color: #a8b6c8;
  --region-bg: rgba(168, 182, 200, 0.12);
}

.region-blue {
  --region-color: #8fc2f0;
  --region-bg: rgba(143, 194, 240, 0.12);
}

.region-crimson {
  --region-color: #f09a9a;
  --region-bg: rgba(240, 154, 154, 0.13);
}

.region-green {
  --region-color: #97d19b;
  --region-bg: rgba(151, 209, 155, 0.12);
}

.region-amber {
  --region-color: #e6bd6a;
  --region-bg: rgba(230, 189, 106, 0.12);
}

.region-steel {
  --region-color: #a9bfd9;
  --region-bg: rgba(169, 191, 217, 0.12);
}

.region-plum {
  --region-color: #e0a7cf;
  --region-bg: rgba(224, 167, 207, 0.12);
}

.region-stone {
  --region-color: #b8b2ac;
  --region-bg: rgba(184, 178, 172, 0.12);
}

.region-violet {
  --region-color: #c2a7f5;
  --region-bg: rgba(194, 167, 245, 0.12);
}

.region-indigo {
  --region-color: #a2adef;
  --region-bg: rgba(162, 173, 239, 0.12);
}

.region-neutral {
  --region-color: #9aa7b7;
  --region-bg: rgba(154, 167, 183, 0.1);
}

.boss-id {
  min-width: 0;
  overflow: hidden;
  color: var(--muted-2);
  font-family: var(--font-mono);
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.boss-state {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 5px;
  padding: 3px 7px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 600;
  white-space: nowrap;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
}

.boss-state .dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--muted);
}

.boss-state.is-killed {
  color: #8ee6a8;
  border-color: rgba(74, 222, 128, 0.25);
  background: rgba(74, 222, 128, 0.08);
}

.boss-state.is-killed .dot {
  background: var(--ok);
}

.boss-state.is-alive {
  color: var(--muted-2);
}

.boss-diff {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
}

.diff-label {
  color: var(--muted-2);
  font-size: 10px;
}

.boss-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
  margin-bottom: 12px;
}

.stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.stat .k {
  color: var(--muted-2);
  font-size: 10px;
}

.stat .v {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.stat .v.small {
  font-family: var(--font-mono);
  font-size: 12px;
}

.boss-expand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: auto;
  padding-top: 10px;
  color: var(--muted-2);
  font-size: 11px;
  border-top: 1px solid var(--line);
}

.boss-expand .chevron {
  color: var(--muted);
  transition: transform 0.15s ease;
}

.boss-card[open] .boss-expand .chevron {
  transform: rotate(90deg);
}

.boss-card[open] .boss-expand {
  color: var(--accent);
}

.boss-detail {
  display: grid;
  gap: 8px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.detail-title {
  color: var(--muted-2);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.12em;
}

.diff-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 7px 0;
  border-bottom: 1px dashed var(--line);
}

.diff-row:last-of-type {
  border-bottom: none;
}

.diff-metrics {
  color: var(--muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.diff-best {
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.diff-total {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted-2);
  font-size: 11px;
}

.diff-total strong {
  color: var(--text);
  font-weight: 600;
}

.badge {
  display: inline-block;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  border: 1px solid transparent;
  border-radius: 999px;
}

.diff-1 {
  color: #8ecae6;
  border-color: rgba(142, 202, 230, 0.3);
  background: rgba(142, 202, 230, 0.1);
}

.diff-2 {
  color: #ffd166;
  border-color: rgba(255, 209, 102, 0.3);
  background: rgba(255, 209, 102, 0.1);
}

.diff-3 {
  color: #ff8fab;
  border-color: rgba(255, 143, 171, 0.3);
  background: rgba(255, 143, 171, 0.1);
}

.diff-4 {
  color: #c77dff;
  border-color: rgba(199, 125, 255, 0.3);
  background: rgba(199, 125, 255, 0.1);
}

.empty-state {
  padding: 36px 20px;
  color: var(--muted-2);
  font-size: 13px;
  text-align: center;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.footnote {
  margin-top: 12px;
  color: var(--muted-2);
  font-size: 11px;
  line-height: 1.6;
}

footer {
  margin-top: 44px;
  padding-top: 16px;
  color: var(--muted-2);
  font-size: 11px;
  border-top: 1px solid var(--line);
}

/* ---------- motion ---------- */

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .btn.is-loading::before {
    animation: none;
  }

  * {
    transition-duration: 0.01ms !important;
  }
}

/* ---------- responsive ---------- */

@media (max-width: 1000px) {
  .cards {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .boss-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .boss-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .wrap {
    padding: 14px 14px 40px;
  }

  .home {
    padding-top: 18px;
  }

  .result-head {
    padding-top: 22px;
    align-items: flex-start;
  }

  .cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .file-drop {
    grid-template-columns: 40px minmax(0, 1fr);
    gap: 12px;
    min-height: 76px;
    padding: 13px 14px;
  }

  .boss-avatar-wrap {
    width: 44px;
    height: 44px;
  }

  .file-badge {
    width: 40px;
    height: 40px;
  }

  .file-action {
    display: none;
  }

  .upload-footer {
    flex-direction: column;
    align-items: stretch;
  }

  .upload-footer .btn {
    width: 100%;
  }

  .upload-note {
    text-align: center;
  }
}
