/* Legacy fallback for older mobile browser kernels before the modern layer below. */
body {
  margin: 0;
  min-width: 320px;
  background: #101114;
  color: #f2f3f5;
  font-family:
    Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
}

button,
input,
select {
  font: inherit;
}

.site-header,
.top-nav,
.filter-strip,
.section-head,
.card-title-row,
.detail-title-row,
.provider-button,
.import-head,
.field-grid,
.import-actions,
.stats-head,
.stats-controls {
  display: flex;
}

.site-header {
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 14px 0;
}

.brand,
.nav-link,
.secondary-link {
  color: #f2f3f5;
  text-decoration: none;
}

.brand {
  display: inline-flex;
  gap: 10px;
  align-items: center;
  font-weight: 800;
}

.brand-mark {
  display: inline-flex;
  width: 34px;
  height: 34px;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: #28c2a0;
  color: #fff;
}

.top-nav,
.segmented,
.provider-row,
.tag-row {
  flex-wrap: wrap;
  gap: 8px;
}

.nav-item,
.nav-link,
.segment,
.theme-button,
.provider-button,
.secondary-button,
.primary-button,
.secondary-link {
  min-height: 36px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  background: #181a20;
  color: #f2f3f5;
  padding: 0 13px;
}

main,
.stats-page {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto 60px;
}

.hero-band,
.resource-card,
.rank-panel,
.detail-card,
.import-shell,
.import-fields,
.stats-head,
.stats-panel,
.metric-card,
.provider-stat,
.transfer-output,
.empty-state {
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: #181a20;
}

.hero-band {
  overflow: hidden;
  margin-bottom: 22px;
  background: #17191f;
}

.hero-content {
  padding: 32px 24px;
}

.kicker {
  color: #28c2a0;
}

.search-shell {
  display: flex;
  max-width: 540px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: #20242c;
}

.search-shell input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: #f2f3f5;
  padding: 0 16px;
}

.search-shell button {
  border: 0;
  border-left: 1px solid rgba(255, 255, 255, 0.12);
  background: transparent;
  color: #a9b0bd;
}

.resource-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
}

.resource-card {
  position: relative;
  width: 260px;
  overflow: hidden;
}

.card-hit {
  position: absolute;
  inset: 0;
  z-index: 2;
  border: 0;
  background: transparent;
}

.poster,
.detail-poster {
  min-height: 154px;
  padding: 14px;
  background: #247b86;
  color: #fff;
}

.card-body,
.rank-panel,
.detail-main,
.import-shell,
.import-fields,
.stats-head,
.stats-panel,
.metric-card,
.provider-stat,
.transfer-output {
  padding: 16px;
}

.content-layout,
.import-page,
.stats-grid,
.metric-grid {
  display: flex;
  gap: 24px;
  align-items: flex-start;
}

.content-layout > div,
.import-shell,
.stats-grid > .stats-panel:first-child {
  flex: 1 1 0;
}

.rank-panel,
.import-fields,
.stats-grid > .stats-panel:last-child {
  flex: 0 0 300px;
}

.provider-grid,
.field-table,
.provider-stats,
.stats-shell {
  display: grid;
  gap: 10px;
}

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

.provider-button {
  justify-content: space-between;
  align-items: center;
  width: 100%;
}

.detail-dialog[open] {
  position: fixed;
  inset: 20px;
  z-index: 100;
  display: block;
  width: auto;
  height: auto;
  overflow: auto;
}

.dialog-fallback-open::before {
  position: fixed;
  inset: 0;
  z-index: 99;
  background: rgba(5, 7, 12, 0.72);
  content: "";
}

@media (max-width: 860px) {
  .content-layout,
  .import-page,
  .stats-grid,
  .metric-grid {
    display: block;
  }

  .rank-panel,
  .import-fields {
    margin-top: 18px;
  }

  .resource-card {
    width: 100%;
  }
}

:root {
  color-scheme: dark;
  --bg: #101114;
  --surface: #181a20;
  --surface-2: #20242c;
  --text: #f2f3f5;
  --muted: #a9b0bd;
  --line: rgba(255, 255, 255, 0.12);
  --accent: #28c2a0;
  --accent-2: #f2a33a;
  --danger: #df5e54;
  --shadow: 0 18px 60px rgba(0, 0, 0, 0.28);
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #e9edf2;
  --text: #191c22;
  --muted: #5f6876;
  --line: rgba(20, 24, 31, 0.12);
  --shadow: 0 18px 60px rgba(33, 40, 52, 0.14);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Microsoft YaHei", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 20px;
  align-items: center;
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 14px 0;
  backdrop-filter: blur(16px);
}

