:root,
[data-theme="dark"] {
  --bg: #080b10;
  --panel: #111720;
  --panel2: #182231;
  --fg: #e6edf6;
  --muted: #8a97ad;
  --border: #243049;
  --accent: #55b8ff;
  --accent-warm: #ffb454;
  --accent-green: #62d394;
  --shadow: rgba(0, 0, 0, 0.4);
}

[data-theme="light"] {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --panel2: #eef2f8;
  --fg: #10151f;
  --muted: #5b6675;
  --border: #d8dfea;
  --accent: #1f6fe0;
  --accent-warm: #a86000;
  --accent-green: #177a46;
  --shadow: rgba(20, 30, 50, 0.08);
}

:root {
  --r-common: #9aa6b5;
  --r-uncommon: #5dca8b;
  --r-rare: #3a86e8;
  --r-epic: #9b6bff;
  --r-legendary: #ffab4c;
  --r-mythic: #ff5cf0;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--fg);
  font: 15px/1.6 system-ui, -apple-system, Segoe UI, sans-serif;
}

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

a:hover {
  text-decoration: underline;
}

.muted {
  color: var(--muted);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 0.9rem;
  min-height: 58px;
  padding: 0.65rem 1rem;
  background: color-mix(in srgb, var(--panel) 92%, transparent);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px);
}

.brand {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 0.65rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel2);
  font-weight: 600;
  color: var(--fg);
  letter-spacing: 0;
}

.brand:hover {
  border-color: var(--accent);
  text-decoration: none;
}

.topbar-title {
  color: var(--muted);
  font-size: 0.82rem;
  white-space: nowrap;
}

.search {
  flex: 1;
  max-width: 620px;
  padding: 0.45rem 0.7rem;
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--fg);
}

.search-results {
  position: absolute;
  top: 56px;
  right: 1.2rem;
  z-index: 10;
  width: min(360px, calc(100vw - 2.4rem));
  max-height: 420px;
  overflow: auto;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 16px 36px var(--shadow);
}

.search-results a {
  display: block;
  padding: 0.45rem 0.7rem;
  color: var(--fg);
}

.search-results a:hover {
  background: var(--panel2);
  text-decoration: none;
}

.toggle {
  width: 36px;
  height: 36px;
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--fg);
  cursor: pointer;
  font-size: 18px;
}

.wiki-frame {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  gap: 1.4rem;
  max-width: 1440px;
  margin: 0 auto;
  padding: 1.2rem;
}

.site-sidebar {
  position: sticky;
  top: 74px;
  align-self: start;
  max-height: calc(100vh - 92px);
  overflow: auto;
  padding: 0.7rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 16px 36px var(--shadow);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  min-height: 54px;
  margin-bottom: 0.9rem;
  padding: 0.45rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel2);
}

.sidebar-brand img {
  display: block;
  width: min(100%, 170px);
  height: auto;
}

.sidebar-brand:hover {
  border-color: var(--accent);
  text-decoration: none;
}

.sidebar-section + .sidebar-section {
  margin-top: 0.9rem;
  padding-top: 0.9rem;
  border-top: 1px solid var(--border);
}

.sidebar-section h2 {
  margin: 0 0 0.45rem;
  padding: 0 0.25rem;
  border: 0;
  color: var(--accent-warm);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.sidebar-link {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.75rem;
  align-items: center;
  min-height: 36px;
  padding: 0.45rem 0.55rem;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--fg);
}

.sidebar-link small {
  color: var(--muted);
  font-size: 0.7rem;
}

.sidebar-link:hover {
  background: var(--panel2);
  border-color: var(--border);
  text-decoration: none;
}

.sidebar-link-active {
  background: color-mix(in srgb, var(--accent) 16%, var(--panel2));
  border-color: color-mix(in srgb, var(--accent) 50%, var(--border));
}

.sidebar-link-active small {
  color: var(--accent-green);
}

.sidebar-expand {
  width: 100%;
  margin: 0 0 12px;
  padding: 6px 8px;
  font: inherit;
  font-size: 12px;
  color: var(--muted);
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
}

.sidebar-expand:hover {
  color: var(--fg);
}

.sidebar-section > summary {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  list-style: none;
}

.sidebar-section > summary::-webkit-details-marker {
  display: none;
}

.sidebar-section > summary::before {
  width: 0;
  height: 0;
  content: '';
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  border-left: 4px solid currentColor;
  transition: transform 120ms ease;
}

.sidebar-section[open] > summary::before {
  transform: rotate(90deg);
}

.sidebar-section > summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.page {
  display: grid;
  grid-template-areas: 'body info' 'body toc' 'related .';
  grid-template-columns: minmax(0, 1fr) 240px;
  gap: 24px;
  align-items: start;
}

.page-body {
  grid-area: body;
  min-width: 0;
  overflow-x: auto;
}

