:root {
  --bg: #0d0d0d;
  --surface-1: #151619;
  --surface-2: #1c1e22;
  --surface-3: #24272c;
  --border: #34373d;
  --text: #f0f0f0;
  --muted: #b9bec7;
  --accent: #d4af37;
  --accent-soft: rgba(212, 175, 55, 0.2);
}

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

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
}

.layout {
  min-height: 100vh;
}

.top-nav {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 12px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  background: #121317;
}

.brand {
  font-weight: 700;
  font-size: 24px;
  line-height: 1.1;
  color: var(--accent);
  min-width: 0;
  flex: 1;
}

.nav-menu-toggle {
  display: none;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  padding: 0 12px;
  margin: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-3);
  color: var(--text);
  cursor: pointer;
}

.nav-menu-toggle-bars {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.nav-menu-toggle-bar {
  display: block;
  width: 22px;
  height: 2px;
  border-radius: 1px;
  background: currentColor;
}

.top-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
  align-items: center;
}

.top-link {
  color: var(--muted);
  text-decoration: none;
  padding: 8px 10px;
  border-radius: 6px;
  border: 1px solid transparent;
}

.top-link:hover,
.top-link.active {
  color: var(--text);
  border-color: var(--accent);
  background: var(--accent-soft);
}

.main-content {
  max-width: 1280px;
  margin: 0 auto;
  padding: 20px;
  display: flex;
  gap: 16px;
}

.side-nav {
  width: 240px;
  flex-shrink: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  padding: 12px;
  height: fit-content;
}

.side-nav-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.side-nav-title {
  margin: 0;
  font-size: 18px;
  min-width: 0;
  flex: 1;
  line-height: 1.25;
}

.side-nav-toggle {
  display: none;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  padding: 0 12px;
  margin: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-3);
  color: var(--text);
  cursor: pointer;
}

.side-nav-toggle-bars {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.side-nav-toggle-bar {
  display: block;
  width: 22px;
  height: 2px;
  border-radius: 1px;
  background: currentColor;
}

.side-nav-panel {
  min-width: 0;
}

.side-links {
  display: grid;
  gap: 6px;
}

.side-link {
  color: var(--muted);
  text-decoration: none;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 8px;
}

.side-link:hover,
.side-link.active {
  color: var(--text);
  background: var(--accent-soft);
  border-color: var(--accent);
}

.content-area {
  flex: 1;
  min-width: 0;
}

.page-card,
.controls,
.table-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.page-card {
  padding: 16px;
}

.page-card:has(.guide-markdown) {
  padding: 22px 24px 28px;
}

.guide-markdown {
  width: 100%;
  min-width: 0;
  font-family: system-ui, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 1.0625rem;
  line-height: 1.7;
  letter-spacing: 0.01em;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  color: var(--text);
}

.guide-markdown > *:first-child {
  margin-top: 0;
}

.guide-markdown > *:last-child {
  margin-bottom: 0;
}

.guide-markdown h1,
.guide-markdown h2,
.guide-markdown h3,
.guide-markdown h4,
.guide-markdown h5,
.guide-markdown h6 {
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: 0.02em;
  color: var(--text);
}

.guide-markdown h1 {
  margin: 0 0 1rem;
  padding-bottom: 0.65rem;
  font-size: 1.85rem;
  color: var(--accent);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 0 0 var(--accent-soft);
}

.guide-markdown h2 {
  margin: 2.25rem 0 0.85rem;
  font-size: 1.35rem;
  color: #f5e6b8;
  padding-bottom: 0.3rem;
  border-bottom: 1px solid rgba(212, 175, 55, 0.35);
}

.guide-markdown h2:first-of-type,
.guide-markdown h1 + h2 {
  margin-top: 1.25rem;
}

.guide-markdown h3 {
  margin: 1.75rem 0 0.6rem;
  font-size: 1.12rem;
  color: var(--muted);
}

.guide-markdown h4 {
  margin: 1.5rem 0 0.5rem;
  font-size: 1.02rem;
  color: var(--muted);
}

.guide-markdown h5,
.guide-markdown h6 {
  margin: 1.25rem 0 0.45rem;
  font-size: 0.95rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.guide-markdown p {
  margin: 0 0 1rem;
  color: #e8eaef;
}

.guide-markdown a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-color: rgba(212, 175, 55, 0.45);
  text-underline-offset: 0.15em;
  word-break: break-word;
  transition: color 0.15s ease, text-decoration-color 0.15s ease;
}

.guide-markdown a:hover {
  color: #f0d878;
  text-decoration-color: var(--accent);
}

.guide-markdown strong {
  color: #fff8e8;
  font-weight: 700;
}

.guide-markdown em {
  color: var(--muted);
  font-style: italic;
}

.guide-markdown ul,
.guide-markdown ol {
  margin: 0 0 1rem;
  padding-left: 1.35rem;
  color: #e8eaef;
}

.guide-markdown li {
  margin: 0.4rem 0;
  color: inherit;
}

.guide-markdown li::marker {
  color: var(--accent);
}

.guide-markdown ul ul,
.guide-markdown ul ol,
.guide-markdown ol ul,
.guide-markdown ol ol {
  margin-bottom: 0.35rem;
}

.guide-markdown blockquote {
  margin: 1.25rem 0;
  padding: 0.85rem 1rem 0.85rem 1.1rem;
  border-left: 4px solid var(--accent);
  border-radius: 0 8px 8px 0;
  background: linear-gradient(90deg, var(--accent-soft), transparent 55%);
  color: var(--muted);
  font-style: italic;
}

.guide-markdown blockquote p {
  margin: 0 0 0.65rem;
  color: inherit;
}

.guide-markdown blockquote p:last-child {
  margin-bottom: 0;
}

.guide-markdown hr {
  margin: 2rem 0;
  border: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent) 20%, var(--border) 50%, var(--accent) 80%, transparent);
  opacity: 0.85;
}

