:root {
  color-scheme: dark;
  --bg: #0a0a0c;
  --bg-2: #111114;
  --bg-3: #19191e;
  --surface: #121215;
  --surface-hover: #17171b;
  --topbar-bg: rgba(10, 10, 12, 0.82);

  --border: #232329;
  --border-2: #32323a;
  --highlight: inset 0 1px 0 rgba(255, 255, 255, 0.04);

  --text: #f4f4f6;
  --text-2: #a1a1aa;
  --text-3: #71717a;

  --accent: #3b82f6;
  --accent-hover: #60a5fa;
  --accent-2: #2563eb;
  --accent-soft: rgba(59, 130, 246, 0.14);

  --green: #22c55e;
  --green-soft: rgba(34, 197, 94, 0.14);
  --danger: #ef4444;
  --danger-hover: #dc2626;
  --danger-soft: rgba(239, 68, 68, 0.14);

  --radius: 6px;
  --radius-lg: 10px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.55);

  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", "SF Mono", Menlo, Consolas, monospace;
}

[data-theme="light"] {
  color-scheme: light;
  --bg: #fafafa;
  --bg-2: #f4f4f5;
  --bg-3: #e4e4e7;
  --surface: #ffffff;
  --surface-hover: #fafafa;
  --topbar-bg: rgba(255, 255, 255, 0.85);

  --border: #e4e4e7;
  --border-2: #d4d4d8;
  --highlight: inset 0 1px 0 rgba(255, 255, 255, 0.8);

  --text: #18181b;
  --text-2: #52525b;
  --text-3: #71717a;

  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-2: #1d4ed8;
  --accent-soft: rgba(37, 99, 235, 0.08);

  --green: #16a34a;
  --green-soft: rgba(22, 163, 74, 0.1);
  --danger: #dc2626;
  --danger-hover: #b91c1c;
  --danger-soft: rgba(220, 38, 38, 0.08);

  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 1px 3px rgba(0, 0, 0, 0.03);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.08);
}

*, *::before, *::after { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14.5px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

::selection {
  background: var(--accent-soft);
  color: var(--accent-hover);
}

a { color: var(--accent); text-decoration: none; transition: color 0.15s ease; }
a:hover { color: var(--accent-hover); text-decoration: underline; }

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

.container { max-width: 1180px; margin: 0 auto; padding: 0 24px; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--topbar-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner { display: flex; align-items: center; gap: 24px; height: 60px; }

.brand {
  font-weight: 700;
  font-size: 17px;
  color: var(--text);
  letter-spacing: -0.02em;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.brand:hover { color: var(--text); text-decoration: none; opacity: 0.9; }

.nav { display: flex; gap: 4px; flex: 1; }
.nav a {
  color: var(--text-2);
  padding: 6px 11px;
  border-radius: var(--radius);
  font-size: 13.5px;
  font-weight: 500;
  transition: color 0.15s, background 0.15s;
}
.nav a:hover, .nav a.active {
  color: var(--text);
  background: var(--bg-3);
  text-decoration: none;
}

.auth { display: flex; align-items: center; gap: 8px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-family: var(--font);
  font-size: 13.5px;
  font-weight: 500;
  line-height: 1.2;
  padding: 8px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border-2);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--highlight), var(--shadow);
  cursor: pointer;
  user-select: none;
  transition: background 0.12s ease, border-color 0.12s ease, transform 0.08s ease;
}
.btn:hover { background: var(--bg-3); border-color: var(--text-3); }
.btn:active { transform: translateY(1px); }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18), var(--shadow);
}
.btn-primary:hover { background: var(--accent-2); border-color: var(--accent-2); color: #fff; }

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-2);
  box-shadow: none;
}
.btn-ghost:hover { background: var(--bg-3); color: var(--text); border-color: transparent; }

.btn-sm { padding: 5px 10px; font-size: 12.5px; }

