/* =========================
   Reset & base
   ========================= */
* { box-sizing: border-box; }
.hidden { display: none !important; }
html, body { height: 100%; }
/* Prevent white flash before JS runs in dark mode */
html.dark { background: #0f172a; }

html {
  scrollbar-gutter: stable;
}

body {
  margin: 0;
  font-family: Arial, sans-serif;
  background: #f5f6f7;
  color: #222;
}

/* Título do header */
.topbar .site-title{
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  font-size: 36px;
  line-height: 1.1;
  font-weight: 700;
}
.site-title-link {
  display: inherit;
  align-items: inherit;
  gap: inherit;
  color: inherit;
  text-decoration: none;
}

/* Ícone à esquerda de “Dofus Builds” */
.topbar .title-logo{
  width: 26px;         /* ↑ aumenta o ícone */
  height: 26px;
  object-fit: contain;
  border-radius: 4px;
}

/* (opcional) um pouco maior em telas grandes */
@media (min-width: 992px){
  .topbar .site-title{ font-size: 30px; }
  .topbar .title-logo{ width: 28px; height: 28px; }
}



/* =========================
   Topbar
   ========================= */
.topbar {
  background: #fff;
  border-bottom: 1px solid #e6e6e6;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.topbar h1 { margin: 0; color: #e67e22; font-size: 20px; }
.topbar nav {
  display: flex;
  align-items: center;
}
.topbar nav button,
#btn-public-builds,
#btn-group-builds,
#btn-beta {
  margin-left: 8px; padding: 8px 16px; border: 0; border-radius: 8px;
  background: #3498db; color: #fff; cursor: pointer;
  font-size: 14px; font-family: inherit; font-weight: 500;
  text-decoration: none; display: inline-flex; align-items: center;
  line-height: 1.4; transition: background .15s;
}
.topbar nav button:hover,
#btn-public-builds:hover,
#btn-group-builds:hover { background: #2980b9; }
/* Beta: cor distinta para sinalizar versão experimental */
#btn-beta { background: #8b5cf6; gap: 4px; }
#btn-beta:hover { background: #7c3aed; }

/* Features button (distinct violet) */
#btn-features { background: #8b5cf6; gap: 4px; }
#btn-features:hover { background: #7c3aed; }

/* Undo / Redo icon buttons (equipment history) */
.topbar nav button.tb-icon-btn { padding: 7px 11px; min-width: 36px; justify-content: center; font-size: 16px; font-weight: 700; background: #64748b; }
.topbar nav button.tb-icon-btn:hover { background: #475569; }
.topbar nav button.tb-icon-btn:disabled { opacity: .4; cursor: default; background: #64748b; }
body.dark .topbar nav button.tb-icon-btn { background: #475569; }
body.dark .topbar nav button.tb-icon-btn:hover { background: #334155; }

/* =========================
   Layout principal (3 colunas)
   ========================= */
main {
  max-width: 1600px;
  margin: 1px 0;
  padding: 6px 4px 0 10px;
  display: grid;
  grid-template-columns: 320px auto 460px; /* Stats | Center | Right */
  gap: 32px;
  align-items: start;
}
#left-panel, #center-panel, #right-panel { outline: none !important; }

/* Cards */
.card {
  background: #fff;
  border-radius: 12px;
  border: 1px solid #e2e8f0;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  padding: 12px;
}
.card h2 { margin: 0 0 8px; font-size: 18px; }

/* =========================
   Lists genéricas
   ========================= */
.stat-list { list-style: none; padding: 0; margin: 0; }
.stat-list li {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 8px; border-bottom: 1px solid #f1f5f9;
}
.stat-list li:last-child { border-bottom: none; }
.stat-list .icon, .res-name .icon { display: inline-flex; width: 20px; justify-content: center; }

/* =========================
   Painel de Resistência (direita)
   ========================= */
#resistance-panel .res-head {
  display: grid; grid-template-columns: 1fr 60px 60px;
  gap: 8px; padding: 6px 8px; color: #666; font-weight: 600;
}
#resistance-panel .res-head span:first-child { grid-column: 2 / span 1; text-align: center; }
#resistance-panel .res-head span:last-child { text-align: center; }
#resistance-panel .res-row {
  display: grid; grid-template-columns: 1fr 60px 60px;
  align-items: center; padding: 6px 8px; border-top: 1px solid #eee;
}
#resistance-panel .res-name { display: flex; align-items: center; gap: 8px; min-width: 0; overflow: hidden; }
#resistance-panel .res-name > span:not(.icon) {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
#resistance-panel .res-values { display: contents; }
#resistance-panel .res-values span { text-align: center; }
#resistance-panel .dash { color: #bbb; }

#damage-panel .stat-list li {
  display: grid;
  grid-template-columns: 22px 1fr 34px;
  column-gap: 4px;
  align-items: center;
  white-space: nowrap;
  overflow: hidden;
}
/* Truncate long translated labels in Damage panel */
#damage-panel .stat-list li > span:nth-child(2) {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
#damage-panel .stat-list li .value {
  display: block;
  text-align: right;
}

/* Damage + Resistance panels: compact sizing */
#right-panel .card { padding: 6px 8px; }
#right-panel .card h2 { font-size: 14px; margin: 0 0 3px; }
/* Override the global 40px icon — the real cause of tall rows */
#right-panel .icon.icon-img { width: 18px; height: 18px; margin-right: 4px; }
#right-panel .stat-list .icon,
#resistance-panel .res-name .icon { width: 18px; min-width: 18px; }
#damage-panel .dmg-col-head { padding: 2px 6px; visibility: hidden; }
#damage-panel .stat-list li { padding: 2px 6px; }
#resistance-panel .res-head { padding: 2px 6px; }
#resistance-panel .res-row { padding: 2px 6px; }
.res-placeholder { visibility: hidden; }
#resistance-panel .res-row { grid-template-columns: 1fr 46px 46px; }
#resistance-panel .res-head { grid-template-columns: 1fr 46px 46px; }

/* =========================
   Equipamentos (centro)
   ========================= */
#character-panel.card { padding: 8px 8px 8px 28px; width: calc(100% - 4px); }

.slots-grid {
  display: grid;
  grid-template-columns: 80px 300px 80px;
  grid-template-rows: repeat(5, min-content);
  gap: 6px 8px;
  align-items: start;
  justify-content: center;
  column-gap: 44px;
  width: 100%;
}
.slot.left  { grid-column: 1; }
.slot.right { grid-column: 3; }
.slot.left:nth-of-type(1)  { grid-row: 1; }
.slot.left:nth-of-type(2)  { grid-row: 2; }
.slot.left:nth-of-type(3)  { grid-row: 3; }
.slot.left:nth-of-type(4)  { grid-row: 4; }
.slot.left:nth-of-type(5)  { grid-row: 5; }
.slot.right:nth-of-type(1) { grid-row: 1; }
.slot.right:nth-of-type(2) { grid-row: 2; }
.slot.right:nth-of-type(3) { grid-row: 3; }
.slot.right:nth-of-type(4) { grid-row: 4; }
.slot.right:nth-of-type(5) { grid-row: 5; }

.dofus-grid {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 10px 14px;
  margin-top: 20px;
  justify-items: center;
}

.avatar-box {
  grid-column: 2;
  grid-row: 1 / span 3;
  align-self: stretch;
  border: 2px dashed #cbd5e1;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  color: #64748b; font-weight: 600;
  background: linear-gradient(#fafafa, #f5f7fa);
  cursor: pointer;
  overflow: hidden;
  transition: border-color .15s;
}
.avatar-box:hover { border-color: #93c5fd; }
.avatar-box { position: relative; }
.avatar-box #avatar-video,
.avatar-box #avatar-img  {
  display: none;
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.avatar-box.has-avatar { border-style: solid; border-color: #93c5fd; background: #0f172a; }
.avatar-box.has-avatar #avatar-placeholder { display: none; }

.avatar-remove {
  display: none;
  position: absolute;
  top: 6px; right: 6px;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: #ef4444;
  color: #fff;
  border: none;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  padding: 0;
  z-index: 10;
  opacity: 0;
  transition: opacity .15s;
  pointer-events: none;
}
.avatar-box.has-avatar .avatar-remove { display: flex; }
.avatar-box:hover .avatar-remove { opacity: 1; pointer-events: auto; }
.avatar-remove:hover { background: #b91c1c; }

/* Avatar modal box (positioned above backdrop) */
.modal-box {
  position: absolute;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(0,0,0,.28);
  overflow: hidden;
  z-index: 1;
}
body.dark .modal-box { background: #1e293b; color: #e2e8f0; }

/* Avatar picker modal */
.avatar-picker-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  padding: 20px;
  justify-content: center;
  max-height: 70vh;
  overflow-y: auto;
}
.avatar-class-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  border-radius: 12px;
  border: 2px solid #e2e8f0;
  padding: 10px;
  transition: border-color .15s, background .15s;
}
.avatar-class-card:hover { border-color: #3b82f6; background: rgba(59,130,246,.06); }
.avatar-class-card.selected { border-color: #3b82f6; background: rgba(59,130,246,.1); }
.avatar-class-card video { width: 110px; height: 110px; object-fit: cover; border-radius: 8px; pointer-events: none; }
.avatar-class-card img  { width: 110px; height: 110px; object-fit: cover; border-radius: 8px; pointer-events: none; }
.avatar-class-card span { font-size: .85rem; font-weight: 700; }
body.dark .avatar-class-card { border-color: #334155; }
body.dark .avatar-class-card:hover { background: rgba(59,130,246,.12); }

.slot { display: flex; flex-direction: column; gap: 3px; align-items: center; }
.slot-box {
  width: 60px; height: 60px;
  border-radius: 11px; border: 2px solid #e5e7eb;
  background: linear-gradient(#ffffff, #f7f9fc);
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
  position: relative;
  transition: transform .08s ease, box-shadow .08s ease, border-color .08s ease;
}
.slot-box::after {
  content: "+"; position: absolute; inset: 0; display: grid; place-items: center;
  font-size: 21px; color: #94a3b8;
}
.slot-box:hover { transform: translateY(-1px); box-shadow: 0 6px 16px rgba(0,0,0,0.07); border-color: #c7d2fe; }
.slot-label { font-size: 12px; color: #475569; text-align: center; user-select: none; white-space: nowrap; max-width: 110px; overflow: hidden; text-overflow: ellipsis; display: block; }

.slot-box.is-placeholder .slot-icon { filter: grayscale(100%); opacity: 0.85; transition: filter .2s, opacity .2s; }
.slot-box.level-exceeded  { border-color: #ef4444 !important; box-shadow: 0 0 0 2px rgba(239,68,68,0.3); }
.slot-box.condition-failed { border-color: #ef4444 !important; box-shadow: 0 0 0 2px rgba(239,68,68,0.3); }
.slot-box.has-img:not(.is-placeholder):hover .slot-icon { filter: grayscale(0%); opacity: 1; }
.slot-icon { width: 48px; height: 48px; object-fit: contain; display: block; margin: 4px auto; }
.slot-box.has-img::after { content: ""; }

/* Dofus placeholder x equipado */
.dofus-grid .slot-box { width: 48px; height: 48px; border-radius: 8px; }
.dofus-grid .slot-box::after { font-size: 17px; }
.dofus-grid .slot-icon { width: 38px; height: 38px; }
.dofus-grid .slot-label { font-size: 10px; }
.dofus-grid .slot-box.is-placeholder .slot-icon { filter: grayscale(100%); opacity: 0.85; }
.dofus-grid .slot-box:not(.is-placeholder) .slot-icon { filter: none !important; opacity: 1 !important; }

/* =========================
   Modal Dofus
   ========================= */
.modal.hidden { display: none; }
.modal { position: fixed; inset: 0; z-index: 1000; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.35); }
.modal-dialog {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: min(560px, 92vw); background: #fff; border-radius: 12px; box-shadow: 0 12px 32px rgba(0,0,0,.25);
  overflow: hidden;
}
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; border-bottom: 1px solid #eee; }
.modal-header h3 { margin: 0; font-size: 18px; }
.modal-close { border: 0; background: transparent; font-size: 22px; line-height: 1; cursor: pointer; }
.modal-body { padding: 10px; max-height: 60vh; overflow: auto; }

.picker-list {
  list-style: none; margin: 0; padding: 0;
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px;
}
.picker-list li {
  position: relative;
  border: 1px solid #e5e7eb; border-radius: 10px; padding: 10px;
  display: flex; align-items: center; gap: 10px; cursor: pointer;
  background: #fff; transition: box-shadow .12s, transform .06s, border-color .12s;
}
.picker-list li:hover { border-color: #c7d2fe; box-shadow: 0 6px 14px rgba(0,0,0,0.08); transform: translateY(-1px); }
.picker-list img { width: 36px; height: 36px; }
.picker-title { font-size: 13px; }

/* =========================
   Stats (esquerda) — 1 col até Power, 2 cols depois
   ========================= */
#stats .stat-list{
  display: grid;
  grid-template-columns: minmax(0,1fr) minmax(0,1fr); /* ← tracks encolhem */
  column-gap: 12px;
  width: 100%;
}

/* Level, AP, MP, Range, primary stats e footer: ocupam as 2 colunas (1 por linha) */
#stats .stat-list li:nth-child(-n+4),
#stats .stat-list li.primary-stat,
#stats .stat-list li.stat-alloc-footer { grid-column: 1 / -1; }

/* Cada item é um grid interno (não-primary) */
#stats .stat-list li:not(.stat-alloc-header):not(.primary-stat){
  min-width: 0;
  display: grid;
  grid-template-columns: 28px 1fr 42px;
  column-gap: 8px;
  align-items: center;
  padding: 6px 8px;
}

/* Para as LINHAS EM DUAS COLUNAS (Power em diante) -> compacto */
#stats .stat-list li:not(.stat-alloc-header):not(.primary-stat):not(:nth-child(-n+4)){
  grid-template-columns: 20px 1fr 32px;
  column-gap: 6px;
}
#stats .stat-list li img { width: 18px; height: 18px; }
#stats .stat-list li:not(.stat-alloc-header):not(.primary-stat):not(:nth-child(-n+4)) img{ width: 18px; height: 18px; }
#stats .stat-list li:not(.stat-alloc-header):not(.primary-stat):not(:nth-child(-n+4)) .value{
  min-width: 24px;
  height: 24px;
  font-size: 12px;
  padding: 2px 6px;
}

/* Label do meio SEM depender de classe .label */
#stats .stat-list li > *:nth-child(2),
#stats .stat-list li .label{
  min-width: 0;                 /* ← ESSENCIAL */
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Pílulas (valores) */
#stats .stat-list .value{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  height: 28px;
  padding: 3px 8px;
  border-radius: 999px;
  background: #f8fafc;
  box-shadow: inset 0 0 0 1px #e2e8f0;
  color: #0f172a;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  justify-self: end;
}

/* Input do LEVEL compacto e SEM cortar */
#level-input{
  width: 100%;
  height: 28px;
  font-size: 16px;
  padding: 4px 8px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  box-sizing: border-box;
  justify-self: end;
}

/* =========================
   Alocação inline de atributos
   ========================= */

/* Seletor de alta especificidade (121) para vencer #stats .stat-list li (111) + !important */
#stats .stat-list li.primary-stat,
#stats .stat-list li.stat-alloc-footer {
  display: grid !important;
  grid-template-columns: 26px 1fr 48px 26px 38px 46px !important;
  column-gap: 4px !important;
  row-gap: 0 !important;
  align-items: center !important;
  padding: 4px 6px !important;
}

/* Primary stat rows */
#stats .stat-list li.primary-stat img:first-child { width: 22px; height: 22px; }
.stat-label { font-size: 12px; font-weight: 500; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Base input */
.stat-alloc-input {
  width: 100%; height: 26px; font-size: 12px; text-align: center;
  border: 1px solid #dde1ea; border-radius: 6px;
  background: #f8fafc; outline: none; padding: 0 2px;
  -moz-appearance: textfield;
  box-sizing: border-box;
}
.stat-alloc-input::-webkit-outer-spin-button,
.stat-alloc-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.stat-alloc-input:focus { border-color: #7c9cff; box-shadow: 0 0 0 2px rgba(124,156,255,.2); }

/* Scroll checkbox cell */
.stat-scroll-cell {
  display: flex; align-items: center; justify-content: center; cursor: pointer; margin: 0;
}
.stat-scroll-cell input { width: 15px; height: 15px; margin: 0; accent-color: #6366f1; cursor: pointer; }

/* Total pill override for primary rows */
#stats .stat-list li.primary-stat .value {
  font-size: 12px !important;
  min-width: 34px !important;
  height: 24px !important;
  padding: 2px 6px !important;
  justify-self: center !important;
}

/* Power cell */
.stat-power-cell {
  display: flex; align-items: center; justify-content: center; gap: 2px;
  font-size: 12px; font-weight: 600; color: #7c3aed;
  margin-left: 8px;
}
.stat-power-cell img { width: 12px; height: 12px; opacity: .7; }
#stats .stat-list li.primary-stat:not(.has-power) .stat-power-cell { visibility: hidden; }

/* Footer row — especificidade 211 (ID+class+tag+ID) vence qualquer !important de 111 */
#stats .stat-list li#stat-alloc-footer-row {
  display: grid !important;
  grid-template-columns: 26px 1fr 48px 26px 38px 46px !important;
  column-gap: 4px !important;
  row-gap: 0 !important;
  align-items: center !important;
  padding: 4px 6px !important;
  border-top: 1px solid #e2e8f0 !important;
  font-size: 10px;
  font-weight: 600;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.saf-pts { font-size: 11px; color: #475569; text-transform: none; letter-spacing: 0; font-weight: 700; white-space: nowrap; }
.saf-lbl { text-align: center; }
.saf-scroll-all {
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; margin: 0;
}
.saf-scroll-all input { width: 15px; height: 15px; margin: 0; accent-color: #6366f1; cursor: pointer; }
.saf-scroll-all img { display: none; }
.saf-pow { display: flex; align-items: center; justify-content: center; gap: 2px; margin-left: 8px; }

/* Power cell: largura fixa, números tabulares para 4 dígitos */
.stat-power-cell {
  width: 46px;
  justify-content: flex-end;
}
.stat-power-cell span {
  font-variant-numeric: tabular-nums;
  min-width: 28px;
  text-align: right;
  display: inline-block;
}

:root{
  --stats-pill-w: 56px;
}

/* grid de duas colunas do card de stats */
#stats .stat-list{
  column-gap: 24px !important;        /* mais respiro entre as metades */
  grid-auto-rows: minmax(46px, auto) !important; /* mesma altura de linha => valores alinhados */
}

/* linhas até Power (uma por linha) */
#stats .stat-list li{
  grid-template-columns: 28px minmax(0,1fr) var(--stats-pill-w) !important; /* ícone | label | valor */
}

/* linhas após Power (duas por linha) */
#stats .stat-list > li:nth-child(n+11){
  grid-template-columns: 26px minmax(0,1fr) var(--stats-pill-w) !important;
}

/* pílulas dos valores: mesma largura e ancoradas à borda direita do item */
#stats .stat-list .value{
  min-width: var(--stats-pill-w) !important;
  justify-content: center !important; /* número centralizado dentro da pílula */
  justify-self: end !important;       /* pílula encostada à direita da célula */
}

/* labels não quebram (evita “encavalamento”) */
#stats .stat-list li > *:nth-child(2){
  min-width: 0 !important;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* Primeiros 10 itens ocupam as duas colunas (uma linha por item) */
#stats .stat-list li:nth-child(-n+10){
  grid-column: 1 / -1;
}

/* === Layout com 3 colunas: Stats | Character | Right === */
main{
  grid-template-columns: 440px minmax(0, 1fr) 430px !important;
  gap: 24px !important;
}

#left-panel   { grid-column: 1; }
#center-panel { grid-column: 2; }
#right-panel  {
  grid-column: 3;
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-left: -4px;
  position: relative;
  overflow: visible;
}
#right-main {
  display: contents;
}
/* Trilho lateral à direita do right-panel (WIP + anúncio vertical) */
#side-rail {
  position: absolute;
  left: 560px; /* 460px painel + 100px gap */
  top: 0;
  width: 200px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

#combat-panels {
  display: grid;
  grid-template-columns: 195px 1fr;
  gap: 8px;
  align-items: stretch;
}


/* telas médias (laptops 1280–1450px): compacta o character panel sem empilhar colunas */
@media (max-width: 1450px) {
  .slots-grid {
    grid-template-columns: 80px auto 80px;
    column-gap: 16px;
    gap: 8px 16px;
  }
}

/* Empilha tudo em 1 coluna em telas estreitas / zoom alto (150–200%).
   O !important é necessário para vencer o grid fixo de 440/1fr/430 definido
   mais abaixo com !important — sem ele esta faixa (769–1200px) quebrava. */
@media (max-width: 1200px){
  main{
    grid-template-columns: 1fr !important;
    gap: 16px !important;
  }
  #left-panel, #center-panel, #right-panel{
    grid-column: auto !important;
  }
  /* Character Panel primeiro (mesma ordem do mobile) */
  #center-panel { order: 0; }
  #left-panel   { order: 1; }
  #right-panel  { order: 2; margin-left: 0 !important; position: static !important; }
  /* Trilho lateral (WIP + ad): sai do posicionamento absoluto e entra no fluxo */
  #side-rail {
    position: static !important;
    left: auto !important;
    top: auto !important;
    width: 100% !important;
    margin-top: 4px;
  }
}