.brand {
  display: inline-flex;
  gap: 10px;
  align-items: center;
  color: var(--text);
  font-weight: 800;
  text-decoration: none;
  white-space: nowrap;
}

.brand-mark {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), #3178ff 58%, var(--danger));
  color: #fff;
}

.top-nav {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
}

.top-nav::-webkit-scrollbar {
  display: none;
}

.nav-item,
.nav-link,
.segment,
.theme-button {
  min-height: 36px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
}

.nav-item {
  padding: 0 13px;
  white-space: nowrap;
}

.nav-link {
  display: inline-flex;
  align-items: center;
  padding: 0 13px;
  text-decoration: none;
  white-space: nowrap;
}

.nav-item:hover,
.nav-link:hover,
.segment:hover,
.theme-button:hover,
.nav-item.is-active,
.nav-link.is-active,
.segment.is-active {
  border-color: var(--line);
  background: var(--surface);
  color: var(--text);
}

.theme-button {
  width: 38px;
  background: var(--surface);
}

main {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto 60px;
}

.hero-band {
  position: relative;
  min-height: 280px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #17191f;
  box-shadow: var(--shadow);
}

.hero-media {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, rgba(10, 12, 16, 0.94) 0%, rgba(10, 12, 16, 0.58) 48%, rgba(10, 12, 16, 0.18) 100%),
    url("/assets/catalog-banner.png") center / cover no-repeat;
}

:root[data-theme="light"] .hero-media {
  background:
    linear-gradient(90deg, rgba(246, 248, 250, 0.93) 0%, rgba(246, 248, 250, 0.72) 44%, rgba(246, 248, 250, 0.14) 100%),
    url("/assets/catalog-banner.png") center / cover no-repeat;
}

.hero-content {
  position: relative;
  width: min(640px, 100%);
  padding: 46px clamp(22px, 5vw, 56px);
}

.kicker {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 26px;
  font-size: clamp(34px, 6vw, 60px);
  line-height: 1.02;
  letter-spacing: 0;
}

.search-shell {
  display: grid;
  grid-template-columns: 1fr 42px;
  width: min(540px, 100%);
  min-height: 52px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
}

.search-shell input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  padding: 0 16px;
}

.search-shell button {
  border: 0;
  border-left: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font-size: 24px;
}

.filter-strip {
  display: flex;
  gap: 12px;
  justify-content: space-between;
  align-items: center;
  margin: 22px 0;
}

.segmented {
  display: flex;
  gap: 8px;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
}

.segmented::-webkit-scrollbar {
  display: none;
}

.segment {
  padding: 0 14px;
  white-space: nowrap;
}

select {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  padding: 0 12px;
}

.content-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 28px;
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 14px;
}

.section-head h2 {
  margin: 0;
  font-size: 20px;
}

.section-head span {
  color: var(--muted);
}

.resource-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 16px;
}

.resource-card {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  transition:
    transform 160ms ease,
    border-color 160ms ease;
}

.resource-card:hover {
  transform: translateY(-2px);
  border-color: color-mix(in srgb, var(--accent) 54%, var(--line));
}

.card-hit {
  position: absolute;
  inset: 0;
  z-index: 2;
  border: 0;
  background: transparent;
}

.poster,
.detail-poster {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 154px;
  padding: 14px;
  overflow: hidden;
  color: #fff;
  background-position: center;
  background-size: cover;
}

.poster::before,
.detail-poster::before {
  position: absolute;
  inset: 0;
  content: "";
  background:
    radial-gradient(circle at 22% 18%, rgba(255, 255, 255, 0.28), transparent 20%),
    radial-gradient(circle at 75% 35%, rgba(255, 255, 255, 0.2), transparent 18%),
    linear-gradient(135deg, var(--poster-a), var(--poster-b));
}

.poster.has-cover::before,
.detail-poster.has-cover::before {
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.08), rgba(0, 0, 0, 0.68));
}

.poster::after,
.detail-poster::after {
  position: absolute;
  inset: auto 12px 12px auto;
  width: 64px;
  height: 64px;
  border: 1px solid rgba(255, 255, 255, 0.32);
  border-radius: 50%;
  content: "";
}

.poster span,
.poster strong,
.detail-poster span,
.detail-poster strong {
  position: relative;
  z-index: 1;
}

.poster span,
.detail-poster span {
  width: fit-content;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.28);
  padding: 5px 9px;
  font-size: 12px;
}

