:root {
  --bg: #0f1115;
  --panel: #171a21;
  --panel2: #1e222b;
  --border: #2a2f3a;
  --text: #e3e6ec;
  --muted: #8b93a3;
  --accent: #4f9cf7;
  --good: #3fbf6f;
  --bad: #e05d5d;
  --warn: #e0a84f;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif; }
a { color: var(--accent); text-decoration: none; cursor: pointer; }
a:hover { text-decoration: underline; }

header { display: flex; align-items: center; gap: 24px; padding: 0 20px; height: 52px; background: var(--panel); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 5; }
.brand { font-weight: 700; font-size: 17px; letter-spacing: .3px; }
nav { display: flex; gap: 4px; flex: 1; }
nav a { color: var(--muted); padding: 6px 12px; border-radius: 6px; }
nav a:hover { color: var(--text); background: var(--panel2); text-decoration: none; }
nav a.active { color: var(--text); background: var(--panel2); }
.pill { font-size: 12px; color: var(--muted); }
.pill b { color: var(--text); }

main { padding: 20px; max-width: 1500px; margin: 0 auto; }
h2 { margin: 0 0 14px; font-size: 18px; }
h3 { margin: 0 0 10px; font-size: 15px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 16px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.spacer { flex: 1; }
.stack > * + * { margin-top: 10px; }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 4px 10px; }
.kv div:nth-child(odd) { color: var(--muted); }

button, .btn { background: var(--panel2); color: var(--text); border: 1px solid var(--border); padding: 6px 12px; border-radius: 6px; cursor: pointer; font: inherit; }
button:hover { border-color: var(--accent); }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.danger:hover { border-color: var(--bad); color: var(--bad); }
button:disabled { opacity: .5; cursor: default; }
button.link { background: none; border: none; color: var(--accent); padding: 0 4px; }

input, select, textarea { background: var(--bg); color: var(--text); border: 1px solid var(--border); border-radius: 6px; padding: 6px 8px; font: inherit; }
textarea { width: 100%; font-family: ui-monospace, Consolas, monospace; font-size: 12px; }
input[type=number] { width: 90px; }
label.field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
label.check { display: inline-flex; gap: 6px; align-items: center; cursor: pointer; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { color: var(--muted); font-weight: 500; font-size: 12px; position: sticky; top: 0; background: var(--panel); }
tr:hover td { background: rgba(255,255,255,.02); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-wrap { overflow: auto; max-height: 70vh; }

.icon { width: 20px; height: 20px; border-radius: 3px; vertical-align: middle; margin-right: 6px; }
.q4 { color: #a335ee; }
.q3 { color: #0070dd; }
.q5 { color: #ff8000; }
.pos { color: var(--good); }
.neg { color: var(--bad); }

.progress { height: 6px; background: var(--panel2); border-radius: 3px; overflow: hidden; min-width: 80px; }
.progress > div { height: 100%; background: var(--accent); transition: width .4s; }
.status { font-size: 12px; padding: 1px 7px; border-radius: 10px; background: var(--panel2); }
.status.done { color: var(--good); }
.status.error { color: var(--bad); }
.status.running { color: var(--accent); }
.status.cancelled { color: var(--muted); }

.tabs { display: flex; gap: 4px; margin-bottom: 12px; }
.tabs button.active { border-color: var(--accent); color: var(--accent); }

.char-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 6px; max-height: 340px; overflow: auto; padding: 4px; }
.char-pick label { background: var(--panel2); padding: 6px 8px; border-radius: 6px; border: 1px solid transparent; }
.char-pick label:has(input:checked) { border-color: var(--accent); }

.matrix td.cell { text-align: right; font-variant-numeric: tabular-nums; min-width: 70px; }
.matrix th.char { text-align: right; vertical-align: bottom; min-width: 90px; max-width: 120px; overflow: hidden; text-overflow: ellipsis; }
.matrix th.char .spec { display: block; font-size: 11px; color: var(--muted); font-weight: 400; overflow: hidden; text-overflow: ellipsis; }
.matrix th.char span { display: block; overflow: hidden; text-overflow: ellipsis; }
.matrix th:first-child, .matrix td:first-child { position: sticky; left: 0; background: var(--panel); z-index: 1; }
.matrix thead th:first-child { z-index: 2; }
.matrix td.best { outline: 1px solid var(--good); outline-offset: -2px; }

.modal { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex; align-items: flex-start; justify-content: center; padding: 40px 20px; z-index: 20; overflow: auto; }
.modal-body { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 20px; width: min(1100px, 100%); position: relative; }
.modal-close { position: absolute; top: 10px; right: 10px; border: none; font-size: 22px; background: none; }
.hidden { display: none !important; }

.toast { position: fixed; bottom: 20px; right: 20px; background: var(--panel2); border: 1px solid var(--border); padding: 10px 16px; border-radius: 8px; max-width: 480px; z-index: 30; white-space: pre-wrap; }
.toast.error { border-color: var(--bad); }

pre.code { background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: 10px; overflow: auto; max-height: 50vh; font-size: 12px; }
.error-text { color: var(--bad); white-space: pre-wrap; }
.matrix td.cell .repl { display: block; font-size: 11px; color: var(--muted); max-width: 180px; margin-left: auto; overflow: hidden; text-overflow: ellipsis; }
.badge { font-size: 10px; text-transform: uppercase; letter-spacing: .4px; padding: 1px 5px; border-radius: 4px; background: rgba(79,156,247,.15); color: var(--accent); margin-right: 6px; vertical-align: middle; }
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--text); }

/* profile */
.modal.wide .modal-body { width: min(1320px, 100%); padding: 0; overflow: hidden; }
.modal.wide .modal-close { z-index: 3; }
.pf { --cls: var(--accent); }
.pf-hero { display: grid; grid-template-columns: 1fr auto auto; gap: 24px; align-items: center; padding: 26px 30px;
  background: linear-gradient(120deg, color-mix(in srgb, var(--cls) 22%, transparent), transparent 60%), var(--panel2);
  border-bottom: 1px solid var(--border); }
.pf-hero h1 { margin: 0; font-size: 34px; line-height: 1.1; letter-spacing: .3px; }
.pf-line { font-size: 16px; margin: 4px 0 2px; }
.pf-tiles { display: flex; gap: 10px; }
.pf-tile { background: rgba(0,0,0,.25); border: 1px solid var(--border); border-radius: 10px; padding: 10px 16px; min-width: 120px; display: flex; flex-direction: column; }
.pf-tile span { font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); }
.pf-tile b { font-size: 24px; font-variant-numeric: tabular-nums; }
.pf-tile small { color: var(--muted); font-size: 11px; max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pf-actions { display: flex; flex-direction: column; gap: 6px; margin-right: 26px; }
.badge.muted-badge { background: rgba(255,255,255,.06); color: var(--muted); }
.pf-body { display: grid; grid-template-columns: minmax(0, 1fr) 340px minmax(0, 1fr); gap: 18px; padding: 22px 30px; }
.pf-col { display: flex; flex-direction: column; gap: 6px; }
.pf-center { display: flex; flex-direction: column; gap: 14px; }
.pf-card { background: var(--panel2); border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; }
.pf-card h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); margin-bottom: 12px; }
.pf-lower { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; padding: 0 30px 18px; }
.pf-edit { margin: 0 30px 26px; }
.pf-edit summary { cursor: pointer; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .6px; }

.gi { display: flex; gap: 12px; align-items: center; padding: 6px 8px; border-radius: 8px; color: var(--text); min-height: 62px; border: 1px solid transparent; }
.gi:hover { background: var(--panel2); border-color: var(--border); text-decoration: none; }
.gi.right { flex-direction: row-reverse; text-align: right; }
.gi-icon { position: relative; width: 46px; height: 46px; flex: none; border-radius: 6px; border: 2px solid #555; background: #000; overflow: hidden; }
.gi-icon img { width: 100%; height: 100%; display: block; }
.gi.q3 .gi-icon { border-color: #0070dd; } .gi.q4 .gi-icon { border-color: #a335ee; } .gi.q5 .gi-icon { border-color: #ff8000; }
.gi.q3 .gi-name { color: #3d9bff; } .gi.q4 .gi-name { color: #c27bff; } .gi.q5 .gi-name { color: #ff8000; }
.gi-ilvl { position: absolute; bottom: 0; right: 0; left: 0; text-align: center; font-size: 11px; font-weight: 700; background: rgba(0,0,0,.72); line-height: 15px; }
.gi-text { min-width: 0; }
.gi-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gi-sub { font-size: 12px; color: var(--muted); }
.gi-ench { font-size: 12px; color: #1eff00; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gi-noench { font-size: 12px; color: var(--warn); }
.gi-gems { display: flex; gap: 3px; margin-top: 2px; flex-wrap: wrap; }
.gi.right .gi-gems { justify-content: flex-end; }
.gem { width: 15px; height: 15px; border-radius: 3px; }
.gem-text { font-size: 11px; color: var(--muted); background: rgba(255,255,255,.05); padding: 0 4px; border-radius: 3px; }
.gi-empty { opacity: .45; }

.pf-stats { display: flex; flex-direction: column; gap: 10px; }
.pf-stat.big { flex: 1; background: rgba(0,0,0,.2); border-radius: 8px; padding: 8px 10px; display: flex; flex-direction: column; }
.pf-stat.big span { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.pf-stat.big b { font-size: 20px; font-variant-numeric: tabular-nums; }
.pf-stat .row { gap: 8px; }
.pf-stat .bar { height: 5px; background: rgba(255,255,255,.06); border-radius: 3px; margin-top: 4px; overflow: hidden; }
.pf-stat .bar div { height: 100%; border-radius: 3px; }
.spark { display: block; margin-bottom: 8px; }
table.compact td { padding: 4px 6px; }

.pf-drops { display: flex; flex-direction: column; gap: 4px; max-height: 340px; overflow: auto; }
.pf-drop { display: flex; align-items: center; gap: 8px; padding: 5px 6px; border-radius: 6px; }
.pf-drop:hover { background: rgba(255,255,255,.03); }
.pf-drop .grow { flex: 1; min-width: 0; }
.pf-drop .grow > a { white-space: nowrap; }
.pf-drop .num { text-align: right; font-variant-numeric: tabular-nums; }
.pf-bags { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 6px; max-height: 340px; overflow: auto; }
.pf-bag { display: flex; gap: 8px; align-items: center; padding: 5px; border-radius: 6px; color: var(--text); }
.pf-bag:hover { background: rgba(255,255,255,.03); text-decoration: none; }
.pf-bag img { width: 30px; height: 30px; border-radius: 4px; border: 1px solid #555; }
.pf-bag.q4 .gi-name { color: #c27bff; } .pf-bag.q3 .gi-name { color: #3d9bff; }

@media (max-width: 1100px) {
  .pf-body { grid-template-columns: 1fr 1fr; }
  .pf-center { grid-column: 1 / -1; order: 3; }
  .pf-hero { grid-template-columns: 1fr; }
  .pf-lower { grid-template-columns: 1fr; }
}

.gi-wrap { display: flex; align-items: stretch; gap: 4px; }
.gi-wrap.right { flex-direction: row-reverse; }
.gi-wrap > .gi { flex: 1; min-width: 0; }
.gi-up-spacer { width: 44px; flex: none; }
.gi-up { width: 44px; flex: none; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  padding: 0; border-radius: 8px; background: rgba(63,191,111,.08); border: 1px solid rgba(63,191,111,.25); color: var(--good); }
.gi-up:hover { background: rgba(63,191,111,.16); border-color: var(--good); }
.gi-up .arrow { font-size: 20px; line-height: 1; }
.gi-up .gain { font-size: 10px; font-variant-numeric: tabular-nums; }
.gi-wrap.active .gi { background: var(--panel2); border-color: var(--good); }
.gi-wrap.active .gi-up { background: rgba(63,191,111,.22); border-color: var(--good); }
.pf-upg-cur { display: flex; gap: 10px; align-items: center; padding: 8px; border-radius: 8px; background: rgba(0,0,0,.2); margin-bottom: 12px; }
.pf-upg-cur img { width: 38px; height: 38px; border-radius: 6px; border: 2px solid #a335ee; }
.gi-name.q4 { color: #c27bff; } .gi-name.q3 { color: #3d9bff; } .gi-name.q5 { color: #ff8000; }
.pf-ctx + .pf-ctx { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border); }
.pf-ctx-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.pf-upg { display: flex; align-items: center; gap: 8px; padding: 6px; border-radius: 6px; }
.pf-upg .grow { flex: 1; min-width: 0; }
.pf-upg .grow > a { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: inline-block; max-width: 100%; vertical-align: bottom; }
.pf-upg .num { text-align: right; font-variant-numeric: tabular-nums; }
.pf-upg.best { background: rgba(63,191,111,.08); outline: 1px solid rgba(63,191,111,.3); }

.badge.cat-badge { background: rgba(255,128,0,.15); color: #ffa94d; }

tr.bg-keep td { opacity: .6; }

tr.pf-prof-active td { background: rgba(79,156,247,.08); }
.pf-actions select { max-width: 180px; }
.char-pick label select { margin-left: auto; font-size: 11px; padding: 1px 4px; max-width: 110px; }

/* guild site */
a.brand { color: var(--text); text-decoration: none; }
.user-chip { display: flex; align-items: center; gap: 8px; font-size: 13px; white-space: nowrap; }
nav a { cursor: pointer; text-decoration: none; }
.big-btn { padding: 10px 22px; font-size: 15px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; text-decoration: none; }
a.btn { display: inline-block; text-decoration: none; color: var(--text); }
a.btn:hover { text-decoration: none; border-color: var(--accent); }
.notice { background: rgba(224,168,79,.1); border: 1px solid rgba(224,168,79,.35); border-radius: 8px; padding: 10px 12px; margin: 14px 0; }

body.landing-mode header nav, body.landing-mode #queue-pill { visibility: hidden; }
.landing { min-height: calc(100vh - 120px); display: flex; align-items: center; justify-content: center; }
.landing-card { background: var(--panel); border: 1px solid var(--border); border-radius: 14px; padding: 40px; max-width: 520px; text-align: center; }
.landing-card h1 { margin: 6px 0 10px; font-size: 26px; }
.landing-card .brand.big { font-size: 15px; letter-spacing: 2px; text-transform: uppercase; color: var(--accent); }
.landing-card .big-btn { margin: 18px 0 10px; }

.hero-row { display: flex; align-items: center; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.char-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.char-card { background: var(--panel); border: 1px solid var(--border); border-left: 4px solid var(--cls); border-radius: 10px; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.char-card-head { display: flex; flex-direction: column; }
.char-card-head a { font-size: 17px; text-decoration: none; }
.char-card-stats { display: flex; gap: 18px; }
.char-card-stats div { display: flex; flex-direction: column; }
.char-card-stats span { font-size: 11px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); }
.char-card-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.char-card-actions button { font-size: 12px; padding: 4px 8px; }
.setup { margin-top: 16px; }
.add-list { display: flex; flex-direction: column; gap: 4px; }
.add-row { display: flex; align-items: center; gap: 10px; padding: 6px 8px; background: var(--panel2); border-radius: 6px; flex-wrap: wrap; }
.steps-list { margin: 8px 0; padding-left: 20px; line-height: 1.8; }
.tips { margin: 0; padding-left: 18px; line-height: 1.8; }
details summary { cursor: pointer; }

.step { display: flex; align-items: center; gap: 10px; }
.step span { width: 24px; height: 24px; border-radius: 50%; background: var(--accent); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-size: 13px; }
.action-cards { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.action-card { text-align: left; display: flex; flex-direction: column; gap: 4px; padding: 14px; border-radius: 10px; background: var(--panel2); }
.action-card b { font-size: 15px; }
.action-card span { font-size: 12px; color: var(--muted); }
.action-card.active { border-color: var(--accent); background: rgba(79,156,247,.1); }
.presets button.active { border-color: var(--accent); color: var(--accent); }
.start-row { margin-top: 6px; }

.suggest { display: flex; flex-direction: column; gap: 2px; max-width: 520px; }
.suggest-item { display: flex; align-items: center; gap: 8px; text-align: left; border: none; background: var(--panel2); }
.suggest-item:hover { background: rgba(79,156,247,.12); }
.pf-edit.readonly .row.end, .pf-edit.readonly [data-prof-main], .pf-edit.readonly [data-prof-del],
.pf-edit.readonly [data-prof-rename], .pf-edit.readonly #notes-save { display: none; }

@media (max-width: 760px) {
  header { height: auto; flex-wrap: wrap; padding: 8px 12px; gap: 8px; }
  nav { order: 3; flex: 1 1 100%; overflow-x: auto; }
  .user-chip { margin-left: auto; }
  #queue-pill { display: none; }
  main { padding: 12px; }
  .grid { grid-template-columns: 1fr; }
  .modal { padding: 0; }
  .modal-body, .modal.wide .modal-body { width: 100%; min-height: 100vh; border-radius: 0; }
  .pf-hero { padding: 18px; }
  .pf-body, .pf-lower { padding-left: 14px; padding-right: 14px; }
  .pf-body { grid-template-columns: 1fr; }
  .pf-tiles { flex-wrap: wrap; }
  .landing-card { padding: 24px; }
  .row > .field { min-width: 45%; }
}

tr.gp-added td { opacity: .5; }
.ctx-tabs { flex-wrap: wrap; margin: 4px 0 8px; }
.who-table tr.who-no td { opacity: .55; }
.who-missing { margin-top: 10px; padding: 10px 12px; background: var(--panel2); border-radius: 8px; }

.char-pick label.no-sim { opacity: .45; cursor: not-allowed; }

/* loot page */
.loot-top { margin-bottom: 14px; }
.boss-list { display: flex; flex-direction: column; gap: 8px; }
.boss { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.boss-head { width: 100%; display: flex; align-items: center; gap: 12px; padding: 12px 16px; border: none; border-radius: 0; background: none; text-align: left; }
.boss-head:hover { background: var(--panel2); }
.boss-name { display: flex; flex-direction: column; min-width: 200px; }
.boss-name b { font-size: 15px; }
.boss-icons { display: flex; gap: 2px; flex: 1; }
.boss-icons .icon { width: 24px; height: 24px; margin: 0; }
.boss-meta { color: var(--muted); white-space: nowrap; }
.chev { display: inline-block; transition: transform .15s; color: var(--muted); }
.boss.open > .boss-head .chev, .loot-item.open .loot-row .chev { transform: rotate(90deg); }
.boss-body { border-top: 1px solid var(--border); }
.boss:not(.open) .boss-body { display: none; }
.loot-item + .loot-item { border-top: 1px solid rgba(255,255,255,.04); }
.loot-row { display: flex; align-items: center; gap: 10px; padding: 8px 16px; cursor: pointer; }
.loot-row:hover { background: rgba(255,255,255,.025); }
.loot-item.open .loot-row { background: rgba(79,156,247,.07); }
.loot-icon .icon { width: 28px; height: 28px; margin: 0; }
.loot-name { display: flex; flex-direction: column; min-width: 220px; flex: 0 0 auto; }
.takers { display: flex; gap: 6px; flex-wrap: wrap; flex: 1; align-items: center; }
.taker { font-size: 12px; padding: 2px 8px; border-radius: 12px; background: rgba(255,255,255,.04); border-left: 3px solid var(--cls); color: var(--cls); }
.taker b { color: var(--good); font-weight: 600; margin-left: 4px; }
.loot-detail { padding: 6px 16px 14px 54px; background: rgba(0,0,0,.15); }
@media (max-width: 760px) {
  .boss-icons { display: none; }
  .boss-name, .loot-name { min-width: 0; }
  .loot-row { flex-wrap: wrap; }
  .loot-detail { padding-left: 12px; overflow-x: auto; }
}

.sim-summary { font-size: 13px; color: var(--muted); background: var(--panel2); border-radius: 8px; padding: 8px 12px; }
.sim-summary:empty { display: none; }
.sim-summary b { color: var(--text); }
