/* Melvor Idle 2 item database: a dark "codex" look, our own glyphs, no game art. */
:root {
  --bg: #0d1117;
  --panel: #141a23;
  --panel-2: #1a2230;
  --line: #263042;
  --line-2: #33405a;
  --text: #ece6d8;
  --muted: #9aa3b4;
  --faint: #6b7487;
  --gold: #e0b45c;
  --gold-dim: #8a6a2c;
  --good: #6fcf7f;
  --bad: #ef7d6d;
  --accent: #6fb3ff;
  --t1: #a8784a; --t2: #9aa3ad; --t3: #c7ced6; --t4: #4f86d6; --t5: #3fb67d; --t6: #d65252; --t7: #9b6cf0; --t8: #e8c25a;
  --melee: #e0745c; --ranged: #6fcf7f; --magic: #7aa7ff;
  --fire: #ff7a45; --water: #4fb6ff; --earth: #b48c4f; --air: #c9e4ff;
  --radius: 8px;
  --shadow: 0 10px 30px rgba(0, 0, 0, .45);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: radial-gradient(1200px 500px at 70% -10%, #1b2434 0%, transparent 60%), var(--bg);
  color: var(--text);
  font: 14px/1.45 "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-variant-numeric: tabular-nums;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; border-radius: 4px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }

/* ---- top bar */
.top {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 14px;
  padding: 10px 20px;
  background: rgba(13, 17, 23, .92); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 700; letter-spacing: .3px; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand svg { width: 28px; height: 28px; color: var(--gold); }
.brand small { display: block; font-weight: 500; color: var(--muted); font-size: 11px; letter-spacing: .6px; text-transform: uppercase; }
.nav { display: flex; gap: 4px; }
.nav a { padding: 6px 12px; border-radius: 6px; color: var(--muted); font-weight: 600; }
.nav a.on, .nav a:hover { background: var(--panel-2); color: var(--text); text-decoration: none; }
.jump { margin-left: auto; position: relative; width: min(360px, 40vw); }
.jump input {
  width: 100%; padding: 8px 12px 8px 34px; border-radius: 8px;
  background: var(--panel); border: 1px solid var(--line); outline: none;
}
.jump input:focus { border-color: var(--gold-dim); }
.jump svg { position: absolute; left: 10px; top: 9px; width: 16px; height: 16px; color: var(--faint); }
.jump kbd { position: absolute; right: 8px; top: 7px; }
kbd { font: 11px/1 ui-monospace, monospace; padding: 3px 6px; border: 1px solid var(--line-2); border-bottom-width: 2px; border-radius: 4px; color: var(--muted); background: var(--panel-2); }
.jump-list {
  position: absolute; top: 40px; left: 0; right: 0; max-height: 60vh; overflow: auto;
  background: var(--panel); border: 1px solid var(--line-2); border-radius: 10px; box-shadow: var(--shadow); padding: 6px;
}
.jump-list a { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 6px; color: var(--text); }
.jump-list a.on, .jump-list a:hover { background: var(--panel-2); text-decoration: none; }
.jump-list .kind { margin-left: auto; font-size: 11px; color: var(--faint); text-transform: uppercase; letter-spacing: .5px; }

/* ---- layout */
main { max-width: 1500px; margin: 0 auto; padding: 18px 20px 120px; }
.hero { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 14px; }
.hero h1 { margin: 0; font-size: 24px; letter-spacing: .2px; }
.hero p { margin: 2px 0 0; color: var(--muted); }
.hero .ver { font-size: 12px; color: var(--faint); text-align: right; }

/* ---- category tabs */
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.tab {
  display: inline-flex; align-items: center; gap: 8px; padding: 7px 12px; border-radius: 999px; cursor: pointer;
  background: var(--panel); border: 1px solid var(--line); color: var(--muted); font-weight: 600;
}
.tab svg { width: 16px; height: 16px; }
.tab b { font-weight: 600; color: var(--faint); font-size: 12px; }
.tab[aria-pressed="true"] { background: linear-gradient(180deg, #2a2416, #1f1b12); border-color: var(--gold-dim); color: var(--text); }
.tab[aria-pressed="true"] svg { color: var(--gold); }
.tab:hover { color: var(--text); }

/* ---- tool row */
.tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 10px; }
.search { position: relative; flex: 1 1 260px; max-width: 420px; }
.search input { width: 100%; padding: 9px 12px 9px 34px; border-radius: 8px; background: var(--panel); border: 1px solid var(--line); outline: none; }
.search input:focus { border-color: var(--gold-dim); }
.search svg { position: absolute; left: 10px; top: 10px; width: 16px; height: 16px; color: var(--faint); }
.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 12px; border-radius: 8px; cursor: pointer;
  background: var(--panel); border: 1px solid var(--line); color: var(--text); font-weight: 600; white-space: nowrap;
}
.btn:hover { border-color: var(--line-2); background: var(--panel-2); }
.btn svg { width: 16px; height: 16px; }
.btn.gold { border-color: var(--gold-dim); background: linear-gradient(180deg, #2a2416, #1f1b12); }
.btn .count { background: var(--gold); color: #1a1408; border-radius: 999px; padding: 0 6px; font-size: 11px; }
select.btn { appearance: none; padding-right: 28px; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 14px) 52%, calc(100% - 9px) 52%; background-size: 5px 5px; background-repeat: no-repeat; }
.result-count { margin-left: auto; color: var(--muted); }

/* ---- quick pills */
.quick { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; margin-bottom: 10px; padding: 10px 12px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.quick:empty { display: none; }
.group { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.group > span { color: var(--faint); font-size: 12px; text-transform: uppercase; letter-spacing: .5px; margin-right: 2px; }
.pill {
  padding: 5px 10px; border-radius: 999px; cursor: pointer; font-weight: 600; font-size: 13px;
  background: var(--panel-2); border: 1px solid var(--line); color: var(--muted);
}
.pill:hover { color: var(--text); }
.pill[aria-pressed="true"] { color: #1a1408; background: var(--gold); border-color: var(--gold); }
.pill.melee[aria-pressed="true"] { background: var(--melee); border-color: var(--melee); }
.pill.ranged[aria-pressed="true"] { background: var(--ranged); border-color: var(--ranged); }
.pill.magic[aria-pressed="true"] { background: var(--magic); border-color: var(--magic); }
.mini-select { padding: 5px 26px 5px 10px; border-radius: 999px; font-size: 13px; }

/* ---- paperdoll */
.doll { display: grid; grid-template-columns: repeat(3, 34px); grid-auto-rows: 34px; gap: 4px; }
.doll button { display: grid; place-items: center; border-radius: 6px; cursor: pointer; background: var(--panel-2); border: 1px solid var(--line); color: var(--muted); padding: 0; }
.doll button svg { width: 20px; height: 20px; }
.doll button[aria-pressed="true"] { border-color: var(--gold); color: var(--gold); background: #2a2416; }
.doll button:hover { color: var(--text); }

/* ---- chips */
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.chips:empty { display: none; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 6px 4px 10px; border-radius: 999px; background: #1f2a3c; border: 1px solid #2f4466; font-size: 13px; }
.chip button { border: 0; background: transparent; color: var(--muted); cursor: pointer; padding: 0 4px; font-size: 16px; line-height: 1; }
.chip button:hover { color: var(--text); }
.chips .clear { background: transparent; border: 0; color: var(--accent); cursor: pointer; font-weight: 600; }

/* ---- table */
.table-wrap { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: auto; }
table.items { width: 100%; border-collapse: collapse; }
.items th {
  position: sticky; top: 0; z-index: 2; text-align: left; white-space: nowrap;
  font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .5px;
  background: var(--panel-2); border-bottom: 1px solid var(--line-2); padding: 0;
}
.items th button { all: unset; display: flex; align-items: center; gap: 4px; padding: 9px 10px; cursor: pointer; width: 100%; box-sizing: border-box; }
.items th button:hover { color: var(--text); }
.items th[aria-sort] button { color: var(--gold); }
.items th.num button { justify-content: flex-end; }
.items td { padding: 6px 10px; border-bottom: 1px solid #1d2533; white-space: nowrap; }
.items td.num { text-align: right; }
.items tr { cursor: pointer; }
.items tbody tr:hover { background: #18202d; }
.items tbody tr.on { background: #221d12; }
.items .name { display: flex; align-items: center; gap: 10px; min-width: 220px; }
.items .name b { font-weight: 600; }
.items .name small { display: block; color: var(--faint); font-size: 12px; }
.neg { color: var(--bad); }
.zero { color: var(--faint); }
.bar { display: inline-block; height: 4px; border-radius: 2px; background: var(--gold-dim); vertical-align: middle; margin-right: 6px; opacity: .8; }
.cmp-box { width: 18px; height: 18px; accent-color: var(--gold); cursor: pointer; }
.more-rows { padding: 14px; text-align: center; color: var(--faint); }
.empty { padding: 40px; text-align: center; color: var(--muted); }

/* ---- glyph tiles */
.tile {
  --tier: var(--t2);
  position: relative; display: inline-grid; place-items: center; flex: none;
  width: 34px; height: 34px; border-radius: 7px;
  background: radial-gradient(circle at 30% 25%, color-mix(in srgb, var(--tier) 30%, #1d2533), #121822 75%);
  border: 1px solid color-mix(in srgb, var(--tier) 60%, transparent);
  color: color-mix(in srgb, var(--tier) 75%, white);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .06);
}
.tile svg { width: 22px; height: 22px; }
.tile.art { background: radial-gradient(circle at 50% 40%, #222c3c, #121822 75%); }
.tile img { width: 28px; height: 28px; object-fit: contain; image-rendering: auto; filter: drop-shadow(0 1px 1px rgba(0,0,0,.5)); }
.tile.big img { width: 54px; height: 54px; }
.tile.big.monster { width: 96px; height: 96px; }
.tile.big.monster img { width: 88px; height: 88px; }
.ing .tile img { width: 16px; height: 16px; }
.tray .slot-item .tile img { width: 20px; height: 20px; }
.mcard { display: grid; grid-template-columns: 56px 1fr; column-gap: 10px; align-items: center; }
.mcard .mimg { grid-row: span 3; width: 56px; height: 56px; object-fit: contain; }
.mcard > :not(.mimg) { grid-column: 2; }
.tile.big { width: 64px; height: 64px; border-radius: 12px; }
.tile.big svg { width: 40px; height: 40px; }
.tile .pip { position: absolute; right: -4px; bottom: -4px; font: 700 9px/1 system-ui; padding: 2px 3px; border-radius: 4px; background: var(--gold); color: #1a1408; }
.tier1 { --tier: var(--t1); } .tier2 { --tier: var(--t2); } .tier3 { --tier: var(--t3); } .tier4 { --tier: var(--t4); }
.tier5 { --tier: var(--t5); } .tier6 { --tier: var(--t6); } .tier7 { --tier: var(--t7); } .tier8 { --tier: var(--t8); }

/* ---- badges */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--panel-2); border: 1px solid var(--line-2); color: var(--muted); }
.badge.melee { color: var(--melee); border-color: color-mix(in srgb, var(--melee) 50%, transparent); }
.badge.ranged { color: var(--ranged); border-color: color-mix(in srgb, var(--ranged) 50%, transparent); }
.badge.magic { color: var(--magic); border-color: color-mix(in srgb, var(--magic) 50%, transparent); }
.badge.fire { color: var(--fire); } .badge.water { color: var(--water); } .badge.earth { color: var(--earth); } .badge.air { color: var(--air); }
.badge.gold { color: var(--gold); border-color: var(--gold-dim); }
.lvl { display: inline-flex; align-items: center; gap: 4px; padding: 1px 7px; border-radius: 6px; background: #202a3a; font-size: 12px; color: var(--text); }
.lvl.miss { background: #3a2020; color: #ffb4a8; }

/* ---- detail panel */
.panel {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 40; width: min(620px, 100vw);
  background: var(--panel); border-left: 1px solid var(--line-2); box-shadow: var(--shadow);
  overflow: auto; transform: translateX(105%); transition: transform .18s ease;
}
.panel.open { transform: none; }
.panel-shade { position: fixed; inset: 0; z-index: 35; background: rgba(0, 0, 0, .4); display: none; }
.panel-shade.open { display: block; }
.detail { padding: 20px 22px 40px; }
.detail.page { max-width: 900px; margin: 0 auto; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; }
.detail-head { display: flex; gap: 16px; align-items: flex-start; }
.detail-head h2 { margin: 0 0 4px; font-size: 22px; }
.detail-head .sub { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; color: var(--muted); }
.detail-actions { margin-left: auto; display: flex; gap: 6px; flex: none; }
.icon-btn { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 8px; background: var(--panel-2); border: 1px solid var(--line); cursor: pointer; color: var(--muted); }
.icon-btn:hover { color: var(--text); border-color: var(--line-2); }
.icon-btn svg { width: 18px; height: 18px; }
.desc { margin: 12px 0 0; color: var(--muted); font-style: italic; }
.section { margin-top: 22px; }
.section h3 { display: flex; align-items: center; gap: 8px; margin: 0 0 10px; font-size: 13px; text-transform: uppercase; letter-spacing: .8px; color: var(--gold); }
.section h3::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.section h3 .n { color: var(--faint); font-weight: 600; }
.reqs { display: flex; flex-wrap: wrap; gap: 6px; }
.statgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 4px 18px; }
.stat { display: flex; align-items: center; gap: 8px; padding: 3px 0; border-bottom: 1px dashed #222b3a; }
.stat .k { color: var(--muted); flex: 1; }
.stat .v { font-weight: 700; }
.stat .meter { width: 54px; height: 4px; border-radius: 2px; background: #222b3a; overflow: hidden; }
.stat .meter i { display: block; height: 100%; background: linear-gradient(90deg, var(--gold-dim), var(--gold)); }
.stat-head { grid-column: 1 / -1; margin-top: 8px; font-size: 11px; text-transform: uppercase; letter-spacing: .6px; color: var(--faint); }
ul.bonus { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
ul.bonus li { display: flex; gap: 8px; align-items: flex-start; padding: 7px 10px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; }
ul.bonus li::before { content: "▲"; color: var(--good); font-size: 10px; margin-top: 4px; }

/* source and use rows */
.src { display: grid; grid-template-columns: 34px 1fr auto; gap: 4px 12px; align-items: center; padding: 9px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel-2); margin-bottom: 6px; }
.src .what { min-width: 0; }
.src .what b { font-weight: 600; }
.src .what small { display: block; color: var(--faint); }
.src .rate { text-align: right; white-space: nowrap; }
.src .rate b { font-size: 15px; color: var(--gold); }
.src .rate small { display: block; color: var(--muted); font-size: 12px; }
.src .kindicon { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 8px; background: #121822; border: 1px solid var(--line); color: var(--muted); }
.src .kindicon svg { width: 18px; height: 18px; }
.src.best { border-color: var(--gold-dim); box-shadow: inset 3px 0 0 var(--gold); }
.ings { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.ing { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px 2px 3px; border-radius: 999px; background: #121822; border: 1px solid var(--line); color: var(--text); font-size: 12px; }
.ing .tile { width: 20px; height: 20px; border-radius: 5px; }
.ing .tile svg { width: 14px; height: 14px; }
.src-sort { display: flex; gap: 6px; margin-bottom: 8px; }
.note { font-size: 12px; color: var(--faint); margin-top: 6px; }
.unver { color: #f0c36b; font-size: 11px; font-weight: 700; margin-left: 6px; }

/* ---- compare tray */
.tray {
  position: fixed; left: 50%; bottom: 14px; transform: translateX(-50%); z-index: 25;
  display: flex; align-items: center; gap: 10px; padding: 8px 10px 8px 14px;
  background: #1b2230; border: 1px solid var(--gold-dim); border-radius: 12px; box-shadow: var(--shadow);
}
.tray[hidden] { display: none; }
.tray .slots { display: flex; gap: 6px; }
.tray .slot-item { display: inline-flex; align-items: center; gap: 6px; padding: 3px 8px 3px 3px; border-radius: 8px; background: var(--panel-2); font-size: 12px; max-width: 170px; }
.tray .slot-item span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tray .slot-item .tile { width: 24px; height: 24px; }
.tray .slot-item .tile svg { width: 16px; height: 16px; }
table.cmp { border-collapse: collapse; width: 100%; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.cmp th, .cmp td { padding: 7px 12px; border-bottom: 1px solid #1d2533; text-align: right; }
.cmp th:first-child, .cmp td:first-child { text-align: left; color: var(--muted); }
.cmp thead th { vertical-align: bottom; }
.cmp .best-v { color: var(--good); font-weight: 700; }
.cmp .worst-v { color: var(--bad); }

/* ---- monster / area pages */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.card { display: block; padding: 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; color: var(--text); }
.card:hover { border-color: var(--line-2); text-decoration: none; background: var(--panel-2); }
.card h4 { margin: 0 0 4px; font-size: 15px; }
.card .meta { color: var(--muted); font-size: 12px; }
.loot td, .loot th { text-align: left; }

/* ---- drawer (more filters) */
.drawer { position: fixed; top: 0; left: 0; bottom: 0; z-index: 45; width: min(400px, 100vw); background: var(--panel); border-right: 1px solid var(--line-2); box-shadow: var(--shadow); transform: translateX(-105%); transition: transform .18s ease; display: flex; flex-direction: column; }
.drawer.open { transform: none; }
.drawer header { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.drawer header h2 { margin: 0; font-size: 16px; }
.drawer .body { padding: 14px 16px; overflow: auto; flex: 1; display: grid; gap: 18px; align-content: start; }
.drawer footer { padding: 12px 16px; border-top: 1px solid var(--line); display: flex; gap: 8px; }
.drawer footer .btn { flex: 1; justify-content: center; }
.field > label, .field > .label { display: block; font-size: 12px; text-transform: uppercase; letter-spacing: .5px; color: var(--faint); margin-bottom: 6px; }
.field .row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.field input[type=number] { width: 80px; padding: 6px 8px; border-radius: 6px; background: var(--panel-2); border: 1px solid var(--line); }
.field select { padding: 6px 8px; border-radius: 6px; background: var(--panel-2); border: 1px solid var(--line); max-width: 100%; }
.check { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.check input { accent-color: var(--gold); width: 16px; height: 16px; }
.levels { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px 12px; }
.levels label { display: flex; align-items: center; justify-content: space-between; gap: 8px; color: var(--muted); font-size: 13px; }
.levels input { width: 64px; padding: 4px 6px; border-radius: 6px; background: var(--panel-2); border: 1px solid var(--line); }

footer.site { margin-top: 30px; color: var(--faint); font-size: 12px; text-align: center; }

/* ---- phones */
@media (max-width: 760px) {
  .top { padding: 8px 12px; gap: 8px; flex-wrap: wrap; }
  .brand small { display: none; }
  .jump { order: 3; width: 100%; }
  .jump kbd { display: none; }
  main { padding: 12px 12px 120px; }
  .hero { flex-direction: column; align-items: flex-start; gap: 4px; }
  .hero .ver { text-align: left; }
  .tabs { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; }
  .result-count { width: 100%; margin-left: 0; }
  .tabs { align-items: center; }
  .tab { flex: none; padding: 6px 10px; }
  .tools .search { flex: 1 1 100%; max-width: none; }
  .tools .btn { flex: 1 1 auto; justify-content: center; }
  .quick { gap: 10px; padding: 8px 10px; }
  table.items thead { display: none; }
  table.items, .items tbody { display: block; }
  .items tr { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; padding: 8px 10px; border-bottom: 1px solid #1d2533; }
  .items td { border: 0; padding: 0; }
  .items td.c-name { flex: 1 1 calc(100% - 40px); order: 0; }
  .items td.c-cmp { order: 1; }
  .items td.extra { display: none; order: 2; font-size: 12px; color: var(--muted); text-align: left; }
  .items td.extra::before { content: attr(data-label) " "; color: var(--faint); }
  .items td.extra.num.top3, .items td.extra.sorted { display: inline-block; }
  .items td.extra.zero-cell { display: none; }
  .items td.extra .bar { display: none; }
  .items tbody tr > td.extra:first-of-type { margin-left: 44px; }
  .items .name { min-width: 0; }
  .panel { width: 100vw; }
  .src { grid-template-columns: 30px 1fr; }
  .src .rate { grid-column: 2; text-align: left; }
  .tray { left: 8px; right: 8px; transform: none; flex-wrap: wrap; }
}