.poster strong,
.detail-poster strong {
  font-size: 24px;
}

.poster-blue {
  --poster-a: #1f6feb;
  --poster-b: #19b7a5;
}

.poster-green {
  --poster-a: #0f8a5f;
  --poster-b: #c2a23a;
}

.poster-red {
  --poster-a: #bd3b43;
  --poster-b: #2f5f9e;
}

.poster-amber {
  --poster-a: #bd6b18;
  --poster-b: #247b86;
}

.poster-purple {
  --poster-a: #7657d6;
  --poster-b: #d75062;
}

.poster-slate {
  --poster-a: #43515f;
  --poster-b: #9c6f37;
}

.card-body {
  padding: 14px;
}

.card-title-row,
.detail-title-row {
  display: flex;
  gap: 12px;
  align-items: start;
  justify-content: space-between;
}

.card-title-row h3 {
  margin: 0;
  font-size: 18px;
  line-height: 1.3;
}

.card-title-row strong,
.detail-title-row strong {
  color: var(--accent-2);
}

.card-body p {
  min-height: 44px;
  margin: 8px 0 12px;
  color: var(--muted);
  line-height: 1.55;
}

.meta-row,
.provider-row,
.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.meta-row {
  color: var(--muted);
  font-size: 13px;
}

.provider-row {
  margin-top: 12px;
}

.provider-chip,
.tag-row span {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: color-mix(in srgb, var(--chip, var(--accent)) 16%, transparent);
  color: var(--text);
  padding: 4px 8px;
  font-size: 12px;
}

.rank-panel {
  align-self: start;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 16px;
}

.rank-panel ol {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.rank-panel button {
  display: flex;
  width: 100%;
  min-height: 42px;
  justify-content: space-between;
  align-items: center;
  border: 1px solid transparent;
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text);
  padding: 0 12px;
  text-align: left;
}

.rank-panel button:hover {
  border-color: var(--line);
}

.rank-panel strong {
  color: var(--accent-2);
}

.empty-state {
  display: grid;
  min-height: 180px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
}

.detail-dialog {
  width: min(860px, calc(100% - 28px));
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
}

.detail-dialog::backdrop {
  background: rgba(5, 7, 12, 0.72);
  backdrop-filter: blur(6px);
}

.detail-card {
  position: relative;
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.dialog-close {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 3;
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-size: 22px;
}

.detail-poster {
  min-height: 100%;
}

.detail-main {
  padding: 28px;
}

.detail-main h2 {
  margin-bottom: 4px;
  font-size: 30px;
}

.detail-subtitle,
.detail-summary {
  color: var(--muted);
  line-height: 1.7;
}

.detail-summary {
  margin-bottom: 18px;
}

.tag-row {
  margin-bottom: 20px;
}

.provider-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.provider-button {
  display: flex;
  min-height: 54px;
  align-items: center;
  justify-content: space-between;
  border: 1px solid color-mix(in srgb, var(--provider) 42%, var(--line));
  border-radius: 8px;
  background: color-mix(in srgb, var(--provider) 15%, transparent);
  color: var(--text);
  padding: 0 14px;
}

.provider-button:hover {
  background: color-mix(in srgb, var(--provider) 24%, transparent);
}

.provider-button:disabled {
  cursor: wait;
  opacity: 0.62;
}

.transfer-output {
  display: grid;
  gap: 8px;
  margin-top: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  padding: 14px;
}

.transfer-output span {
  color: var(--accent);
  font-weight: 700;
}

.transfer-output a {
  min-width: 0;
  overflow-wrap: anywhere;
  color: var(--text);
}

.import-page {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 24px;
}

.import-shell,
.import-fields {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: clamp(18px, 4vw, 28px);
}

.import-head,
.field-grid,
.import-actions {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
}

.import-head {
  margin-bottom: 18px;
}

.import-head h1 {
  margin: 0;
  font-size: clamp(28px, 5vw, 42px);
}

.field-grid {
  margin-bottom: 14px;
}

.admin-token {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

.admin-token span {
  color: var(--muted);
  font-size: 13px;
}

.admin-token input {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: 0;
  background: var(--surface-2);
  color: var(--text);
  padding: 0 12px;
}

.file-drop {
  display: grid;
  min-height: 48px;
  flex: 1;
  place-items: center;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--muted);
  text-align: center;
}

.file-drop input {
  width: 1px;
  height: 1px;
  opacity: 0;
}

.secondary-button,
.primary-button,
.secondary-link {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  padding: 0 16px;
  text-decoration: none;
}

.secondary-button,
.secondary-link {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text);
}

