/* SkyBlock DPS Lab – panels: loadout (inventory slots, accessory bag, buffs), results (headline numbers, damage vs
   target, build-up bars, stats table with source breakdown, notes) and upgrades (sortable table, sticky plan summary).
   Brief: research/DESIGN.md. Uses the tokens of css/styles.css only; game icons / tooltips are styled by css/mc.css.
   Loaded after styles.css. */

/* ------------------------------------------------------------------------------------------ */
/* Shared                                                                                       */

.col-loadout, .col-results { display: flex; flex-direction: column; gap: var(--sp-4); min-width: 0; }
.col-loadout > .card + .card, .col-results > .card + .card { margin-top: 0; }
.card-hint { font-size: 12px; color: var(--faint); }

.lo-label, .res-sec-title {
  margin: 0 0 var(--sp-2); font-size: 11px; font-weight: 500; line-height: 16px; text-transform: uppercase;
  letter-spacing: .04em; color: var(--faint);
}
.dot { margin: 0 6px; color: var(--faint); }
.neg { color: var(--loss) !important; }
.mc-icon--ph { display: inline-block; flex: none; border-radius: var(--radius-sm); background: var(--raised); }

/* Disclosures ("Show all buffs", "Other stats", "Multiplier sources") */
.buff-more > summary, .stats-more > summary, .buckets-more > summary, .notes-more > summary {
  display: flex; align-items: center; gap: 6px; min-height: 32px; cursor: pointer; list-style: none;
  font-size: 13px; font-weight: 500; color: var(--muted); border-radius: var(--radius-sm);
}
.buff-more > summary:hover, .stats-more > summary:hover, .buckets-more > summary:hover, .notes-more > summary:hover { color: var(--text); }
.buff-more > summary::-webkit-details-marker, .stats-more > summary::-webkit-details-marker,
.buckets-more > summary::-webkit-details-marker, .notes-more > summary::-webkit-details-marker, .stat-sum::-webkit-details-marker, .up-more > summary::-webkit-details-marker { display: none; }
details > summary .chev { color: var(--faint); transition: transform .12s; }
details[open] > summary > .chev { transform: rotate(90deg); }
.stats-more-hint { font-weight: 400; font-size: 12px; margin-left: 4px; }
.buckets-more > summary, .stats-more > summary { flex-wrap: wrap; row-gap: 0; }

/* ------------------------------------------------------------------------------------------ */
/* Loadout: inventory slots                                                                     */

