:root {
  color-scheme: dark;
  --bg: #101419;
  --panel: #171d24;
  --panel-2: #1d252e;
  --line: #2b3642;
  --text: #eef3f6;
  --muted: #94a4b2;
  --accent: #e5c65a;
  --accent-2: #6fb4d8;
  --good: #8bd090;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Segoe UI", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 24px;
  min-height: 48px;
  padding: 0 28px;
  background: #0d1218;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 5;
}

.brand {
  color: var(--accent);
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}

.nav-menu {
  display: flex;
  align-items: stretch;
  gap: 4px;
  min-width: 0;
}

.nav-item {
  position: relative;
}

.nav-item button {
  height: 48px;
  border: 0;
  border-left: 1px solid transparent;
  border-right: 1px solid transparent;
  background: transparent;
  color: var(--text);
  padding: 0 13px;
  font: inherit;
  cursor: pointer;
}

.nav-item button::after {
  content: "";
  display: inline-block;
  margin-left: 7px;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid var(--muted);
  vertical-align: middle;
}

.nav-item:hover button,
.nav-item:focus-within button {
  background: var(--panel);
  border-color: var(--line);
  color: var(--accent);
}

.dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  width: 420px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 2px;
  padding: 10px;
  background: #111820;
  border: 1px solid var(--line);
  box-shadow: 0 16px 28px rgba(0, 0, 0, 0.28);
  visibility: hidden;
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 120ms ease, transform 120ms ease, visibility 120ms ease;
}

.dropdown.compact {
  width: 250px;
  grid-template-columns: 1fr;
}

.nav-item:hover .dropdown,
.nav-item:focus-within .dropdown {
  visibility: visible;
  opacity: 1;
  transform: translateY(0);
}

.dropdown a {
  color: var(--accent-2);
  text-decoration: none;
  padding: 8px;
  border-radius: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dropdown a:hover,
.dropdown a.active {
  color: var(--accent);
  background: var(--panel-2);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 20px 28px;
  border-bottom: 1px solid var(--line);
  background: #121820;
}

h1 {
  margin: 0;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: 0;
}

p { margin: 4px 0 0; color: var(--muted); }

.meta {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.meta span {
  border: 1px solid var(--line);
  background: var(--panel);
  padding: 6px 9px;
  border-radius: 6px;
  color: var(--muted);
  font-size: 13px;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 410px;
  min-height: calc(100vh - 127px);
}

.browser {
  min-width: 0;
  border-right: 1px solid var(--line);
}

.filters {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 240px 150px;
  gap: 10px;
  padding: 14px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 1;
}

body[data-view="patterns"] .filters {
  grid-template-columns: minmax(220px, 1fr) 220px 240px 150px;
}

[hidden] {
  display: none !important;
}

input, select {
  width: 100%;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #0f141a;
  color: var(--text);
  padding: 0 10px;
  font: inherit;
}

input[type="range"] {
  height: 22px;
  padding: 0;
  accent-color: var(--accent);
}

.groups { padding-bottom: 24px; }

.group {
  border-bottom: 1px solid var(--line);
}

.group-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 14px;
  background: #121820;
  border-bottom: 1px solid var(--line);
  color: var(--accent);
  font-weight: 700;
}

.group-title span:last-child {
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
}

.thead, .row {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) 136px 48px 52px 52px repeat(6, 52px);
  align-items: center;
}

.symbiant-head,
.symbiant-row {
  grid-template-columns: minmax(420px, 1fr) 70px 90px 70px;
  column-gap: 18px;
}

.weapon-head,
.weapon-row {
  grid-template-columns: minmax(420px, 1fr) 64px 118px 96px 72px;
  column-gap: 16px;
}

.armor-head,
.armor-row {
  grid-template-columns: minmax(420px, 1fr) 64px 190px 190px 82px;
  column-gap: 16px;
}

.utility-head,
.utility-row {
  grid-template-columns: minmax(420px, 1fr) 64px 190px 190px 82px;
  column-gap: 16px;
}

.tradeskill-head,
.tradeskill-row {
  grid-template-columns: minmax(420px, 1fr) 64px 180px 220px 82px;
  column-gap: 16px;
}

.pattern-head,
.pattern-row {
  grid-template-columns: minmax(360px, 1fr) 64px 130px 260px 190px 82px;
  column-gap: 16px;
}