.infobox {
  grid-area: info;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.page-toc {
  position: sticky;
  top: 76px;
  grid-area: toc;
}

.page-related {
  grid-area: related;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.infobox dl {
  display: grid;
  grid-template-columns: auto;
  gap: 8px;
  margin: 0;
}

.infobox dt,
.page-toc h2,
.page-related h2 {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.infobox dd {
  margin: 0 0 4px;
}

.page-toc ul,
.page-related ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.page-toc li {
  margin: 0 0 4px;
}

.page-related ul {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.wiki-table {
  width: 100%;
  margin: 12px 0 20px;
  border-collapse: collapse;
  font-size: 13px;
}

.wiki-table th,
.wiki-table td {
  padding: 6px 10px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.wiki-table th {
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.wiki-table .num {
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.wiki-table .empty {
  color: var(--muted);
  font-style: italic;
}

.hub-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  margin-top: 20px;
}

.hub-card {
  padding: 16px 18px;
  border: 1px solid var(--border);
  border-radius: 10px;
}

.hub-card h2 {
  margin: 0 0 6px;
  font-size: 15px;
}

.hub-card p {
  margin: 0 0 10px;
  font-size: 13px;
}

.hub-card ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.hub-card li {
  margin: 0 0 6px;
}

@media (max-width: 900px) {
  .page {
    grid-template-areas: 'info' 'toc' 'body' 'related';
    grid-template-columns: minmax(0, 1fr);
  }

  .page-toc {
    position: static;
  }
}

.wiki-main {
  min-width: 0;
}

.layout {
  display: grid;
  grid-template-columns: 190px 1fr;
  gap: 1rem;
  padding: 0;
}

.sidebar {
  position: sticky;
  top: 74px;
  align-self: start;
  padding: 0.8rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.sidebar .side-h {
  margin: 0 0 0.5rem;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
}

.sidebar a {
  display: block;
  padding: 0.2rem 0;
  color: var(--fg);
  text-transform: capitalize;
}

.content {
  min-width: 0;
  max-width: 980px;
}

.item-index {
  max-width: 1120px;
}

.section-tabs {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin: 0 0 1rem;
  padding: 0.55rem;
  overflow-x: auto;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.section-tabs-title {
  flex: 0 0 auto;
  color: var(--accent-warm);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.section-tabs a {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 0.4rem;
  min-height: 32px;
  padding: 0.25rem 0.6rem;
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--fg);
  text-transform: capitalize;
}

.section-tabs a:hover {
  border-color: var(--accent);
  text-decoration: none;
}

h1 {
  margin: 0.2rem 0 1rem;
  font-size: 1.6rem;
}

h1 small,
h2 small {
  color: var(--muted);
  font-size: 0.6em;
  font-weight: 400;
}

h2 {
  margin: 1.6rem 0 0.8rem;
  padding-bottom: 0.3rem;
  border-bottom: 1px solid var(--border);
  font-size: 1.1rem;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 0.7rem;
}

.card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  padding: 0.8rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--fg);
  text-align: center;
  transition: border-color 0.15s, transform 0.1s;
}

.card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  text-decoration: none;
}

.icon {
  width: 48px;
  height: 48px;
  object-fit: contain;
}

.icon-text {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--panel2);
  border-radius: 8px;
  color: var(--muted);
  font-size: 13px;
}

.card-name {
  font-size: 0.85rem;
  font-weight: 500;
}

.r {
  padding: 0.05rem 0.4rem;
  border-radius: 10px;
  color: #08101c;
  font-size: 0.62rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.r-common {
  background: var(--r-common);
}

.r-uncommon {
  background: var(--r-uncommon);
}

.r-rare {
  background: var(--r-rare);
  color: #fff;
}

.r-epic {
  background: var(--r-epic);
  color: #fff;
}

.r-legendary {
  background: var(--r-legendary);
}

.r-mythic {
  background: var(--r-mythic);
  color: #fff;
}

.item {
  max-width: 840px;
  padding: 0.3rem 0 2rem;
}

.back {
  display: inline-block;
  margin-bottom: 1rem;
}

.item-head {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.item-head .icon {
  width: 72px;
  height: 72px;
}

.meta {
  color: var(--muted);
  text-transform: capitalize;
}

.desc {
  font-size: 1.05rem;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.chip {
  padding: 0.25rem 0.6rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.85rem;
}

.chip i {
  color: var(--muted);
  font-size: 0.75rem;
  font-style: normal;
}

.drop-sources {
  margin-top: 1.5rem;
}

.drop-source {
  display: grid;
  grid-template-columns: minmax(220px, 0.8fr) minmax(0, 1.2fr);
  gap: 0.9rem;
  margin: 0.7rem 0;
  padding: 0.85rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.drop-source h3 {
  margin: 0;
  font-size: 0.98rem;
}

.drop-source p {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 0.86rem;
}

.drop-locations {
  display: grid;
  gap: 0.35rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.drop-locations li {
  padding: 0.35rem 0.5rem;
  background: var(--panel2);
  border-radius: 6px;
  font-size: 0.86rem;
}

.drop-unmapped {
  align-self: center;
}

.stats,
.ingredients {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0;
  list-style: none;
}

.stats li,
.ingredients li {
  padding: 0.3rem 0.6rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 0.35rem 0.6rem;
  border: 1px solid var(--border);
  text-align: left;
}

th {
  background: var(--panel);
}

@media (max-width: 720px) {
  .topbar {
    flex-wrap: wrap;
  }

  .topbar-title {
    display: none;
  }

  .search {
    order: 3;
    flex-basis: 100%;
    max-width: none;
  }

  .wiki-frame {
    grid-template-columns: 1fr;
    padding: 0.8rem;
  }

  .site-sidebar {
    position: static;
    display: flex;
    gap: 0.75rem;
    max-height: none;
    overflow-x: auto;
  }

  .drop-source {
    grid-template-columns: 1fr;
  }

  .sidebar-brand {
    flex: 0 0 160px;
    margin-bottom: 0;
  }

  .sidebar-section {
    min-width: 180px;
  }

  .sidebar-section + .sidebar-section {
    margin-top: 0;
    padding-top: 0;
    padding-left: 0.75rem;
    border-top: 0;
    border-left: 1px solid var(--border);
  }

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

  .sidebar {
    position: static;
  }
}