.loadout-card .card-body { display: flex; flex-direction: column; gap: var(--sp-4); container-type: inline-size; }
.lo-section { min-width: 0; }
.lo-gear { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--sp-4); }
.lo-gear--tight { gap: var(--sp-1); }
@container (min-width: 540px) {
  .lo-gear { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .lo-gear--tight { gap: var(--sp-1) var(--sp-4); }
}
.inv-col { display: flex; flex-direction: column; gap: var(--sp-1); }

.inv-slot {
  display: flex; align-items: center; gap: var(--sp-3); width: 100%; min-height: 52px; padding: 5px 10px 5px 5px;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text);
  text-align: left; font: inherit; transition: background-color .12s, border-color .12s;
}
.inv-slot:hover { background: var(--hover); border-color: var(--border-strong); }
.inv-slot[aria-expanded="true"] { border-color: var(--accent); }
.inv-slot:focus-visible { outline-offset: 1px; }
.inv-slot.is-empty { border-style: dashed; }
.inv-slot.is-skel { pointer-events: none; }
.inv-slot--wide { min-height: 72px; gap: var(--sp-3); }
.inv-ico { flex: none; display: grid; place-items: center; min-width: 40px; min-height: 40px; }
.inv-ico > .mc-icon--ph { width: 40px !important; height: 40px !important; }
.inv-slot--wide .inv-ico > .mc-icon--ph { width: 60px !important; height: 60px !important; }
/* Empty slot: the same recessed frame as a filled one (css/mc.css .mc-icon--frame), a little quieter. */
.mc-icon--empty { opacity: .7; }
.inv-slot.is-empty .inv-name { font-weight: 400; }
.inv-body { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.inv-line { display: flex; align-items: baseline; gap: var(--sp-2); min-width: 0; }
.inv-name {
  flex: 0 1 auto; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
  font-size: 13px; font-weight: 500; line-height: 18px;
}
.inv-slot--wide .inv-name { font-size: 14px; font-weight: 600; }
.inv-name .item-name { overflow-wrap: normal; }
.slot-loc { flex: none; margin-left: auto; white-space: nowrap; font-size: 11px; color: var(--faint); font-variant-numeric: tabular-nums; }
.slot-meta { display: flex; align-items: center; gap: 6px; min-width: 0; font-size: 12px; line-height: 17px; color: var(--muted); }
.slot-meta-text { flex: 0 1 auto; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.slot-meta-text > span { white-space: nowrap; }
.inv-slot--wide .slot-meta { align-items: flex-start; }
.inv-slot--wide .slot-meta-text { white-space: normal; }
.slot-meta .ench { color: var(--mc-9); }
.slot-meta .ench--ult { color: var(--mc-d); font-weight: 600; }
.slot-meta .dot { margin: 0 5px; }
.slot-gems { flex: none; display: inline-flex; gap: 1px; margin-left: auto; }
.inv-slot--wide .slot-gems { margin-top: 1px; }
.slot-stats { display: flex; flex-wrap: wrap; gap: 0 12px; font-size: 12px; line-height: 17px; color: var(--muted); }
.slot-stat { display: inline-flex; align-items: baseline; gap: 2px; white-space: nowrap; }
.slot-stat .num { color: var(--text); }
.legacy-attr { color: var(--warn); }
.inv-swap { flex: none; display: inline-flex; align-items: center; gap: 2px; font-size: 11px; color: var(--faint); font-variant-numeric: tabular-nums; }
.inv-slot:hover .inv-swap { color: var(--muted); }

/* Swap menu (popover from dom.js) */
.pop--alts { width: min(440px, calc(100vw - 16px)); }
.pop--alts .pop-body { padding: 0; }
.alt-list { display: flex; flex-direction: column; gap: 1px; max-height: min(440px, 62vh); overflow-y: auto; padding: 4px; }
.alt-opt {
  display: flex; align-items: center; gap: var(--sp-3); min-height: 48px; padding: 4px 8px 4px 4px;
  border-radius: var(--radius); cursor: pointer;
}
.alt-opt:hover { background: var(--hover); }
.alt-opt:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.alt-opt.is-current { background: var(--accent-weak); }
.alt-ico { flex: none; display: grid; place-items: center; width: 40px; height: 40px; }
.alt-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.alt-title { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 13px; font-weight: 500; }
.alt-title .item-name { overflow-wrap: normal; }
.alt-sub { display: flex; flex-wrap: wrap; align-items: baseline; font-size: 12px; color: var(--muted); }
.alt-sub .slot-stats { display: inline-flex; }
.alt-current { flex: none; font-size: 11px; color: var(--accent); }
.alt-empty { padding: 12px; font-size: 13px; color: var(--faint); }

/* Accessory bag: MP + power stone slot, then facts / enrichments / tuning as label | value rows */
.acc-bag { padding-top: var(--sp-4); border-top: 1px solid var(--border); }
.acc-top { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: var(--sp-3); align-items: stretch; margin-bottom: var(--sp-2); }
.acc-mp {
  display: flex; flex-direction: column; justify-content: center; min-width: 88px; padding: 0 var(--sp-3);
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface);
}
.acc-mp-val { font-size: 20px; font-weight: 600; line-height: 24px; letter-spacing: -0.01em; }
.acc-mp-unit { font-size: 11px; line-height: 14px; color: var(--faint); text-transform: uppercase; letter-spacing: .04em; }
.acc-list { margin: 0; }
.acc-row {
  display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: var(--sp-3); align-items: center;
  min-height: 36px; padding: 6px 0; border-top: 1px solid var(--border);
}
.acc-row:first-child { border-top: 0; }
.acc-row dt { font-size: 12px; color: var(--muted); }
.acc-row dd { margin: 0; min-width: 0; font-size: 13px; }
.acc-facts { font-size: 12px; color: var(--muted); }
.acc-chips { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 16px; font-size: 13px; }
.acc-chip { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.acc-chip-name { display: inline-flex; align-items: baseline; gap: 1px; }
.acc-chip .stat-sym { width: auto; margin-right: 3px; }
.acc-tun-pts { font-size: 12px; }

/* Buffs */
.buffs-card .card-body { display: flex; flex-direction: column; gap: var(--sp-4); }
.buff-group { min-width: 0; }
.buff-row { display: flex; align-items: flex-start; gap: var(--sp-3); padding: 2px 0; border-top: 1px solid var(--border); }
.buff-group > .lo-label + .buff-row { border-top: 0; }
.buff-ico { flex: none; display: grid; place-items: center; width: 32px; height: 32px; margin-top: 4px; }
.buff-row > .switch-row { flex: 1 1 auto; min-width: 0; }
.buff-row.is-skipped .switch-label { color: var(--muted); }
.buff-desc { color: var(--faint); }
.buff-note { color: var(--muted); }
.buff-note.is-warn { color: var(--warn); }
.buff-level { margin-left: 2px; }
.buff-warns {
  display: flex; flex-direction: column; gap: 4px; margin: 0; padding: 8px 12px; list-style: none; font-size: 12px; color: var(--muted);
  border: 1px solid color-mix(in srgb, var(--warn) 35%, var(--border)); border-radius: var(--radius);
}
.buff-warns li { display: flex; align-items: flex-start; gap: 8px; }
.buff-warns .ico { flex: none; margin-top: 1px; color: var(--warn); }
.buff-more > .buff-group { margin-top: var(--sp-3); }

/* ------------------------------------------------------------------------------------------ */
/* Results                                                                                      */

.res-hero .card-body { display: flex; flex-direction: column; gap: var(--sp-4); }
.res-head { display: inline-flex; align-items: center; gap: var(--sp-2); min-width: 0; font-size: 13px; }
.res-head .item-name { font-weight: 500; overflow-wrap: normal; white-space: nowrap; }

/* Headline numbers */
.kpis { display: flex; flex-wrap: wrap; gap: var(--sp-4) var(--sp-6); }
.kpi { display: flex; flex-direction: column; gap: 2px; min-width: 88px; }
.kpi-label { font-size: 12px; line-height: 16px; color: var(--muted); white-space: nowrap; }
.kpi-value {
  font-size: 20px; font-weight: 600; line-height: 1.2; letter-spacing: -0.01em; white-space: nowrap;
  font-variant-numeric: tabular-nums; color: var(--text);
}
.kpi--hero .kpi-value { font-size: 28px; letter-spacing: -0.02em; }
.kpi-value .unit { margin-left: 1px; font-size: .55em; font-weight: 500; color: var(--faint); letter-spacing: 0; }
.kpi-value .approx { font-size: .5em; }
.kpi-sub { max-width: 220px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 12px; line-height: 16px; color: var(--faint); }
.kpis--hero > .kpi--hero { padding-right: var(--sp-6); border-right: 1px solid var(--border); }
.kpis--sm { gap: var(--sp-3) var(--sp-5); }
.kpis--sm .kpi-value { font-size: 16px; }
.kpis--ehp { padding-bottom: var(--sp-4); border-bottom: 1px solid var(--border); }
.is-immune .kpis--hero .kpi-value { color: var(--faint); }

/* Banners & warnings */
.res-banner {
  display: flex; align-items: flex-start; gap: var(--sp-3); padding: var(--sp-3) var(--sp-4);
  border: 1px solid var(--border); border-left: 2px solid var(--accent); border-radius: var(--radius); background: var(--raised);
}
.res-banner > .ico { flex: none; margin-top: 2px; color: var(--accent); }
.res-banner--bad { border-left-color: var(--loss); }
.res-banner--bad > .ico { color: var(--loss); }
.res-banner-title { font-size: 13px; font-weight: 600; }
.res-banner-text { margin-top: 2px; font-size: 12px; color: var(--muted); }
.res-warns {
  display: flex; align-items: flex-start; gap: var(--sp-2); padding: 8px 12px; font-size: 12px; color: var(--muted);
  border: 1px solid color-mix(in srgb, var(--warn) 35%, var(--border)); border-radius: var(--radius);
}
.res-warns > .ico { flex: none; margin-top: 1px; color: var(--warn); }
.res-warns ul { display: flex; flex-direction: column; gap: 2px; margin: 0; padding: 0; list-style: none; }

/* Damage dealt to the target */
.eff {
  display: flex; flex-direction: column; gap: var(--sp-3); padding: var(--sp-3) var(--sp-4);
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--raised);
}
.eff--same { gap: 2px; }
.eff-head { display: flex; align-items: baseline; gap: var(--sp-2); }
.eff-title { font-size: 13px; font-weight: 600; }
.eff-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(112px, 1fr)); gap: var(--sp-3) var(--sp-4); }
.eff-cell { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.eff-label { font-size: 12px; color: var(--muted); }
.eff-val { font-size: 16px; font-weight: 600; font-variant-numeric: tabular-nums; }
.eff-raw { font-size: 11px; color: var(--faint); font-variant-numeric: tabular-nums; white-space: nowrap; }
.eff-factor { color: var(--muted); }
.eff-steps { font-size: 12px; color: var(--muted); }
.eff-step { white-space: nowrap; }
.eff-step .num { color: var(--text); }
.eff-sub { font-size: 12px; color: var(--faint); }

/* Sections inside the headline card (ability, extra damage) */
.res-sec { padding-top: var(--sp-4); border-top: 1px solid var(--border); }
.res-note { margin-top: var(--sp-2); font-size: 12px; color: var(--muted); }
.res-notes-list { display: flex; flex-direction: column; gap: 3px; margin: 0; padding-left: 16px; font-size: 12px; color: var(--muted); }
.res-sec .res-notes-list { margin-top: var(--sp-2); }
.extra-list { margin: 0; padding: 0; list-style: none; }
.extra-list li {
  display: grid; grid-template-columns: minmax(0, 1fr) auto 80px; gap: var(--sp-3); align-items: baseline;
  padding: 6px 0; border-top: 1px solid var(--border); font-size: 13px;
}
.extra-list li:first-child { border-top: 0; padding-top: 0; }
.extra-tag { font-size: 11px; color: var(--faint); white-space: nowrap; }
.extra-val { text-align: right; font-weight: 500; white-space: nowrap; }
.extra-val .unit, .extra-total .unit { margin-left: 1px; font-size: 11px; color: var(--faint); }
.extra-total {
  display: flex; justify-content: space-between; gap: var(--sp-3); margin-top: 4px; padding-top: 8px;
  border-top: 1px solid var(--border-strong); font-size: 13px; font-weight: 600;
}
.approx-legend { display: flex; align-items: baseline; gap: 6px; padding-top: var(--sp-3); border-top: 1px solid var(--border); font-size: 12px; color: var(--faint); }
.approx-legend > .approx { margin-left: 0; }
.approx-legend b { font-weight: 500; color: var(--muted); }

/* Damage build-up: formula steps as horizontal bars (one neutral colour, log scale) */
.buildup-card .card-body { display: flex; flex-direction: column; gap: var(--sp-2); }
.waterfall { display: flex; flex-direction: column; }
.wf-row {
  display: grid; grid-template-columns: minmax(0, 1fr) 68px minmax(64px, 180px) 76px; gap: var(--sp-3); align-items: center;
  min-height: 30px; border-top: 1px solid var(--border); font-size: 13px;
}
.waterfall > .wf-row:nth-child(2) { border-top: 0; }
.wf-label { min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.wf-factor { text-align: right; white-space: nowrap; color: var(--muted); font-variant-numeric: tabular-nums; }
.wf-factor.is-down { color: var(--loss); }
.wf-bar { display: block; height: 6px; overflow: hidden; border-radius: 1px; background: var(--raised); }
.wf-bar > span { display: block; height: 100%; background: color-mix(in srgb, var(--text) 38%, transparent); }
.wf-total { text-align: right; white-space: nowrap; font-weight: 500; }
.wf-row--result { border-top-color: var(--border-strong); font-weight: 600; }
.wf-row--result .wf-bar { background: none; }
.wf-row--result .wf-total { font-size: 15px; font-weight: 600; }
.buckets-more { margin-top: var(--sp-2); padding-top: var(--sp-2); border-top: 1px solid var(--border); }
.buckets { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: var(--sp-4) var(--sp-6); padding: var(--sp-2) 0 var(--sp-1); }
.bucket { width: 100%; border-collapse: collapse; align-self: start; font-size: 12px; }
.bucket th { padding: 0 0 4px; border-bottom: 1px solid var(--border); text-align: left; font-weight: 600; color: var(--text); }
.bucket td { padding: 3px 0; vertical-align: top; color: var(--muted); }
.bucket .num { padding-left: var(--sp-2); text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.bucket td.num { color: var(--text); }

/* Stats: two columns of name | value rows; a row opens its per-source breakdown */
.stats-card .card-body { display: flex; flex-direction: column; gap: var(--sp-3); container-type: inline-size; }
.stat-table { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 var(--sp-6); }
@container (max-width: 480px) {
  .stat-table { grid-template-columns: minmax(0, 1fr); }
  .stat-col + .stat-col > .stat-row:first-child { border-top: 1px solid var(--border); }
}
.stat-col { display: flex; flex-direction: column; min-width: 0; }
.stat-row { border-top: 1px solid var(--border); }
.stat-col > .stat-row:first-child { border-top: 0; }
.stat-sum {
  display: flex; align-items: center; gap: var(--sp-2); min-height: 32px; padding: 0 4px; margin: 0 -4px;
  border-radius: var(--radius-sm); cursor: pointer; list-style: none;
}
.stat-sum:hover { background: var(--hover); }
.stat-name { flex: 1 1 auto; min-width: 0; display: flex; align-items: center; gap: 4px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 13px; }
.stat-val { flex: none; font-size: 13px; font-weight: 600; }
.stat-row[open] > .stat-sum .chev { transform: rotate(180deg); }
.stat-row[open] > .stat-sum { background: var(--raised); }
.stat-bd { padding: 4px 0 10px; }
.stat-bd-empty { padding: 6px 4px; font-size: 12px; color: var(--faint); }
.bd-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.bd-table th, .bd-table td { padding: 3px 4px; text-align: left; vertical-align: middle; }
.bd-table td.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; color: var(--text); }
.bd-group th { padding-top: 8px; font-size: 11px; font-weight: 500; text-transform: uppercase; letter-spacing: .04em; color: var(--faint); }
.bd-group td.num { padding-top: 8px; color: var(--muted); }
.bd-table tr:first-child th, .bd-table tr:first-child td { padding-top: 2px; }
.bd-src { display: inline-flex; align-items: center; gap: 6px; min-width: 0; color: var(--muted); }
.bd-spacer { flex: none; display: inline-block; width: 16px; height: 16px; }
.bd-label { min-width: 0; }
.bd-from { color: var(--faint); }
.bd-total th, .bd-total td { padding-top: 6px; border-top: 1px solid var(--border); font-weight: 600; color: var(--text); }
.stats-more { padding-top: var(--sp-1); border-top: 1px solid var(--border); }
.stats-more > .stat-table { margin-top: var(--sp-1); }

/* Notes at the end of the results column */
.res-notes { padding: 0 var(--sp-1); }
.notes-more > summary { min-height: 28px; font-size: 12px; }
.notes-more > .res-notes-list { margin-top: 2px; }

/* ------------------------------------------------------------------------------------------ */
/* Upgrades                                                                                     */

.upgrades-card > .card-body { padding: 0; }
.up-toolbar {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 0 var(--sp-4);
  padding: 0 var(--sp-4); border-bottom: 1px solid var(--border);
}
.up-tabs { display: flex; max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.up-tabs::-webkit-scrollbar { display: none; }
.budget { display: flex; align-items: center; flex-wrap: wrap; gap: var(--sp-2); padding: 8px 0; }
.budget-label { font-size: 12px; color: var(--muted); }
.budget .input { width: 92px; height: 24px; padding: 0 8px; font-size: 12px; }
.up-descrow { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); padding: var(--sp-3) var(--sp-4) var(--sp-2); }
.up-desc { font-size: 12px; color: var(--muted); }
.up-sort-mobile { display: none; align-items: center; gap: 6px; flex: none; font-size: 12px; }

.up-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.up-table th {
  height: 32px; padding: 0 var(--sp-3); border-bottom: 1px solid var(--border); text-align: left; white-space: nowrap;
  font-size: 11px; font-weight: 500; text-transform: uppercase; letter-spacing: .04em; color: var(--faint);
}
.up-table td { padding: 8px var(--sp-3); border-bottom: 1px solid var(--border); vertical-align: middle; }
.up-table tbody tr:last-child td { border-bottom: 0; }
.up-table tbody tr:hover td { background: var(--raised); }
.up-row.is-planned td { background: var(--accent-weak); }
.up-row.is-planned:hover td { background: color-mix(in srgb, var(--accent) 16%, var(--surface)); }
.up-table .c-rank { width: 48px; padding-left: var(--sp-4); text-align: right; color: var(--faint); }
.up-table td.c-rank { vertical-align: top; padding-top: 16px; }
.up-table .c-gain, .up-table .c-cost, .up-table .c-eff { width: 1%; text-align: right; white-space: nowrap; }
.up-table .c-plan { width: 64px; padding-right: var(--sp-4); text-align: center; }
.th-sort {
  display: inline-flex; align-items: center; gap: 2px; padding: 0; border: 0; background: none;
  font: inherit; color: inherit; text-transform: inherit; letter-spacing: inherit; cursor: pointer;
}
.th-sort:hover, .th-sort.is-active { color: var(--text); }
.sort-ico { opacity: 0; transition: transform .12s, opacity .12s; }
.th-sort:hover .sort-ico, .th-sort.is-active .sort-ico { opacity: 1; }
.sort-ico.is-asc { transform: rotate(180deg); }
.c-gain .th-sort, .c-cost .th-sort, .c-eff .th-sort, .c-rank .th-sort { flex-direction: row-reverse; }

.up-title { display: flex; align-items: flex-start; gap: var(--sp-3); min-width: 0; }
.up-ico { flex: none; display: grid; place-items: center; width: 32px; height: 32px; }
.up-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; padding-top: 1px; }
.up-name { font-weight: 500; line-height: 18px; overflow-wrap: anywhere; }
.up-sub, .up-more > summary { display: flex; flex-wrap: wrap; align-items: center; gap: 0 10px; font-size: 12px; line-height: 17px; color: var(--faint); }
.up-more > summary { width: fit-content; cursor: pointer; list-style: none; border-radius: var(--radius-sm); }
.up-more-label { display: inline-flex; align-items: center; gap: 2px; color: var(--muted); }
.up-more > summary:hover .up-more-label { color: var(--text); }
.up-more[open] .up-more-label .chev { transform: rotate(180deg); }
.up-req { color: var(--warn); }
.up-details {
  display: flex; flex-direction: column; gap: 6px; max-width: 560px; margin-top: 6px; padding: 8px 10px;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); font-size: 12px; color: var(--muted);
}
.up-cost-table { width: 100%; border-collapse: collapse; }
.up-cost-table td { padding: 2px 0; border: 0; background: none !important; vertical-align: middle; }
.up-cost-table td.num { padding-left: var(--sp-3); text-align: right; white-space: nowrap; color: var(--text); font-variant-numeric: tabular-nums; }
.up-cost-item { display: inline-flex; align-items: center; gap: 6px; }
.up-gain { display: block; font-weight: 600; color: var(--gain); }
.gain-bar { display: block; width: 64px; height: 2px; margin: 4px 0 0 auto; overflow: hidden; border-radius: 1px; background: var(--border); }
.gain-bar > span { display: block; height: 100%; background: var(--gain); }
.up-cost { color: var(--text); }
.up-cost.is-free { color: var(--muted); }
.per-unit { margin-left: 1px; font-size: 11px; color: var(--faint); }
.up-eff { color: var(--muted); }
.mob-label { display: none; }
.up-foot { padding: var(--sp-2) var(--sp-4); font-size: 12px; color: var(--faint); }
.up-empty { padding: var(--sp-8) var(--sp-4); text-align: center; font-size: 13px; color: var(--muted); }

