:root {
  --bg: #f3f4f5;
  --surface: #ffffff;
  --surface-2: #eef0f2;
  --border: #dde0e4;
  --text: #1a1c1f;
  --muted: #62676e;
  --accent: #15558f;
  --accent-soft: #e2edf7;
  --accent-text: #ffffff;
  --xp: #3f8f12;
  --xp-soft: #e8f5dd;
  --warn: #b4540a;
  --warn-soft: #fff1e3;
  --danger: #c0352b;
  --shadow: 0 1px 2px rgb(16 18 20 / 6%), 0 4px 16px rgb(16 18 20 / 5%);
  --radius: 12px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111213;
    --surface: #1a1b1d;
    --surface-2: #232528;
    --border: #2e3135;
    --text: #ebedef;
    --muted: #9a9fa6;
    --accent: #5b9bd5;
    --accent-soft: #16283a;
    --accent-text: #0a1420;
    --xp: #8ee05a;
    --xp-soft: #1f2e17;
    --warn: #f3a65a;
    --warn-soft: #33230f;
    --danger: #ff7b70;
    --shadow: 0 1px 2px rgb(0 0 0 / 30%);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #111213;
  --surface: #1a1b1d;
  --surface-2: #232528;
  --border: #2e3135;
  --text: #ebedef;
  --muted: #9a9fa6;
  --accent: #5b9bd5;
  --accent-soft: #16283a;
  --accent-text: #0a1420;
  --xp: #8ee05a;
  --xp-soft: #1f2e17;
  --warn: #f3a65a;
  --warn-soft: #33230f;
  --danger: #ff7b70;
  --shadow: 0 1px 2px rgb(0 0 0 / 30%);
  color-scheme: dark;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); }

.wrap { max-width: 1180px; margin: 0 auto; padding: 0 16px; }

/* Header */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.header-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-top: 18px;
  padding-bottom: 18px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 38px;
  height: 38px;
  flex: none;
  border-radius: 6px;
  image-rendering: pixelated;
}
h1 { margin: 0; font-size: 20px; letter-spacing: -0.01em; }
.brand p { margin: 0; color: var(--muted); font-size: 13px; }
.setup { display: flex; gap: 10px; flex-wrap: wrap; }
.setup label, .options label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}

select, input[type="search"] {
  font: inherit;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  min-width: 0;
}
select:focus-visible, input:focus-visible, button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
input[type="search"] { width: 100%; }

/* Layout */
.layout {
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
  gap: 20px;
  padding-top: 20px;
  padding-bottom: 20px;
  align-items: start;
}
.col { display: grid; gap: 20px; min-width: 0; }
@media (max-width: 860px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  min-width: 0;
}
.card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}
h2 { margin: 0; font-size: 16px; }
.hint { color: var(--muted); font-size: 12px; }
.fineprint { color: var(--muted); font-size: 12px; margin: 10px 0 0; }

.link-btn {
  font: inherit;
  font-size: 13px;
  background: none;
  border: 0;
  color: var(--accent);
  cursor: pointer;
  padding: 2px 4px;
}

/* Mod search */
.search { position: relative; }
.results {
  position: absolute;
  z-index: 5;
  left: 0;
  right: 0;
  top: calc(100% + 6px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 10px 30px rgb(0 0 0 / 18%);
  max-height: 380px;
  overflow-y: auto;
  padding: 6px;
}
.result, .mod {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 8px;
  border-radius: 8px;
}
.result:hover { background: var(--surface-2); }
.mod-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--surface-2);
  object-fit: cover;
}
.mod-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mod-meta { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mod-meta.ok { color: var(--xp); }
.mod-meta.bad { color: var(--warn); }
.results .empty { padding: 12px; color: var(--muted); font-size: 13px; }

.btn {
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 6px 12px;
  cursor: pointer;
  background: var(--accent);
  color: var(--accent-text);
}
.btn:disabled { background: var(--surface-2); color: var(--muted); cursor: default; }
.btn.ghost { background: transparent; color: var(--muted); border-color: var(--border); }
.btn.ghost:hover { color: var(--danger); border-color: var(--danger); }

.mod-list { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 4px; }
#pack-box:not(:empty) + .mod-list:empty::before { content: none; }
.mod-list:empty::before {
  content: "No mods added. Search above to add enchantments from Modrinth mods.";
  display: block;
  color: var(--muted);
  font-size: 13px;
  padding: 6px 2px;
}
.mod { background: var(--surface-2); }
.progress { height: 3px; border-radius: 2px; background: var(--border); margin-top: 4px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--accent); transition: width .15s; }

/* Mods / modpacks toggle */
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 2px; }
.seg button {
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  border: 0;
  border-radius: 6px;
  padding: 4px 10px;
  background: none;
  color: var(--muted);
  cursor: pointer;
}
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.upload-row { margin: 8px 2px 0; font-size: 13px; color: var(--muted); }
.upload { padding: 0; }
.upload-hint { display: block; font-size: 12px; margin-top: 2px; }
.upload input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.upload:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* Imported modpack */
#pack-box:empty { display: none; }
.pack {
  margin-top: 10px;
  border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--border));
  background: var(--accent-soft);
  border-radius: 10px;
  padding: 8px;
}
.pack .mod { background: none; padding: 0; }
.pack-body { font-size: 13px; padding: 8px 2px 0 2px; }
.pack-body p { margin: 0 0 6px; }
.pack details { margin-top: 4px; }
.pack summary { cursor: pointer; font-weight: 600; font-size: 13px; }
.pack ul { margin: 6px 0 0; padding-left: 18px; color: var(--muted); max-height: 220px; overflow-y: auto; }
.pack li b { color: var(--text); font-weight: 600; }
.pack .btn { margin-top: 4px; }