.guide-markdown details {
  margin: 1.1rem 0;
  padding: 0.75rem 0.95rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-3);
}

.guide-markdown summary {
  cursor: pointer;
  font-weight: 700;
  color: var(--accent);
}

.guide-markdown summary > * {
  display: inline;
}

.guide-markdown .video-embed {
  position: relative;
  width: var(--embed-width, 100%);
  max-width: 100%;
  margin: 1rem auto;
  aspect-ratio: var(--embed-aspect-ratio, 16 / 9);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: #000;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
}

.guide-markdown .video-embed iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

.guide-markdown img,
.guide-markdown video {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  border: 1px solid var(--border);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
}

.guide-markdown pre,
.guide-markdown code {
  max-width: 100%;
  font-family: ui-monospace, "Cascadia Code", "Segoe UI Mono", Consolas, monospace;
}

.guide-markdown code {
  font-size: 0.9em;
  padding: 0.15em 0.4em;
  border-radius: 5px;
  background: var(--surface-3);
  border: 1px solid var(--border);
  color: #f5e6b8;
}

.guide-markdown pre code {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: inherit;
}

.guide-markdown pre {
  overflow-x: auto;
  margin: 1rem 0;
  padding: 14px 16px;
  border-radius: 8px;
  background: var(--surface-1);
  border: 1px solid var(--border);
  box-shadow: inset 0 0 0 1px var(--accent-soft);
  font-size: 0.88rem;
  line-height: 1.55;
}

.guide-markdown table {
  width: 100%;
  max-width: 100%;
  margin: 1.25rem 0;
  border-collapse: collapse;
  font-size: 0.95rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.2);
}

.guide-markdown thead {
  background: linear-gradient(180deg, rgba(212, 175, 55, 0.14), var(--surface-3));
}

.guide-markdown th {
  padding: 10px 12px;
  text-align: left;
  font-weight: 700;
  color: var(--accent);
  border-bottom: 1px solid var(--border);
}

.guide-markdown td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  color: #e8eaef;
  word-break: break-word;
}

.guide-markdown tbody tr:nth-child(even) {
  background: rgba(255, 255, 255, 0.02);
}

.guide-markdown tbody tr:last-child td {
  border-bottom: 0;
}

h1 {
  margin: 0 0 6px;
}

.sub,
.muted,
#status {
  margin-top: 0;
  color: var(--muted);
}

.controls {
  padding: 12px;
  margin-bottom: 14px;
}

.type-toggles {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 10px;
}

.toggle-option {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  font-weight: 600;
}

.toggle-option input {
  width: auto;
  min-width: 22px;
  min-height: 22px;
  margin: 0;
}

label {
  display: block;
  margin-bottom: 6px;
  font-weight: 600;
}

input,
select {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface-1);
  color: var(--text);
  margin-bottom: 10px;
  box-sizing: border-box;
  font-size: 16px;
}