.primary-button {
  border: 1px solid color-mix(in srgb, var(--accent) 52%, var(--line));
  background: var(--accent);
  color: #07110f;
  font-weight: 800;
}

.primary-button:disabled {
  cursor: wait;
  opacity: 0.7;
}

#importInput {
  width: 100%;
  min-height: 360px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: 0;
  background: var(--surface-2);
  color: var(--text);
  padding: 14px;
  line-height: 1.65;
}

.import-actions {
  margin-top: 14px;
}

.import-result {
  margin-top: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  line-height: 1.65;
}

.import-result.is-success {
  border-color: color-mix(in srgb, var(--accent) 46%, var(--line));
  background: color-mix(in srgb, var(--accent) 12%, transparent);
}

.import-result.is-error {
  border-color: color-mix(in srgb, var(--danger) 54%, var(--line));
  background: color-mix(in srgb, var(--danger) 12%, transparent);
}

.import-result ol {
  margin-bottom: 0;
  padding-left: 22px;
}

.import-fields {
  align-self: start;
}

.import-fields h2 {
  margin-top: 0;
}

.field-table {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px 14px;
  color: var(--muted);
}

.field-table strong {
  color: var(--text);
  white-space: nowrap;
}

.stats-page {
  width: min(1180px, calc(100% - 32px));
}

.stats-shell {
  display: grid;
  gap: 18px;
}

.stats-head,
.stats-controls {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
}

.stats-head {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: clamp(18px, 4vw, 28px);
}

.stats-head h1 {
  margin: 0;
  font-size: clamp(28px, 5vw, 42px);
}

.stats-controls {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.stats-controls input {
  min-height: 42px;
  width: min(260px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: 0;
  background: var(--surface-2);
  color: var(--text);
  padding: 0 12px;
}

.stats-message {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
}

.stats-message.is-error {
  border-color: color-mix(in srgb, var(--danger) 54%, var(--line));
  background: color-mix(in srgb, var(--danger) 12%, transparent);
}

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

.metric-card,
.stats-panel,
.provider-stat {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.metric-card {
  display: grid;
  gap: 8px;
  min-height: 96px;
  align-content: center;
  padding: 16px;
}

.metric-card span,
.provider-stat span,
.provider-stat small,
.stats-table td span {
  color: var(--muted);
}

.metric-card strong {
  font-size: clamp(24px, 4vw, 34px);
  line-height: 1;
}

.metric-card.is-good strong {
  color: var(--accent);
}

.metric-card.is-bad strong {
  color: var(--danger);
}

.stats-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 18px;
}

.stats-panel {
  min-width: 0;
  padding: 16px;
}

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

.stats-table {
  width: 100%;
  min-width: 680px;
  border-collapse: collapse;
}

.stats-table th,
.stats-table td {
  border-bottom: 1px solid var(--line);
  padding: 12px 10px;
  text-align: left;
  vertical-align: top;
}

.stats-table th {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.stats-table td strong,
.stats-table td span {
  display: block;
}

.stats-table tr:last-child td {
  border-bottom: 0;
}

.provider-stats {
  display: grid;
  gap: 10px;
}

.provider-stat {
  display: grid;
  gap: 6px;
  padding: 14px;
}

.provider-stat small {
  line-height: 1.5;
}

@media (max-width: 860px) {
  .site-header {
    grid-template-columns: 1fr auto;
  }

  .top-nav {
    grid-column: 1 / -1;
    order: 3;
  }

  .content-layout {
    grid-template-columns: 1fr;
  }

  .import-page {
    grid-template-columns: 1fr;
  }

  .stats-grid,
  .metric-grid {
    grid-template-columns: 1fr;
  }

  .rank-panel {
    display: none;
  }

  .detail-card {
    grid-template-columns: 1fr;
  }

  .detail-poster {
    min-height: 220px;
  }
}

@media (max-width: 560px) {
  main,
  .site-header {
    width: min(100% - 20px, 1180px);
  }

  .hero-band {
    min-height: 250px;
  }

  .filter-strip {
    align-items: stretch;
    flex-direction: column;
  }

  .import-head,
  .field-grid,
  .import-actions,
  .stats-head,
  .stats-controls {
    align-items: stretch;
    flex-direction: column;
  }

  .field-table {
    grid-template-columns: 1fr;
  }

  .resource-grid {
    grid-template-columns: 1fr;
  }

  .provider-grid {
    grid-template-columns: 1fr;
  }

  .detail-main {
    padding: 22px;
  }
}