/* "Now → after all N" summary: sticks to the bottom of the viewport while the table scrolls. */
.up-summary {
  position: sticky; bottom: 0; z-index: 5; display: flex; flex-direction: column; gap: 6px;
  padding: var(--sp-3) var(--sp-4); border-top: 1px solid var(--border-strong); background: var(--raised);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}
.sum-main { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px var(--sp-5); }
.sum-title { font-size: 13px; font-weight: 600; }
.sum-numbers { display: inline-flex; align-items: baseline; gap: var(--sp-2); font-size: 13px; }
.sum-metric { color: var(--muted); }
.sum-numbers .from { color: var(--muted); }
.sum-numbers .arrow { color: var(--faint); }
.sum-numbers .to { font-size: 18px; font-weight: 600; }
.sum-gain { font-weight: 600; color: var(--gain); }
.sum-cost { font-size: 13px; }
.sum-cost .coins { font-weight: 500; }
.sum-main > .btn { margin-left: auto; }
.sum-stats { display: flex; flex-wrap: wrap; gap: 2px var(--sp-5); margin: 0; padding: 0; list-style: none; font-size: 12px; color: var(--muted); }
.sum-stat { display: inline-flex; align-items: baseline; gap: 4px; white-space: nowrap; }
.sum-stat .num { color: var(--text); }
.sum-stat .delta { color: var(--gain); }