/* Items */
#item-filter { margin-bottom: 10px; }
.item-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-height: 320px;
  overflow-y: auto;
  padding: 2px;
}
.item {
  font: inherit;
  font-size: 13px;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 11px;
  cursor: pointer;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.item:hover { border-color: var(--accent); }
.item[aria-selected="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
}
.item .ns { opacity: .65; font-size: 11px; margin-left: 4px; }

/* Enchantments */
.ench-list { display: grid; gap: 4px; }
.ench-group {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  margin: 12px 2px 2px;
}
.ench {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 7px 8px 7px 10px;
  border-radius: 8px;
  border: 1px solid transparent;
}
.ench:hover { background: var(--surface-2); }

/* Description: a tooltip under the name on hover or keyboard focus */
.ench { position: relative; }
.ench-desc {
  /* hidden visually but read by screen readers */
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
}
.ench[data-desc]::after {
  content: attr(data-desc);
  position: absolute;
  left: 8px;
  top: calc(100% - 2px);
  z-index: 10;
  width: max-content;
  max-width: min(380px, calc(100% - 16px));
  padding: 7px 11px;
  border-radius: 8px;
  background: var(--text);
  color: var(--bg);
  font-size: 13px;
  line-height: 1.4;
  box-shadow: 0 8px 24px rgb(0 0 0 / 25%);
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-3px);
  transition: opacity .12s, transform .12s, visibility 0s linear .12s;
}
.ench[data-desc]:hover::after,
.ench[data-desc]:has(:focus-visible)::after {
  opacity: 1;
  visibility: visible;
  transform: none;
  transition: opacity .12s .35s, transform .12s .35s, visibility 0s linear .35s;
}
/* Touch screens can't hover: show the description inline instead */
@media (hover: none) {
  .ench[data-desc]::after { content: none; }
  .ench-desc {
    position: static;
    width: auto;
    height: auto;
    overflow: visible;
    clip-path: none;
    display: block;
    font-size: 12px;
    color: var(--muted);
    margin-top: 2px;
  }
}
.ench.on { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 35%, transparent); }
.ench.blocked { opacity: .5; }
.ench-name {
  font: inherit;
  text-align: left;
  background: none;
  border: 0;
  color: inherit;
  padding: 0;
  cursor: pointer;
  min-width: 0;
}
.ench-name strong { font-weight: 600; }
.ench-sub { display: block; font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 0 6px;
  margin-left: 6px;
  border-radius: 4px;
  background: var(--surface-2);
  color: var(--muted);
  vertical-align: 1px;
}
.ench.on .badge { background: var(--surface); }
.badge { white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis; vertical-align: middle; }
@media (max-width: 520px) {
  .ench { grid-template-columns: minmax(0, 1fr); gap: 6px; }
  .ench .levels { justify-content: flex-start; }
}
.levels { display: flex; gap: 3px; flex-wrap: wrap; justify-content: flex-end; }
.lvl {
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  min-width: 30px;
  padding: 3px 6px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
}
.lvl:hover:not(:disabled) { border-color: var(--accent); color: var(--text); }
.lvl[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.lvl:disabled { cursor: not-allowed; }
.lvl-input { width: 68px; font: inherit; font-size: 13px; padding: 3px 6px; border-radius: 6px; border: 1px solid var(--border); background: var(--surface); color: var(--text); }
.placeholder { color: var(--muted); font-size: 14px; padding: 8px 2px; margin: 0; }

.options {
  display: flex;
  flex-wrap: wrap;
  gap: 14px 20px;
  align-items: flex-end;
  border-top: 1px solid var(--border);
  margin-top: 14px;
  padding-top: 14px;
}
.options label.check {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  padding-bottom: 8px;
}
.check input { width: 16px; height: 16px; accent-color: var(--accent); }

/* Result */
.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}
@media (max-width: 520px) { .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.stat { background: var(--surface-2); border-radius: 10px; padding: 10px 12px; }
.stat b { display: block; font-size: 22px; line-height: 1.2; font-variant-numeric: tabular-nums; }
.stat span { font-size: 12px; color: var(--muted); }
.stat.xp { background: var(--xp-soft); }
.stat.xp b { color: var(--xp); }

.steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; counter-reset: step; }
.step {
  counter-increment: step;
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
}
.step::before {
  content: counter(step);
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
  font-size: 13px;
}
.slots { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; min-width: 0; }
.slot {
  background: var(--surface-2);
  border-radius: 6px;
  padding: 3px 8px;
  font-size: 13px;
  max-width: 100%;
}
.slot.item-slot { background: var(--accent-soft); }
.slot small { color: var(--muted); }
.plus { color: var(--muted); font-weight: 700; }
.cost { font-weight: 700; color: var(--xp); white-space: nowrap; font-variant-numeric: tabular-nums; }
.cost.too { color: var(--danger); }
.note {
  margin: 0 0 12px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--warn-soft);
  color: var(--warn);
  font-size: 13px;
}
.books { margin: 14px 0 0; font-size: 13px; color: var(--muted); }
.spinner { color: var(--muted); font-size: 14px; }

.site-footer { color: var(--muted); font-size: 12px; padding-bottom: 28px; }
.site-footer p { margin: 4px 0; }