.pattern-head.no-flags,
.pattern-row.no-flags {
  grid-template-columns: minmax(360px, 1fr) 64px 130px 260px 190px;
}

.thead {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0;
  border-bottom: 1px solid var(--line);
  background: #121820;
  min-height: 34px;
  padding: 0 14px;
}

.thead span:not(:first-child) { text-align: right; }
.thead span:nth-child(2) { text-align: left; }

.row {
  min-height: 58px;
  border-bottom: 1px solid #202a34;
  padding: 7px 14px;
  cursor: pointer;
}

.symbiant-row {
  min-height: 92px;
}

.weapon-row {
  min-height: 76px;
}

.armor-row {
  min-height: 76px;
}

.utility-row {
  min-height: 76px;
}

.tradeskill-row {
  min-height: 76px;
}

.pattern-row {
  min-height: 76px;
}

.part-strip {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 5px;
  align-items: center;
}

.part-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 22px;
  padding: 2px 6px;
  border: 1px solid #39505e;
  background: #14212a;
  color: var(--accent-2);
  font-size: 12px;
  white-space: nowrap;
}

.part-badge strong {
  color: var(--accent);
}

.part-badge.missing,
.part-badge.muted {
  color: var(--muted);
  border-color: #2c3944;
  background: #111820;
}