/* ------------------------------------------------------------------------------------------ */
/* Narrow screens                                                                               */

@media (max-width: 640px) {
  .wf-row { grid-template-columns: minmax(0, 1fr) 60px 68px; }
  .wf-bar { display: none; }
  .kpis--hero > .kpi--hero { flex: 1 0 100%; padding-right: 0; border-right: 0; }
  .kpi--hero .kpi-value { font-size: 26px; }

  /* Upgrades: rows become stacked blocks; the header row stays for screen readers, sorting moves to a select. */
  .up-sort-mobile { display: inline-flex; }
  .up-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .up-table, .up-table tbody { display: block; }
  .up-table .up-row { display: flex; flex-wrap: wrap; align-items: flex-start; row-gap: 4px; padding: 10px var(--sp-4); border-bottom: 1px solid var(--border); }
  .up-table tbody tr:last-child { border-bottom: 0; }
  .up-table .up-row > td { display: block; width: auto; padding: 0; border: 0; background: none; }
  .up-table .up-row > td.c-rank { order: 1; flex: 0 0 24px; padding: 8px 0 0; text-align: left; }
  .up-table .up-row > td.c-title { order: 2; flex: 0 0 calc(100% - 64px); min-width: 0; }
  .up-table .up-row > td.c-plan { order: 3; flex: 0 0 40px; padding-top: 6px; text-align: right; }
  .up-table .up-row > td.c-gain { order: 4; margin-left: 68px; text-align: left; }
  .up-table .up-row > td.c-cost, .up-table .up-row > td.c-eff { order: 5; margin-left: var(--sp-4); text-align: left; }
  .up-table--nocost .up-row > td.c-gain { margin-left: 68px; }
  .up-row.is-planned { background: var(--accent-weak); }
  .gain-bar { display: none; }
  .mob-label { display: inline; color: var(--faint); }
  .up-details { max-width: none; }
  /* Cost breakdown: item (icon, name, source) on its own line, "qty × unit" and the total below it – never past the box. */
  .up-cost-table, .up-cost-table tbody { display: block; }
  .up-cost-table tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: var(--sp-3); padding: 4px 0; }
  .up-cost-table tr + tr { border-top: 1px solid var(--border); }
  .up-cost-table td:first-child { grid-column: 1 / -1; }
  .up-cost-table td.num { padding-left: 0; }
  .up-cost-table td.num:nth-child(2) { text-align: left; color: var(--muted); }
  .up-cost-item { display: block; }
  .up-cost-item > .mc-icon { margin-right: 6px; vertical-align: -3px; }
  .up-summary { padding: var(--sp-2) var(--sp-4); }
  .sum-numbers .to { font-size: 16px; }
  .sum-main { gap: 2px var(--sp-4); }
  .sum-stats { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding-right: var(--sp-6);
    -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent);
    mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent); } /* scrolls sideways: fade, not a hard cut */
  .sum-stats::-webkit-scrollbar { display: none; }

  .acc-row { grid-template-columns: 84px minmax(0, 1fr); }

  /* Extra damage: the description gets the full width, tag + value below it. */
  .extra-list li { grid-template-columns: minmax(0, 1fr) auto; row-gap: 2px; }
  .extra-label { grid-column: 1 / -1; }
  /* Disclosure hints go below their label instead of squeezing it. */
  .stats-more-hint { flex-basis: 100%; margin-left: 20px; }
}

