/* ABHGD Leaderboard — design system */

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

:root {
  /* A calm, app-like palette inspired by modern community/chat clients. */
  --bg-base: #111214;
  --bg-surface: #1a1b1e;
  --bg-raised: #232428;
  --bg-input: #0f1012;
  --bg-hover: rgba(255, 255, 255, .055);

  --text-primary: #f2f3f5;
  --text-secondary: #b5bac1;
  --text-muted: #858b94;

  --brand: #5865f2;
  --brand-strong: #4752c4;
  --brand-soft: rgba(88, 101, 242, .18);

  --green: #23a55a;
  --green-soft: rgba(35, 165, 90, .15);
  --red: #f23f43;
  --red-soft: rgba(242, 63, 67, .15);
  --yellow: #f0b232;
  --yellow-soft: rgba(240, 178, 50, .15);
  --orange: #e67e22;
  --orange-soft: rgba(230, 126, 34, .16);
  --purple: #9b59b6;
  --purple-soft: rgba(155, 89, 182, .17);

  --gold: #f0b232;
  --silver: #c4c9ce;
  --bronze: #c78355;

  --border: rgba(255, 255, 255, .075);
  --border-strong: rgba(255, 255, 255, .14);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .24);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, .3);
  --shadow-lg: 0 20px 56px rgba(0, 0, 0, .42);

  --radius-sm: 5px;
  --radius: 8px;
  --radius-lg: 12px;

  --header-h: 56px;
  --maxw: 1180px;
  --sidebar-w: 236px;
  --speed: .14s;
}

:root[data-theme="light"] {
  --bg-base: #f2f3f5;
  --bg-surface: #ffffff;
  --bg-raised: #e9eaed;
  --bg-input: #e3e5e8;
  --bg-hover: rgba(6, 6, 7, .055);

  --text-primary: #2e3338;
  --text-secondary: #4e5058;
  --text-muted: #6d6f78;

  --brand: #5865f2;
  --brand-strong: #4752c4;
  --brand-soft: rgba(88, 101, 242, .11);

  --green: #16834b;
  --green-soft: rgba(22, 131, 75, .11);
  --red: #da373c;
  --red-soft: rgba(218, 55, 60, .1);
  --yellow: #9f6f12;
  --yellow-soft: rgba(159, 111, 18, .12);
  --orange: #b85e16;
  --orange-soft: rgba(184, 94, 22, .1);
  --purple: #7846a3;
  --purple-soft: rgba(120, 70, 163, .1);

  --border: rgba(6, 6, 7, .09);
  --border-strong: rgba(6, 6, 7, .17);

  --shadow-sm: 0 1px 2px rgba(20, 22, 25, .07);
  --shadow-md: 0 8px 24px rgba(20, 22, 25, .11);
  --shadow-lg: 0 20px 56px rgba(20, 22, 25, .16);
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}

html { scroll-behavior: smooth; }

body {
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg-base);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.5;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

svg { flex-shrink: 0; }
/* Safety net: icons rendered without an explicit size (no data-icon-size and
   no context rule below) would otherwise stretch to fill their flex parent. */
svg:not([width]) { width: 16px; height: 16px; }

:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  border-radius: 4px;
}

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

.skip-link {
  position: absolute; left: 12px; top: -60px; z-index: 300;
  background: var(--brand); color: #fff; padding: 10px 16px;
  border-radius: var(--radius-sm); font-weight: 600; text-decoration: none;
  transition: top var(--speed);
}
.skip-link:focus { top: 12px; }

/* ------------------------------------------------------------------ HEADER */

.header {
  background: color-mix(in srgb, var(--bg-surface) 88%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  height: var(--header-h);
  display: flex; align-items: center; gap: 12px;
  padding: 0 16px;
  position: sticky; top: 0; z-index: 100;
}

.header-brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.header-logo {
  width: 36px; height: 36px; border-radius: 11px;
  background: var(--brand);
  display: grid; place-items: center; color: #fff; flex-shrink: 0;
}
.header-logo svg { width: 18px; height: 18px; }
.header-title h1 { font-size: 15px; font-weight: 700; letter-spacing: -.2px; line-height: 1.2; }
.header-title p { font-size: 11px; color: var(--text-muted); line-height: 1.2; }

.header-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }

.icon-btn {
  background: transparent; border: 1px solid transparent;
  color: var(--text-secondary); cursor: pointer;
  width: 34px; height: 34px; border-radius: var(--radius-sm);
  display: grid; place-items: center; transition: all var(--speed);
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.icon-btn svg { width: 17px; height: 17px; }

.user-chip {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg-raised); border: 1px solid var(--border);
  border-radius: 999px; padding: 4px 6px 4px 4px;
  font-size: 13px; font-weight: 600; cursor: pointer;
  transition: all var(--speed); max-width: 200px;
}
.user-chip:hover { border-color: var(--border-strong); background: var(--bg-hover); }
.user-chip-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar {
  width: 26px; height: 26px; border-radius: 50%; flex-shrink: 0;
  background: linear-gradient(135deg, var(--brand), var(--purple));
  display: grid; place-items: center;
  font-size: 12px; font-weight: 700; color: #fff;
}
.avatar.lg { width: 60px; height: 60px; font-size: 24px; border-radius: 16px; }
.mod-dot {
  width: 7px; height: 7px; border-radius: 50%; background: var(--green);
  box-shadow: 0 0 0 2px var(--bg-raised);
}

