/* ==========================================================================
   items.css — card de item (lista/grid) + barra de filtros sticky
   Tudo com prefixo .items-/.item/.f* para não colidir com o CSS global.

   Variáveis que você pode sobrescrever no seu tema:
     --items-sticky-top   altura de uma navbar fixa (ex.: 64px). Padrão 0.
     --items-toolbar-bg   fundo da barra (padrão: cinza translúcido + blur)
     --color-accent       cor de destaque (chips marcados, botão primário)
   ========================================================================== */

.items-page {
    --i-border: rgba(128, 128, 128, .34);
    --i-fill: rgba(128, 128, 128, .13);
    --i-accent: var(--color-accent, #4d8dff);
    --i-gold: #e0a800;
    /* Largura ÚNICA (não muda entre lista/grid — trocar de view não deve
       redimensionar a barra de busca). Cresce em telas grandes (4K etc.)
       para o grid aproveitar o espaço, sem ficar gigante em ultrawide. */
    max-width: min(96vw, 2400px);
    margin: 0 auto;
    padding: 0 12px 64px;
    box-sizing: border-box;
}

.items-page *, .items-page *::before, .items-page *::after { box-sizing: border-box; }

/* Reserva o espaço da barra de rolagem sempre, pra abrir/fechar o painel de
   filtros (que muda a altura da página) não empurrar o conteúdo horizontalmente
   e recalcular colunas do grid no meio do caminho. Aplicado em html E body
   porque não sei qual dos dois é o container que realmente rola no seu site. */
html, body { scrollbar-gutter: stable; }
.items-page [hidden] { display: none !important; }

/* Neutraliza o hover padrão do seu card_blank (ex.: scale/translate/shadow)
   só dentro da barra de filtros — ela não deve "crescer" ao passar o mouse. */
.items-toolbar > *:hover,
.items-toolbar > * { transform: none !important; transition: none !important; }


/* ==========================================================================
   Elementos: cor por elemento (usada em chips do card e nos filtros)
   ========================================================================== */
.res--physical   { --c: #a89078; }
.res--fire       { --c: #f2622a; }
.res--ice        { --c: #3ab8e8; }
.res--earth      { --c: #4cb050; }
.res--energy     { --c: #b25be0; }
.res--death      { --c: #8a8a9c; }
.res--holy       { --c: #e8b923; }
.res--drowning   { --c: #3a7be8; }
.res--life-drain { --c: #d94060; }
.res--mana-drain { --c: #3a88d9; }


/* ==========================================================================
   BARRA DE FILTROS (sticky)
   ========================================================================== */
.items-toolbar {
    position: sticky;
    top: calc(var(--items-sticky-top, 0px) + 8px + 90px);   /* +90px = navbar */
    z-index: 40;
    /* margin: 8px auto; */
    margin: 8px auto 30px auto;
    border-radius: 16px;
    /* min-width: 250px; */
    width: 1000px;
    max-width: min(90vw, 1600px);
    box-shadow:
        0 5px 20px rgba(0, 0, 0, 0.25),
        0 1px 2px rgba(0, 0, 0, 0.2);
    /* fundo e blur vêm do card_blank */
}
.items-toolbar > * { width: 100%; max-width: none; margin: 0; background: var(--card-color, var(--i-fill)) !important; }
.items-toolbar__inner { padding: 6px 8px; margin: calc(-1 * var(--item-card-pad, 20px)); }

.items-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    /* width: 1300px; */
}

.items-search { flex: 1 1 200px; min-width: 0; }
.items-sort   { display: flex; gap: 6px; min-width: 0; }
.items-view   { display: flex; gap: 4px; }

/* -- campos ---------------------------------------------------------------- */
.items-toolbar input[type="search"],
.items-toolbar input[type="number"],
.items-toolbar select {
    width: 100%;
    min-height: 42px;
    padding: 0 12px;
    font: inherit;
    font-size: 16px;               /* 16px evita zoom automático no iOS */
    color: inherit;
    background: var(--i-fill);
    border: 1px solid var(--i-border);
    border-radius: 10px;
}
.items-toolbar select option { color: #111; background: #fff; }
.items-toolbar input::placeholder { color: inherit; opacity: .55; }

/* -- botões ---------------------------------------------------------------- */
.ibtn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 42px;
    padding: 0 12px;
    font: inherit;
    font-size: 15px;
    color: inherit;
    background: var(--i-fill);
    border: 1px solid var(--i-border);
    border-radius: 10px;
    cursor: pointer;
    white-space: nowrap;
}
.ibtn:hover { border-color: var(--i-accent); }
.ibtn--icon { width: 42px; padding: 0; }
.ibtn[aria-pressed="true"],
.ibtn[aria-expanded="true"],
.ibtn--primary { color: #fff; background: var(--i-accent); border-color: transparent; }

.items-badge {
    display: inline-grid;
    place-items: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    font-size: 12px;
    font-weight: 700;
    color: #fff;
    background: var(--i-accent);
    border-radius: 10px;
}

.ilink {
    padding: 6px 4px;
    font: inherit;
    font-size: 14px;
    color: inherit;
    text-decoration: underline;
    background: none;
    border: 0;
    opacity: .8;
    cursor: pointer;
}
.ilink:hover { opacity: 1; }

.items-toolbar :is(button, input, select, summary):focus-visible,
.fchip input:focus-visible + span,
.fmode input:focus-visible + span {
    outline: 2px solid var(--i-accent);
    outline-offset: 2px;
}

/* -- status ---------------------------------------------------------------- */
.items-status {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 8px;
    padding: 0 4px;
    font-size: 13px;
}

/* -- painel ---------------------------------------------------------------- */
.items-panel {
    max-height: min(62vh, 560px);
    margin-top: 10px;
    padding-top: 12px;
    overflow-y: auto;
    overscroll-behavior: contain;
    border-top: 1px solid var(--i-border);
}
.items-panel__grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 270px), 1fr));
    gap: 16px 24px;
}
.items-panel__foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 16px;
    padding-top: 10px;
    border-top: 1px solid var(--i-border);
}

.fgroup { min-width: 0; margin: 0; padding: 0; border: 0; }
.fgroup legend { padding: 0; margin-bottom: 8px; font-size: 14px; font-weight: 600; }

.fchips { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 8px; }
.fchips__label { font-size: 13px; opacity: .75; margin-right: 2px; }

.fchip { position: relative; cursor: pointer; }
.fchip input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    opacity: 0;
    cursor: pointer;
}
.fchip span {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    min-height: 34px;
    padding: 0 11px;
    font-size: 14px;
    user-select: none;
    background: var(--i-fill);
    border: 1px solid var(--i-border);
    border-radius: 999px;
    transition: background-color .12s, border-color .12s;
}
.fchip i { font-style: normal; }
.fchip small { font-size: 11px; opacity: .6; }
.fchip:hover span { border-color: var(--c, var(--i-accent)); }
.fchip input:checked + span {
    font-weight: 600;
    background: color-mix(in srgb, var(--c, var(--i-accent)) 32%, transparent);
    border-color: var(--c, var(--i-accent));
}
.fchip--tier span { color: var(--i-gold); letter-spacing: 1px; }

.frow { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }

.fmode {
    display: inline-flex;
    overflow: hidden;
    border: 1px solid var(--i-border);
    border-radius: 999px;
}
.fmode label { position: relative; cursor: pointer; }
.fmode input { position: absolute; inset: 0; margin: 0; opacity: 0; cursor: pointer; }
.fmode span { display: block; padding: 6px 13px; font-size: 13px; }
.fmode input:checked + span { color: #fff; background: var(--i-accent); }

.fselect { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; }
.fselect select { width: auto; min-height: 36px; font-size: 14px; }

.fcheck { display: flex; align-items: center; gap: 8px; margin-top: 2px; font-size: 14px; cursor: pointer; }
.fcheck input { width: 18px; height: 18px; accent-color: var(--i-accent); }

.fnums { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 10px; }
.fnum { display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.fnum input { min-height: 38px; }

.fhint { margin: 8px 0 0; font-size: 12.5px; line-height: 1.4; opacity: .7; }


/* ==========================================================================
   LISTA / GRID — container
   ========================================================================== */
.items-list { display: flex; flex-direction: column; gap: 8px; max-width: min(90vw, 1000px); }

.items-list[data-view="grid"] {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr));
    gap: 10px;
    max-width: min(90vw, 1600px);
}

.items-empty { padding: 56px 16px; text-align: center; }
.items-empty p { margin: 0 0 12px; font-size: 17px; }


/* ==========================================================================
   CARD DO ITEM
   ========================================================================== */
/* content-visibility foi removido: a estimativa de altura (92px) não bate com o
   card real (lista ~90px, grid ~220px+chips), e isso fazia os cards "pularem"
   de tamanho ao entrar na tela. Sem isso o navegador só perde um pouco de
   performance em categorias com 500+ itens (ex.: weapons). */

/* neutraliza largura/margem que o card_blank possa ter */
.item > * { width: 100%; max-width: none; margin: 0; background: var(--card-color, var(--i-fill)) !important; }
.items-list[data-view="grid"] .item > * { height: 100%; }

/* Pegadinha clássica do CSS Grid: o min-width padrão de um item de grid é "auto"
   (= largura do conteúdo, ex.: texto sem quebra), então mesmo com
   minmax(240px, 1fr) o navegador alargava as colunas além de 240px pra caber o
   conteúdo — e isso é o que fazia o grid mostrar só 2 colunas com tela sobrando. */
.items-list[data-view="grid"] .item { min-width: 0; }

.item__inner {
    display: grid;
    align-items: center;
    column-gap: 14px;
    padding: 6px 8px;
    /* anula parte do padding do card_blank. Ajuste conforme o seu card_blank */
    margin: calc(-1 * var(--item-card-pad, 20px));
}

.item__media {
    grid-area: media;
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    background: var(--i-fill, rgba(128, 128, 128, .13));
    border-radius: 10px;
}
.item__media img {
    width: 32px;
    height: 32px;
    object-fit: contain;
    image-rendering: pixelated;
}

.item__head {
    grid-area: head;
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 2px 8px;
    min-width: 0;
}
.item__name { margin: 0; font-size: 16px; font-weight: 600; line-height: 1.3; overflow-wrap: anywhere; }
.item__name a { color: inherit; text-decoration: none; }
.item__name a:hover { text-decoration: underline; }

.item__tier { font-size: 12px; letter-spacing: 1px; color: #e0a800; white-space: nowrap; }
.item__tier-off { opacity: .25; }

/* -- números --------------------------------------------------------------- */
.item__stats { grid-area: stats; display: flex; gap: 4px; margin: 0; }

.stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 68px;
    padding: 3px 6px;
    border-radius: 8px;
}
.stat dt { margin: 0; font-size: 15px; font-weight: 600; white-space: nowrap; opacity: .7; }
.stat dd { margin: 0; font-size: 16px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat dd small { display: block; font-size: 11px; font-weight: 400; opacity: .75; }
.stat--empty dd { font-weight: 400; opacity: .3; }
.stat--info { align-items: flex-start; min-width: 0; max-width: 220px; text-align: left; }
.stat--info dd { font-size: 14px; font-weight: 500; overflow-wrap: anywhere; }

/* destaca a coluna pela qual a lista está ordenada */
.items-list[data-sorted="armor"]   .stat[data-key="armor"],
.items-list[data-sorted="defense"] .stat[data-key="defense"],
.items-list[data-sorted="attack"]  .stat[data-key="attack"],
.items-list[data-sorted="damage"]  .stat[data-key="damage"],
.items-list[data-sorted="range"]   .stat[data-key="range"],
.items-list[data-sorted="level"]   .stat[data-key="level"],
.items-list[data-sorted="weight"]  .stat[data-key="weight"],
.items-list[data-sorted="imb"]     .stat[data-key="imb"],
.items-list[data-sorted="vol"]     .stat[data-key="vol"] {
    background: color-mix(in srgb, var(--i-accent, #4d8dff) 20%, transparent);
}

/* -- chips ----------------------------------------------------------------- */
.item__chips { grid-area: chips; display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }

.chip {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 1px 8px;
    font-size: 12.5px;
    line-height: 1.6;
    white-space: nowrap;
    background: var(--i-fill, rgba(128, 128, 128, .13));
    border: 1px solid var(--i-border, rgba(128, 128, 128, .34));
    border-radius: 999px;
}
.chip i { font-style: normal; }
.chip b { font-weight: 700; }

.chip.res {
    font-weight: 600;
    background: color-mix(in srgb, var(--c) 20%, transparent);
    border-color: color-mix(in srgb, var(--c) 55%, transparent);
}
.chip.res--neg { color: #e5484d; border-style: dashed; }
.chip.aug {
    /* Uma linha quando cabe. Só quebra ENTRE o nome da magia e o efeito (os dois
       blocos são nowrap), nunca no meio de "Fierce Berserk". */
    --c: #e0a800;
    display: inline-block;
    padding: 2px 10px;
    border-radius: 12px;
    line-height: 1.5;
    white-space: normal;
    background: color-mix(in srgb, var(--c) 14%, transparent);
    border-color: color-mix(in srgb, var(--c) 45%, transparent);
}
.chip.aug .aug-name,
.chip.aug .aug-value { white-space: nowrap; }
.chip.aug .aug-name { margin: 0 4px 0 3px; }
.chip.meta { opacity: .8; }

/* -- link "esticado": o card inteiro fica clicável (abre a página do item),
      sem quebrar os links de dentro (nome, criaturas do dropped by) -- */
.item__inner { position: relative; isolation: isolate; }
.item__stretched-link { position: absolute; inset: 0; z-index: 1; border-radius: inherit; cursor: pointer; }
.item__name a,
.item__drops summary,
.item__drops-list a { position: relative; z-index: 2; }

/* -- texto "You see a ..." igual ao jogo (estilo enviado pelo usuário, tirado
      direto do elemento do tibiafandom): Verdana bold, verde clássico do
      Tibia, contorno preto. Fica dentro do card, embaixo do nome. Sempre
      nessa cor/fonte, não segue tema claro/escuro do site — é assim no jogo. -- */
.item-look.tibiatext.tibiagreen {
    display: block;
    flex: 0 0 100%;          /* .item__head é flex-wrap: sem isso o texto curto (armaduras) ficava AO LADO do nome */
    width: 100%;
    margin-top: 4px;
    font-family: Verdana, Tahoma, sans-serif;
    font-size: 8pt;
    font-weight: bold;
    line-height: normal;
    color: #00F000;
    text-decoration: none;
    text-shadow:
        0.1em 0.1em 0.08em #000, -0.1em -0.1em 0.08em #000,
        0.1em -0.1em 0.08em #000, -0.1em 0.1em 0.08em #000,
        -0.1em 0 0.08em #000, 0.1em 0 0.08em #000;
}
.item-look .p-attributes { display: inline; }
.item-look div, .item-look span, .item-look br { font-size: inherit; font-weight: inherit; line-height: inherit; }
/* .p-reqs e .p-weight ficam como <div> normal (display:block, o padrão) —
   é isso que cria a quebra de linha depois de "Tier: 0." igual ao jogo.
   Deixar como inline gruda "0.It can only..." sem espaço. */

/* -- dropado por ------------------------------------------------------------ */
.item__drops { grid-area: drops; margin-top: 6px; font-size: 13px; }
.item__drops summary,
.item__drops-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    opacity: .75;
    margin: 0;
}
.item__drops summary { cursor: pointer; list-style: none; }
.item__drops summary::-webkit-details-marker { display: none; }
.item__drops summary::before { content: "▸"; font-size: 11px; }
.item__drops[open] summary::before { content: "▾"; }
.item__drops-count {
    padding: 0 7px;
    font-size: 11px;
    background: var(--i-fill, rgba(128, 128, 128, .13));
    border-radius: 999px;
}
.item__drops-list {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 6px;
    max-width: 560px;         /* sem isso a lista esticava até a borda do card, que agora é bem largo */
    margin-top: 6px;
}
.item__drops-list a {
    padding: 1px 8px;
    color: inherit;
    text-decoration: none;
    background: var(--i-fill, rgba(128, 128, 128, .13));
    border: 1px solid var(--i-border, rgba(128, 128, 128, .34));
    border-radius: 999px;
    opacity: .85;
}
.item__drops-list a:hover { opacity: 1; border-color: var(--i-accent, #4d8dff); text-decoration: underline; }


/* ==========================================================================
   LAYOUT: LISTA (padrão)
   desktop:  [img] nome/chips ........................ [colunas de números]
   ========================================================================== */
.items-list[data-view="list"] .item__inner {
    grid-template-columns: 44px minmax(0, 1fr) auto;
    grid-template-areas:
        "media head  stats"
        "..... chips stats"
        "..... drops stats";
    /* "media" só ocupa a 1ª linha (perto do nome). Se não houver chips/drops,
       as duas últimas linhas colapsam a 0 e o card não sobra espaço vazio;
       nome e imagem ficam centralizados juntos na única linha que existe. */
}
.items-list[data-view="list"] .item__stats { justify-content: flex-end; }


/* ==========================================================================
   LAYOUT: GRID (parecido com o character_card: nome no topo, imagem + números)
   ========================================================================== */
.items-list[data-view="grid"] .item__inner {
    grid-template-columns: 60px minmax(0, 1fr);
    grid-template-areas:
        "head  head"
        "media stats"
        "chips chips"
        "drops drops";
    row-gap: 10px;
    padding: 8px;
    align-items: start;
}
.items-list[data-view="grid"] .item__head { justify-content: center; text-align: center; }
.items-list[data-view="grid"] .item__media { width: 44px; height: 44px; }
/* imagem em si fica do mesmo tamanho do modo lista (ver .item__media img acima):
   não amplia o sprite, então não borra */

.items-list[data-view="grid"] .item__stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px 14px;
    align-self: center;
}
.items-list[data-view="grid"] .stat {
    /* Sem row+space-between: com nome+valor lado a lado, "8+44💀" (detalhe
       elemental) não cabia na metade da célula e vazava pra direita.
       Empilhado (rótulo em cima, valor embaixo) sempre cabe. */
    flex-direction: column;
    align-items: flex-start;
    min-width: 0;
    padding: 2px 6px;
}
.items-list[data-view="grid"] .stat dt,
.items-list[data-view="grid"] .stat dd { width: 100%; }
.items-list[data-view="grid"] .stat dd { text-align: left; }
.items-list[data-view="grid"] .stat dd small { display: block; margin-left: 0; }
.items-list[data-view="grid"] .stat--empty { display: none; }
.items-list[data-view="grid"] .stat--info { grid-column: 1 / -1; flex-direction: column; max-width: none; }
.items-list[data-view="grid"] .item__chips,
.items-list[data-view="grid"] .item__drops { margin-top: 0; }



/* ==========================================================================
   MOBILE
   ========================================================================== */
@media (max-width: 720px) {
    /* lista: números descem para uma linha abaixo do nome */
    .items-list[data-view="list"] .item__inner {
        grid-template-columns: 44px minmax(0, 1fr);
        grid-template-areas:
            "media head"
            "stats stats"
            "chips chips"
            "drops drops";
        row-gap: 4px;
    }
    .items-list[data-view="list"] .item__stats {
        flex-wrap: wrap;
        justify-content: flex-start;
        margin-top: 4px;
    }
    .items-list[data-view="list"] .stat { min-width: 60px; padding: 2px 4px; }
    .items-list[data-view="list"] .item__chips { margin-top: 2px; }
    .item__inner { padding: 6px 8px; }
}

@media (max-width: 640px) {
    .items-page { padding: 0 8px 48px; }

    .items-toolbar { top: calc(var(--items-sticky-top, 0px) + 4px + 90px); }
    .items-toolbar__inner { padding: 4px 6px; }

    /* linha 1: busca + lista/grid   |   linha 2: filtros + ordenação */
    .items-bar {
        display: grid;
        grid-template-columns: auto minmax(0, 1fr) auto;
        grid-template-areas:
            "search  search  view"
            "filters sort    sort";
        gap: 8px;
    }
    .items-search  { grid-area: search; }
    .items-view    { grid-area: view; }
    .ibtn--filters { grid-area: filters; }
    .items-sort    { grid-area: sort; }
    .items-sort select { flex: 1; min-width: 0; }

    .ibtn, .items-toolbar input[type="search"], .items-toolbar select { min-height: 44px; }
    .ibtn--icon { width: 44px; }

    .items-panel { max-height: 58vh; max-height: 58dvh; }
    .fchip span { min-height: 38px; }

    .items-list[data-view="grid"] { grid-template-columns: 1fr; gap: 10px; }
}

/* telas muito estreitas: o botão de filtros vira só ícone + contador */
@media (max-width: 380px) {
    .ibtn__label { display: none; }
}

@media (prefers-reduced-motion: reduce) {
    .items-page * { transition: none !important; }
}


/* ==========================================================================
   PÁGINA DE ITEM INDIVIDUAL (/items/<slug>)
   ========================================================================== */
.item-page .items-list { margin: 0 auto 32px; max-width: 560px; }

/* o card fica maior aqui (é o único item da página) */
.item-page .items-list[data-view="grid"] .item__media { width: 88px; height: 88px; border-radius: 14px; }
.item-page .items-list[data-view="grid"] .item__media img { width: 64px; height: 64px; }
.item-page .items-list[data-view="grid"] .item__inner { grid-template-columns: 88px minmax(0, 1fr); column-gap: 32px; }
/* só aqui: "Lvl: 220" lado a lado em vez de valor embaixo (lista/grid das categorias não mudam) */
.item-page .items-list[data-view="grid"] .stat { flex-direction: row; align-items: baseline; gap: 6px; }
.item-page .items-list[data-view="grid"] .stat dt { display: inline-flex; align-items: baseline; }
.item-page .items-list[data-view="grid"] .stat dt > span { margin-right: 4px; }
.item-page .items-list[data-view="grid"] .stat dt::after { content: ":"; }
.item-page .items-list[data-view="grid"] .stat dt,
.item-page .items-list[data-view="grid"] .stat dd { width: auto; }
.item-page .items-list[data-view="grid"] .stat dd small { display: inline; margin-left: 4px; }
.item-page .item__name { font-size: 22px; }
.item-page .item__inner { padding: 22px; row-gap: 14px; }
.item-page .item__stats { font-size: 15px; }
.item-page .item-look.tibiatext.tibiagreen { font-size: 9.5pt; }

.proficiency-wrap { max-width: 900px; margin: 28px auto 0; }
.proficiency-wrap h2 { margin: 0 0 10px; font-size: 15px; opacity: .75; font-weight: 600; text-align: center; }

/* -- tabela de proficiência: 1 coluna por nível (igual ao layout que você
      mandou), linhas alinhadas (a 1ª perk de cada nível fica na mesma altura,
      a 2ª também, etc. — quem faz isso é o Jinja no item_detail.html, que
      monta 1 <tr> por "posição" de perk, não 1 <tr> só). Fundo = card_blank +
      --card-color, igual aos outros cards. -- */
.proficiency-table-wrap { border-radius: 10px; }
.proficiency-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;   /* rolagem suave no iOS */
    max-width: 100%;
}
.proficiency-table-wrap > * { width: 100%; max-width: none; margin: 0; background: var(--card-color, var(--i-fill)) !important; }
.proficiency-table {
    width: 100%;
    min-width: 640px;
    border-collapse: collapse;
    font-size: 13px;
    table-layout: fixed;
}
.proficiency-table th,
.proficiency-table td {
    padding: 10px 8px;
    text-align: center;
    vertical-align: middle;
    border-bottom: 1px solid var(--i-border-strong, rgba(255, 255, 255, .18));
    border-right: 1px solid var(--i-border-strong, rgba(255, 255, 255, .18));
}
.proficiency-table th:last-child,
.proficiency-table td:last-child { border-right: 0; }
.proficiency-table tr:last-child td { border-bottom: 0; }
.proficiency-table th {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .04em;
    text-align: center;
    opacity: .7;
}
.proficiency-row-label {
    width: 90px;
    text-align: left !important;
    font-weight: 700;
    vertical-align: top;
}
.proficiency-cell { min-width: 96px; }
.proficiency-cell--empty { opacity: .35; }

.perk-list { display: flex; flex-direction: column; gap: 10px; }
.perk {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}
.perk-icon {
    /* --pf-box vem de PROFICIENCY_ICON_SCALE (items_service.py) — aumenta/
       diminui o ícone, a moldura e o badge juntos, proporcionalmente */
    position: relative;
    display: grid;
    place-items: center;
    width: var(--pf-box, 38px);
    height: var(--pf-box, 38px);
    font-size: 19px;
    border-radius: 6px;
    background: var(--i-fill, rgba(128, 128, 128, .13));
    border: 1px solid var(--i-border, rgba(128, 128, 128, .34));
    flex: none;
}
/* ícone real: base + moldura (Weapon_Proficiency_Border_Active) por cima de
   TODA imagem de proficiência + badge da roda (só perks ligados a 1 magia
   específica: crítico, cooldown, mana/life leech, dano de magia) no canto.

   A moldura NÃO é mais uma <img> separada — virou um ::after com
   background-size:100% 100%, sempre do MESMO tamanho de .perk-icon (a mesma
   caixa que já cresce certinho com --pf-box). Antes, como eram dois elementos
   de tamanho calculado em separado, bastava uma regra de CSS antiga/conflitante
   pra moldura ficar "presa" no tamanho velho enquanto o ícone crescia. Agora
   é fisicamente impossível dessincronizar: é a largura/altura de UM elemento só. */
.perk-icon--img { background: none !important; border: 0 !important; overflow: visible !important; }
.perk-icon--img img {
    /* reset forte: zera qualquer "img { max-width:100%; height:auto }" ou
       parecido que o resto do seu site possa ter. NUNCA declarar width/height
       aqui (nem "auto") — isso faria o navegador ignorar os atributos
       width/height do HTML (que vêm de PROFICIENCY_BOX_SIZE/icon_size no
       Python e são a fonte real do tamanho de cada camada). */
    position: absolute !important;
    max-width: none !important;
    max-height: none !important;
    object-fit: fill !important;   /* 'none' NÃO escala a imagem (só recorta no tamanho nativo) — era o bug do PROFICIENCY_ICON_SCALE */
    image-rendering: pixelated !important;
    image-rendering: crisp-edges !important;
}
.perk-icon__base {
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
    z-index: 1 !important;
}
.perk-icon__border {
    top: 0 !important;
    left: 0 !important;
    transform: none !important;
    z-index: 2 !important;
    pointer-events: none !important;
}
.perk-icon__badge {
    /* o CENTRO do badge fica exatamente em cima do canto superior direito da
       caixa, não importa o tamanho dele (translate 50%/-50% do próprio badge) */
    top: 0 !important;
    right: 0 !important;
    left: auto !important;
    transform: translate(50%, -50%) !important;
    z-index: 3 !important;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, .6));
}
.perk-text { position: relative; z-index: 0; margin-top: 2px; font-size: 11.5px; line-height: 1.3; opacity: .9; text-align: center; }

/* -- hover dos cards de item: cor/sombra/tamanho vêm do seu tema -- */
.item { position: relative; transition: transform .15s ease, box-shadow .15s ease; }
.items-page:not(.item-page) .item:hover { transform: scale(1.08); z-index: 5; }
.items-page:not(.item-page) .item:hover > * {
    background: var(--card-hover-highlight, var(--card-color, var(--i-fill))) !important;
    box-shadow: var(--card-hover-shadow, 0 10px 28px rgba(0, 0, 0, .35));
}

@media (max-width: 640px) {
    .item-page .items-list[data-view="grid"] .item__media { width: 64px; height: 64px; border-radius: 12px; }
    .item-page .items-list[data-view="grid"] .item__media img { width: 48px; height: 48px; }
    .item-page .items-list[data-view="grid"] .item__inner { grid-template-columns: 64px minmax(0, 1fr); column-gap: 18px; }
    .item-page .item__name { font-size: 19px; }
    .item-page .item__inner { padding: 16px; }
    .proficiency-cell { min-width: 84px; }
}


/* Tema claro: divisórias da tabela de proficiência ficam escuras (o padrão
   claro/branco ficava invisível em fundo claro). Cobre os seletores mais
   comuns de toggle de tema — ajuste o seletor se o seu for diferente. */
@media (prefers-color-scheme: light) {
    .proficiency-table th,
    .proficiency-table td { border-color: rgba(0, 0, 0, .18); }
}
.light .proficiency-table th, .light .proficiency-table td,
[data-theme="light"] .proficiency-table th, [data-theme="light"] .proficiency-table td,
.theme-light .proficiency-table th, .theme-light .proficiency-table td {
    border-color: rgba(0, 0, 0, .18);
}

@media (max-width: 640px) {
    .items-toolbar { position: static; }
}

/* item_detail: respiro entre as seções do card */
.item-page .item__stats { margin-bottom: 10px; }
.item-page .item__chips { margin-bottom: 8px; }

/* chips centralizados horizontalmente (linha própria, não junto do dropped by) */
.item-page .item__chips { justify-content: center; }

/* "Dropado por" numa linha própria, a lista de criaturas em OUTRA linha embaixo
   — as duas centralizadas, mas não mais juntas na mesma linha */
.item-page .item__drops--open {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}
.item-page .item__drops--open .item__drops-label { margin: 0; justify-content: center; }
.item-page .item__drops--open .item__drops-list { margin-top: 0; justify-content: center; }

/* atk composto ("8+44") maior, só no item_detail */
.item-page .stat dd small { font-size: 13px; }

/* fundo quadrado atrás da imagem do item (88px — a imagem em si continua 64px, centralizada) */
.item-page .items-list[data-view="grid"] .item__media {
    background: var(--i-fill, rgba(128, 128, 128, .13));
}




/* Remove os controles nativos do input type="search" */
.items-toolbar .items-search input[type="search"]::-webkit-search-cancel-button,
.items-toolbar .items-search input[type="search"]::-webkit-search-decoration,
.items-toolbar .items-search input[type="search"]::-webkit-search-results-button,
.items-toolbar .items-search input[type="search"]::-webkit-search-results-decoration {
    -webkit-appearance: none !important;
    appearance: none !important;
    display: none !important;
}



.items-search { position: relative; }

.items-toolbar .items-search input[type="search"] { padding-right: 38px; }

.items-clear {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 28px;
    height: 28px;
    display: grid;
    place-items: center;
    padding: 0;
    font-size: 16px;
    color: inherit;
    background: none;
    border: 0;
    border-radius: 50%;
    opacity: .7;
    cursor: pointer;
}
.items-clear:hover { opacity: 1; background: var(--i-border); }
.items-clear[hidden] { display: none; }