.btn-danger {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.15), var(--shadow);
}
.btn-danger:hover { background: var(--danger-hover); border-color: var(--danger-hover); color: #fff; }

.hidden { display: none !important; }

main { padding: 32px 0 80px; min-height: calc(100vh - 130px); }
.footer {
  border-top: 1px solid var(--border);
  padding: 24px 0;
  color: var(--text-3);
  font-size: 13px;
  background: var(--bg-2);
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: var(--highlight), var(--shadow);
}
.card + .card { margin-top: 16px; }

h1 { font-size: 26px; font-weight: 700; margin: 0 0 6px; letter-spacing: -0.025em; color: var(--text); }
h2 { font-size: 18px; font-weight: 600; margin: 0 0 12px; letter-spacing: -0.015em; color: var(--text); }
h3 { font-size: 14.5px; font-weight: 600; margin: 0 0 8px; color: var(--text-2); }
p { margin: 0 0 12px; color: var(--text-2); }
.muted { color: var(--text-3); font-size: 13px; }
.mono { font-family: var(--mono); font-size: 12.5px; }

.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }

.input, select, textarea {
  font-family: var(--font);
  font-size: 13.5px;
  color: var(--text);
  background: var(--bg-2);
  border: 1px solid var(--border-2);
  border-radius: var(--radius);
  padding: 8px 11px;
  outline: none;
  width: 100%;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}
.input::placeholder, textarea::placeholder { color: var(--text-3); }
.input:hover, select:hover, textarea:hover { border-color: var(--text-3); }
.input:focus, select:focus, textarea:focus {
  background: var(--surface);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
textarea { min-height: 110px; resize: vertical; line-height: 1.5; }
textarea.mono { font-family: var(--mono); font-size: 13px; }

.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 20px; }
.toolbar .input { max-width: 300px; }
.toolbar select { max-width: 170px; }

.mod-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }

.mod-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: var(--highlight), var(--shadow);
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}
.mod-card:hover {
  background: var(--surface-hover);
  border-color: var(--border-2);
  box-shadow: var(--highlight), var(--shadow-lg);
}

.mod-card-head { display: flex; gap: 12px; align-items: flex-start; }
.mod-logo {
  width: 52px;
  height: 52px;
  border-radius: 8px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  flex-shrink: 0;
  object-fit: contain;
  padding: 4px;
}

.mod-title {
  font-weight: 600;
  font-size: 15.5px;
  color: var(--text);
  letter-spacing: -0.01em;
  transition: color 0.15s;
}
.mod-card:hover .mod-title { color: var(--accent-hover); }

.mod-id { font-size: 12px; color: var(--text-3); font-family: var(--mono); margin-top: 1px; }
.mod-desc {
  font-size: 13px;
  color: var(--text-2);
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 37px;
}
.mod-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--text-3);
  align-items: center;
  font-variant-numeric: tabular-nums;
  margin-top: auto;
  padding-top: 4px;
}

.tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border-radius: 4px;
  background: var(--bg-3);
  border: 1px solid var(--border);
  font-size: 11px;
  color: var(--text-2);
  font-weight: 500;
  letter-spacing: 0.01em;
}
.tag.featured {
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 32%, transparent);
  color: var(--accent-hover);
}
.tag.green {
  background: var(--green-soft);
  border-color: color-mix(in srgb, var(--green) 32%, transparent);
  color: var(--green);
}

.badge-row { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0; }
.badge-row img { height: 20px; border-radius: 4px; }

.detail-header {
  display: flex;
  gap: 20px;
  align-items: flex-start;
  margin-bottom: 24px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.detail-logo {
  width: 88px;
  height: 88px;
  border-radius: 12px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  object-fit: contain;
  padding: 6px;
}
.detail-title { font-size: 28px; font-weight: 700; margin: 0; letter-spacing: -0.025em; }
.detail-id { font-family: var(--mono); font-size: 13px; color: var(--text-3); margin-top: 3px; }
.detail-stats {
  display: flex;
  gap: 20px;
  margin-top: 12px;
  font-size: 13px;
  color: var(--text-2);
  flex-wrap: wrap;
  font-variant-numeric: tabular-nums;
}
.detail-stats strong { color: var(--text); font-weight: 600; }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 20px; }
.tab {
  padding: 9px 14px;
  color: var(--text-2);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  font-size: 13.5px;
  font-weight: 500;
  transition: color 0.15s, border-color 0.15s;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }
.tabpane { display: none; }
.tabpane.active { display: block; }

.version-list { display: flex; flex-direction: column; gap: 10px; }
.version-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  box-shadow: var(--highlight);
  transition: border-color 0.15s;
}
.version-item:hover { border-color: var(--border-2); }
.version-meta { font-size: 13px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.version-meta strong { color: var(--text); font-family: var(--mono); }

.md { white-space: pre-wrap; word-wrap: break-word; font-size: 14px; color: var(--text-2); line-height: 1.65; }
.md h1, .md h2, .md h3 { color: var(--text); margin-top: 20px; }
.md code {
  font-family: var(--mono);
  font-size: 12.5px;
  background: var(--bg-3);
  border: 1px solid var(--border);
  padding: 2px 5px;
  border-radius: 4px;
  color: var(--text);
}

.form { display: flex; flex-direction: column; gap: 16px; max-width: 600px; }
.form label { font-size: 13px; color: var(--text); font-weight: 500; display: block; margin-bottom: 6px; }
.form .hint { font-size: 12px; color: var(--text-3); margin-top: 5px; }

.table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.table th, .table td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--border); font-size: 13.5px; }
.table th {
  color: var(--text-3);
  font-weight: 600;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--bg-2);
}
.table tbody tr:hover { background: var(--bg-2); }
.table tbody tr:last-child td { border-bottom: none; }

.empty { text-align: center; padding: 64px 20px; color: var(--text-3); }
.empty h3 { color: var(--text-2); margin-bottom: 6px; font-size: 16px; }

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-3);
  border: 1px solid var(--border-2);
  color: var(--text);
  padding: 10px 16px;
  border-radius: var(--radius);
  font-size: 13.5px;
  font-weight: 500;
  box-shadow: var(--highlight), var(--shadow-lg);
  z-index: 100;
}

.loading { text-align: center; padding: 64px 20px; color: var(--text-3); }
.skeleton {
  background: linear-gradient(90deg, var(--bg-2) 0%, var(--bg-3) 50%, var(--bg-2) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
  border-radius: var(--radius);
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
.skeleton-card { height: 124px; border-radius: var(--radius-lg); }
.skeleton-row { height: 16px; margin-bottom: 10px; }
.skeleton-row.short { width: 60%; }

#notif-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 17px;
  height: 17px;
  padding: 0 5px;
  background: var(--danger);
  color: #fff;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  margin-left: 4px;
}

@media (max-width: 640px) {
  .container { padding: 0 16px; }
  .topbar-inner { gap: 12px; }
  .nav { display: none; }
  .mod-grid { grid-template-columns: 1fr; }
  .detail-title { font-size: 22px; }
  .toolbar .input, .toolbar select { max-width: 100%; }
}

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }
.text-sm { font-size: 13px; }
.text-xs { font-size: 12px; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }
.text-muted { color: var(--text-3); }
.rounded { border-radius: var(--radius); }
.rounded-lg { border-radius: var(--radius-lg); }
.shadow { box-shadow: var(--shadow); }
.shadow-lg { box-shadow: var(--shadow-lg); }
.border { border: 1px solid var(--border); }
.bg-white { background: var(--surface); }
.p-4 { padding: 16px; }
.p-6 { padding: 24px; }
.w-full { width: 100%; }

#bg-canvas {
  position: fixed;
  inset: 0;
  z-index: -1;
  width: 100%;
  height: 100%;
  pointer-events: none;
  opacity: 0.25;
}