.row:hover, .row.active { background: var(--panel-2); }
.row:nth-child(even) { background: #141b22; }

.namecell {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.icon {
  width: 34px;
  height: 34px;
  image-rendering: pixelated;
  border: 1px solid var(--line);
  background: #050708;
}

.title {
  display: block;
  color: var(--accent);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sub {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.source-inline {
  display: block;
  margin-top: 3px;
  color: var(--good);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.linepill {
  width: max-content;
  max-width: 160px;
  color: var(--accent-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.location {
  color: var(--accent-2);
  font-size: 12px;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding-right: 10px;
}

.num { color: var(--good); font-variant-numeric: tabular-nums; }
.row > .num, .thead > span:not(:first-child) { text-align: right; }
.blank { color: #536170; }

.detail {
  padding: 20px;
  background: #11171e;
  position: sticky;
  top: 48px;
  height: calc(100vh - 127px);
  overflow: auto;
}

.placeholder {
  padding: 30px;
  color: var(--muted);
}

.placeholder h2 {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 22px;
  letter-spacing: 0;
}

.detail-head {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  margin-bottom: 16px;
}

.detail .icon { width: 48px; height: 48px; }

.detail h2 {
  margin: 0;
  color: var(--accent);
  font-size: 21px;
  line-height: 1.2;
  letter-spacing: 0;
}

.parts-panel {
  margin-top: 14px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.parts-panel h3 {
  margin: 0 0 10px;
  color: var(--accent);
  font-size: 14px;
  font-weight: 700;
}

.parts-grid {
  display: grid;
  gap: 8px;
}

.part-card {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  padding: 8px;
  border: 1px solid var(--line);
  background: #131a21;
}

.part-card.missing {
  opacity: 0.72;
}

.part-title {
  color: var(--accent-2);
  font-size: 13px;
}

.part-title strong {
  color: var(--accent);
}

.part-name,
.part-meta {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.part-empty {
  display: block;
  border-style: dashed;
}

.kv {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  gap: 8px 12px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}

.kv span:nth-child(odd) { color: var(--muted); }

.qlbox {
  border-top: 1px solid var(--line);
  padding: 12px 0;
}

.qlbox-head,
.qlbox-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.qlbox-head {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
}

.qlbox-head strong {
  color: var(--accent);
  font-size: 18px;
}

.qlbox-foot {
  margin-top: 6px;
  color: var(--muted);
  font-size: 11px;
}

.desc {
  border-top: 1px solid var(--line);
  padding-top: 14px;
  line-height: 1.5;
}

.source-note {
  margin-top: 12px;
  color: var(--muted);
  line-height: 1.45;
  font-size: 13px;
}

.reqbox {
  border-top: 1px solid var(--line);
  padding: 14px 0;
}

.sourcebox {
  border-top: 1px solid var(--line);
  padding: 14px 0;
}

.reqbox h3,
.sourcebox h3 {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0;
}

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

.sourcegrid {
  display: grid;
  gap: 8px;
}

.sourcecard {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 6px;
  padding: 10px;
}

.source-title {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
  padding-bottom: 8px;
  border-bottom: 1px solid #24303b;
}

.source-title strong {
  color: var(--accent);
  font-size: 13px;
  line-height: 1.25;
}

.source-title span {
  flex: 0 0 auto;
  color: var(--good);
  font-size: 12px;
}

.sourcecard dl {
  display: grid;
  grid-template-columns: 86px minmax(0, 1fr);
  gap: 6px 10px;
  margin: 9px 0 0;
  font-size: 12px;
  line-height: 1.35;
}

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

.sourcecard dd {
  margin: 0;
  color: var(--good);
  overflow-wrap: anywhere;
}

.source-empty {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 6px;
  padding: 10px;
  color: var(--muted);
  font-size: 13px;
}

.reqgroups {
  display: grid;
  gap: 12px;
}

.reqgroup h4 {
  margin: 0 0 7px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.reqgrid div {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 6px;
  padding: 8px;
  min-width: 0;
}

.reqgrid span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.reqgrid strong {
  display: block;
  margin-top: 2px;
  color: var(--good);
  font-size: 13px;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.stats {
  margin-top: 14px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.stats h3 {
  margin: 0 0 8px;
  font-size: 14px;
  color: var(--muted);
  letter-spacing: 0;
}

.statgrid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  font-size: 13px;
}

.statgrid div {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 7px;
  background: var(--panel);
  overflow: hidden;
  text-overflow: ellipsis;
}

.statgrid span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.statgrid strong {
  display: block;
  margin-top: 2px;
  color: var(--good);
  font-size: 13px;
  font-weight: 600;
}

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

@media (max-width: 900px) {
  .site-nav {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
    padding: 10px 14px;
    position: static;
  }
  .nav-menu {
    width: 100%;
    overflow-x: auto;
  }
  .dropdown {
    position: fixed;
    left: 12px;
    right: 12px;
    width: auto;
    max-height: 70vh;
    overflow: auto;
  }
  .layout { grid-template-columns: 1fr; }
  .browser { border-right: 0; }
  .detail { position: static; height: auto; border-top: 1px solid var(--line); }
  .filters { grid-template-columns: 1fr; }
  body[data-view="patterns"] .filters { grid-template-columns: 1fr; }
  .browser { overflow-x: auto; }
  .groups { min-width: 980px; }
  body[data-view="symbiants"] .browser { overflow-x: hidden; }
  body[data-view="symbiants"] .groups { min-width: 0; }
  body[data-view="symbiants"] .symbiant-head,
  body[data-view="symbiants"] .symbiant-row {
    grid-template-columns: minmax(300px, 1fr) 52px 74px 56px;
    column-gap: 12px;
  }
  body[data-view="weapons"] .groups { min-width: 760px; }
  body[data-view="weapons"] .weapon-head,
  body[data-view="weapons"] .weapon-row {
    grid-template-columns: minmax(300px, 1fr) 52px 98px 78px 58px;
    column-gap: 12px;
  }
  body[data-view="armor"] .groups { min-width: 820px; }
  body[data-view="armor"] .armor-head,
  body[data-view="armor"] .armor-row {
    grid-template-columns: minmax(300px, 1fr) 52px 150px 150px 72px;
    column-gap: 12px;
  }
  body[data-view="utilities"] .groups { min-width: 820px; }
  body[data-view="utilities"] .utility-head,
  body[data-view="utilities"] .utility-row {
    grid-template-columns: minmax(300px, 1fr) 52px 150px 150px 72px;
    column-gap: 12px;
  }
  body[data-view="tradeskills"] .groups { min-width: 850px; }
  body[data-view="tradeskills"] .tradeskill-head,
  body[data-view="tradeskills"] .tradeskill-row {
    grid-template-columns: minmax(300px, 1fr) 52px 150px 180px 72px;
    column-gap: 12px;
  }
  body[data-view="patterns"] .groups { min-width: 1040px; }
  body[data-view="patterns"] .pattern-head,
  body[data-view="patterns"] .pattern-row {
    grid-template-columns: minmax(300px, 1fr) 52px 110px 230px 150px 72px;
    column-gap: 12px;
  }
  body[data-view="patterns"] .pattern-head.no-flags,
  body[data-view="patterns"] .pattern-row.no-flags {
    grid-template-columns: minmax(300px, 1fr) 52px 110px 230px 150px;
  }
}
