:root {
  --bg: #12141a; --panel: #1a1d25; --panel2: #222632; --line: #2e3342; --text: #e6e8ee; --muted: #8d94a8;
  --gold: #d9b45a; --good: #4fbf7a; --warn: #e0a643; --bad: #e0605a; --over: #8f6bd8; --accent: #5b8def;
  --alb: #c94a4a; --mid: #4a7fd1; --hib: #3fa864;
  --craft: #59b7c9; --mine: #d9b45a; --sugg: #8aa2ff;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.4 "Segoe UI", system-ui, sans-serif; }
button, select, input, textarea { font: inherit; color: inherit; }
button { background: var(--panel2); border: 1px solid var(--line); border-radius: 6px; padding: 6px 11px; cursor: pointer; }
button:hover { border-color: #4a5168; }
button.primary { background: linear-gradient(#3e6fd6, #3159b3); border-color: #3e6fd6; color: #fff; font-weight: 600; }
button.primary:hover { filter: brightness(1.1); }
button.mini { padding: 1px 7px; font-size: 11px; float: right; }
select, input, textarea { background: var(--panel2); border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; }
textarea { width: 100%; font-family: Consolas, monospace; font-size: 12px; }
.hint { color: var(--muted); font-size: 12px; font-weight: 400; }

.top { display: flex; align-items: center; gap: 12px; padding: 10px 16px; background: var(--panel); border-bottom: 1px solid var(--line); flex-wrap: wrap; position: sticky; top: 0; z-index: 5; }
.brand { font-size: 18px; letter-spacing: .5px; color: var(--gold); margin-right: 6px; }
.brand b { color: var(--text); }
.fld { display: flex; flex-direction: column; font-size: 11px; color: var(--muted); gap: 2px; }
.realms { display: flex; gap: 4px; }
.realms button { opacity: .55; }
.realms button.on { opacity: 1; font-weight: 600; }
.realms .alb.on { background: var(--alb); border-color: var(--alb); }
.realms .mid.on { background: var(--mid); border-color: var(--mid); }
.realms .hib.on { background: var(--hib); border-color: var(--hib); }
.spacer { flex: 1; }
.menu { position: relative; }
.menu-pop { position: absolute; right: 0; top: 110%; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 6px; min-width: 230px; display: none; box-shadow: 0 10px 30px #0008; z-index: 20; }
.menu-pop.open { display: block; }
.menu-pop button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 6px 8px; }
.menu-pop button:hover { background: var(--panel2); }
.menu-pop hr { border: 0; border-top: 1px solid var(--line); margin: 4px 0; }
.menu-pop .save-row { display: flex; }
.menu-pop .save-row button:last-child { width: auto; color: var(--muted); }
.era-note { padding: 6px 16px; font-size: 12px; color: var(--muted); background: #161920; border-bottom: 1px solid var(--line); }

.layout { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr) minmax(0, .85fr); gap: 14px; padding: 14px; align-items: start; }
@media (max-width: 1100px) { .layout { grid-template-columns: minmax(0, 1fr); } }
.col-head { font-weight: 600; margin-bottom: 8px; }
.group { margin-bottom: 12px; }
.group-title { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); margin: 6px 2px; }
.col { min-width: 0; }
.slotgrid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.slot { background: var(--panel); border: 1px solid var(--line); border-left: 3px solid var(--line); border-radius: 7px; padding: 7px 9px; cursor: pointer; position: relative; min-height: 58px; transition: border-color .15s; }
.slot:hover { border-color: #4a5168; }
.slot.mine { border-left-color: var(--mine); }
.slot.sugg { border-left-color: var(--sugg); }
.slot.craft { border-left-color: var(--craft); }
.slot.inactive { opacity: .4; }
.slot .sname { font-size: 11px; color: var(--muted); display: flex; justify-content: space-between; }
.slot .iname { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.slot .iname.empty { color: #5d6478; font-weight: 400; font-style: italic; }
.slot .ibon { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.slot .tag { font-size: 10px; padding: 0 5px; border-radius: 8px; }
.tag.mine { background: #d9b45a22; color: var(--mine); }
.tag.sugg { background: #8aa2ff22; color: var(--sugg); }
.tag.craft { background: #59b7c922; color: var(--craft); }
.slot .pin { position: absolute; right: 6px; bottom: 4px; font-size: 12px; opacity: .35; border: 0; background: none; padding: 2px; }
.slot .pin.on { opacity: 1; }

.scorebox { display: flex; gap: 14px; align-items: center; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px; margin-bottom: 12px; }
.ring { position: relative; width: 96px; height: 96px; flex: none; }
.ring svg { transform: rotate(-90deg); width: 100%; height: 100%; }
.ring circle { fill: none; stroke-width: 11; }
.ring .bg { stroke: var(--panel2); }
.ring .fg { stroke: var(--good); stroke-linecap: round; transition: stroke-dashoffset .5s, stroke .5s; }
.ringval { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 26px; font-weight: 700; }
.ringval small { font-size: 13px; color: var(--muted); }
.scoretitle { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; }
.verdict { font-size: 17px; font-weight: 600; }
.sub { color: var(--muted); font-size: 12px; }

.barsec { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px 10px; margin-bottom: 10px; }
.barsec h4 { margin: 2px 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); display: flex; justify-content: space-between; }
.bar { display: grid; grid-template-columns: 118px 1fr 74px; align-items: center; gap: 8px; font-size: 12.5px; padding: 2px 0; }
.bar.unimportant { opacity: .5; }
.bar .lbl { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar .lbl .star { color: var(--gold); font-size: 10px; }
.bar .track { height: 9px; background: var(--panel2); border-radius: 5px; position: relative; overflow: hidden; }
.bar .fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 5px; }
.bar .ofill { position: absolute; top: 0; bottom: 0; background: var(--over); opacity: .85; }
.bar .capline { position: absolute; top: -2px; bottom: -2px; width: 2px; background: #fff6; }
.bar .num { text-align: right; font-variant-numeric: tabular-nums; }
.num .waste { color: var(--bad); font-size: 11px; }
.c-good { background: var(--good); } .c-warn { background: var(--warn); } .c-bad { background: var(--bad); }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-bottom: 10px; }
.card h3 { margin: 0 0 8px; font-size: 13px; }
.card.small { font-size: 12px; }
.gap { display: flex; justify-content: space-between; padding: 3px 0; border-bottom: 1px dashed #2a2f3c; font-size: 12.5px; }
.gap:last-child { border: 0; }
.gap .need { color: var(--warn); font-variant-numeric: tabular-nums; }
.gap .need.waste { color: var(--bad); }
.upg { padding: 5px 0; border-bottom: 1px dashed #2a2f3c; font-size: 12.5px; cursor: pointer; }
.upg:hover .uname { text-decoration: underline; }
.upg .gain { float: right; color: var(--good); font-weight: 600; }
.upg .uslot { color: var(--muted); font-size: 11px; }
.piece { margin-bottom: 7px; font-size: 12.5px; }
.piece .ph { display: flex; justify-content: space-between; color: var(--craft); font-weight: 600; }
.piece .imb.ok { color: var(--good); } .piece .imb.over { color: var(--bad); }
.piece ul { margin: 2px 0 0 0; padding-left: 16px; color: #cfd3de; }
.chips { display: flex; flex-wrap: wrap; gap: 5px; }
.chip { font-size: 11.5px; padding: 2px 8px; border-radius: 10px; background: var(--panel2); border: 1px solid var(--line); cursor: default; }
.chip.click { cursor: pointer; user-select: none; }
.chip.main { background: #3e6fd633; border-color: #3e6fd6; }
.chip.minor { background: #3e6fd614; border-color: #3e6fd677; }
.chip.off { opacity: .45; text-decoration: line-through; }
.chip.k-stat { border-color: #6b7a99; } .chip.k-res { border-color: #3fa86488; } .chip.k-toa { border-color: #d9b45a88; } .chip.k-skill { border-color: #5b8def88; } .chip.k-cap { border-color: #8f6bd888; }
.chk { display: flex; gap: 6px; align-items: center; margin: 3px 0; cursor: pointer; }
.foot { color: var(--muted); font-size: 11px; padding: 4px; }
.foot a { color: var(--muted); }

.modal { position: fixed; inset: 0; background: #000a; display: flex; align-items: center; justify-content: center; z-index: 50; }
.modal[hidden] { display: none; }
.dlg { width: min(860px, 96vw); height: min(760px, 92vh); background: var(--panel); border: 1px solid var(--line); border-radius: 12px; display: flex; flex-direction: column; box-shadow: 0 20px 60px #000c; }
.dlg-head { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.dlg-title { font-weight: 700; font-size: 16px; }
.tabs { display: flex; gap: 4px; flex: 1; }
.tabs button { border-color: transparent; background: none; color: var(--muted); }
.tabs button.on { background: var(--panel2); border-color: var(--line); color: var(--text); }
.x { border: 0; background: none; font-size: 16px; }
.dlg-body { flex: 1; overflow: hidden; padding: 12px 14px; display: flex; flex-direction: column; }
.dlg-body > div { display: flex; flex-direction: column; gap: 8px; min-height: 0; flex: 1; overflow: auto; }
.dlg-body > div[hidden] { display: none; }
.dlg-foot { padding: 8px 14px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; }
.pk-tools { display: flex; gap: 8px; align-items: center; }
.pk-tools input { flex: 1; }
.pk-list { overflow: auto; flex: 1; border: 1px solid var(--line); border-radius: 8px; }
.pk-item { padding: 7px 10px; border-bottom: 1px solid #262a36; cursor: pointer; display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; }
.pk-item:hover { background: var(--panel2); }
.pk-item.cur { background: #3e6fd622; }
.pk-item .n { font-weight: 600; }
.pk-item .g { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.pk-item .g.pos { color: var(--good); } .pk-item .g.neg { color: var(--bad); } .pk-item .g.zero { color: var(--muted); }
.pk-item .meta { font-size: 11px; color: var(--muted); }
.pk-item .chips { grid-column: 1 / -1; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.gemrow { display: flex; gap: 6px; align-items: center; }
.gemrow select { min-width: 170px; }
.imb { font-weight: 600; }
.imb.ok { color: var(--good); } .imb.over { color: var(--bad); }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); max-width: min(560px, 92vw); text-align: center; background: #2b3247; border: 1px solid #4a5168; padding: 8px 16px; border-radius: 8px; opacity: 0; transition: opacity .25s; pointer-events: none; z-index: 99; }
.toast.show { opacity: 1; }
.welcome { background: linear-gradient(135deg, #1f2433, #1a1d25); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; margin-bottom: 10px; }
.welcome ol { margin: 6px 0 0; padding-left: 20px; }

/* --- v2 additions --- */
.top button:disabled { opacity: .4; cursor: default; }
.badge { background: var(--gold); color: #1a1d25; border-radius: 9px; padding: 0 6px; font-size: 11px; font-weight: 700; margin-left: 4px; }
.slot .isrc { font-size: 10.5px; color: #6f7790; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-right: 44px; }
.slot .acts { position: absolute; right: 4px; bottom: 3px; display: flex; gap: 0; }
.slot .acts button { border: 0; background: none; padding: 2px 3px; font-size: 12px; opacity: .35; }
.slot .acts button:hover, .slot .acts button.on { opacity: 1; }
.welcome b { color: var(--gold); }
.note { font-size: 11px; color: var(--muted); margin-top: 4px; }
.opt-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 5px 0; }
.opt-row select { padding: 3px 6px; }
.own { color: var(--good); font-size: 11px; font-weight: 600; }
.pk-item .side { text-align: right; display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.pk-item .ban { border: 0; background: none; padding: 0 2px; font-size: 12px; opacity: .4; }
.pk-item .ban:hover { opacity: 1; }
.pk-item.owned { box-shadow: inset 3px 0 0 var(--mine); }
.v-slot { display: inline-block; min-width: 74px; color: var(--muted); font-size: 11px; font-weight: 400; }
.dlg.small { width: min(460px, 94vw); height: auto; }
.dlg.small .dlg-body { padding: 14px; gap: 10px; overflow: visible; }
.dlg.small .dlg-body > * { flex: none; }
.dlg.small input, .dlg.small textarea { width: 100%; }
.dlg.small .dlg-foot { gap: 8px; }
#askText { white-space: pre-wrap; }
.num .rr { color: var(--gold); font-size: 11px; }
.bar { grid-template-columns: 118px 1fr 88px; }

/* delve preview: ambiguity switch + skipped words */
button.amb { flex-basis: 100%; text-align: left; font-size: 12px; padding: 4px 8px; border: 1px dashed var(--gold, #d6a93e); background: transparent; }
.chips .skipped { flex-basis: 100%; }

/* procs & charges */
.abil { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.abt { display: inline-block; font-size: 10.5px; padding: 0 6px; border-radius: 8px; border: 1px solid var(--line); color: var(--gold); margin-right: 3px; white-space: nowrap; }
.abt.ab-P { color: #e08a5a; } .abt.ab-R { color: #5ab4e0; } .abt.ab-W { color: var(--good); }
.slot .iab { font-size: 10.5px; color: var(--gold); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-right: 44px; }
.chips .abil { flex-basis: 100%; }
#abilCard { margin-top: 12px; }
.abrow { padding: 5px 0; border-top: 1px solid var(--line); }
.abrow:first-child { border-top: 0; }
.abhead { font-size: 12.5px; }
.abslot { color: var(--muted); font-size: 11px; margin-right: 4px; }

.sitefoot { margin: 28px auto 18px; padding: 0 16px; max-width: 900px; text-align: center; font-size: 12px; opacity: .55; }
.sitefoot a { color: inherit; text-decoration: underline; }
.tplname { display: flex; align-items: center; gap: 6px; }
.tplname input { width: 170px; background: transparent; border-color: transparent; font-weight: 600; }
.tplname input:hover, .tplname input:focus { background: var(--panel2); border-color: var(--line); outline: none; }
.tplname input::placeholder { font-weight: 400; color: var(--muted); }
#tplSaved { font-size: 12px; color: var(--muted); min-width: 52px; }