/* ——— EXO quase colado ao Stats (sem sticky) ——— */
/* Se o gap do seu grid for 24px, usar -16px deixa ~8px de espaço entre os cards.
   Quer zero espaço? troque por -24px. */

/* Exo rows: mesmo grid de 6 colunas dos primary stats — exo vai p/ col 4, valor p/ col 5 */
#stats .stat-list li.has-exo {
  grid-template-columns: 26px 1fr 48px 26px 38px 46px !important;
  column-gap: 4px !important;
  padding-left: 6px !important;
  padding-right: 6px !important;
}
#stats .stat-list li.has-exo .exo-inline { grid-column: 4; }
#stats .stat-list li.has-exo .value {
  grid-column: 5;
  justify-self: center !important;
  min-width: 34px !important;
  height: 24px !important;
  padding: 2px 6px !important;
  font-size: 12px !important;
}

/* Level row: mesma grid de 6 cols; input abrange cols 4-5; EXO label na col 4 row 2 */
#stats .stat-list li:first-child {
  grid-template-columns: 26px 1fr 48px 26px 38px 46px !important;
  column-gap: 4px !important;
  grid-template-rows: auto 18px;
  padding-bottom: 2px;
}
#stats .stat-list li:first-child input#level-input { grid-column: 4 / 6; width: 100%; }
#stats .stat-list li:first-child::after {
  content: "EXO";
  grid-column: 4;
  grid-row: 2;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  color: #94a3b8;
  text-align: center;
  letter-spacing: .03em;
  display: flex;
  align-items: center;
  justify-content: center;
}
.exo-inline {
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.exo-inline input[type=”checkbox”] {
  width: 15px;
  height: 15px;
  margin: 0;
  cursor: pointer;
  accent-color: #6366f1;
}
.exo-inline input:disabled {
  opacity: .35;
  cursor: not-allowed;
}


/* ==== Equipment Picker bits (non-intrusive) ==== */
.modal-controls{display:flex;gap:10px;align-items:center;padding:10px;border-bottom:1px solid #eee}
.modal-controls input[type="search"]{flex:1 1 auto;height:36px;padding:0 12px;border-radius:10px;border:1px solid rgba(0,0,0,.12);outline:0}
.modal-subinfo{font-size:12px;opacity:.75}
.picker-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(180px,1fr));gap:12px;padding:12px}
.picker-card{background:#fff;border-radius:12px;padding:10px;box-shadow:0 1px 0 rgba(0,0,0,.06),0 6px 18px rgba(0,0,0,.06);display:grid;grid-template-columns:48px 1fr;align-items:center;gap:10px;cursor:pointer;border:1px solid rgba(0,0,0,.06);transition:transform .12s ease,box-shadow .12s ease}
.picker-card:hover{transform:translateY(-1px);box-shadow:0 2px 0 rgba(0,0,0,.06),0 10px 22px rgba(0,0,0,.08)}
.picker-card img{width:48px;height:48px;object-fit:contain}
.picker-card .pc-title{font-weight:600;line-height:1.2}
.picker-card .pc-sub{font-size:12px;opacity:.7}


/* === Modal base (for equipment picker) === */
.modal.hidden { display: none; }
.modal { position: fixed; inset: 0; z-index: 1000; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.45); }
.modal-card {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: min(880px, 94vw);
  height: 80vh;
  max-height: 80vh;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 16px 40px rgba(0,0,0,.28);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; border-bottom: 1px solid #eee; }
.modal-header h3 { margin: 0; font-size: 18px; }
.modal-close { border: 0; background: transparent; font-size: 20px; line-height: 1; cursor: pointer; }
.modal-footer { padding: 10px; border-top: 1px solid #eee; display: flex; justify-content: flex-end; gap: 8px; }

/* Controls + results layout */
.modal-controls { display: flex; gap: 10px; align-items: center; padding: 10px 12px; border-bottom: 1px solid #eee; }
.modal-controls input[type="search"] { flex: 1 1 auto; height: 36px; padding: 0 12px; border-radius: 10px; border: 1px solid rgba(0,0,0,.12); outline: none; }
.modal-subinfo { font-size: 12px; opacity: .75; }

.picker-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; padding: 12px; overflow: auto; flex: 1 1 auto; }
.picker-card {
  background: #fff; border-radius: 12px; padding: 10px;
  box-shadow: 0 1px 0 rgba(0,0,0,.06), 0 6px 18px rgba(0,0,0,.06);
  display: grid; grid-template-columns: 48px 1fr; align-items: center; gap: 10px;
  cursor: pointer; border: 1px solid rgba(0,0,0,.06);
  transition: transform .12s ease, box-shadow .12s ease;
}
.picker-card:hover { transform: translateY(-1px); box-shadow: 0 2px 0 rgba(0,0,0,.06), 0 10px 22px rgba(0,0,0,.08); }
.picker-card img { width: 48px; height: 48px; object-fit: contain; }
.picker-card .pc-title { font-weight: 600; line-height: 1.2; }
.picker-card .pc-sub { font-size: 12px; opacity: .7; }



/* === Equipment modal additions: level filters, pager, preview === */
.modal-controls .lv-inp{ width:90px; height:36px; padding:0 10px; border-radius:10px; border:1px solid rgba(0,0,0,.12); }
/* Picker level-range (min–max) inputs — narrower, centered, no number spinners */
.modal-controls .lvl-range{ display:inline-flex; align-items:center; gap:5px; flex:none; }
.modal-controls .lvl-range .lv-inp{ width:72px; padding:0 8px; text-align:center; -moz-appearance:textfield; appearance:textfield; }
.modal-controls .lvl-range .lv-inp::-webkit-outer-spin-button,
.modal-controls .lvl-range .lv-inp::-webkit-inner-spin-button{ -webkit-appearance:none; margin:0; }
.modal-controls .lvl-dash{ color:#94a3b8; }
.modal-pager{ display:flex; gap:10px; justify-content:center; align-items:center; padding:6px 12px; border-top:1px dashed #eee; }
.btn.sm{ font-size:12px; padding:6px 10px; border-radius:8px; }
.pc-actions{ display:flex; align-items:center; gap:8px; justify-self:end; }
.pc-preview{ margin-top:6px; }
.pc-preview > summary{ cursor:pointer; font-size:12px; opacity:.8; }
.pc-effects{ margin:6px 0 0 0; padding-left:16px; font-size:13.5px; line-height:1.3; }

/* Filter toggle button */
.filter-toggle {
  background: #f1f5f9;
  color: #334155;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 4px 12px;
  cursor: pointer;
  font-size: .85rem;
  white-space: nowrap;
  transition: border-color .15s, color .15s;
}
.filter-toggle:hover { border-color: #3b82f6; }
.filter-toggle.has-filters { border-color: #3b82f6; color: #3b82f6; background: #eff6ff; }

/* Modal body: results left, filter sidebar right (equipment picker only) */
.modal-card .modal-body {
  display: flex;
  flex-direction: row;
  flex: 1 1 auto;
  overflow: hidden;
  min-height: 0;
}
.modal-main {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  overflow: hidden;
  min-width: 0;
}
.modal-card.filter-open { width: min(1100px, 96vw); }

/* Filter sidebar */
.filter-panel {
  width: 210px;
  flex-shrink: 0;
  padding: 12px 10px;
  background: #f8fafc;
  border-left: 1px solid #e2e8f0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.filter-panel.hidden { display: none; }
.filter-group { display: flex; flex-direction: column; gap: 4px; }
.filter-group-label {
  font-size: .68rem;
  text-transform: uppercase;
  color: #94a3b8;
  font-weight: 700;
  letter-spacing: .05em;
}
.filter-chips { display: flex; flex-wrap: wrap; gap: 4px; }
.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 12px;
  border: 1.5px solid #e2e8f0;
  background: #fff;
  color: #475569;
  font-size: .75rem;
  cursor: pointer;
  transition: background .12s, border-color .12s, color .12s, box-shadow .12s, transform .08s;
}
.filter-chip:hover { border-color: #93c5fd; color: #1d4ed8; }
.filter-chip.active {
  background: #4f46e5;
  border-color: #4f46e5;
  color: #fff;
  font-weight: 700;
  box-shadow: 0 0 0 3px rgba(79,70,229,.25), 0 2px 6px rgba(79,70,229,.35);
  transform: scale(1.06);
}
.chip-ico { width: 14px; height: 14px; object-fit: contain; flex-shrink: 0; }
.filter-chip.active .chip-ico { filter: brightness(10); }

/* Basic / Advanced mode switch inside filter panels */
.filter-mode-switch {
  display: flex;
  gap: 4px;
  position: sticky;
  top: 0;
}
.fmode-btn {
  flex: 1;
  padding: 4px 8px;
  border-radius: 6px;
  border: 1.5px solid #e2e8f0;
  background: #fff;
  color: #475569;
  font-size: .72rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .12s, border-color .12s, color .12s;
}
.fmode-btn:hover { border-color: #93c5fd; color: #1d4ed8; }
.fmode-btn.active {
  background: #4f46e5;
  border-color: #4f46e5;
  color: #fff;
  box-shadow: 0 0 0 2px rgba(79,70,229,.2);
}
/* Advanced filter rows: stat label + numeric "≥" threshold input */
.filter-rows { display: flex; flex-direction: column; gap: 3px; }
.filter-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: .75rem;
  color: #475569;
}
.filter-row-name {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.filter-num {
  width: 48px;
  flex-shrink: 0;
  padding: 2px 5px;
  border: 1.5px solid #e2e8f0;
  border-radius: 6px;
  font-size: .72rem;
  text-align: right;
  background: #fff;
  color: #0f172a;
}
.filter-num:focus { outline: none; border-color: #4f46e5; }
/* Legendary-only toggle inside the filter panel */
.filter-legendary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 5px 8px;
  border-radius: 8px;
  border: 1.5px solid #e2c060;
  background: #fffdf5;
  color: #8a6d1a;
  font-size: .74rem;
  font-weight: 700;
  cursor: pointer;
  transition: background .12s, border-color .12s, color .12s, box-shadow .12s;
}
.filter-legendary:hover { border-color: #e0a020; }
.filter-legendary.active {
  background: linear-gradient(90deg, #f0c040, #e0a020);
  border-color: #e0a020;
  color: #1a1206;
  box-shadow: 0 0 0 2px rgba(224,160,32,.25);
}
/* Legendary item name → gold (only legendary cards) */
.picker-card.is-legendary .pc-title { color: #e0a020; }
body.dark .picker-card.is-legendary .pc-title { color: #f0c040; }
/* Legendary badge on picker cards */
.pc-legendary {
  display: inline-block;
  margin: 3px 0 1px;
  padding: 1px 7px;
  border-radius: 10px;
  font-size: .6rem;
  font-weight: 800;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: #1a1206;
  background: linear-gradient(90deg, #f0c040, #e0a020);
  box-shadow: 0 1px 3px rgba(224,160,32,.4);
}

/* Effect icons in item cards */
.pc-effects li { display: flex; align-items: flex-start; gap: 4px; list-style: none; padding: 0; }
.pc-effects .eff-ico { margin-top: 1px; }
.pc-effects { padding-left: 0; text-align: left; }
.pc-effects .eff-ico { width: 13px; height: 13px; object-fit: contain; flex-shrink: 0; }
.filter-clear-btn {
  position: sticky;
  bottom: 0;
  margin-top: auto;
  padding: 5px 10px;
  border-radius: 6px;
  border: 1px solid #222;
  background: #111;
  color: #ccc;
  font-size: .78rem;
  cursor: pointer;
  transition: border-color .12s, color .12s, background .12s;
  /* small top shadow so it visually separates from chips when sticky */
  box-shadow: 0 -4px 8px rgba(0,0,0,.25);
}
.filter-clear-btn:hover { border-color: #ef4444; color: #ef4444; background: #1a0000; }

/* Pet category tabs */
.pet-tabs { display: flex; gap: 6px; padding: 8px 12px; border-bottom: 1px solid #eee; flex-wrap: wrap; }
.pet-tabs.hidden { display: none; }
.pet-tab { padding: 4px 12px; border-radius: 999px; border: 1px solid #e2e8f0; background: #f8fafc; font-size: 12px; cursor: pointer; transition: background .12s, border-color .12s; white-space: nowrap; }
.pet-tab:hover { background: #eff6ff; border-color: #bfdbfe; }
.pet-tab.active { background: #4f46e5; border-color: #4f46e5; color: #fff; font-weight: 700; box-shadow: 0 0 0 3px rgba(79,70,229,.25), 0 2px 6px rgba(79,70,229,.35); transform: scale(1.06); }
.pc-effects .muted{ opacity:.6; }
/* Weapon AP cost line has no icon — indent text to line up with icon'd effect lines */
.pc-weapon-cost{ padding-left:17px; font-weight:600; }
/* Divider between a weapon's characteristics block (damage/AP/range) and its stats */
.pc-effects li.pc-weapon-divider{ display:block; height:0; padding:0; margin:7px 0; border-top:1px solid rgba(148,163,184,.28); }
/* Weapon attack/damage lines: emphasized (bigger + bold, larger icon) */
.pc-effects li.pc-dmg{ font-size:14px; font-weight:700; }
.pc-effects li.pc-dmg .eff-ico{ width:20px; height:20px; }
/* Resist Total synthetic line (sum of elemental %-resistances) */
.pc-effects li.pc-res-total{ font-weight:700; margin-top:3px; }
.pc-conditions, .df-conditions {
  font-size: 11px;
  color: #d97706;
  margin-top: 4px;
  font-style: italic;
  line-height: 1.3;
}
body.dark .pc-conditions, body.dark .df-conditions { color: #fbbf24; }
.picker-card{ grid-template-columns: 48px 1fr auto; position: relative; }
.pc-main{ display:flex; flex-direction:column; gap:2px; }

/* Favorite star (per-card, top-right) */
.pc-fav{
  position: absolute; top: 6px; right: 6px;
  display: flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: 50%;
  font-size: 23px; line-height: 1; color: #94a3b8;
  background: rgba(0,0,0,.05);
  cursor: pointer; user-select: none; z-index: 2;
  transition: color .12s ease, transform .12s ease, background .12s ease;
}
.pc-fav:hover{ transform: scale(1.15); color: #f59e0b; background: rgba(245,158,11,.15); }
.pc-fav.active{ color: #f59e0b; }
body.dark .pc-fav{ color: #cbd5e1; background: rgba(255,255,255,.08); }
body.dark .pc-fav:hover{ color: #fbbf24; background: rgba(251,191,36,.2); }
body.dark .pc-fav.active{ color: #fbbf24; }

/* Clickable item reference ({{item,…}}) inside spell descriptions */
.item-ref{
  color: #2563eb; font-weight: 700; cursor: pointer;
  text-decoration: underline; text-decoration-style: dotted; text-underline-offset: 2px;
}
.item-ref:hover{ text-decoration-style: solid; }
body.dark .item-ref{ color: #7dd3fc; }

/* In-app preview popup for a referenced item */
.item-ref-popup{
  position: fixed; z-index: 100000; max-width: 280px;
  background: #fff; color: #1e293b;
  border: 1px solid #e2e8f0; border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0,0,0,.18);
  padding: 10px 12px; font-size: 13px; line-height: 1.35;
}
.item-ref-popup.hidden{ display: none; }
.item-ref-popup .irp-head{ display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.item-ref-popup .irp-head img{ width: 40px; height: 40px; object-fit: contain; flex: none; }
.item-ref-popup .irp-name{ font-weight: 700; }
.item-ref-popup .irp-sub{ font-size: 11px; opacity: .7; }
.item-ref-popup ul{ list-style: none; margin: 4px 0 0; padding: 0; }
.item-ref-popup li{ padding: 1px 0; }
.item-ref-popup li img{ width: 14px; height: 14px; object-fit: contain; vertical-align: -2px; margin: 0 1px; }
body.dark .item-ref-popup{
  background: #1e293b; color: #e2e8f0; border-color: #4a6089;
  box-shadow: 0 0 0 1px rgba(74,96,137,.25), 0 10px 30px rgba(0,0,0,.5);
}

/* ===== Spells modal ===== */
.spells-card{ display: flex; flex-direction: column; max-width: 860px; width: 92vw; max-height: 86vh; }
.spells-controls{ gap: 8px; flex-wrap: wrap; }
.spells-seg{ display: inline-flex; border: 1px solid #e2e8f0; border-radius: 8px; overflow: hidden; }
.spells-seg-btn{ background: #f8fafc; color: #475569; border: 0; padding: 6px 14px; cursor: pointer; font-size: .85rem; border-right: 1px solid #e2e8f0; }
.spells-seg-btn:last-child{ border-right: 0; }
.spells-seg-btn.active{ background: #3b82f6; color: #fff; }
/* "Base damage" toggle: show raw spell numbers instead of calculated damage */
.spells-base-toggle{
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; cursor: pointer; user-select: none;
  border: 1px solid #e2e8f0; border-radius: 8px; background: #f8fafc; color: #475569; font-size: .85rem;
}
.spells-base-toggle input{ cursor: pointer; margin: 0; }
.spells-grid{
  display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px;
  padding: 14px; overflow: auto; flex: 1 1 auto;
}
/* Card: the icon FLOATS top-left inside the text column — header/description
   flow beside it, then the content continues at full card width below it
   (no permanently reserved left column). */
.spell-card{
  display: block; position: relative; /* anchor for the rank pills (top-right) */
  background: #fff; border: 1px solid #e2e8f0; border-radius: 10px; padding: 10px;
}
.spell-card.is-passive{ background: #f8fafc; }
/* Equipped weapon pseudo-spell: gold accents to stand apart from class spells */
.spell-card.is-weapon{ border-color: #f0c040; }
body.dark .spell-card.is-weapon{ border-color: #f0c040; box-shadow: 0 0 0 1px rgba(240,192,64,.25); }
.sb-weapon{ background: #f0c040; color: #3a2b00; }
.spell-ico{ float: left; width: 64px; height: 64px; object-fit: contain; margin: 0 10px 6px 0; }
/* Height cap lives on the INNER column only. Putting max-height/overflow on the
   .spell-card itself (a grid item) makes Chrome collapse every row to min-content
   once the grid scrolls — cards imploded to ~44px. The inner div is safe. */
.spell-info{ max-height: 330px; overflow-y: auto; padding-right: 4px; scrollbar-width: thin; }
.spell-info::-webkit-scrollbar{ width: 6px; }
/* Track starts below the pinned rank pills so the bar never sits under them */
.spell-info::-webkit-scrollbar-track{ margin-top: 24px; }
.spell-info::-webkit-scrollbar-thumb{ background: #cbd5e1; border-radius: 3px; }
/* Chromium honors scrollbar-width too and it DISABLES ::-webkit-scrollbar
   styling — where the webkit selector exists, revert to auto so the 6px bar
   with the track margin above actually applies (Firefox keeps thin). */
@supports selector(::-webkit-scrollbar) {
  .spell-info{ scrollbar-width: auto; }
}
body.dark .spell-info::-webkit-scrollbar-thumb{ background: #475569; }

/* Header: line 1 = name (rank pills pinned top-right), line 2 = level + badges */
.spell-head{ display: flex; align-items: flex-start; gap: 6px; }
.spell-headmain{ flex: 1 1 auto; min-width: 0; }
.spell-head .spell-name{ font-size: 13.5px; }
.spell-sub{ display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 3px; font-size: 12px; }

/* Rank pills (1/2/3) — highest unlocked rank is auto-selected.
   Pinned to the card's top-right corner (same spot on every card); absolute
   against .spell-card, so they don't scroll away with .spell-info. */
.spell-ranks{ display: inline-flex; gap: 3px; flex: none; position: absolute; top: 10px; right: 10px; }
/* Reserve room so a long spell name doesn't run under the pinned pills */
.spell-card:has(.spell-ranks) .spell-name{ padding-right: 64px; }
.rank-pill{
  min-width: 18px; height: 18px; padding: 0 4px; font-size: 11px; font-weight: 700;
  border-radius: 4px; border: 1px solid #e2e8f0; background: #f8fafc; color: #64748b;
  cursor: pointer; line-height: 1;
}
.rank-pill.active{ background: #22c55e; border-color: #22c55e; color: #fff; }

/* Stats + calculated damage — separated from the description by a dashed rule.
   clear:left drops it below the floated icon → always full card width. */
.sp-body{
  clear: left;
  margin-top: 7px; padding-top: 7px; border-top: 1px dashed #e2e8f0;
  display: flex; flex-direction: column; gap: 6px;
}
.sp-body .spell-meta{ margin-top: 0; font-size: 13px; gap: 8px 14px; align-items: center; }
.sp-body .spell-stat{ gap: 4px; font-weight: 600; }
.sp-body .spell-stat img{ width: 15px; height: 15px; }
.ss-label{ color: #94a3b8; font-size: 13px; font-weight: 500; }
.sp-grp{ display: flex; flex-direction: column; gap: 3px; }
.sp-grp-head{
  display: flex; align-items: center; gap: 10px;
  font-size: 12px; font-weight: 600; color: #64748b;
}
.sp-area{ display: inline-flex; align-items: center; gap: 5px; }
.sp-zone-ico{ height: 17px; width: auto; }
.sp-zone-size{ font-size: 11px; color: #84cc16; font-weight: 800; }
.sp-zone-all{ font-size: 13px; color: #84cc16; font-weight: 800; line-height: 1; }
/* Damage lines: one per row — normal hit, crit right below it.
   The number never breaks mid-range (.sp-num nowrap); when the line is too
   narrow the small tags (element/Steal/CC) wrap below, left-aligned. */
.sp-dmg-line{ display: flex; flex-wrap: wrap; align-items: center; gap: 2px 6px; font-weight: 700; font-size: 14.5px; }
.sp-num{ white-space: nowrap; }
.sp-dmg-line img{ width: 18px; height: 18px; object-fit: contain; }
.sp-cc{ font-size: 10px; color: #f59e0b; font-weight: 800; }
.sp-elem{ font-size: 11px; font-weight: 600; text-transform: lowercase; }
.sp-el-neutral{ color: #8b97a8; }
.sp-el-earth  { color: #8d5a2b; }
.sp-el-fire   { color: #dc2626; }
.sp-el-water  { color: #2563eb; }
.sp-el-air    { color: #16a34a; }
body.dark .sp-el-neutral{ color: #9aa7bd; }
body.dark .sp-el-earth  { color: #c08a50; }
body.dark .sp-el-fire   { color: #f87171; }
body.dark .sp-el-water  { color: #60a5fa; }
body.dark .sp-el-air    { color: #4ade80; }
/* Divider between normal and critical damage lines */
.sp-cc-sep{ border-top: 1px dashed #d8dee9; margin: 4px 0 3px; }
body.dark .sp-cc-sep{ border-top-color: #3b4a68; }
.sp-steal{ font-size: 10px; color: #ec4899; font-weight: 800; }
.sp-dur{ font-size: 10px; color: #8b5cf6; font-weight: 700; }
.spell-info{ min-width: 0; }
.spell-name{ font-weight: 700; line-height: 1.2; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.spell-desc{ font-size: 12.5px; opacity: .85; margin-top: 3px; line-height: 1.35; }
.spell-meta{ display: flex; flex-wrap: wrap; gap: 10px; margin-top: 6px; font-size: 12px; color: #475569; }
.spell-stat{ display: inline-flex; align-items: center; gap: 3px; }
.spell-stat img{ width: 14px; height: 14px; object-fit: contain; }
.spell-lvl{ color: #64748b; }
.spell-badge{ font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; padding: 1px 6px; border-radius: 999px; }
.sb-passive{ background: #e0e7ff; color: #4338ca; }
.sb-invoc{ background: #dcfce7; color: #15803d; }
.sb-var{ background: #fef3c7; color: #a16207; }
.spells-empty{ grid-column: 1 / -1; text-align: center; opacity: .7; padding: 32px 8px; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.spells-pick-btn{ background: #3b82f6; }

body.dark .spells-seg{ border-color: #4a6089; }
body.dark .spells-seg-btn{ background: #0f172a; color: #94a3b8; border-right-color: #4a6089; }
body.dark .spells-seg-btn.active{ background: #3b82f6; color: #fff; }
body.dark .spells-base-toggle{ background: #0f172a; border-color: #4a6089; color: #94a3b8; }
body.dark .spell-card{ background: #1e293b; border-color: #4a6089; }
body.dark .spell-card.is-passive{ background: #172033; }
body.dark .spell-meta, body.dark .spell-lvl{ color: #94a3b8; }
body.dark .rank-pill{ background: #0f172a; border-color: #4a6089; color: #94a3b8; }
body.dark .rank-pill.active{ background: #22c55e; border-color: #22c55e; color: #fff; }
body.dark .sp-body{ border-top-color: #33415c; }
body.dark .sp-grp-head{ color: #94a3b8; }
body.dark .ss-label{ color: #64748b; }
body.dark .sb-passive{ background: #312e81; color: #c7d2fe; }
body.dark .sb-invoc{ background: #14532d; color: #bbf7d0; }
body.dark .sb-var{ background: #78350f; color: #fde68a; }

.btn{ background:#222; color:#fff; border:0; padding:8px 12px; border-radius:10px; cursor:pointer }
.btn.ghost{ background:transparent; border:1px solid rgba(0,0,0,.12); color:#222 }
.btn:disabled{ opacity:.5; cursor:default }


/* Item preview card in modal */
.item-preview{ position:sticky; top:8px; margin-bottom:12px; }
.item-preview.hidden{ display:none; }
.item-preview .card.big{ background:#fff; border-radius:12px; padding:12px; box-shadow:0 6px 18px rgba(0,0,0,.12); }
.item-preview .card-head{ display:flex; align-items:center; gap:12px; }
.item-preview .card-img{ width:48px; height:48px; }
.item-preview .card-title{ font-weight:600; }
.item-preview .card-level{ margin-left:auto; opacity:.7; }
.item-preview .card-effects{ margin:8px 0 0 60px; padding-left:0; list-style:none; }
.item-preview .card-effects li{ margin:2px 0; }

/* Set overlay (within modal) */
.set-overlay{ position:absolute; inset:0; z-index:10; background:rgba(0,0,0,.55); display:flex; align-items:center; justify-content:center; }
.set-overlay.hidden{ display:none; }
.set-overlay .set-card{ width:94vw; max-width:880px; max-height:82vh; overflow:auto; background:#fff; border-radius:12px; box-shadow:0 16px 40px rgba(0,0,0,.4); }
.set-card{ padding:12px; }
.set-head{ display:flex; align-items:center; justify-content:space-between; margin-bottom:8px; }
.set-head-actions{ display:flex; align-items:center; gap:8px; }
.set-title{ font-weight:700; }
.set-close{ background:none; border:0; font-size:24px; line-height:1; cursor:pointer; }
.set-equip-all{ background:#3b82f6; color:#fff; border:none; border-radius:6px; padding:5px 12px; font-size:13px; font-weight:600; cursor:pointer; transition:background .15s; }
.set-equip-all:hover:not(:disabled){ background:#2563eb; }
.set-equip-all:disabled{ background:#93c5fd; cursor:not-allowed; }
.set-grid{ display:grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap:8px; }
.set-item{ display:flex; flex-direction:column; gap:6px; padding:8px; background:#fff; border:1px solid rgba(0,0,0,.06); border-radius:10px; cursor:pointer; transition: box-shadow .12s; }
.set-item:hover{ box-shadow: 0 2px 10px rgba(0,0,0,.1); }
.si-header{ display:flex; align-items:center; gap:8px; }
.set-item img{ width:36px; height:36px; flex-shrink:0; }
.set-item .t{ display:flex; flex-direction:column; align-items:flex-start; }
.si-name{ font-weight:600; font-size:.85rem; }
.si-effects{ list-style:none; margin:0; padding:0 0 0 2px; display:flex; flex-direction:column; gap:1px; border-top:1px solid #f1f5f9; padding-top:5px; }
.si-effects li{ display:flex; align-items:center; gap:3px; font-size:11px; color:#475569; }
.si-effects .eff-ico{ width:12px; height:12px; object-fit:contain; flex-shrink:0; }
.pc-setlink{ background:none; border:0; padding:0; color:#0b83ff; cursor:pointer; }

/* ===== Set bonus tiers (inside set overlay) ===== */
.set-bonuses{ display:flex; flex-direction:column; gap:8px; padding:10px 0 4px; }
.set-bonus-tier{ background:#f8fafc; border:1px solid #e2e8f0; border-radius:8px; padding:10px 12px; }
.sb-head{ font-size:11px; font-weight:700; text-transform:uppercase; letter-spacing:.06em; color:#64748b; margin-bottom:6px; }
.sb-list{ list-style:none; margin:0; padding:0; display:flex; flex-direction:column; gap:3px; }
.sb-list li{ display:flex; align-items:center; gap:5px; font-size:12px; line-height:1.3; }
.sb-ico{ width:14px; height:14px; object-fit:contain; flex-shrink:0; }
.sb-ico-placeholder{ width:14px; height:14px; flex-shrink:0; }
body.dark .set-bonus-tier{ background:#0f172a; border-color:#334155; }
body.dark .sb-head{ color:#64748b; }
body.dark .sb-list li{ color:#cbd5e1; }

/* ===== Dofus modal: layout maior + efeitos harmonizados ===== */
#dofus-modal .modal-dialog{
  width: min(1100px, 92vw);
}

#dofus-modal .modal-body {
  height: 78vh;
  max-height: 78vh;
  display: flex;
  flex-direction: row;
  overflow: hidden;
  padding: 0;
}
#dofus-modal #dofus-list {
  flex: 1 1 auto;
  overflow-y: auto;
  min-width: 0;
  padding: 10px;
}

/* Grade dos Dofus dentro do modal */
#dofus-list.picker-list{
  grid-template-columns: repeat(3, 1fr);
}

/* Efeitos como bullets simples (sem pílulas) */
#dofus-modal .df-effects{
  margin: 6px 0 0 0;
  padding-left: 16px;          /* espaço pro marcador */
  font-size: 12px;
  line-height: 1.25;
  max-height: 120px;           /* evita card muito alto */
  overflow: auto;
}

#dofus-modal .df-effects li{
  display: list-item;          /* evita herdar display:flex de .picker-list li,
                                  que quebrava o texto (com <span> internos) em colunas */
  list-style: disc;
  background: none;
  border: 0;
  padding: 0;
  margin: 2px 0;
}

/* Responsivo: 2 colunas em telas médias, 1 no mobile */
@media (max-width: 980px){
  #dofus-list.picker-list{ grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 620px){
  #dofus-list.picker-list{ grid-template-columns: 1fr; }
  #dofus-modal .modal-dialog{ width: 94vw; }
}

/* Ícones nos efeitos dos Dofus (lista do modal) */
#dofus-modal .df-eff-ico{
  width: 16px;
  height: 16px;
  vertical-align: -2px; /* alinha com o texto */
  margin-right: 6px;
  object-fit: contain;
}


/* ===== Painel: ícones como imagens ===== */
.icon.icon-img{
  display: inline-block;
  width: 18px;
  height: 18px;
  vertical-align: -3px;
  margin-right: 6px;
  background-position: center;
  background-repeat: no-repeat;
  background-size: contain;
}

/* Damage */
.i-dmg-neutral  { background-image: url('../assets/neutral.webp'); }
.i-dmg-earth    { background-image: url('../assets/earth.webp'); }
.i-dmg-fire     { background-image: url('../assets/fire.webp'); }
.i-dmg-water    { background-image: url('../assets/water.webp'); }
.i-dmg-air      { background-image: url('../assets/air.webp'); }

.i-dmg-pushback { background-image: url('../assets/dmgpushback.webp'); }
.i-dmg-crit     { background-image: url('../assets/damcrit.webp'); }
.i-dmg-weapon   { background-image: url('../assets/damweapon.webp'); }
.i-dmg-ranged   { background-image: url('../assets/damranged.webp'); } /* Distance → Ranged */
.i_dmg_distance { background-image: url('../assets/damranged.webp'); } /* (apenas fallback se alguém usar) */
.i-dmg-spell    { background-image: url('../assets/damspell.webp'); }  /* NOVO */
.i-dmg-melee    { background-image: url('../assets/dammelee.webp'); }

/* Resistance (percentual e fixa usam o mesmo ícone por elemento) */
.i-res-neutral  { background-image: url('../assets/neutral.webp'); }
.i-res-earth    { background-image: url('../assets/earth.webp'); }
.i-res-fire     { background-image: url('../assets/fire.webp'); }
.i-res-water    { background-image: url('../assets/water.webp'); }
.i-res-air      { background-image: url('../assets/air.webp'); }

/* Resistências situacionais */
.i-res-melee    { background-image: url('../assets/dammelee.webp'); }
.i-res-ranged   { background-image: url('../assets/damranged.webp'); }
.i-res-pushback { background-image: url('../assets/respushback.webp'); }
.i-res-crit     { background-image: url('../assets/rescrit.webp'); }

/* ===== Painel (Damage / Resistance): ícones grandes ===== */
.icon.icon-img{
  width: 40px;
  height: 40px;
  vertical-align: middle;
  margin-right: 8px;
  background-position: center;
  background-repeat: no-repeat;
  background-size: contain;
}

/* Largura dos holders de ícone nas linhas */
.stat-list .icon,
#resistance-panel .res-name .icon{
  display: inline-flex;
  justify-content: center;
  width: 26px;      /* antes era 20px */
  min-width: 26px;
}

/* (Opcional) em telas bem estreitas, reduza para 28px para caber melhor */
@media (max-width: 520px){
  .icon.icon-img{ width: 28px; height: 28px; }
  .stat-list .icon, #resistance-panel .res-name .icon{ width: 28px; min-width: 28px; }
}

/* ===== Set Bonus Panel ===== */
#set-bonus-section {
  align-self: stretch;
}

#wip-panel .wip-title {
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: #94a3b8;
  margin: 0 0 8px;
}
#wip-panel .wip-msg {
  font-size: .78rem;
  color: #64748b;
  line-height: 1.6;
  margin: 0 0 10px;
}
#wip-panel .wip-feedback {
  font-size: .78rem;
  color: #64748b;
  line-height: 1.5;
}
#wip-panel .wip-feedback a {
  color: #94a3b8;
  text-decoration: underline;
  text-underline-offset: 2px;
}
#wip-panel .wip-feedback a:hover { color: #64748b; }

/* ===== Anúncios (Google AdSense — unidades manuais, ver js/ads.js) ===== */
/* Containers nascem com [hidden]; js/ads.js só os exibe quando há slot configurado. */
.ad-box[hidden] { display: none !important; }
/* Sem anúncio pra servir (adblock / sem inventário): colapsa, não deixa caixa vazia */
ins.adsbygoogle[data-ad-status="unfilled"] { display: none !important; }

/* Banner horizontal entre o main e a Craft Zone — alinhado ao main */
#ad-bottom {
  max-width: 1600px;
  margin: 10px 0 0;
  padding: 0 4px 0 10px;
}
#ad-bottom ins.adsbygoogle { display: block; min-height: 90px; }

/* Vertical no trilho lateral (dentro do #side-rail, abaixo do WIP) */
#ad-side ins.adsbygoogle { display: block; width: 200px; min-height: 200px; }
/* Só existe quando o trilho lateral cabe inteiro na tela */
@media (max-width: 1929px) {
  #ad-side { display: none !important; }
}
@media (max-width: 768px) {
  #ad-bottom { padding: 0 6px; }
  #ad-bottom ins.adsbygoogle { min-height: 100px; }
}

.set-bonus-list {
  display: flex;
  gap: 10px;
  min-height: 32px;
  align-items: flex-start;
}
.sbl-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.set-bonus-empty {
  color: #94a3b8;
  font-size: 13px;
  align-self: center;
}

.sbi {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 10px 14px;
  min-width: 180px;
  max-width: 260px;
  flex: 0 0 auto;
}

.sbi-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 2px;
}

.sbi-name {
  font-weight: 700;
  font-size: 14px;
  color: #1e293b;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  line-height: 1.3;
}

.sbi-count {
  font-size: 11px;
  color: #fff;
  white-space: nowrap;
  background: #3b82f6;
  border-radius: 999px;
  padding: 1px 7px;
  flex-shrink: 0;
}

.sbi-tier {
  font-size: 11px;
  color: #94a3b8;
  margin-bottom: 5px;
}

.sbi-effects {
  list-style: none;
  margin: 0;
  padding: 0;
}

.sbi-effects li {
  font-size: 12px;
  color: #334155;
  padding: 2px 0;
  border-bottom: 1px solid #f1f5f9;
  display: flex;
  align-items: center;
  gap: 5px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.sbi-ico {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  object-fit: contain;
}

.sbi-effects li:last-child {
  border-bottom: none;
}

/* ===== Remove (×) button on equipped slots ===== */
.slot-remove {
  display: none;
  position: absolute;
  top: 3px; right: 3px;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: #ef4444;
  color: #fff;
  border: none;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  padding: 0;
  z-index: 10;
  opacity: 0;
  transition: opacity .15s;
  pointer-events: none;
}
.slot-box[data-item-id] .slot-remove,
.dofus-grid .slot-box:not(.is-placeholder) .slot-remove {
  display: flex;
}
.slot-box:hover .slot-remove {
  opacity: 1;
  pointer-events: auto;
}
.slot-remove:hover {
  background: #b91c1c;
}

/* =============================================
   FORJAMAGIA BUTTON
   ============================================= */
.slot-mage {
  display: none;
  position: absolute;
  left: -28px; top: 50%; transform: translateY(-50%);
  width: 28px; height: 28px;
  border-radius: 8px 0 0 8px;
  background: #6366f1;
  color: #fff;
  border: none;
  font-size: 16px;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  padding: 0;
  z-index: 10;
  opacity: 0;
  transition: opacity .12s .15s; /* .15s delay before hiding */
  pointer-events: none;
}
.slot-box[data-item-id] .slot-mage { display: flex; opacity: 1; pointer-events: auto; }
.slot-mage:hover { opacity: 1; background: #4f46e5; pointer-events: auto; transition: opacity .1s 0s; }

/* =============================================
   FORJAMAGIA MODAL
   ============================================= */
.fmg-card {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%,-50%);
  width: min(760px, 94vw);
  max-height: 85vh;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 16px 40px rgba(0,0,0,.28);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.fmg-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid #e2e8f0;
}
.fmg-title { font-size: 15px; font-weight: 700; color: #1e293b; }
.fmg-body {
  flex: 1 1 auto; overflow-y: auto;
  padding: 12px 16px;
  display: flex; flex-direction: column; gap: 8px;
}
/* Efeitos editáveis em 3 colunas */
.fmg-effects-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px 20px;
}
.fmg-row {
  display: grid;
  grid-template-columns: 1fr 76px;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  border-radius: 6px;
  transition: background .15s;
}
.fmg-row.edited { background: rgba(34,197,94,.12); }
.fmg-stat-name { font-size: 13px; color: #334155; display: flex; align-items: center; gap: 5px; }
.fmg-stat-name img { width: 14px; height: 14px; object-fit: contain; flex-shrink: 0; }
.fmg-row.edited .fmg-stat-name { color: #15803d; font-weight: 600; }
.fmg-input {
  width: 100%; height: 30px;
  background: #fff;
  border: 1px solid #e2e8f0; border-radius: 6px;
  padding: 0 8px; font-size: 13px; text-align: right; color: #1e293b;
}
.fmg-row.edited .fmg-input { border-color: #22c55e; color: #15803d; }
.fmg-footer {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 10px 16px;
  border-top: 1px solid #e2e8f0;
}
.fmg-empty { color: #94a3b8; font-size: 13px; text-align: center; padding: 24px 0; margin: 0; }
.fmg-divider { border: none; border-top: 1px dashed #e2e8f0; margin: 8px 0; }

/* Exo section */
.fmg-exo-section {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 0 4px;
}
.fmg-exo-label {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  color: #94a3b8; letter-spacing: .05em; flex-shrink: 0;
}
.fmg-exo-btn {
  padding: 3px 10px; border-radius: 20px; border: 1px solid #cbd5e1;
  background: #f1f5f9; color: #64748b; font-size: 12px; font-weight: 600;
  cursor: pointer; transition: background .15s, color .15s, border-color .15s;
}
.fmg-exo-btn:hover { background: #e2e8f0; color: #334155; }
.fmg-exo-btn.active { background: #6366f1; border-color: #4f46e5; color: #fff; }
body.dark .fmg-exo-label { color: #475569; }
body.dark .fmg-exo-btn { background: #0f172a; border-color: #334155; color: #94a3b8; }
body.dark .fmg-exo-btn:hover { background: #1e293b; color: #cbd5e1; }
body.dark .fmg-exo-btn.active { background: #4f46e5; border-color: #6366f1; color: #fff; }

/* Section separator */
.fmg-section-sep {
  display: flex; align-items: center; gap: 8px;
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .06em; color: #94a3b8;
  margin: 2px 0;
}
.fmg-section-sep::before, .fmg-section-sep::after {
  content: ''; flex: 1; border-top: 1px solid #e2e8f0;
}

/* Stat picker — always visible, 3-column grid */
.fmg-stat-picker {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0 8px;
  padding: 10px 8px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
}
.fmg-picker-group { display: flex; flex-direction: column; gap: 1px; }
.fmg-picker-heading {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .06em; color: #94a3b8;
  padding: 2px 6px 5px; border-bottom: 1px solid #e2e8f0; margin-bottom: 3px;
}
.fmg-picker-stat {
  display: flex; align-items: center; gap: 5px;
  text-align: left; background: none; border: none; border-radius: 4px;
  padding: 3px 6px; font-size: 12px; color: #334155; cursor: pointer; line-height: 1.4;
}
.fmg-picker-stat img { width: 14px; height: 14px; object-fit: contain; flex-shrink: 0; }
.fmg-picker-stat:hover { background: #e0e7ff; color: #4338ca; }

/* added rows */
.fmg-added-wrapper {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px 16px;
}
.fmg-row-added {
  grid-template-columns: 1fr 66px 20px;
}
.fmg-row-added .fmg-stat-name { display: flex; align-items: center; gap: 6px; }
/* Sufixo % para stats percentuais (critical, ranged/spell/melee damage) */
.fmg-input-wrap { display: flex; align-items: center; gap: 3px; min-width: 0; }
.fmg-input-wrap .fmg-input { flex: 1; min-width: 0; }
.fmg-pct { font-size: 12px; font-weight: 600; color: #64748b; flex-shrink: 0; }
body.dark .fmg-pct { color: #94a3b8; }
.fmg-remove { background: none; border: none; color: #94a3b8; cursor: pointer; font-size: 13px; padding: 0; line-height: 1; justify-self: center; }
.fmg-remove:hover { color: #ef4444; }

/* dark mode */
body.dark .fmg-card { background: #1e293b; color-scheme: dark; }
body.dark .fmg-header { border-bottom-color: #334155; }
body.dark .fmg-title { color: #f1f5f9; }
body.dark .fmg-body { background: #1e293b; }
body.dark .fmg-stat-name { color: #cbd5e1; }
body.dark .fmg-row.edited { background: rgba(34,197,94,.18); }
body.dark .fmg-row.edited .fmg-stat-name { color: #4ade80; }
body.dark .fmg-input { background: #0f172a; border-color: #334155; color: #e2e8f0; }
body.dark .fmg-row.edited .fmg-input { border-color: #4ade80; color: #4ade80; }
body.dark .fmg-footer { border-top-color: #334155; background: #1e293b; }
body.dark .fmg-divider { border-top-color: #334155; }
body.dark .fmg-section-sep { color: #64748b; }
body.dark .fmg-section-sep::before, body.dark .fmg-section-sep::after { border-top-color: #334155; }
body.dark .fmg-stat-picker { background: #0f172a; border-color: #334155; }
body.dark .fmg-picker-heading { color: #64748b; border-bottom-color: #334155; }
body.dark .fmg-picker-stat { color: #94a3b8; }
body.dark .fmg-picker-stat:hover { background: #1e3a5f; color: #93c5fd; }

/* =============================================
   TOAST NOTIFICATIONS
   ============================================= */
#toast-container {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}
.toast {
  background: #1e293b;
  color: #f1f5f9;
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 4px 16px rgba(0,0,0,.35);
  opacity: 0;
  transform: translateY(10px);
  transition: opacity .2s ease, transform .2s ease;
  white-space: nowrap;
}
.toast.show {
  opacity: 1;
  transform: translateY(0);
}

/* =============================================
   DARK MODE
   ============================================= */
body.dark {
  background: #0f172a;
  color: #e2e8f0;
}

/* Topbar */
body.dark .topbar {
  background: #1e293b;
  border-bottom-color: #334155;
}

/* Cards */
body.dark .card {
  background: #1e293b;
  border-color: #4a6089;
  box-shadow: 0 0 0 1px rgba(74,96,137,.25), 0 1px 4px rgba(0,0,0,.5);
}
body.dark .card h2 { color: #e2e8f0; }
body.dark .card-header h2 { color: #e2e8f0; }

/* Stat lists */
body.dark .stat-list li {
  border-bottom-color: #334155;
}
body.dark .stat-list li:last-child { border-bottom-color: transparent; }

/* Stat value pills */
body.dark #stats .stat-list .value {
  background: #243147;
  box-shadow: inset 0 0 0 1px #334155;
  color: #e2e8f0;
}

/* Level input */
body.dark #level-input {
  background: #0f172a;
  border-color: #475569;
  color: #e2e8f0;
}

/* EXO column header (::after on Level li) */
body.dark #stats .stat-list li:first-child::after {
  color: #64748b;
}

/* Inline stat allocation — dark mode */
body.dark #stats .stat-list li#stat-alloc-footer-row { color: #64748b; border-top-color: #334155 !important; }
body.dark .saf-pts { color: #e2e8f0; }
body.dark .stat-alloc-input { background: #0f172a; border-color: #475569; color: #e2e8f0; }
body.dark .stat-alloc-input:focus { border-color: #7c9cff; }
body.dark .stat-power-cell { color: #a78bfa; }

/* Resistance panel */
body.dark #resistance-panel .res-head { color: #94a3b8; border-bottom-color: #334155; }
body.dark #resistance-panel .res-row { border-top-color: #334155; color: #e2e8f0; }
body.dark .dash { color: #475569; }

/* Damage panel */
body.dark #damage-panel .stat-list li { color: #e2e8f0; border-bottom-color: #334155; }

/* Character slots */
body.dark .slot-box {
  background: linear-gradient(#1e293b, #162032);
  border-color: #334155;
}
body.dark .slot-box:hover { border-color: #6366f1; }
body.dark .slot-box::after { color: #475569; }
body.dark .slot-label { color: #64748b; }

/* Avatar box */
body.dark .avatar-box {
  border-color: #334155;
  background: #1e293b;
  color: #64748b;
}

/* Dofus slots */
body.dark .dofus-grid .slot-box { border-color: #334155; }

/* Modals */
body.dark .modal-dialog,
body.dark .modal-card {
  background: #1e293b;
  box-shadow: 0 16px 40px rgba(0,0,0,.6);
}
body.dark .modal-header {
  border-bottom-color: #334155;
  color: #e2e8f0;
}
body.dark .modal-header h3 { color: #e2e8f0; }
body.dark .modal-close { color: #94a3b8; }
body.dark .modal-footer { border-top-color: #334155; }
body.dark .modal-controls {
  border-bottom-color: #334155;
  background: #1e293b;
}
body.dark .modal-controls input[type="search"],
body.dark .modal-controls .lv-inp {
  background: #0f172a;
  border-color: #475569;
  color: #e2e8f0;
}
body.dark .modal-controls input::placeholder { color: #64748b; }
body.dark .modal-pager { border-top-color: #334155; color: #e2e8f0; }

/* Picker cards (equipment modal) */
body.dark .picker-card {
  background: #243147;
  border-color: #334155;
  box-shadow: 0 1px 0 rgba(0,0,0,.3), 0 4px 12px rgba(0,0,0,.3);
  color: #e2e8f0;
}
body.dark .picker-card .pc-sub { color: #94a3b8; }

/* Picker list (dofus modal) */
body.dark .picker-list li {
  background: #243147;
  border-color: #334155;
  color: #e2e8f0;
}
body.dark .picker-title { color: #e2e8f0; }

/* Filter panel */
body.dark .filter-panel {
  background: #172033;
  border-left-color: #334155;
}
body.dark .filter-chip {
  background: #1e293b;
  border-color: #334155;
  color: #94a3b8;
}
body.dark .filter-chip:hover { border-color: #6366f1; color: #a5b4fc; }
body.dark .filter-chip.active {
  background: #4f46e5;
  border-color: #6366f1;
  color: #fff;
  box-shadow: 0 0 0 3px rgba(99,102,241,.3), 0 2px 8px rgba(99,102,241,.4);
}
body.dark .filter-toggle {
  background: #243147;
  border-color: #334155;
  color: #94a3b8;
}
body.dark .filter-toggle.has-filters { background: #1e3a5f; border-color: #3b82f6; color: #93c5fd; }
body.dark .fmode-btn { background: #243147; border-color: #334155; color: #94a3b8; }
body.dark .fmode-btn:hover { border-color: #6366f1; color: #a5b4fc; }
body.dark .fmode-btn.active { background: #4f46e5; border-color: #6366f1; color: #fff; }
body.dark .filter-row { color: #94a3b8; }
body.dark .filter-num { background: #1e293b; border-color: #334155; color: #e2e8f0; }
body.dark .filter-num:focus { border-color: #6366f1; }
body.dark .filter-legendary { background: #2a2410; border-color: #6b551d; color: #e0c060; }
body.dark .filter-legendary:hover { border-color: #e0a020; }
body.dark .filter-legendary.active { background: linear-gradient(90deg, #f0c040, #d09010); border-color: #f0c040; color: #1a1206; }

/* Pet tabs */
body.dark .pet-tabs { border-bottom-color: #334155; }
body.dark .pet-tab { background: #243147; border-color: #334155; color: #94a3b8; }
body.dark .pet-tab:hover { background: #1e3a5f; border-color: #6366f1; color: #a5b4fc; }
body.dark .pet-tab.active { background: #4f46e5; border-color: #6366f1; color: #fff; font-weight: 700; box-shadow: 0 0 0 3px rgba(99,102,241,.3), 0 2px 8px rgba(99,102,241,.4); transform: scale(1.06); }

/* Set overlay (inside modal) */
body.dark .set-overlay { background: rgba(0,0,0,.7); }
body.dark .set-overlay .set-card { background: #1e293b; box-shadow: 0 16px 40px rgba(0,0,0,.6); }
body.dark .set-item { background: #243147; border-color: #334155; color: #e2e8f0; }
body.dark .si-effects li { color: #94a3b8; border-bottom-color: #334155; }

/* Buttons */
body.dark .btn { background: #334155; color: #e2e8f0; }
body.dark .btn.ghost { border-color: #475569; color: #94a3b8; }

/* Topbar nav buttons */
body.dark .topbar nav button,
body.dark #btn-public-builds,
body.dark #btn-group-builds { background: #334155; color: #e2e8f0; }
body.dark .auth-nav { border-left-color: #334155; }
body.dark #btn-dark-mode { background: #f59e0b; color: #0f172a; }

.lang-btn {
  margin-left: 8px; padding: 8px 12px; border: 0; border-radius: 8px;
  background: #3498db; cursor: pointer; display: inline-flex; align-items: center;
  justify-content: center; align-self: stretch; /* match height of the text buttons */
  line-height: 1; transition: background .15s;
}
.lang-btn:hover { background: #2980b9; }
body.dark .lang-btn { background: #334155; }
body.dark .lang-btn:hover { background: #475569; }
.lang-menu {
  position: fixed;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,.15);
  z-index: 9999;
  min-width: 90px;
  overflow: hidden;
}
body.dark .lang-menu { background: #1e2d42; border-color: #4a6089; }
.lang-option {
  padding: 7px 12px;
  font-size: .82rem;
  display: flex;
  align-items: center;
  gap: 8px;
  color: #1e293b;
  white-space: nowrap;
  cursor: pointer;
}
.lang-option:hover { background: #f1f5f9; }
body.dark .lang-option { color: #e2e8f0; }
body.dark .lang-option:hover { background: #263548; }

/* Item preview card */
body.dark .item-preview .card.big {
  background: #1e293b;
  box-shadow: 0 6px 18px rgba(0,0,0,.4);
  color: #e2e8f0;
}

/* Set Bonus panel */
body.dark .sbi {
  background: #243147;
  border-color: #334155;
}
body.dark .sbi-name { color: #e2e8f0; }
body.dark .sbi-effects li { color: #94a3b8; border-bottom-color: #334155; }
body.dark #wip-panel .wip-title { color: #475569; }
body.dark #wip-panel .wip-msg,
body.dark #wip-panel .wip-feedback { color: #475569; }
body.dark #wip-panel .wip-feedback a { color: #64748b; }
body.dark #wip-panel .wip-feedback a:hover { color: #94a3b8; }

/* =============================================
   SETS BROWSER
   ============================================= */
.avatar-reset-row {
  grid-column: 2;
  grid-row: 4;
  display: flex;
  justify-content: center;
  align-items: center;
  align-self: center;
  position: relative;
  z-index: 1;
}
.sets-browser-row {
  grid-column: 2;
  grid-row: 5;
  display: flex;
  justify-content: center;
  align-items: center;
  align-self: center;
  position: relative;
  z-index: 1;
}
.sets-browser-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  min-width: 150px; /* equal width for Reset / Sets across all languages */
  border-radius: 10px;
  border: 2px dashed #cbd5e1;
  background: linear-gradient(#fafafa, #f5f7fa);
  color: #64748b;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color .15s, background .15s, color .15s;
}
.sets-browser-btn:hover {
  border-color: #6366f1;
  background: #f0f0ff;
  color: #4f46e5;
}
#btn-reset-panel {
  border-color: #fca5a5;
  background: linear-gradient(#fff5f5, #fee2e2);
  color: #dc2626;
}
#btn-reset-panel:hover {
  border-color: #ef4444;
  background: #fee2e2;
  color: #b91c1c;
}
#btn-sets-browser {
  border-color: #93c5fd;
  background: linear-gradient(#eff6ff, #dbeafe);
  color: #2563eb;
}
#btn-sets-browser:hover {
  border-color: #3b82f6;
  background: #dbeafe;
  color: #1d4ed8;
}

/* Complete / Partial view-mode toggle */
.view-mode-toggle {
  display: flex;
  background: #e2e8f0;
  border-radius: 8px;
  padding: 3px;
  gap: 2px;
  flex-shrink: 0;
}
.view-mode-btn {
  background: transparent;
  border: none;
  border-radius: 6px;
  color: #64748b;
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 5px 14px;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}
.view-mode-btn.active {
  background: #4f46e5;
  color: #fff;
  box-shadow: 0 1px 4px rgba(79,70,229,.35);
}
.view-mode-btn:hover:not(.active) {
  background: #cbd5e1;
  color: #1e293b;
}
body.dark .view-mode-toggle { background: #1e293b; }
body.dark .view-mode-btn { color: #64748b; }
body.dark .view-mode-btn.active { background: #4f46e5; color: #fff; }
body.dark .view-mode-btn:hover:not(.active) { background: #334155; color: #e2e8f0; }

/* Sets modal body override */
#sets-modal .modal-body {
  padding: 0;
  overflow: hidden;
}
#sets-modal .modal-main {
  overflow-y: auto;
}

/* Grid of set cards */
.sets-browser-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
  padding: 12px;
  align-content: start;
  width: 100%;
  box-sizing: border-box;
}

.sets-loading-msg {
  padding: 32px;
  text-align: center;
  color: #94a3b8;
  font-size: 14px;
}

.sb-card {
  background: #fff;
  border-radius: 10px;
  padding: 10px 12px;
  border: 1px solid #e5e7eb;
  box-shadow: 0 2px 6px rgba(0,0,0,.04);
  transition: transform .1s, box-shadow .1s, border-color .1s, opacity .1s;
  cursor: pointer;
  align-self: start;
}
.sb-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(0,0,0,.08);
  border-color: #6366f1;
}
.sb-card--busy {
  opacity: 0.5;
  pointer-events: none;
}
.sb-card-header {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  padding-bottom: 7px;
  margin-bottom: 7px;
  border-bottom: 1px solid #f1f5f9;
}
.sb-card-name-block {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.sb-card-name {
  font-weight: 700;
  font-size: 13px;
  color: #1e293b;
  line-height: 1.3;
}
.sb-card-level {
  font-size: 10px;
  font-weight: 600;
  color: #64748b;
  line-height: 1;
}
.sb-card-badge {
  font-size: 10px;
  color: #fff;
  background: #6366f1;
  border-radius: 999px;
  padding: 2px 7px;
  white-space: nowrap;
  flex-shrink: 0;
  align-self: flex-start;
}
.sb-items-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  margin-bottom: 8px;
  min-height: 30px;
}
.sb-items-strip img {
  width: 30px;
  height: 30px;
  object-fit: contain;
  border-radius: 4px;
  background: #f8fafc;
  border: 1px solid #e5e7eb;
}
.sb-items-strip .img-ph {
  width: 30px;
  height: 30px;
  border-radius: 5px;
  background: linear-gradient(110deg, #f1f5f9 30%, #e8edf3 50%, #f1f5f9 70%);
  background-size: 200% 100%;
  animation: sb-shimmer 1.2s linear infinite;
  border: 1px solid #e5e7eb;
}
@keyframes sb-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.sb-effects {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 12px;
  color: #334155;
}
.sb-effects li {
  padding: 2px 0;
  display: flex;
  align-items: center;
  gap: 4px;
  border-bottom: 1px solid #f8fafc;
}
.sb-effects li:last-child { border-bottom: none; }
.sb-effects .eff-ico { width: 12px; height: 12px; object-fit: contain; flex-shrink: 0; }
#sets-sentinel {
  height: 40px;
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #94a3b8;
  font-size: 12px;
}

/* Dark mode — sets browser */
body.dark .sets-browser-btn {
  border-color: #334155;
  background: linear-gradient(#1e293b, #162032);
  color: #64748b;
}
body.dark .sets-browser-btn:hover {
  border-color: #6366f1;
  background: #2d2d4a;
  color: #a5b4fc;
}
body.dark #btn-reset-panel {
  border-color: #7f1d1d;
  background: linear-gradient(#2d1515, #3b1c1c);
  color: #f87171;
}
body.dark #btn-reset-panel:hover {
  border-color: #ef4444;
  background: #3b1c1c;
  color: #fca5a5;
}
body.dark #btn-sets-browser {
  border-color: #1e3a5f;
  background: linear-gradient(#0f2133, #0f2840);
  color: #60a5fa;
}
body.dark #btn-sets-browser:hover {
  border-color: #3b82f6;
  background: #0f2840;
  color: #93c5fd;
}
body.dark .sb-card {
  background: #1e293b;
  border-color: #334155;
}
body.dark .sb-card:hover { border-color: #6366f1; }
body.dark .sb-card-header { border-bottom-color: #334155; }
body.dark .sb-card-name { color: #e2e8f0; }
body.dark .sb-card-level { color: #94a3b8; }
body.dark .sb-effects { color: #94a3b8; }
body.dark .sb-effects li { border-bottom-color: #243147; }
body.dark .sb-items-strip img { background: #0f172a; border-color: #334155; }
body.dark .sb-items-strip .img-ph {
  background: linear-gradient(110deg, #1e293b 30%, #243147 50%, #1e293b 70%);
  background-size: 200% 100%;
  border-color: #334155;
}
.sb-item-wrap {
  position: relative;
  width: 40px;
  height: 40px;
  flex-shrink: 0;
}
.sb-item-x {
  position: absolute;
  inset: 0;
  border-radius: 5px;
  background: rgba(0, 0, 0, 0.22);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  font-weight: 900;
  color: rgba(220, 40, 40, 1);
  text-shadow: 0 0 4px rgba(0,0,0,0.8);
  pointer-events: none;
}
.sb-item-x::after { content: '✕'; }

/* Hover tooltip — always dark-themed. The container is just a flex wrapper (transparent);
   background/border live on the individual cards so the empty area beside a short card
   doesn't show a gray box. */
#slot-tooltip { color: #e2e8f0 !important; }
#slot-tooltip .st-card {
  background: #1c2433 !important;
  border-color: #334155 !important;
}
#slot-tooltip .st-name { color: #fbbf24 !important; border-bottom-color: #334155 !important; }

/* =============================================
   AUTH NAV
   ============================================= */
.auth-nav {
  display: flex;
  align-items: center;
}

.btn-auth {
  background: #6366f1;
  color: #fff;
  border: none;
  border-radius: 7px;
  padding: 6px 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
}
.btn-auth:hover { background: #4f46e5; }

.auth-user-menu {
  display: flex;
  align-items: center;
}
#btn-auth-logout { background: #e74c3c; }
#btn-auth-logout:hover { background: #c0392b; }
body.dark #btn-auth-logout { background: #7f1d1d; }
body.dark #btn-auth-logout:hover { background: #991b1b; }

.auth-username-label {
  font-size: 13px;
  font-weight: 600;
  color: #475569;
  padding: 0 4px;
}
body.dark .auth-username-label { color: #94a3b8; }

.btn-auth-action {
  border: none;
  border-radius: 7px;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  background: #e0e7ff;
  color: #3730a3;
  transition: background .15s;
}
.btn-auth-action:hover { background: #c7d2fe; }
body.dark .btn-auth-action { background: #312e81; color: #c7d2fe; }
body.dark .btn-auth-action:hover { background: #3730a3; }

.btn-auth-logout {
  background: #fee2e2;
  color: #991b1b;
}
.btn-auth-logout:hover { background: #fecaca; }
body.dark .btn-auth-logout { background: #450a0a; color: #fca5a5; }
body.dark .btn-auth-logout:hover { background: #7f1d1d; }

/* =============================================
   AUTH MODAL
   ============================================= */
.auth-card {
  position: relative;
  z-index: 1;
  background: #fff;
  border-radius: 16px;
  width: 100%;
  max-width: 400px;
  padding: 32px;
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
}
body.dark .auth-card { background: #1e293b; color: #e2e8f0; }

.auth-close {
  position: absolute;
  top: 14px;
  right: 16px;
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: #94a3b8;
}

.auth-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 24px;
  background: #f1f5f9;
  border-radius: 8px;
  padding: 4px;
}
body.dark .auth-tabs { background: #0f172a; }

.auth-tab {
  flex: 1;
  border: none;
  border-radius: 6px;
  padding: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  background: none;
  color: #64748b;
  transition: all .15s;
}
.auth-tab.active {
  background: #fff;
  color: #1e293b;
  box-shadow: 0 1px 4px rgba(0,0,0,.1);
}
body.dark .auth-tab.active { background: #1e293b; color: #e2e8f0; }

.auth-oauth { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }

.btn-oauth {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border: 1.5px solid #e2e8f0;
  border-radius: 8px;
  background: #fff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
}
body.dark .btn-oauth { background: #0f172a; border-color: #334155; color: #e2e8f0; }
.btn-oauth:hover { background: #f8fafc; }
body.dark .btn-oauth:hover { background: #1e293b; }
.btn-oauth img, .btn-oauth svg { width: 18px; height: 18px; flex-shrink: 0; }

.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 16px 0;
  color: #94a3b8;
  font-size: 12px;
}
.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: #e2e8f0;
}
body.dark .auth-divider::before,
body.dark .auth-divider::after { background: #334155; }

.auth-input {
  display: block;
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid #e2e8f0;
  border-radius: 8px;
  font-size: 14px;
  margin-bottom: 10px;
  background: #fff;
  color: #1e293b;
  outline: none;
  transition: border-color .15s;
}
body.dark .auth-input { background: #0f172a; border-color: #334155; color: #e2e8f0; }
.auth-input:focus { border-color: #6366f1; }

.auth-submit {
  width: 100%;
  padding: 11px;
  font-size: 14px;
  font-weight: 700;
  margin-top: 4px;
}

.auth-link {
  background: none;
  border: none;
  color: #6366f1;
  font-size: 13px;
  cursor: pointer;
  margin-top: 10px;
  text-decoration: underline;
  display: block;
  text-align: center;
}

.auth-msg { font-size: 13px; margin-top: 10px; text-align: center; }
.auth-msg.hidden { display: none; }
.auth-msg-error { color: #ef4444; }
.auth-msg-ok    { color: #22c55e; }

/* =============================================
   MINHAS BUILDS MODAL
   ============================================= */
#mybuilds-modal, #auth-modal, #username-prompt-modal, #account-modal {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
#mybuilds-modal.hidden, #auth-modal.hidden, #username-prompt-modal.hidden, #account-modal.hidden { display: none !important; }

.mybuilds-card {
  position: relative;
  z-index: 1;
  background: #fff;
  border-radius: 16px;
  width: 100%;
  max-width: 860px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
  overflow: hidden;
}
body.dark .mybuilds-card { background: #1e293b; color: #e2e8f0; }

.mybuilds-actions {
  padding: 12px 20px;
  border-bottom: 1px solid #e2e8f0;
}
body.dark .mybuilds-actions { border-color: #334155; }

.mybuilds-list {
  flex: 1;
  overflow-y: auto;
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ── Build preview card ── */
.mb-build-card {
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 12px 14px;
  transition: box-shadow .15s;
}
body.dark .mb-build-card { border-color: #334155; }
.mb-build-card:hover { box-shadow: 0 2px 12px rgba(0,0,0,.1); }

.mb-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.mb-card-name {
  font-weight: 700;
  font-size: 14px;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.mb-card-badge { font-size: 12px; opacity: .7; flex-shrink: 0; }
.mb-vis-btn { font-size: 11px; padding: 3px 8px; flex-shrink: 0; }

.mb-card-actions { display: flex; gap: 4px; flex-shrink: 0; margin-left: auto; }
.mb-card-actions .btn { font-size: 11px; padding: 3px 8px; }

.mb-card-body {
  display: flex;
  gap: 16px;
  align-items: flex-start;
}

/* Mini character panel */
.mb-equip-col { flex-shrink: 0; }

.mb-slots-wrapper {
  display: flex;
  gap: 4px;
}
.mb-slot-col {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.mb-slot {
  width: 52px;
  height: 52px;
  border-radius: 7px;
  border: 1px solid rgba(0,0,0,.1);
  background: #f1f5f9;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
body.dark .mb-slot { background: #0f172a; border-color: rgba(255,255,255,.1); }
.mb-slot img { width: 100%; height: 100%; object-fit: contain; }
.mb-slot-ph { opacity: .25; filter: grayscale(1); }

.mb-dofus-row {
  display: flex;
  gap: 3px;
  margin-top: 4px;
}
.mb-dofus-slot {
  width: 40px;
  height: 40px;
  border-radius: 5px;
  border: 1px solid rgba(0,0,0,.1);
  background: #f1f5f9;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
body.dark .mb-dofus-slot { background: #0f172a; border-color: rgba(255,255,255,.1); }
.mb-dofus-slot img { width: 100%; height: 100%; object-fit: contain; }

/* 3-panel stats section */
.mb-data-col {
  flex: 1;
  min-width: 0;
  display: flex;
  gap: 8px;
  font-size: 12px;
  align-items: flex-start;
}

.mb-sub-panel {
  flex: 1;
  min-width: 0;
  border: 1px solid #e2e8f0;
  border-radius: 7px;
  overflow: hidden;
}
body.dark .mb-sub-panel { border-color: #334155; }

.mb-sub-title {
  font-weight: 700;
  font-size: 11px;
  padding: 4px 6px;
  background: #f1f5f9;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  gap: 4px;
}
body.dark .mb-sub-title { background: #0f172a; border-color: #334155; }

.mb-level-badge {
  margin-left: auto;
  font-size: 10px;
  font-weight: 600;
  color: #3b82f6;
}

.mb-res-head {
  margin-left: auto;
  display: flex;
  gap: 14px;
  font-size: 10px;
  color: #64748b;
}

.mb-prow {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 2px 6px;
  border-bottom: 1px solid rgba(0,0,0,.04);
}
body.dark .mb-prow { border-color: rgba(255,255,255,.05); }
.mb-prow:last-child { border-bottom: none; }

.mb-prow-res { gap: 2px; }
.mb-sec-grid .mb-prow { min-width: 0; overflow: hidden; }

.mb-pico {
  width: 13px;
  height: 13px;
  object-fit: contain;
  flex-shrink: 0;
}
.mb-plabel { flex: 1; min-width: 0; color: #64748b; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
body.dark .mb-plabel { color: #94a3b8; }
.mb-pval { font-weight: 600; text-align: right; min-width: 36px; flex-shrink: 0; }
.mb-pval.dash { color: #94a3b8; font-weight: 400; }

#save-build-modal {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
#save-build-modal.hidden { display: none !important; }

.save-modal-card {
  position: relative;
  z-index: 1;
  background: #fff;
  border-radius: 14px;
  padding: 24px;
  width: 100%;
  max-width: 360px;
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
body.dark .save-modal-card { background: #1e293b; color: #e2e8f0; }

.save-modal-title { margin: 0; font-size: 16px; font-weight: 700; }
.save-modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
.save-visibility { display: flex; align-items: center; gap: 6px; font-size: 13px; cursor: pointer; }

/* =============================================
   MOBILE RESPONSIVE  (≤ 768px)
   ============================================= */
@media (max-width: 768px) {

  /* — Topbar — */
  .topbar {
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px 10px;
  }
  .topbar .site-title { font-size: 20px !important; }
  .topbar .title-logo { width: 20px !important; height: 20px !important; }
  .topbar nav {
    flex-wrap: wrap;
    gap: 4px;
    justify-content: flex-end;
  }
  .topbar nav button,
  #btn-public-builds,
  #btn-group-builds {
    padding: 6px 10px;
    font-size: 12px;
    margin-left: 0;
    border-radius: 6px;
  }
  .lang-btn { padding: 6px 8px; margin-left: 0; }

  /* — Main grid: single column, character first — */
  main {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
    padding: 8px 6px !important;
    margin: 0 !important;
  }
  #center-panel { order: 0; grid-column: 1 !important; }
  #left-panel   { order: 1; grid-column: 1 !important; }
  #right-panel  { order: 2; grid-column: 1 !important; margin-left: 0 !important; overflow: hidden !important; }

  /* Trilho lateral (WIP + ad): sai do posicionamento absoluto e entra no fluxo normal abaixo do conteúdo */
  #right-panel { position: static !important; }
  #side-rail {
    position: static !important;
    left: auto !important;
    top: auto !important;
    width: 100% !important;
    margin-top: 4px;
  }

  /* — Character panel slots — */
  #character-panel.card { padding: 8px 10px; }
  .slots-grid {
    grid-template-columns: 1fr 100px 1fr !important;
    column-gap: 8px !important;
    gap: 6px 8px !important;
  }
  .slot-box { width: 76px; height: 94px; }
  .slot-icon { width: 60px; height: 60px; }
  .slot-label { font-size: 11px; }

  /* Avatar: smaller on mobile, span 2 rows */
  .avatar-box {
    grid-row: 1 / span 2 !important;
  }

  /* — Reset / Sets buttons: shrink to fit the narrow center column (no overlap onto slots) — */
  .sets-browser-btn {
    min-width: 0 !important;
    width: 100% !important;
    padding: 7px 6px !important;
    font-size: 12px !important;
    gap: 5px !important;
    border-radius: 8px !important;
  }

  /* — Mage button: inside the slot at the bottom, larger touch area — */
  .slot-mage {
    left: 2px !important;
    right: 2px !important;
    bottom: 2px !important;
    top: auto !important;
    width: auto !important;
    height: 26px !important;
    border-radius: 0 0 8px 8px !important;
    transform: none !important;
    font-size: 12px !important;
  }
  /* Remove button: always visible on mobile (no hover state) */
  .slot-box[data-item-id] .slot-remove {
    opacity: 1 !important;
    pointer-events: auto !important;
  }

  /* — Dofus grid: 3 per row — */
  .dofus-grid {
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 8px !important;
    margin-top: 12px;
  }
  .dofus-grid .slot-box { width: 62px !important; height: 62px !important; }
  .dofus-grid .slot-icon { width: 50px !important; height: 50px !important; }

  /* — Right panel: stack Damage + Resistance — */
  #combat-panels {
    grid-template-columns: 1fr !important;
    gap: 8px;
  }

  /* — Stats: keep 2-col but tighten — */
  #stats .stat-list { column-gap: 8px !important; }

  /* — Modals: full screen — */
  .modal-card,
  .modal-dialog,
  .modal-box,
  .fmg-card,
  .mybuilds-card,
  .auth-card,
  .save-modal-card {
    position: fixed !important;
    inset: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    height: 100dvh !important;
    max-height: 100dvh !important;
    border-radius: 0 !important;
    transform: none !important;
    left: 0 !important;
    top: 0 !important;
    overflow-y: auto;
  }
  .modal-card { height: 100dvh !important; }
  /* auth/save/mybuilds modals are flex-centered, reset to block full-screen */
  #mybuilds-modal,
  #auth-modal,
  #save-build-modal {
    padding: 0 !important;
    align-items: stretch !important;
  }

  /* — Slot tooltip: fixed at bottom — */
  #slot-tooltip {
    position: fixed !important;
    bottom: 8px !important;
    left: 50% !important;
    top: auto !important;
    transform: translateX(-50%) !important;
    max-width: 92vw !important;
    z-index: 10002;
  }

  /* — Picker grid: 1 column on mobile — */
  .picker-grid {
    grid-template-columns: 1fr !important;
    padding: 8px !important;
  }

  /* — Dofus picker: 2 per row on mobile — */
  #dofus-list.picker-list { grid-template-columns: repeat(2, 1fr) !important; }

  /* — Sets browser grid: 1 col — */
  .sets-browser-grid {
    grid-template-columns: 1fr !important;
  }

  /* — Forjamgia: 1 col — */
  .fmg-effects-grid, .fmg-stat-picker, .fmg-added-wrapper { grid-template-columns: 1fr !important; }

  /* — Set overlay inside modal — */
  .set-overlay .set-card { width: 96vw !important; max-width: 96vw !important; }
  .set-grid { grid-template-columns: 1fr 1fr !important; }

  /* — Avatar modal: esconde cards de vídeo no mobile — */
  .avatar-class-card[data-type="video"] { display: none !important; }
}

/* =====================================================================
   COMPACT MODE — telas médias/pequenas (laptops 1366–1750px)
   Encolhe os painéis laterais (fontes + larguras das colunas) para dar
   mais espaço ao Character Panel. Desktop ≥1750px permanece intocado.
   O alinhamento com publicbuilds.html não é afetado: ele depende apenas
   de max-width/padding do <main>, que não mudam aqui (pb-page é block).
   ===================================================================== */
@media (min-width: 1201px) and (max-width: 1750px) {
  :root { --stats-pill-w: 48px; }

  main {
    grid-template-columns: 360px minmax(0, 1fr) 400px !important;
    gap: 14px !important;
  }

  /* ---- Painel Stats (esquerda): fontes e linhas mais compactas ---- */
  #left-panel .card h2 { font-size: 15px; }
  #stats .stat-list { grid-auto-rows: minmax(38px, auto) !important; column-gap: 14px !important; }
  #stats .stat-list li { font-size: 13px; }
  #stats .stat-list li img { width: 16px; height: 16px; }
  #stats .stat-list .value {
    font-size: 12px;
    height: 24px;
    min-width: 30px;
    padding: 2px 6px;
  }
  #level-input { font-size: 13px; height: 24px; }
  .stat-alloc-input { height: 24px; font-size: 11px; }

  /* ---- Damage + Resistance (direita): fontes menores ---- */
  #right-panel .card h2 { font-size: 12px; }
  #damage-panel .stat-list li,
  #resistance-panel .res-row,
  #resistance-panel .res-head { font-size: 13px; }
  #resistance-panel .res-row,
  #resistance-panel .res-head { grid-template-columns: 1fr 40px 40px; }
  #right-panel .icon.icon-img { width: 16px; height: 16px; }

  /* ---- Set Bonuses: cards mais densos ---- */
  #set-bonus-panel h2 { font-size: 13px; }
  .sbi { padding: 8px 10px; min-width: 0; max-width: none; }
  .sbi-name { font-size: 12px; }
  .sbi-count { font-size: 10px; padding: 1px 6px; }
  .sbi-tier { font-size: 10px; margin-bottom: 4px; }
  .sbi-effects li { font-size: 11px; padding: 1px 0; gap: 4px; }
  .sbi-ico { width: 12px; height: 12px; }
  .set-bonus-empty { font-size: 12px; }

  /* ---- Character Panel: aproveita o espaço liberado ----
     Sobrescreve a regra antiga de 1450px que espremia os slots
     contra o avatar (column-gap 16px) quando o centro era estreito.
     O avatar e os gaps agora flexionam com a largura disponível. */
  .slots-grid {
    grid-template-columns: 80px minmax(170px, 320px) 80px;
    column-gap: clamp(16px, 3vw, 44px);
    gap: 8px clamp(16px, 3vw, 44px);
  }
}

/* =====================================================================
   MY ACCOUNT MODAL — trocar email/senha, logout, deletar conta (LGPD)
   ===================================================================== */
.account-card { max-width: 400px; width: 92vw; }
.account-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2px;
}
.account-head h3 { margin: 0; font-size: 17px; font-weight: 700; }
.account-id {
  margin: 0 0 12px;
  font-size: 12.5px;
  color: #64748b;
  word-break: break-all;
}
.account-section {
  border-top: 1px solid #e2e8f0;
  padding: 12px 0;
}
.account-section-title { font-size: 13px; font-weight: 700; margin-bottom: 8px; }
.account-section .auth-input { margin-bottom: 8px; }
.account-btn { width: 100%; }
.account-actions {
  display: flex;
  gap: 8px;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid #e2e8f0;
  padding-top: 14px;
  margin-top: 4px;
}
.account-actions .btn-auth-logout {
  border: 0;
  border-radius: 7px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  background: #fee2e2;
  color: #b91c1c;
}
.account-delete-btn {
  border: 1px solid #e74c3c;
  border-radius: 7px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  background: transparent;
  color: #e74c3c;
}
.account-delete-btn:hover { background: #e74c3c; color: #fff; }
.account-delete-btn:disabled { opacity: .6; cursor: default; }
.account-lgpd {
  font-size: 11px;
  color: #94a3b8;
  margin: 10px 0 0;
  line-height: 1.5;
}
body.dark .account-section,
body.dark .account-actions { border-color: #334155; }
body.dark .account-id { color: #94a3b8; }

/* ===== Site footer ===== */
.site-footer {
  margin-top: 32px;
  background: #fff;
  border-top: 1px solid #e2e8f0;
  color: #475569;
  font-size: 13px;
}
.footer-inner {
  max-width: 1240px;
  margin: 0 auto;
  padding: 28px 24px 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 36px;
  align-items: flex-start;
}
.footer-brand { flex: 1 1 240px; min-width: 200px; }
.footer-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 18px;
  font-weight: 700;
  color: #0f172a;
}
.footer-logo-img { width: 22px; height: 22px; object-fit: contain; border-radius: 4px; }
.footer-tagline { margin: 8px 0 0; color: #94a3b8; font-size: 13px; }
.footer-desc { margin: 10px 0 0; color: #64748b; font-size: 13px; line-height: 1.55; max-width: 320px; }
.footer-free-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 12px;
  padding: 4px 11px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  color: #16a34a;
  background: rgba(34,197,94,.08);
  border: 1px solid rgba(34,197,94,.35);
}
.footer-col { display: flex; flex-direction: column; gap: 8px; min-width: 140px; }
.footer-col h4 {
  margin: 0 0 4px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: #94a3b8;
  font-weight: 700;
}
.footer-col a {
  color: #475569;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: color .12s;
}
.footer-col a:hover { color: #3498db; }
.footer-discord svg { flex-shrink: 0; }
.footer-bottom {
  max-width: 1240px;
  margin: 0 auto;
  padding: 14px 24px 24px;
  border-top: 1px solid #e2e8f0;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}
.footer-disclaimer { margin: 0; color: #94a3b8; font-size: 12px; max-width: 680px; line-height: 1.5; }
.footer-copy { margin: 0; color: #94a3b8; font-size: 12px; white-space: nowrap; }

body.dark .site-footer { background: #1e293b; border-top-color: #334155; color: #cbd5e1; }
body.dark .footer-logo { color: #f1f5f9; }
body.dark .footer-tagline,
body.dark .footer-col h4,
body.dark .footer-disclaimer,
body.dark .footer-copy { color: #94a3b8; }
body.dark .footer-desc { color: #94a3b8; }
body.dark .footer-free-badge { color: #4ade80; background: rgba(74,222,128,.1); border-color: rgba(74,222,128,.3); }
body.dark .footer-col a { color: #cbd5e1; }
body.dark .footer-col a:hover { color: #60a5fa; }
body.dark .footer-bottom { border-top-color: #334155; }

@media (max-width: 768px) {
  .footer-inner { gap: 24px; padding: 24px 16px 12px; }
  .footer-bottom { flex-direction: column; align-items: flex-start; padding: 14px 16px 20px; }
}

/* ===== Footer legal links ===== */
.footer-legal { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 14px; }
.footer-legal a { color: #64748b; text-decoration: none; font-size: 12px; }
.footer-legal a:hover { color: #3498db; }
body.dark .footer-legal a { color: #94a3b8; }
body.dark .footer-legal a:hover { color: #60a5fa; }

/* ===== Legal pages (privacy / terms) ===== */
.tb-back {
  margin-left: 8px; padding: 8px 16px; border-radius: 8px;
  background: #3498db; color: #fff; text-decoration: none;
  font-size: 14px; font-weight: 500; display: inline-flex; align-items: center;
  transition: background .15s;
}
.tb-back:hover { background: #2980b9; }
/* display:block resets the global app `main` grid so legal pages flow normally */
.legal-main { display: block; max-width: 860px; margin: 0 auto; padding: 32px 22px 56px; }
.legal-main h1 { font-size: 1.85rem; margin: 0 0 4px; color: #0f172a; }
.legal-updated { color: #94a3b8; font-size: .82rem; margin: 0 0 28px; }
.legal-main h2 { font-size: 1.12rem; margin: 30px 0 8px; color: #1e293b; }
.legal-main p, .legal-main li { color: #475569; font-size: .92rem; line-height: 1.65; }
.legal-main ul { padding-left: 22px; margin: 8px 0; }
.legal-main li { margin-bottom: 4px; }
.legal-main a { color: #3498db; }
.legal-main strong { color: #334155; }
.legal-note {
  background: #f8fafc; border: 1px solid #e2e8f0; border-left: 3px solid #f59e0b;
  border-radius: 8px; padding: 12px 14px; font-size: .85rem; color: #64748b; margin: 20px 0;
}
body.dark .legal-main h1, body.dark .legal-main h2 { color: #e2e8f0; }
body.dark .legal-main p, body.dark .legal-main li { color: #cbd5e1; }
body.dark .legal-main strong { color: #e2e8f0; }
body.dark .legal-note { background: #162032; border-color: #334155; border-left-color: #f59e0b; color: #94a3b8; }

/* ===== First-visit language picker ===== */
.modal-card.langfirst-card { width: min(360px, 92vw); height: auto; max-height: 82vh; }
.langfirst-head { padding: 20px 20px 6px; font-size: 17px; font-weight: 700; text-align: center; color: #1e293b; }
body.dark .langfirst-head { color: #e2e8f0; }
.langfirst-list { display: flex; flex-direction: column; gap: 8px; padding: 10px 18px 20px; }
.langfirst-opt {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid #e2e8f0;
  border-radius: 10px; background: #fff; cursor: pointer; font-size: 15px; font-weight: 600; color: #1e293b;
  transition: border-color .15s, background .15s;
}
.langfirst-opt:hover { border-color: #3498db; background: #f0f9ff; }
.langfirst-opt img { border-radius: 3px; flex: none; }
body.dark .langfirst-opt { background: #16213e; border-color: #334155; color: #e2e8f0; }
body.dark .langfirst-opt:hover { border-color: #3498db; background: #1e2d42; }

/* ===== Features modal ===== */
.modal-card.features-card { width: min(520px, 92vw); height: auto; max-height: 82vh; }
.features-body { padding: 16px; overflow: auto; display: flex; flex-direction: column; gap: 12px; }
.feature-card {
  display: flex; align-items: center; gap: 14px; padding: 14px 16px;
  border: 1px solid #e2e8f0; border-radius: 12px; text-decoration: none; color: inherit;
  transition: border-color .15s, background .15s, transform .1s;
}
body.dark .feature-card { border-color: #334155; }
.feature-card.feature-live { cursor: pointer; }
.feature-card.feature-live:hover { border-color: #8b5cf6; background: #faf5ff; transform: translateY(-1px); }
body.dark .feature-card.feature-live:hover { border-color: #8b5cf6; background: #241b3a; }
.feature-ico { font-size: 26px; flex: none; line-height: 1; }
.feature-info { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.feature-name { font-weight: 700; font-size: 15px; color: #1e293b; }
body.dark .feature-name { color: #e2e8f0; }
.feature-desc { font-size: 12.5px; color: #64748b; line-height: 1.35; }
body.dark .feature-desc { color: #94a3b8; }
.feature-cta { flex: none; font-weight: 700; font-size: 13px; color: #8b5cf6; white-space: nowrap; }
.feature-card.feature-soon { opacity: .6; }
.feature-badge { flex: none; font-size: 11px; font-weight: 600; color: #64748b; background: #f1f5f9; border-radius: 999px; padding: 3px 10px; white-space: nowrap; }
body.dark .feature-badge { background: #1e2d42; color: #94a3b8; }

/* ===== Craft Zone (resources needed to craft equipped items) ===== */
#craft-panel { max-width: 1600px; margin: 18px 10px 0; padding: 16px 20px 20px; }
.craft-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
#craft-panel .craft-title { margin: 0; font-size: 1.15rem; color: #1e293b; }
body.dark #craft-panel .craft-title { color: #e2e8f0; }
.craft-head-left { display: flex; align-items: center; gap: 12px; }
.craft-mult { display: inline-flex; align-items: center; gap: 3px; }
.craft-mult-x { color: #94a3b8; font-weight: 700; font-size: 15px; }
.craft-mult-inp {
  width: 54px; height: 36px; box-sizing: border-box; padding: 0 8px; border-radius: 8px; border: 1px solid #cbd5e1;
  background: #fff; color: #1e293b; font-size: 14px; font-weight: 700; text-align: center;
  -moz-appearance: textfield; appearance: textfield;
}
.craft-mult-inp::-webkit-outer-spin-button, .craft-mult-inp::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
body.dark .craft-mult-inp { background: #1e2d42; border-color: #4a6089; color: #e2e8f0; }
.craft-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
/* All craft controls share the same 36px height (button, select, segmented, ×N input) */
.craft-sort {
  height: 36px; box-sizing: border-box; padding: 0 10px; border-radius: 8px; border: 1px solid #cbd5e1; cursor: pointer;
  background: #f1f5f9; color: #334155; font-size: 13px; font-weight: 600;
}
body.dark .craft-sort { background: #1e2d42; border-color: #4a6089; color: #cbd5e1; }
.craft-btn {
  height: 36px; box-sizing: border-box; padding: 0 14px; border-radius: 8px; border: 1px solid #cbd5e1; cursor: pointer;
  background: #f1f5f9; color: #334155; font-size: 13px; font-weight: 600; transition: background .15s, border-color .15s;
}
/* Gap separating the two "add" buttons from the view controls on their right */
#craft-add-item { margin-right: 40px; }
.craft-btn:hover { background: #e2e8f0; border-color: #94a3b8; }
.craft-btn.craft-clear { background: transparent; color: #64748b; }
.craft-btn.craft-clear:hover { background: #fee2e2; border-color: #fca5a5; color: #b91c1c; }
body.dark .craft-btn { background: #1e2d42; border-color: #4a6089; color: #cbd5e1; }
body.dark .craft-btn:hover { background: #243450; }
body.dark .craft-btn.craft-clear { background: transparent; color: #94a3b8; }
body.dark .craft-btn.craft-clear:hover { background: #3b0a0a; border-color: #7f1d1d; color: #fca5a5; }

/* Craft item picker (add ANY craftable item, not just equipped ones) */
.craft-pick-card {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: min(440px, 94vw); max-height: 72vh; display: flex; flex-direction: column;
  background: #fff; border-radius: 12px; box-shadow: 0 16px 40px rgba(0,0,0,.28); overflow: hidden;
}
body.dark .craft-pick-card { background: #1e293b; color: #e2e8f0; }
.craft-pick-head { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid #e2e8f0; }
body.dark .craft-pick-head { border-bottom-color: #33415c; }
.craft-pick-head input {
  flex: 1 1 auto; height: 34px; padding: 0 10px; border-radius: 8px; border: 1px solid #cbd5e1; outline: 0;
  background: #fff; color: inherit;
}
body.dark .craft-pick-head input { background: #0f172a; border-color: #4a6089; }
.craft-pick-list { overflow-y: auto; padding: 6px; display: flex; flex-direction: column; gap: 2px; }
.craft-pick-row {
  display: flex; align-items: center; gap: 8px; padding: 5px 8px; border-radius: 8px;
  border: 0; background: transparent; cursor: pointer; text-align: left; font-size: 13px; color: inherit;
}
.craft-pick-row:hover { background: #f1f5f9; }
body.dark .craft-pick-row:hover { background: #243450; }
.craft-pick-row img { width: 28px; height: 28px; object-fit: contain; }
.craft-pick-row .cp-name { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.craft-pick-row .cp-lvl { color: #94a3b8; font-size: 12px; flex: none; }
.craft-pick-row.added .cp-ok { color: #22c55e; font-weight: 800; }
.craft-pick-empty { padding: 14px; text-align: center; opacity: .65; font-size: 13px; }

/* View toggle (Group by item / All resources) — same box pattern as .craft-btn;
   the active option fills indigo. */
.craft-seg { display: inline-flex; align-items: center; gap: 8px; background: transparent; padding: 0; }
.craft-seg-opt {
  height: 36px; box-sizing: border-box; padding: 0 14px; border-radius: 8px; cursor: pointer;
  border: 1px solid #cbd5e1; background: #f1f5f9; color: #334155;
  font-size: 13px; font-weight: 600; transition: background .15s, color .15s, border-color .15s;
}
.craft-seg-opt:not(.active):hover { background: #e2e8f0; border-color: #94a3b8; }
body.dark .craft-seg-opt { background: #1e2d42; border-color: #4a6089; color: #94a3b8; }
body.dark .craft-seg-opt:not(.active):hover { background: #243450; color: #e2e8f0; }
.craft-seg-opt.active,
body.dark .craft-seg-opt.active { background: #6366f1; border-color: #6366f1; color: #fff; }

.craft-empty, .craft-loading, .craft-norecipe { color: #94a3b8; font-size: 13px; padding: 10px 2px; }

/* "All resources" + "Group by item" grids */
/* Multi-column so resources flow TOP→BOTTOM (down column 1, then column 2, …) */
.craft-all   { columns: 345px; column-gap: 26px; }
.craft-all .craft-res { break-inside: avoid; -webkit-column-break-inside: avoid; }
.craft-items { display: grid; grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); gap: 14px; }
.craft-item  { border: 1px solid #e2e8f0; border-radius: 10px; padding: 10px 12px; }
body.dark .craft-item { border-color: #334155; }
.craft-item-head { display: flex; align-items: center; gap: 8px; font-weight: 700; color: #1e293b; margin-bottom: 6px; padding-bottom: 6px; border-bottom: 1px solid #e2e8f0; }
body.dark .craft-item-head { color: #e2e8f0; border-bottom-color: #334155; }
.craft-item-ico { width: 30px; height: 30px; object-fit: contain; flex: none; }
.craft-item-name { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.craft-item-rm { flex: none; border: none; background: transparent; color: #94a3b8; cursor: pointer; font-size: 20px; line-height: 1; padding: 0 4px; border-radius: 5px; }
.craft-item-rm:hover { background: #fee2e2; color: #b91c1c; }
body.dark .craft-item-rm:hover { background: #3b0a0a; color: #fca5a5; }
/* Per-item multiplier box in the item header */
.craft-item-multwrap { flex: none; display: inline-flex; align-items: center; gap: 2px; color: #94a3b8; font-weight: 700; }
.craft-item-mult {
  width: 46px; padding: 4px 6px; border-radius: 6px; border: 1px solid #cbd5e1;
  background: #fff; color: #1e293b; font-size: 13px; font-weight: 700; text-align: center;
  -moz-appearance: textfield; appearance: textfield;
}
.craft-item-mult::-webkit-outer-spin-button, .craft-item-mult::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
body.dark .craft-item-mult { background: #1e2d42; border-color: #4a6089; color: #e2e8f0; }

/* Resource row: icon · name · need · owned input · have-all checkbox */
.craft-res { display: flex; align-items: center; gap: 8px; padding: 4px 0; border-bottom: 1px solid rgba(148,163,184,.14); }
.craft-res-ico  { width: 26px; height: 26px; object-fit: contain; flex: none; }
.craft-res-name { flex: 1 1 auto; min-width: 0; font-size: 13px; color: #334155; line-height: 1.25; overflow-wrap: anywhere; }
body.dark .craft-res-name { color: #cbd5e1; }
.craft-res-need { flex: none; font-weight: 700; font-size: 13px; color: #6366f1; min-width: 34px; text-align: right; }
body.dark .craft-res-need { color: #93acff; }
.craft-res-have {
  flex: none; width: 78px; padding: 3px 2px 3px 6px; border-radius: 6px; border: 1px solid #cbd5e1;
  background: #fff; color: #1e293b; font-size: 12px; text-align: center;
}
/* Keep the native ± spinner always visible, glued to the right edge */
.craft-res-have::-webkit-inner-spin-button { opacity: 1; margin-left: 2px; }
body.dark .craft-res-have { background: #1e2d42; border-color: #4a6089; color: #e2e8f0; color-scheme: dark; }
.craft-res-all { flex: none; display: inline-flex; align-items: center; gap: 4px; font-size: 11px; color: #64748b; cursor: pointer; user-select: none; }
body.dark .craft-res-all { color: #94a3b8; }
.craft-res-all input { cursor: pointer; }
.craft-res.done .craft-res-name { text-decoration: line-through; opacity: .55; }
.craft-res.done .craft-res-ico { opacity: .5; }
/* "Hide completed" toggle: when on, completed rows vanish from both views.
   Sized/styled exactly like .craft-btn so it blends with the control row. */
.craft-hide-done-toggle {
  height: 36px; box-sizing: border-box; padding: 0 14px; border-radius: 8px; border: 1px solid #cbd5e1;
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none;
  background: #f1f5f9; color: #334155; font-size: 13px; font-weight: 600; transition: background .15s, border-color .15s;
}
.craft-hide-done-toggle:hover { background: #e2e8f0; border-color: #94a3b8; }
.craft-hide-done-toggle input {
  cursor: pointer; margin: 0; width: 17px; height: 17px; flex: none; accent-color: #6366f1;
}
body.dark .craft-hide-done-toggle { background: #1e2d42; border-color: #4a6089; color: #cbd5e1; }
body.dark .craft-hide-done-toggle:hover { background: #243450; }
.craft-body.craft-hide-done .craft-res.done { display: none; }

@media (max-width: 768px) {
  #craft-panel { margin: 12px 6px 0; padding: 12px 14px 16px; }
  .craft-all { columns: 1; }
  .craft-items { grid-template-columns: 1fr; }
  .craft-res-all span { display: none; }
}
