:root {
  --bg: #0e1116;
  --panel: #161a22;
  --panel-2: #1c212b;
  --line: #2a303c;
  --text: #e4e6eb;
  --muted: #8d95a5;
  --accent: #c9a45c;
  --accent-2: #e0bd73;
  --focus: #6aa9ff;
  --row-hover: #1f2531;
  --q0: #9d9d9d; --q1: #ffffff; --q2: #1eff00; --q3: #3d9bff; --q4: #b666f5; --q5: #ff8000; --q6: #e6cc80; --q7: #00ccff;
  --green: #1eff00;
  --yellow: #ffd100;
  --warn: #e6a23c;
  --bad: #e5484d;
  --info: #5aa9e6;
  --radius: 8px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { background: var(--bg); }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.45 var(--font); }
a { color: var(--accent-2); }
h1, h2, h3 { margin: 0; font-weight: 600; }
h2 { font-size: 16px; }
h3 { font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin: 12px 0 6px; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.skip { position: absolute; left: -999px; }
.skip:focus { left: 8px; top: 8px; background: var(--panel); padding: 8px; z-index: 50; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.green { color: var(--green); }
.yellow { color: var(--yellow); }
code { background: var(--panel-2); padding: 1px 5px; border-radius: 4px; }

.q0 { color: var(--q0); } .q1 { color: var(--q1); } .q2 { color: var(--q2); } .q3 { color: var(--q3); }
.q4 { color: var(--q4); } .q5 { color: var(--q5); } .q6 { color: var(--q6); } .q7 { color: var(--q7); }
.q-unknown { color: var(--muted); font-style: italic; }

/* ---------- header ---------- */
.top { display: flex; align-items: center; gap: 20px; padding: 12px 20px; background: var(--panel); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand h1 { font-size: 18px; letter-spacing: .01em; }
.logo { width: 34px; height: 34px; border-radius: 7px; display: grid; place-items: center; font-weight: 800; background: linear-gradient(135deg, #3a2f1a, #1b1710); color: var(--accent); border: 1px solid #4a3c20; }
.sub { color: var(--muted); font-size: 12px; }
.search { flex: 1 1 320px; max-width: 560px; }
.search input { width: 100%; padding: 9px 12px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--bg); }
.coverage { font-size: 12px; color: var(--muted); display: flex; flex-direction: column; gap: 4px; min-width: 180px; }
.coverage b { color: var(--text); }
.bar { display: block; height: 5px; background: var(--panel-2); border-radius: 3px; overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--accent); }

.tabs { display: flex; gap: 4px; padding: 0 20px; background: var(--panel); border-bottom: 1px solid var(--line); overflow-x: auto; }
.tabs a { padding: 10px 14px; color: var(--muted); text-decoration: none; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a:hover { color: var(--text); }
.tabs a.active { color: var(--text); border-bottom-color: var(--accent); }
.badge { display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 10px; background: var(--panel-2); color: var(--text); margin-left: 4px; vertical-align: 1px; }
.badge.new { background: #1f3b1a; color: #8df07a; }

/* ---------- layout ---------- */
.layout { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 0; align-items: start; }
.filters { position: sticky; top: 0; max-height: 100vh; overflow-y: auto; padding: 14px 16px 40px; border-right: 1px solid var(--line); background: var(--bg); }
.results { padding: 14px 20px 40px; min-width: 0; }
body[data-tab="compare"] .filters { display: none; }
body[data-tab="compare"] .layout { grid-template-columns: minmax(0, 1fr); }

/* ---------- filters ---------- */
.fhead { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.fhead h2 { flex: 1; }
.filters details { border-top: 1px solid var(--line); padding: 8px 0; }
.filters summary { cursor: pointer; font-weight: 600; font-size: 13px; padding: 2px 0 6px; list-style-position: outside; }
.hint { color: var(--muted); font-size: 12px; margin: 6px 0 0; }
.hint-inline { color: var(--muted); font-weight: 400; font-size: 11px; margin-left: 4px; }
.field { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.field.inline { flex-direction: row; align-items: center; gap: 6px; margin: 0; }
.field input, .field select, .statrow select, .statrow input, #pagein { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; color: var(--text); min-width: 0; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.range { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
.chips { display: flex; flex-wrap: wrap; gap: 5px; }
.chip { border: 1px solid var(--line); background: var(--panel); border-radius: 14px; padding: 3px 10px; font-size: 12px; cursor: pointer; color: var(--text); }
.chip small { color: var(--muted); }
.chip:hover { border-color: #3d4556; }
.chip.on { background: #2a2416; border-color: var(--accent); color: var(--accent-2); }
.chip.on.q0, .chip.on.q1, .chip.on.q2, .chip.on.q3, .chip.on.q4, .chip.on.q5 { background: var(--panel-2); }
.chip.q0 { color: var(--q0); } .chip.q1 { color: var(--q1); } .chip.q2 { color: var(--q2); } .chip.q3 { color: var(--q3); } .chip.q4 { color: var(--q4); } .chip.q5 { color: var(--q5); }
.quick { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
.statrow { display: grid; grid-template-columns: 1fr 70px 28px; gap: 4px; margin-bottom: 5px; }
.sdel { background: none; border: 1px solid var(--line); border-radius: 6px; cursor: pointer; color: var(--muted); }
.check { display: flex; gap: 7px; align-items: center; font-size: 13px; margin: 6px 0; cursor: pointer; }
.check.inline { display: inline-flex; margin: 0 0 0 8px; }
.link { background: none; border: 0; color: var(--accent-2); cursor: pointer; padding: 2px 0; font-size: 13px; }
.link:hover { text-decoration: underline; }
.btn { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 6px 11px; cursor: pointer; font-size: 13px; text-decoration: none; color: var(--text); display: inline-flex; align-items: center; gap: 4px; }
.btn:hover:not(:disabled) { border-color: #3d4556; background: var(--panel-2); }
.btn:disabled { opacity: .4; cursor: default; }
.only-mobile { display: none; }

/* ---------- toolbar / table ---------- */
.toolbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.toolbar .count { margin-right: auto; }
.colpicker { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; margin-bottom: 12px; }
.colpicker fieldset { border: 0; margin: 0; padding: 0; }
.colpicker legend { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 4px; }
.colpicker .check { margin: 3px 0; font-size: 12.5px; }
.cp-actions { grid-column: 1 / -1; display: flex; justify-content: flex-end; }

.tablewrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); }
table.items, table.compare { width: 100%; border-collapse: collapse; font-size: 13px; }
table.items th, table.items td { padding: 5px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; text-align: left; }
table.items thead th { position: sticky; top: 0; background: var(--panel); z-index: 1; padding: 0; }
table.items th button { all: unset; box-sizing: border-box; display: block; width: 100%; padding: 8px; cursor: pointer; font-weight: 600; font-size: 12px; color: var(--muted); }
table.items th.sorted button { color: var(--accent-2); }
table.items th button:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
table.items th.num button { text-align: right; }
.arrow { margin-left: 3px; font-size: 10px; }
.arrow sup { font-size: 8px; }
table.items tbody tr:hover { background: var(--row-hover); }
table.items td.num { text-align: right; font-variant-numeric: tabular-nums; }
table.items td.empty { color: transparent; }
td.vanilla { color: var(--muted); font-style: italic; }
tr.unknown td { color: var(--muted); }
td.c-name { max-width: 420px; overflow: hidden; text-overflow: ellipsis; position: sticky; left: 0; background: var(--bg); }
table.items tbody tr:hover td.c-name { background: var(--row-hover); }
thead th.c-name { left: 0; z-index: 2 !important; }
.c-found { color: var(--muted); }
.iname { display: inline-flex; align-items: center; gap: 7px; text-decoration: none; vertical-align: middle; max-width: 100%; }
.iname span { overflow: hidden; text-overflow: ellipsis; }
.iname:hover span { text-decoration: underline; }
.icon { width: 20px; height: 20px; border-radius: 3px; border: 1px solid #000; flex: none; object-fit: cover; }
.icon.lg { width: 36px; height: 36px; }
.icon.xl { width: 56px; height: 56px; }
.dlg-tt { display: flex; gap: 10px; align-items: flex-start; min-width: 0; }
.dlg-tt .tt { flex: 1; min-width: 0; }
.icon-missing { display: inline-grid; place-items: center; background: #222834; color: var(--muted); font-size: 11px; }
.icon.q0 { border-color: #555; } .icon.q2 { border-color: #146b0a; } .icon.q3 { border-color: #1b4f8a; } .icon.q4 { border-color: #5b2a86; } .icon.q5 { border-color: #8a4700; }
.tag { font-size: 10.5px; padding: 1px 6px; border-radius: 8px; margin-left: 6px; vertical-align: 1px; border: 1px solid; }
.tag.warn { color: var(--warn); border-color: #5a4217; }
.tag.bad { color: var(--bad); border-color: #5a1f22; }
.tag.info { color: var(--info); border-color: #1d3d57; }
.tag.new { color: #8df07a; border-color: #2c5a24; }
.vname { font-size: 12px; color: var(--muted); margin-left: 8px; }
.c-pin { width: 1%; text-align: center; }
.pin { width: 24px; height: 24px; border-radius: 5px; border: 1px solid var(--line); background: var(--panel); cursor: pointer; color: var(--muted); padding: 0; }
.pin.on { color: var(--accent-2); border-color: var(--accent); }
.pager { display: flex; align-items: center; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
#pagein { width: 64px; }
.pager .field.inline { margin-left: auto; }
.empty { padding: 40px 20px; text-align: center; color: var(--muted); border: 1px dashed var(--line); border-radius: var(--radius); }
.empty h2 { color: var(--text); margin-bottom: 8px; }

/* ---------- new items ---------- */
.newbar { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 20px; align-items: end; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 14px; }
.newbar p { margin: 4px 0 10px; font-size: 13px; }
.days { display: flex; gap: 3px; align-items: flex-end; height: 70px; }
.dbar { width: 18px; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; }
.dbar span { display: block; width: 100%; background: var(--accent); border-radius: 2px 2px 0 0; min-height: 1px; }
.dbar i { font-style: normal; font-size: 9px; color: var(--muted); margin-top: 2px; }

/* ---------- tooltip ---------- */
.tt { background: #070b12f2; border: 1px solid #4b5364; border-radius: 6px; padding: 9px 11px; font-size: 13px; line-height: 1.4; color: #fff; max-width: 340px; }
.tt > div { margin: 1px 0; }
.tt-name { font-size: 15px; font-weight: 600; }
.tt-row { display: flex; justify-content: space-between; gap: 16px; }
.tt-ilvl { color: var(--yellow); }
.tt-note { color: var(--muted); font-size: 12px; margin-top: 6px !important; }
.tt-note.bad { color: #ff8a8d; }
.tt-note.warn { color: var(--warn); }
#itemdlg-body > h2 { margin-bottom: 8px; }
#itemdlg-body > p, #itemdlg-body > ul { font-size: 13.5px; }
.tt-vanilla { margin-top: 8px !important; border-top: 1px solid #2d3340; padding-top: 6px; }
.tt-set { margin-top: 8px !important; }
.set-name { color: var(--yellow); }
.set-item { color: #9d9d9d; padding-left: 10px; }
.set-bonus { color: #9d9d9d; }
.tt-sell { color: #ddd; margin-top: 6px !important; }
.pct { color: #9fe39a; }
.gold { color: #ffd100; } .silver { color: #c7c7cf; } .copper { color: #c7773a; }
.tip { position: fixed; left: 0; top: 0; z-index: 40; pointer-events: none; }

/* ---------- dialog ---------- */
dialog { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 12px; padding: 20px; width: min(820px, calc(100vw - 32px)); max-height: calc(100vh - 32px); }
dialog::backdrop { background: #000a; }
.dlg-close { position: absolute; right: 10px; top: 8px; background: none; border: 0; font-size: 24px; color: var(--muted); cursor: pointer; }
.dlg-grid { display: grid; grid-template-columns: minmax(0, 360px) minmax(0, 1fr); gap: 20px; }
.tt.big { max-width: none; }
dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 0; font-size: 13px; }
dt { color: var(--muted); }
dd { margin: 0; }
.changes ul, .setlist { margin: 0; padding-left: 18px; font-size: 13px; }
.setlist { list-style: none; padding: 0; }
.setlist li { margin: 3px 0; }
.dlg-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }

/* ---------- compare ---------- */
table.compare th, table.compare td { padding: 6px 10px; border-bottom: 1px solid var(--line); text-align: right; vertical-align: top; }
table.compare thead th { text-align: left; font-weight: 400; min-width: 160px; }
table.compare tbody th { text-align: left; color: var(--muted); font-weight: 400; white-space: nowrap; }
table.compare td.best { color: #8df07a; font-weight: 600; }
.cmp-tips { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 16px; align-items: flex-start; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--panel-2); border: 1px solid var(--line); padding: 8px 14px; border-radius: 8px; z-index: 60; }
.foot { color: var(--muted); font-size: 12px; padding: 16px 20px 30px; border-top: 1px solid var(--line); }

/* ---------- small screens ---------- */
@media (max-width: 900px) {
  .top { padding: 10px 16px; gap: 10px; }
  .coverage { min-width: 0; width: 100%; }
  .tabs { padding: 0 8px; }
  .layout { grid-template-columns: minmax(0, 1fr); }
  .filters { position: fixed; inset: 0 auto 0 0; width: min(340px, 90vw); z-index: 30; transform: translateX(-105%); transition: transform .2s; max-height: none; border-right: 1px solid var(--line); box-shadow: 0 0 40px #000a; }
  body.filters-open .filters { transform: none; }
  .only-mobile { display: inline-flex; }
  .results { padding: 12px 16px 30px; }
  .newbar { grid-template-columns: minmax(0, 1fr); }
  .days { height: 50px; }
  .dbar { width: 14px; }
  .dlg-grid { grid-template-columns: minmax(0, 1fr); }
  td.c-name { max-width: 220px; }
}