/* ========================================================================================== */
/* Ragnarock panel (ui/ragnarock.js) – BEGIN                                                    */
/* Sits under the "Ragnarock (channel)" buff row in the Buffs card: axe choice, cast pet,        */
/* pet item / Gold collection, axe customisation (Chimera, reforge, gems, books, AoW, stars,     */
/* recomb) and the engine's summary.                                                             */
/* Built from shared primitives (.alt-opt rows, .inv-slot pet button, .seg, .select, .lo-label,  */
/* .buff-warns) so every design preset restyles it; this block only adds layout + shared tokens. */

.rg-panel {
  display: flex; flex-direction: column; gap: var(--sp-3); min-width: 0;
  margin: 0 0 var(--sp-3); padding: var(--sp-3);
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface);
  container-type: inline-size;
}
.rg-sec { display: flex; flex-direction: column; min-width: 0; }
.rg-sec > .lo-label { margin-bottom: 6px; }

/* Axe choice: listbox of .alt-opt rows (same look as the loadout swap menu) */
.rg-list { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.rg-opt { min-height: 44px; }
.rg-opt .alt-title { display: flex; align-items: baseline; gap: var(--sp-2); min-width: 0; }
.rg-opt .alt-title > .item-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.rg-opt .alt-sub { align-items: center; row-gap: 0; }
.rg-opt .alt-sub .slot-gems { margin-left: 6px; vertical-align: middle; }
.rg-last { display: inline-flex; align-items: center; white-space: nowrap; }
.rg-opt .alt-sub .dot { margin: 0 5px; }
.rg-loc { margin-left: auto; }
.rg-check { flex: none; display: inline-grid; place-items: center; color: var(--accent); }
.rg-panel .ench { color: var(--mc-9); }
.rg-panel .ench--ult { color: var(--mc-d); font-weight: 600; }
.rg-panel .reforge { color: var(--muted); }
.rg-str { display: inline-flex; align-items: baseline; gap: 2px; white-space: nowrap; }
.rg-str .num { color: var(--text); }
/* An owned axe card shows the axe as channelled: facts changed by the overrides get an accent dotted underline */
.rg-panel .rg-changed { text-decoration: underline dotted var(--accent); text-decoration-thickness: 2px; text-underline-offset: 3px; }
.rg-panel .slot-gems.rg-changed { padding-bottom: 1px; border-bottom: 2px dotted var(--accent); text-decoration: none; }

/* Cast pet: an inventory slot button that opens the pet list (popover .pop--alts) */
.rg-pet { min-height: 48px; }
.rg-pop .alt-list { max-height: min(460px, 62vh); }
.rg-hint { margin: 6px 0 0; font-size: 12px; line-height: 1.4; color: var(--faint); }
.rg-rows--pet { margin-top: 6px; }

/* Customisation: label | control rows; an overridden value gets the accent bar of the Assumptions panel */
.rg-custom { padding-top: var(--sp-2); border-top: 1px solid var(--border); }
.rg-custom > summary {
  display: flex; align-items: center; gap: 6px; min-height: 32px; cursor: pointer; list-style: none;
  font-size: 13px; font-weight: 500; color: var(--muted); border-radius: var(--radius-sm);
}
.rg-custom > summary::-webkit-details-marker, .rg-bd > summary::-webkit-details-marker { display: none; }
.rg-custom > summary:hover { color: var(--text); }
.rg-custom > summary > span:not(.rg-count) { flex: none; }
.rg-count { flex: 0 1 auto; min-width: 0; margin-left: auto; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 12px; font-weight: 400; color: var(--accent); }
.rg-count.faint { color: var(--faint); }
.rg-custom[open] > summary > .rg-count.faint { display: none; }
.rg-rows { display: flex; flex-direction: column; gap: 2px; padding-top: var(--sp-1); }
.rg-row {
  position: relative; display: grid; grid-template-columns: 84px minmax(0, 1fr); align-items: center; gap: 4px var(--sp-2);
  min-height: 36px; padding: 3px 0 3px 10px;
}
.rg-row::before { content: ''; position: absolute; left: 0; top: 9px; bottom: 9px; width: 2px; border-radius: 1px; background: transparent; }
.rg-row.is-changed::before { background: var(--accent); }
.rg-row-label { font-size: 12px; color: var(--muted); }
.rg-row.is-changed .rg-row-label { color: var(--text); }
.rg-row-ctl { display: flex; min-width: 0; }
.rg-row-ctl > .seg { flex-wrap: wrap; }
.rg-seg > label { min-width: 24px; padding: 0 7px; }
.rg-row-ctl > .select { max-width: 100%; }
.rg-gems { grid-column: 1 / -1; display: flex; flex-direction: column; gap: 4px; }
.rg-gem { display: flex; align-items: center; gap: var(--sp-2); min-width: 0; }
.rg-gem-ico { flex: none; display: grid; place-items: center; width: 20px; height: 20px; }
.rg-gem > .select { flex: 1 1 0; min-width: 0; width: auto; }
.rg-reset-row { padding: var(--sp-1) 0 0 10px; }

/* Summary: the buff in big numbers, then cast Strength / Chimera copy / rule, breakdown and warnings */
.rg-sum { display: flex; flex-direction: column; gap: var(--sp-2); padding-top: var(--sp-3); border-top: 1px solid var(--border); }
.rg-sum-head { display: flex; align-items: baseline; flex-wrap: wrap; gap: 2px var(--sp-2); }
.rg-sum-val {
  display: inline-flex; align-items: baseline; gap: 3px; font-family: var(--font-num); font-size: 20px; font-weight: 600;
  line-height: 24px; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; color: var(--text);
}
.rg-sum-val .stat-sym { font-size: 16px; }
.rg-sum-unit { font-size: 13px; color: var(--muted); }
.rg-sum-tag { margin-left: auto; font-size: 11px; line-height: 16px; text-transform: uppercase; letter-spacing: .04em; color: var(--faint); }
.rg-sum.is-preview .rg-sum-val { color: var(--muted); }
.rg-facts { margin: 0; }
.rg-fact {
  display: flex; align-items: baseline; justify-content: space-between; gap: var(--sp-3); padding: 5px 0;
  border-top: 1px solid var(--border); font-size: 12px; line-height: 18px;
}
.rg-fact:first-child { border-top: 0; }
.rg-fact dt { min-width: 0; color: var(--muted); }
.rg-fact dd { flex: none; margin: 0; text-align: right; white-space: nowrap; color: var(--text); font-variant-numeric: tabular-nums; }
.rg-chim { display: inline-flex; align-items: center; flex-wrap: wrap; gap: 4px; }
.rg-chim .item-name { font-size: 12px; }
.rg-bd > summary {
  display: flex; align-items: center; gap: 6px; min-height: 28px; cursor: pointer; list-style: none;
  font-size: 12px; font-weight: 500; color: var(--muted);
}
.rg-bd > summary:hover { color: var(--text); }
.rg-facts--bd { padding-left: 20px; }
.rg-bd-h { margin: var(--sp-2) 0 0 20px; font-size: 11px; line-height: 16px; text-transform: uppercase; letter-spacing: .04em; color: var(--faint); }
.rg-facts--bd .rg-fact { padding: 3px 0; }
.rg-warns { margin: 0; }
.rg-sum.is-empty { gap: 0; }

/* One-line preview in the buff row while the buff is off */
.rg-preview { display: inline-flex; align-items: baseline; flex-wrap: wrap; gap: 0 3px; color: var(--muted); }
.rg-preview .num { color: var(--text); font-variant-numeric: tabular-nums; }

/* Narrow panel (phones): label above its control, so segmented controls keep one line. */
@container (max-width: 340px) {
  .rg-row { grid-template-columns: minmax(0, 1fr); row-gap: 4px; padding-top: 6px; padding-bottom: 6px; }
  .rg-row::before { top: 6px; bottom: 6px; }
}
@media (max-width: 560px) {
  .rg-panel { padding: var(--sp-2); }
}
/* Ragnarock panel – END */
/* ========================================================================================== */

/* --- "Cheaper step" hint under an upgrade row (best option shown, efficient step noted) --- */
.up-cheaper { color: var(--muted, #9096a0); font-size: 12px; margin-left: 8px; }