.xp-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

.xp-stats {
  margin-top: 12px;
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.xp-stat-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-3);
  padding: 10px;
  display: grid;
  gap: 6px;
}

.xp-progress {
  margin-top: 12px;
  height: 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
  background: var(--surface-1);
}

#xpProgressBar {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--accent), #ff9f42);
  transition: width 180ms ease;
}

.xp-level-tables {
  margin-top: 14px;
}

.xp-tables-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.xp-table-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-3);
  padding: 10px;
}

.xp-table-card h3 {
  margin: 0 0 8px;
  color: var(--text);
}

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

.xp-table th,
.xp-table td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
}

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

.numeric {
  text-align: right;
}

.control-row {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 10px;
}

button {
  background: var(--accent);
  border: 0;
  color: #161616;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
  min-height: 44px;
  padding: 10px 14px;
}

.table-card {
  margin-bottom: 12px;
  overflow: hidden;
}

.group-section {
  margin-bottom: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
}

.group-summary {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 8px 12px;
  padding: 10px 12px;
  cursor: pointer;
  font-weight: 700;
  color: var(--text);
  list-style: none;
}

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

.group-content {
  padding: 8px;
}

.location-section {
  margin-bottom: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-3);
}

.location-summary {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 6px 10px;
  padding: 8px 10px;
  cursor: pointer;
  color: var(--text);
  list-style: none;
}

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

.table-head {
  padding: 10px;
  border-bottom: 1px solid var(--border);
}

.table-title {
  font-weight: 700;
}

.drop-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  padding: 10px;
}

.drop-item {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  padding: 10px;
}

.drop-thumb-wrap {
  border-radius: 6px;
  overflow: hidden;
  background: var(--surface-1);
  border: 1px solid var(--border);
  margin-bottom: 8px;
}

.drop-thumb {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
}

.drop-thumb.is-missing {
  display: none;
}

.drop-name {
  font-weight: 600;
  margin-bottom: 4px;
}

.drop-meta {
  color: var(--muted);
  font-size: 12px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th,
td {
  text-align: left;
  border-bottom: 1px solid #273548;
  padding: 8px 10px;
}

th {
  color: #9fb0c2;
}

@media (max-width: 768px) {
  .top-nav {
    position: relative;
    padding: 12px 14px;
  }

  .brand {
    font-size: 20px;
    flex: 1 1 auto;
  }

  .nav-menu-toggle {
    display: inline-flex;
  }

  .top-links {
    display: none;
    flex-direction: column;
    align-items: stretch;
    flex-basis: 100%;
    width: 100%;
    max-height: min(70vh, calc(100dvh - 120px));
    overflow-y: auto;
    padding: 4px 0 8px;
    margin: 0;
    gap: 4px;
    -webkit-overflow-scrolling: touch;
  }

  .top-nav.top-nav--open .top-links {
    display: flex;
  }

  .top-link {
    padding: 12px 14px;
    text-align: left;
  }

  .main-content {
    flex-direction: column;
    padding: 12px 14px;
    gap: 12px;
  }

  .side-nav {
    width: 100%;
    order: -1;
  }

  .side-nav-header {
    margin-bottom: 0;
  }

  .side-nav-toggle {
    display: inline-flex;
  }

  .side-nav-panel {
    display: none;
    margin-top: 0;
    padding-top: 0;
  }

  .side-nav.side-nav--open .side-nav-header {
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
  }

  .side-nav.side-nav--open .side-nav-panel {
    display: block;
    max-height: min(55vh, 360px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .control-row {
    grid-template-columns: 1fr;
  }

  .drop-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  }

  .xp-tables-grid {
    grid-template-columns: 1fr;
  }

  .type-toggles {
    align-items: stretch;
  }

  .type-toggles button {
    width: 100%;
  }

  .guide-markdown table {
    font-size: 13px;
  }

  .group-summary span:last-child,
  .location-summary span:last-child {
    font-size: 13px;
    font-weight: 600;
    color: var(--muted);
    text-align: right;
    max-width: 100%;
  }
}

@media (min-width: 769px) {
  .top-nav {
    flex-wrap: nowrap;
  }

  .brand {
    flex: 0 1 auto;
  }

  .top-links {
    flex: 1;
    justify-content: flex-end;
  }

  .type-toggles button {
    width: auto;
  }
}