/* --------------------------------------------------------------------- NAV */

.nav {
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  display: flex; gap: 2px; padding: 0 12px;
  overflow-x: auto; scrollbar-width: none;
  position: sticky; top: var(--header-h); z-index: 90;
}
.nav::-webkit-scrollbar { display: none; }

.nav-btn {
  background: none; border: none; color: var(--text-muted);
  padding: 11px 14px; font-size: 13px; font-weight: 600;
  cursor: pointer; border-bottom: 2px solid transparent;
  transition: all var(--speed); white-space: nowrap;
  font-family: inherit; display: flex; align-items: center; gap: 7px;
}
.nav-btn svg { width: 15px; height: 15px; }
.nav-btn:hover { color: var(--text-primary); }
.nav-btn[aria-selected="true"] { color: var(--brand); border-bottom-color: var(--brand); }

.badge-count {
  background: var(--red); color: #fff; font-size: 10px; font-weight: 700;
  padding: 1px 6px; border-radius: 999px; min-width: 18px; text-align: center;
}
.badge-count[data-empty="true"] { display: none; }

/* -------------------------------------------------------------------- MAIN */

.main { max-width: var(--maxw); margin: 0 auto; padding: 20px 14px 64px; }
.section { display: none; animation: fadeUp .22s ease; }
.section.active { display: block; }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

.page-head { margin-bottom: 16px; }
.page-head h2 {
  font-size: 20px; font-weight: 700; letter-spacing: -.3px;
  display: flex; align-items: center; gap: 9px;
}
.page-head h2 svg { width: 19px; height: 19px; color: var(--brand); }
.page-head p { font-size: 13px; color: var(--text-muted); margin-top: 3px; }

/* ------------------------------------------------------------------- CARDS */

.card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 14px;
  overflow: hidden;
}
.card-header {
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
}
.card-header h3 {
  font-size: 14px; font-weight: 650; flex: 1;
  display: flex; align-items: center; gap: 8px; min-width: 0;
}
.card-header h3 svg { width: 16px; height: 16px; color: var(--text-muted); }
.card-header .sub { font-size: 12px; color: var(--text-muted); font-weight: 400; }
.card-body { padding: 0; }
.card-body.padded { padding: 16px; }

.card.collapsible .card-header { cursor: pointer; user-select: none; }
.card.collapsible .card-header:hover { background: var(--bg-hover); }
.collapse-chevron {
  width: 16px; height: 16px; flex: 0 0 16px;
  transition: transform var(--speed); color: var(--text-muted);
}
.card.collapsed .collapse-chevron { transform: rotate(-90deg); }
.card.collapsed .card-body, .card.collapsed .toolbar { display: none; }

.toolbar {
  padding: 10px 12px; border-bottom: 1px solid var(--border);
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
}

/* ------------------------------------------------------------------- STATS */

.stats-row {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px; margin-bottom: 16px;
}
.stat-card {
  background: var(--bg-surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 16px;
  display: flex; align-items: center; gap: 12px;
}
.stat-icon {
  width: 36px; height: 36px; border-radius: 9px; display: grid; place-items: center;
  background: var(--brand-soft); color: var(--brand); flex-shrink: 0;
}
.stat-icon svg { width: 17px; height: 17px; }
.stat-icon.green { background: var(--green-soft); color: var(--green); }
.stat-icon.yellow { background: var(--yellow-soft); color: var(--yellow); }
.stat-icon.purple { background: var(--purple-soft); color: var(--purple); }
.stat-value { font-size: 20px; font-weight: 700; letter-spacing: -.4px; line-height: 1.15; }
.stat-label { font-size: 11px; color: var(--text-muted); font-weight: 500; }

/* ------------------------------------------------------------------ TABLES */

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th {
  background: var(--bg-raised); padding: 9px 14px; text-align: left;
  font-size: 11px; font-weight: 650; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .5px;
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
thead th.sortable { cursor: pointer; user-select: none; transition: color var(--speed); }
thead th.sortable:hover { color: var(--text-primary); }
thead th .sort-ind { display: inline-flex; vertical-align: -2px; margin-left: 4px; opacity: .45; }
thead th[aria-sort] .sort-ind { opacity: 1; color: var(--brand); }
thead th .sort-ind svg { width: 12px; height: 12px; }

tbody td { padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr.row-hover:hover { background: var(--bg-hover); }

.rank {
  font-weight: 700; color: var(--text-muted); font-variant-numeric: tabular-nums;
  display: inline-grid; place-items: center; min-width: 26px; height: 26px;
  border-radius: 7px; font-size: 13px;
}
.rank.g { background: rgba(227, 179, 65, .16); color: var(--gold); }
.rank.s { background: rgba(182, 190, 201, .16); color: var(--silver); }
.rank.b { background: rgba(205, 127, 69, .16); color: var(--bronze); }

.points {
  font-weight: 700; color: var(--brand); font-variant-numeric: tabular-nums; white-space: nowrap;
}

/* -------------------------------------------------------------- DEMON CELL */

.demon-cell { display: flex; align-items: center; gap: 10px; min-width: 0; }
.demon-thumb {
  width: 52px; height: 32px; border-radius: 5px; object-fit: cover; flex-shrink: 0;
  background: var(--bg-raised); border: 1px solid var(--border);
}
.no-thumb {
  width: 52px; height: 32px; border-radius: 5px; flex-shrink: 0;
  background: var(--bg-raised); border: 1px solid var(--border);
  display: grid; place-items: center; color: var(--text-muted);
}
.no-thumb svg { width: 14px; height: 14px; }
.demon-info { min-width: 0; }
.demon-name { font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.demon-sub { font-size: 11px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ------------------------------------------------------------------ BADGES */

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 999px;
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px;
  white-space: nowrap;
}
.badge svg { width: 10px; height: 10px; }
.badge.easy { background: var(--green-soft); color: var(--green); }
.badge.medium { background: var(--brand-soft); color: var(--brand); }
.badge.hard { background: var(--yellow-soft); color: var(--yellow); }
.badge.insane { background: var(--orange-soft); color: var(--orange); }
.badge.extreme { background: var(--red-soft); color: var(--red); }
.badge.plat { background: var(--purple-soft); color: var(--purple); }
.badge.neutral { background: var(--bg-raised); color: var(--text-secondary); }
.badge.mod { background: var(--green-soft); color: var(--green); }

/* -------------------------------------------------------------- COMPLETERS */

.completers { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--bg-raised); border: 1px solid var(--border);
  padding: 2px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 550; color: var(--text-secondary);
  text-decoration: none; transition: all var(--speed);
}
.chip svg { width: 10px; height: 10px; }
a.chip { color: var(--brand); }
a.chip:hover { background: var(--brand-soft); border-color: var(--brand); }

/* ------------------------------------------------------------------ BUTTONS */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 15px; border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 600; font-family: inherit;
  border: 1px solid transparent; cursor: pointer;
  transition: all var(--speed); white-space: nowrap; text-decoration: none;
  line-height: 1.2;
}
.btn svg { width: 15px; height: 15px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn:not(:disabled):active { transform: translateY(1px); }

.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:not(:disabled):hover { background: var(--brand-strong); }
.btn-success { background: var(--green); color: #fff; }
.btn-success:not(:disabled):hover { filter: brightness(1.1); }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:not(:disabled):hover { filter: brightness(1.1); }
.btn-ghost {
  background: var(--bg-raised); color: var(--text-secondary); border-color: var(--border);
}
.btn-ghost:not(:disabled):hover { background: var(--bg-hover); color: var(--text-primary); border-color: var(--border-strong); }
.btn-sm { padding: 6px 11px; font-size: 12px; }
.btn-sm svg { width: 13px; height: 13px; }
.btn-xs { padding: 4px 8px; font-size: 11px; gap: 4px; }
.btn-xs svg { width: 12px; height: 12px; }
.btn-block { width: 100%; }
.btn-icon { padding: 7px; }
.btn-icon svg { width: 15px; height: 15px; }

.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

/* ------------------------------------------------------------------- FORMS */

.field { margin-bottom: 13px; }
.field:last-child { margin-bottom: 0; }
.label {
  display: block; font-size: 11px; font-weight: 650; color: var(--text-secondary);
  text-transform: uppercase; letter-spacing: .5px; margin-bottom: 6px;
}
.label .req { color: var(--red); }
.hint { font-size: 11px; color: var(--text-muted); margin-top: 5px; }

.input, .select, .textarea {
  width: 100%; padding: 9px 12px;
  background: var(--bg-input); color: var(--text-primary);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: 13px; font-family: inherit; transition: all var(--speed);
}
.input::placeholder, .textarea::placeholder { color: var(--text-muted); }
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}
.input:disabled, .textarea:disabled { opacity: .55; cursor: not-allowed; }
.input[aria-invalid="true"] { border-color: var(--red); }
.textarea { resize: vertical; min-height: 76px; line-height: 1.5; }
.select { cursor: pointer; appearance: none; padding-right: 32px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236f7885' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
}

.field-error { font-size: 11px; color: var(--red); margin-top: 5px; display: none; }
.field-error.show { display: block; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 620px) { .grid-2 { grid-template-columns: 1fr; } }

.input-group { display: flex; gap: 7px; align-items: stretch; }
.input-group .input { flex: 1; min-width: 0; }

.check {
  display: flex; align-items: flex-start; gap: 9px;
  padding: 10px 12px; background: var(--bg-raised);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  cursor: pointer; transition: all var(--speed);
}
.check:hover { border-color: var(--border-strong); }
.check input { margin-top: 1px; width: 15px; height: 15px; accent-color: var(--brand); cursor: pointer; flex-shrink: 0; }
.check-text { font-size: 12.5px; font-weight: 550; }
.check-sub { font-size: 11px; color: var(--text-muted); margin-top: 1px; }

.search-input-wrap { position: relative; flex: 1; min-width: 180px; }
.search-input-wrap svg {
  position: absolute; left: 11px; top: 50%; transform: translateY(-50%);
  width: 15px; height: 15px; color: var(--text-muted); pointer-events: none;
}
.search-input-wrap .input { padding-left: 34px; }

/* ------------------------------------------------------------------ ALERTS */

.alert {
  display: none; align-items: flex-start; gap: 9px;
  padding: 11px 13px; border-radius: var(--radius-sm);
  font-size: 12.5px; margin-bottom: 13px; border: 1px solid transparent;
}
.alert.show { display: flex; }
.alert svg { width: 15px; height: 15px; margin-top: 1px; flex-shrink: 0; }
.alert-ok { background: var(--green-soft); color: var(--green); border-color: color-mix(in srgb, var(--green) 30%, transparent); }
.alert-err { background: var(--red-soft); color: var(--red); border-color: color-mix(in srgb, var(--red) 30%, transparent); }
.alert-info { background: var(--brand-soft); color: var(--brand); border-color: color-mix(in srgb, var(--brand) 30%, transparent); }
.alert-warn { background: var(--yellow-soft); color: var(--yellow); border-color: color-mix(in srgb, var(--yellow) 30%, transparent); }

/* ------------------------------------------------------------------ TOASTS */

.toast-region {
  position: fixed; bottom: 18px; right: 18px; z-index: 400;
  display: flex; flex-direction: column; gap: 8px; max-width: min(370px, calc(100vw - 36px));
}
.toast {
  display: flex; align-items: flex-start; gap: 10px;
  background: var(--bg-raised); border: 1px solid var(--border-strong);
  border-left: 3px solid var(--brand);
  border-radius: var(--radius-sm); padding: 11px 13px;
  box-shadow: var(--shadow-lg); font-size: 13px;
  animation: toastIn .2s cubic-bezier(.2, .9, .3, 1);
}
.toast.leaving { animation: toastOut .16s ease forwards; }
.toast svg { width: 16px; height: 16px; flex-shrink: 0; margin-top: 1px; }
.toast-body { flex: 1; min-width: 0; }
.toast-title { font-weight: 650; }
.toast-msg { color: var(--text-secondary); font-size: 12px; margin-top: 1px; overflow-wrap: anywhere; }
.toast-close { background: none; border: none; color: var(--text-muted); cursor: pointer; padding: 2px; }
.toast-close:hover { color: var(--text-primary); }
.toast.ok { border-left-color: var(--green); } .toast.ok > svg { color: var(--green); }
.toast.err { border-left-color: var(--red); } .toast.err > svg { color: var(--red); }
.toast.info { border-left-color: var(--brand); } .toast.info > svg { color: var(--brand); }
.toast.warn { border-left-color: var(--yellow); } .toast.warn > svg { color: var(--yellow); }

@keyframes toastIn { from { opacity: 0; transform: translateX(20px) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateX(20px) scale(.97); } }

@media (max-width: 560px) {
  .toast-region { left: 12px; right: 12px; bottom: 12px; max-width: none; }
}

/* ------------------------------------------------------------------- MODAL */

.modal-backdrop {
  position: fixed; inset: 0; z-index: 350;
  background: rgba(0, 0, 0, .6); backdrop-filter: blur(3px);
  display: grid; place-items: center; padding: 18px;
  animation: fadeIn .14s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: var(--bg-surface); border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  width: 100%; max-width: 420px; overflow: hidden;
  animation: modalIn .18s cubic-bezier(.2, .9, .3, 1);
}
@keyframes modalIn { from { opacity: 0; transform: scale(.96) translateY(8px); } to { opacity: 1; transform: none; } }

.modal-head { padding: 16px 18px 0; display: flex; align-items: center; gap: 10px; }
.modal-icon { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; flex-shrink: 0; }
.modal-icon svg { width: 17px; height: 17px; }
.modal-icon.danger { background: var(--red-soft); color: var(--red); }
.modal-icon.warn { background: var(--yellow-soft); color: var(--yellow); }
.modal-icon.info { background: var(--brand-soft); color: var(--brand); }
.modal-head h3 { font-size: 15px; font-weight: 650; }
.modal-body { padding: 12px 18px 18px; font-size: 13px; color: var(--text-secondary); line-height: 1.55; }
.modal-foot { padding: 0 18px 18px; display: flex; gap: 8px; justify-content: flex-end; }

/* ------------------------------------------------------------------- EMPTY */

.empty { padding: 40px 20px; text-align: center; }
.empty-icon {
  width: 46px; height: 46px; border-radius: 13px; margin: 0 auto 12px;
  background: var(--bg-raised); display: grid; place-items: center; color: var(--text-muted);
}
.empty-icon svg { width: 21px; height: 21px; }
.empty h4 { font-size: 14px; font-weight: 650; margin-bottom: 4px; }
.empty p { font-size: 12.5px; color: var(--text-muted); max-width: 340px; margin: 0 auto; }
.empty .btn { margin-top: 14px; }

/* ---------------------------------------------------------------- SKELETON */

.skeleton {
  background: linear-gradient(90deg, var(--bg-raised) 25%, var(--bg-hover) 50%, var(--bg-raised) 75%);
  background-size: 200% 100%; animation: shimmer 1.3s infinite;
  border-radius: 5px;
}
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.skel-row { display: flex; align-items: center; gap: 12px; padding: 11px 14px; border-bottom: 1px solid var(--border); }
.skel-row:last-child { border-bottom: none; }

.spinner {
  width: 15px; height: 15px; border: 2px solid var(--border-strong);
  border-top-color: var(--brand); border-radius: 50%;
  animation: spin .6s linear infinite; flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }
.btn .spinner { border-top-color: currentColor; border-color: rgba(255,255,255,.3); border-top-color: #fff; }

/* -------------------------------------------------------------- QUOTA METER */

.quota {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; background: var(--bg-raised);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  margin-bottom: 14px;
}
.quota-info { flex: 1; min-width: 0; }
.quota-top { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 6px; }
.quota-label { font-size: 12px; font-weight: 600; }
.quota-count { font-size: 12px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.quota-bar { height: 6px; background: var(--bg-input); border-radius: 999px; overflow: hidden; }
.quota-fill {
  height: 100%; border-radius: 999px; background: var(--green);
  transition: width .3s cubic-bezier(.2,.9,.3,1), background-color .3s;
}
.quota-fill.warn { background: var(--yellow); }
.quota-fill.full { background: var(--red); }
.quota-dots { display: flex; gap: 4px; flex-shrink: 0; }
.quota-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--bg-input); border: 1px solid var(--border-strong); }
.quota-dot.used { background: var(--brand); border-color: var(--brand); }

/* ------------------------------------------------------------------ VERIFY */

.steps { display: flex; gap: 6px; margin-bottom: 18px; }
.step {
  flex: 1; display: flex; align-items: center; gap: 8px;
  padding: 9px 11px; border-radius: var(--radius-sm);
  background: var(--bg-raised); border: 1px solid var(--border);
  font-size: 12px; font-weight: 600; color: var(--text-muted);
  transition: all var(--speed); min-width: 0;
}
.step-num {
  width: 20px; height: 20px; border-radius: 50%; flex-shrink: 0;
  background: var(--bg-input); border: 1px solid var(--border-strong);
  display: grid; place-items: center; font-size: 10px; font-weight: 700;
}
.step-num svg { width: 11px; height: 11px; }
.step-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.step.active { background: var(--brand-soft); border-color: var(--brand); color: var(--brand); }
.step.active .step-num { background: var(--brand); border-color: var(--brand); color: #fff; }
.step.done { color: var(--green); border-color: color-mix(in srgb, var(--green) 35%, transparent); background: var(--green-soft); }
.step.done .step-num { background: var(--green); border-color: var(--green); color: #fff; }
@media (max-width: 560px) { .step-label { display: none; } .step { flex: 0 0 auto; justify-content: center; } }

.code-box {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--bg-input); border: 2px dashed var(--border-strong);
  border-radius: var(--radius); padding: 16px 18px; margin-bottom: 8px;
  cursor: pointer; transition: all var(--speed);
}
.code-box svg { width: 24px; height: 24px; flex-shrink: 0; }
.code-box:hover { border-color: var(--brand); background: var(--brand-soft); }
.code-text {
  font-family: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  font-size: clamp(16px, 4.4vw, 22px); font-weight: 700; letter-spacing: 1.5px;
  color: var(--brand); overflow-wrap: anywhere;
}
.code-timer { font-size: 11px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.code-timer.expiring { color: var(--red); font-weight: 600; }

.instructions { counter-reset: step; margin: 14px 0; }
.instructions li {
  list-style: none; position: relative; padding: 6px 0 6px 30px;
  font-size: 12.5px; color: var(--text-secondary);
}
.instructions li::before {
  counter-increment: step; content: counter(step);
  position: absolute; left: 0; top: 6px;
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--bg-raised); border: 1px solid var(--border);
  display: grid; place-items: center; font-size: 10px; font-weight: 700; color: var(--text-muted);
}

/* ----------------------------------------------------------------- PROFILE */

.profile-head { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; flex-wrap: wrap; }
.profile-name { font-size: 19px; font-weight: 700; letter-spacing: -.3px; }
.profile-meta { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 5px; }
.profile-stat { font-size: 12.5px; color: var(--text-muted); }
.profile-stat strong { color: var(--text-primary); font-weight: 700; font-size: 14px; }
.profile-desc {
  background: var(--bg-raised); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 12px 14px;
  font-size: 13px; margin-bottom: 16px; line-height: 1.6; overflow-wrap: anywhere;
  white-space: pre-wrap;
}
.profile-desc.muted { color: var(--text-muted); font-style: italic; }

.divider { height: 1px; background: var(--border); margin: 18px 0; }
.section-title { font-size: 13px; font-weight: 650; margin-bottom: 11px; display: flex; align-items: center; gap: 7px; }
.section-title svg { width: 15px; height: 15px; color: var(--text-muted); }

/* -------------------------------------------------------------- SUB CARDS */

.sub-card { padding: 14px 16px; border-bottom: 1px solid var(--border); transition: opacity .3s; }
.sub-card:last-child { border-bottom: none; }
.sub-card.resolving { opacity: .35; pointer-events: none; }
.sub-title { font-size: 14px; font-weight: 650; margin-bottom: 5px; overflow-wrap: anywhere; }
.sub-title .by { font-weight: 400; color: var(--text-muted); }
.sub-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 11.5px; color: var(--text-muted); margin-bottom: 10px; }
.sub-meta .who { display: inline-flex; align-items: center; gap: 4px; font-weight: 600; color: var(--text-secondary); }
.sub-meta svg { width: 12px; height: 12px; }
.proof-link {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--bg-raised); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 7px 11px; margin-bottom: 11px;
  font-size: 12px; color: var(--brand); text-decoration: none;
  max-width: 100%; overflow: hidden; transition: all var(--speed);
}
.proof-link:hover { border-color: var(--brand); background: var(--brand-soft); }
.proof-link span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.proof-link svg { width: 13px; height: 13px; flex-shrink: 0; }

.review-box {
  background: var(--bg-raised); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 12px; margin-bottom: 11px;
}
.exists-note {
  display: flex; align-items: center; gap: 7px;
  font-size: 12px; color: var(--text-secondary); margin-bottom: 11px;
  background: var(--brand-soft); border-radius: var(--radius-sm); padding: 8px 11px;
}
.exists-note svg { width: 14px; height: 14px; color: var(--brand); }

/* ------------------------------------------------------------- ADMIN LISTS */

.list-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 13px; border-bottom: 1px solid var(--border);
}
.list-item:last-child { border-bottom: none; }
.list-item:hover { background: var(--bg-hover); }
.list-thumb { width: 34px; height: 22px; border-radius: 4px; object-fit: cover; flex-shrink: 0; border: 1px solid var(--border); }
.list-info { flex: 1; min-width: 0; }
.list-name { font-size: 12.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-sub { font-size: 11px; color: var(--text-muted); }
.list-actions { display: flex; gap: 5px; flex-shrink: 0; }

.btn-del {
  background: none; border: none; color: var(--text-muted); cursor: pointer;
  padding: 5px; border-radius: 5px; display: grid; place-items: center; transition: all var(--speed);
}
.btn-del:hover { color: var(--red); background: var(--red-soft); }
.btn-del svg { width: 14px; height: 14px; }

/* ------------------------------------------------------------ COMBO SELECT */

.combo { position: relative; }
.combo-list {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 60;
  background: var(--bg-surface); border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-md);
  max-height: 230px; overflow-y: auto; display: none;
}
.combo-list.open { display: block; }
.combo-item {
  display: flex; align-items: center; gap: 9px; padding: 8px 11px;
  cursor: pointer; border-bottom: 1px solid var(--border); font-size: 12.5px;
}
.combo-item:last-child { border-bottom: none; }
.combo-item:hover, .combo-item.active { background: var(--brand-soft); }
.combo-item[aria-selected="true"] { color: var(--brand); font-weight: 600; }
.combo-item img { width: 30px; height: 19px; border-radius: 3px; object-fit: cover; flex-shrink: 0; }
.combo-item .ci-name { font-weight: 550; }
.combo-item .ci-sub { font-size: 11px; color: var(--text-muted); }
.combo-empty { padding: 11px; text-align: center; color: var(--text-muted); font-size: 12px; }

/* ------------------------------------------------------------------- MISC */

.text-muted { color: var(--text-muted); }
.text-sm { font-size: 12px; }
.mt-2 { margin-top: 8px; } .mt-3 { margin-top: 12px; }
.mb-2 { margin-bottom: 8px; } .mb-3 { margin-bottom: 12px; }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }

.back-btn {
  display: inline-flex; align-items: center; gap: 7px;
  background: none; border: none; color: var(--text-muted);
  font-size: 13px; font-weight: 600; font-family: inherit;
  cursor: pointer; padding: 7px 0; margin-bottom: 6px; transition: color var(--speed);
}
.back-btn:hover { color: var(--text-primary); }
.back-btn svg { width: 15px; height: 15px; }

.progress-line { height: 4px; background: var(--bg-input); border-radius: 999px; overflow: hidden; margin: 8px 0; }
.progress-fill { height: 100%; background: var(--brand); border-radius: 999px; transition: width .25s; }

.result-log {
  max-height: 220px; overflow-y: auto; font-size: 11.5px;
  background: var(--bg-input); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 9px 11px; margin-top: 9px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.result-log div { padding: 1px 0; }

/* --------------------------------------------------------- MOBILE TABLES */

@media (max-width: 700px) {
  .main { padding: 16px 10px 56px; }
  .hide-sm { display: none !important; }
  thead th, tbody td { padding: 9px 10px; }
  .demon-thumb, .no-thumb { width: 42px; height: 27px; }
}

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ========================================================================== */
/* Public app shell — compact, channel-based navigation                       */
/* ========================================================================== */

.public-app {
  background: var(--bg-base);
}

.public-app .header {
  background: var(--bg-surface);
  backdrop-filter: none;
  box-shadow: 0 1px 0 var(--border), var(--shadow-sm);
}

.public-app .header-brand {
  flex: 0 0 var(--sidebar-w);
  padding-right: 18px;
}

.public-app .header-logo,
.public-app .avatar {
  background: var(--brand);
  box-shadow: none;
}

.public-app .header-logo {
  width: 36px;
  height: 36px;
  border-radius: 11px;
}

.header-context {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding-left: 2px;
}

.context-icon {
  color: var(--text-muted);
  display: grid;
  place-items: center;
}

.context-icon svg { width: 19px; height: 19px; }
.context-title { font-size: 14px; font-weight: 700; line-height: 1.2; }
.context-subtitle { color: var(--text-muted); font-size: 11px; line-height: 1.3; }

.public-app .user-chip {
  border: 0;
  background: var(--bg-raised);
  border-radius: var(--radius-sm);
  padding: 4px 8px 4px 4px;
}

.public-app .nav {
  background: #17181b;
  border: 0;
  padding: 13px 9px 10px;
  gap: 3px;
}

:root[data-theme="light"] .public-app .nav { background: #e3e5e8; }

.public-app .nav-label {
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 750;
  letter-spacing: .08em;
  padding: 7px 9px 4px;
  text-transform: uppercase;
}

.public-app .nav-btn {
  position: relative;
  width: 100%;
  min-height: 40px;
  border: 0;
  border-radius: 5px;
  padding: 9px 11px;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 550;
  justify-content: flex-start;
}

.public-app .nav-btn svg { width: 18px; height: 18px; }
.public-app .nav-btn:hover { color: var(--text-primary); background: var(--bg-hover); }
.public-app .nav-btn[aria-selected="true"] { color: var(--text-primary); background: var(--bg-raised); }
.public-app .nav-btn[aria-selected="true"]::before {
  content: "";
  position: absolute;
  left: -9px;
  top: 9px;
  bottom: 9px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--text-primary);
}

.sidebar-status {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-top: auto;
  padding: 11px 10px 5px;
  color: var(--text-secondary);
  border-top: 1px solid var(--border);
}

.sidebar-status > span:last-child { display: flex; flex-direction: column; min-width: 0; }
.sidebar-status strong { font-size: 11px; font-weight: 650; }
.sidebar-status small { color: var(--text-muted); font-size: 10px; white-space: nowrap; }
.status-dot { width: 8px; height: 8px; flex: 0 0 auto; border-radius: 50%; background: var(--green); }

.public-app .main { padding: 30px 28px 72px; }
.public-app .page-head { margin-bottom: 20px; }
.public-app .page-head h2 { font-size: clamp(22px, 2.3vw, 28px); letter-spacing: -.025em; }
.public-app .page-head h2 svg { width: 22px; height: 22px; }
.public-app .page-head p { color: var(--text-secondary); font-size: 13px; margin-top: 5px; }

.public-app .card,
.public-app .stat-card {
  border-color: var(--border);
  box-shadow: none;
}

.public-app .card { background: var(--bg-surface); }
.public-app .stat-card { background: var(--bg-surface); padding: 15px 16px; }
.public-app .stat-icon { border-radius: 8px; }
.public-app .stat-value { font-size: 19px; }
.public-app .stat-label { color: var(--text-secondary); font-size: 11px; }

.public-app thead th {
  background: rgba(0, 0, 0, .12);
  color: var(--text-muted);
  padding-top: 10px;
  padding-bottom: 10px;
}

:root[data-theme="light"] .public-app thead th { background: rgba(6, 6, 7, .035); }
.public-app tbody td { padding-top: 11px; padding-bottom: 11px; }
.public-app tbody tr.row-hover { transition: background-color var(--speed); }
.public-app tbody tr.row-hover:hover { background: var(--bg-hover); }

.demon-open {
  display: flex;
  width: 100%;
  min-width: 0;
  align-items: center;
  gap: 10px;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  cursor: pointer;
  font: inherit;
  text-align: left;
}

.demon-open:hover .demon-name { color: var(--brand); text-decoration: underline; text-underline-offset: 2px; }
.demon-open .demon-info { flex: 1; }
.demon-open .demon-name,
.demon-open .demon-sub { display: block; }
.public-app .demon-thumb,
.public-app .no-thumb { width: 58px; height: 36px; border-radius: 4px; }
.public-app .demon-name { font-size: 13.5px; }
.public-app .demon-sub { margin-top: 1px; }

.public-app .badge,
.public-app .chip { border-radius: 4px; }
.public-app .chip { border-color: transparent; background: var(--bg-raised); }
.public-app .points { color: var(--text-primary); }

.public-app .input,
.public-app .select,
.public-app .textarea {
  border-color: transparent;
  background-color: var(--bg-input);
  min-height: 40px;
}

.public-app .input:focus,
.public-app .select:focus,
.public-app .textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 1px var(--brand);
}

.public-app .btn { border-radius: 4px; min-height: 36px; }
.public-app .btn-ghost { background: var(--bg-raised); border-color: transparent; }
.public-app .btn-ghost:not(:disabled):hover { background: #35373c; border-color: transparent; }
:root[data-theme="light"] .public-app .btn-ghost:not(:disabled):hover { background: #d5d7da; }

.auth-intro {
  display: flex;
  gap: 11px;
  padding: 12px;
  margin-bottom: 16px;
  border-radius: var(--radius-sm);
  background: var(--brand-soft);
  color: var(--text-secondary);
}

.auth-intro-icon {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
}
.auth-intro-icon svg { width: 17px; height: 17px; }
.auth-intro strong { display: block; color: var(--text-primary); font-size: 12.5px; margin-top: 1px; }
.auth-intro p { font-size: 11.5px; margin-top: 2px; }

/* Demon page */
.demon-detail-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(310px, .9fr);
  overflow: hidden;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: 16px;
}

.demon-detail-cover {
  position: relative;
  min-height: 330px;
  background: #0b0c0e;
  overflow: hidden;
}

.demon-detail-cover::after {
  content: "";
  position: absolute;
  inset: auto 0 0;
  height: 35%;
  background: linear-gradient(transparent, rgba(0, 0, 0, .34));
  pointer-events: none;
}

.demon-detail-cover img { width: 100%; height: 100%; min-height: 330px; display: block; object-fit: cover; }
.demon-detail-placeholder {
  width: 100%;
  height: 100%;
  min-height: 330px;
  display: grid;
  place-items: center;
  color: var(--text-muted);
  background: radial-gradient(circle at 50% 35%, var(--bg-raised), #0b0c0e 68%);
}
.demon-detail-placeholder svg { width: 42px; height: 42px; opacity: .55; }

.demon-detail-copy { display: flex; flex-direction: column; padding: 28px; min-width: 0; }
.demon-detail-kicker {
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 750;
  letter-spacing: .1em;
  text-transform: uppercase;
  margin-bottom: 10px;
}
.demon-detail-title {
  font-size: clamp(27px, 3.4vw, 42px);
  line-height: 1.04;
  letter-spacing: -.045em;
  overflow-wrap: anywhere;
}
.demon-detail-creator { color: var(--text-secondary); font-size: 14px; margin-top: 8px; }
.demon-detail-badges { display: flex; flex-wrap: wrap; gap: 6px; margin: 18px 0 22px; }
.demon-detail-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: auto; padding-top: 22px; }

.demon-facts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  border-top: 1px solid var(--border);
  border-left: 1px solid var(--border);
}
.demon-fact { padding: 12px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.demon-fact strong { display: block; font-size: 17px; line-height: 1.15; }
.demon-fact span { display: block; margin-top: 3px; color: var(--text-muted); font-size: 10px; text-transform: uppercase; letter-spacing: .05em; }

.completion-card .card-header { padding: 15px 17px; }
.completion-list { display: flex; flex-direction: column; }
.completion-row {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  align-items: center;
  gap: 11px;
  min-height: 61px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
}
.completion-row:last-child { border-bottom: 0; }
.completion-row:hover { background: var(--bg-hover); }
.completion-player {
  display: block;
  width: fit-content;
  max-width: 100%;
  overflow: hidden;
  padding: 0;
  border: 0;
  background: none;
  color: var(--text-primary);
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  font-weight: 650;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.completion-player:hover { color: var(--brand); text-decoration: underline; }
.completion-meta { color: var(--text-muted); font-size: 11px; margin-top: 2px; }
.completion-proof { min-width: 92px; }
.detail-empty { padding: 34px 20px; color: var(--text-muted); text-align: center; }
.detail-empty svg { width: 24px; height: 24px; margin-bottom: 8px; }

@media (min-width: 841px) {
  .public-app {
    display: grid;
    grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
    grid-template-rows: var(--header-h) minmax(0, 1fr);
    height: 100vh;
    min-height: 0;
    overflow: hidden;
  }

  .public-app .header {
    position: relative;
    grid-column: 1 / -1;
    grid-row: 1;
    padding: 0 14px;
  }

  .public-app .header-brand {
    align-self: stretch;
    display: flex;
    border-right: 1px solid var(--border);
  }

  .public-app .nav {
    position: relative;
    top: auto;
    z-index: 20;
    grid-column: 1;
    grid-row: 2;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    overflow-y: auto;
  }

  .public-app .main {
    grid-column: 2;
    grid-row: 2;
    width: 100%;
    max-width: none;
    margin: 0;
    overflow-y: auto;
  }

  .public-app .main > .section { width: min(100%, var(--maxw)); margin: 0 auto; }
}

@media (max-width: 840px) {
  .public-app .header-brand { flex: 0 1 auto; padding-right: 0; }
  .public-app .header-title p { display: none; }
  .public-app .header-context { display: none; }
  .public-app .nav { padding: 4px 9px; gap: 3px; }
  .public-app .nav-label,
  .public-app .sidebar-status { display: none; }
  .public-app .nav-btn { width: auto; min-height: 42px; padding: 9px 12px; font-size: 13px; }
  .public-app .nav-btn[aria-selected="true"]::before { left: 12px; right: 12px; top: auto; bottom: -4px; width: auto; height: 2px; }
  .public-app .main { padding: 22px 14px 58px; }
  .demon-detail-hero { grid-template-columns: 1fr; }
  .demon-detail-cover,
  .demon-detail-cover img,
  .demon-detail-placeholder { min-height: 0; aspect-ratio: 16 / 9; }
}

@media (max-width: 620px) {
  .public-app .header { padding: 0 10px; }
  .public-app .header-title h1 { font-size: 14px; }
  .public-app .user-chip-name { display: none; }
  .public-app .nav-btn { justify-content: center; flex: 1 0 auto; }
  .public-app .stats-row { grid-template-columns: 1fr 1fr; }
  .public-app .stat-card:last-child { grid-column: 1 / -1; }
  #demon-table th:nth-child(5),
  #demon-table td:nth-child(5) { display: none; }
  .demon-detail-copy { padding: 22px 18px; }
  .demon-detail-actions .btn { flex: 1 1 auto; }
  .completion-row { grid-template-columns: 30px minmax(0, 1fr) auto; padding: 10px 12px; }
  .completion-proof { min-width: 0; padding: 7px; }
  .completion-proof span { display: none; }
}
