/* ==========================================================================
   Compendium (fenêtre flottante)
   ========================================================================== */
.compendium-window { background: #111215; border: 1px solid var(--line-2); overflow: hidden; }
.compendium-window .float-body { overflow: hidden; }
.compendium { height: 100%; display: grid; grid-template-rows: auto auto minmax(0, 1fr); font-family: var(--font-ui); color: var(--text); }
.comp-head { display: flex; align-items: center; gap: 12px; padding: 14px 16px 10px; cursor: move; border-bottom: 1px solid var(--line); }
.comp-head > div { flex: 1; }
.comp-mark { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: rgba(139, 108, 239, .16); color: var(--violet-2); border: 1px solid rgba(139, 108, 239, .4); }
.comp-head h2 { margin: 0; font: 700 17px var(--font-display); }
.comp-head p { margin: 2px 0 0; font: 500 11px var(--font-mono); color: var(--text-3); }
.comp-tabs { display: flex; gap: 2px; padding: 6px 10px; overflow-x: auto; scrollbar-width: none; border-bottom: 1px solid var(--line); background: #0e0f12; }
.comp-tabs::-webkit-scrollbar { display: none; }
.comp-tabs button { flex: 0 0 auto; display: flex; align-items: center; gap: 5px; height: 32px; padding: 0 9px; border-radius: 8px; border: 0; background: transparent; color: var(--text-3); font: 600 12.5px var(--font-ui); }
.comp-tabs button:hover { color: var(--text); background: var(--ink-2); }
.comp-tabs button.active { color: var(--text); background: var(--ink-3); box-shadow: inset 0 -2px 0 var(--violet); }
.comp-body { display: grid; grid-template-columns: 330px minmax(0, 1fr); min-height: 0; }
.comp-list-col { display: grid; grid-template-rows: auto minmax(0, 1fr); border-right: 1px solid var(--line); min-height: 0; }
.comp-tools { display: grid; gap: 8px; padding: 10px; border-bottom: 1px solid var(--line); }
.comp-search { display: flex; align-items: center; gap: 8px; height: 34px; padding: 0 10px; border-radius: 9px; border: 1px solid var(--line-2); background: var(--ink-1); color: var(--text-3); }
.comp-search input { flex: 1; min-width: 0; border: 0; background: transparent; color: var(--text); outline: none; font: 400 13px var(--font-ui); }
.comp-filters { display: flex; flex-wrap: wrap; gap: 6px; }
.comp-filters select { flex: 1 1 90px; height: 30px; border-radius: 8px; border: 1px solid var(--line-2); background: var(--ink-1); color: var(--text-2); padding: 0 6px; font-size: 12px; }
.comp-hb-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.comp-list { overflow-y: auto; padding: 4px 6px 12px; }
.comp-count { font: 500 10.5px var(--font-mono); color: var(--text-4); padding: 6px 8px 4px; }
.comp-row { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 1px 8px; width: 100%; text-align: left; padding: 7px 10px; border: 0; border-radius: 9px; background: transparent; color: var(--text); }
.comp-row:hover { background: var(--ink-2); }
.comp-row.active { background: rgba(139, 108, 239, .14); }
.comp-row[style]::before { content: ""; position: absolute; left: 0; top: 8px; bottom: 8px; width: 3px; border-radius: 3px; background: var(--hue); }
.comp-row .t { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.comp-row .s { grid-column: 1 / -1; font-size: 11.5px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.comp-row .tag { font: 600 9.5px var(--font-mono); color: var(--text-3); border: 1px solid var(--line-2); border-radius: 5px; padding: 1px 5px; align-self: center; }
.comp-row .tag.hb { color: var(--violet-2); border-color: rgba(139, 108, 239, .45); }
.comp-detail { overflow-y: auto; padding: 18px 22px 30px; min-height: 0; }
.comp-back { display: none; }
.comp-detail h3 { margin: 0; font: 700 22px/1.15 var(--font-display); }
.comp-detail h3 .badge { vertical-align: middle; }
.comp-sub { margin: 4px 0 12px; color: var(--text-3); font-size: 13px; font-style: italic; }
.comp-facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 6px 14px; margin: 0 0 12px; padding: 12px 14px; border-radius: 12px; background: var(--ink-2); border: 1px solid var(--line); }
.comp-facts div { min-width: 0; }
.comp-facts dt { font: 600 10px var(--font-ui); letter-spacing: .1em; text-transform: uppercase; color: var(--text-3); }
.comp-facts dd { margin: 2px 0 0; font-size: 13px; color: var(--text); }
.comp-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 14px; }
.comp-add { display: flex; gap: 6px; }
.comp-add select { height: 30px; border-radius: 8px; border: 1px solid var(--line-2); background: var(--ink-1); color: var(--text); padding: 0 8px; }
.comp-text { color: var(--text-2); font-size: 13.5px; line-height: 1.6; }
.comp-text p { margin: 0 0 8px; }
.comp-text p.li { padding-left: 16px; position: relative; }
.comp-text p.li::before { content: ""; position: absolute; left: 4px; top: .7em; width: 5px; height: 5px; border-radius: 50%; background: var(--violet-2); }
.comp-text h3, .comp-text h4, .comp-text h5 { margin: 16px 0 6px; font: 700 15px var(--font-display); color: var(--text); }
.comp-text h4 .lvl, .comp-text summary .lvl { display: inline-grid; place-items: center; min-width: 24px; height: 20px; margin-right: 6px; border-radius: 6px; background: var(--ink-3); color: var(--violet-2); font: 600 10.5px var(--font-mono); }
.comp-text table, .comp-table { width: 100%; border-collapse: collapse; margin: 8px 0 12px; font-size: 12.5px; }
.comp-text th, .comp-text td, .comp-table th, .comp-table td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.comp-text th, .comp-table th { font: 600 10.5px var(--font-ui); letter-spacing: .08em; text-transform: uppercase; color: var(--text-3); }
.comp-table td:first-child { font-family: var(--font-mono); color: var(--violet-2); }
.comp-table-wrap { overflow-x: auto; margin-bottom: 8px; }
.comp-text details { border-radius: 10px; border: 1px solid var(--line); background: var(--ink-1); margin-bottom: 4px; }
.comp-text details summary { cursor: pointer; padding: 8px 10px; font-weight: 600; color: var(--text); list-style: none; }
.comp-text details summary::-webkit-details-marker { display: none; }
.comp-text details > p { padding: 0 12px; }
.comp-text.monster h4 { padding-bottom: 4px; border-bottom: 1px solid rgba(139, 108, 239, .35); color: var(--violet-2); }
.comp-statline { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-bottom: 10px; }
.comp-statline div { display: grid; padding: 9px 10px; border-radius: 11px; background: var(--ink-2); border: 1px solid var(--line); }
.comp-statline b { font: 700 17px var(--font-display); }
.comp-statline span { font-size: 11px; color: var(--text-3); }
.comp-abil { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; margin-bottom: 10px; }
.comp-abil div { display: grid; justify-items: center; padding: 7px 4px; border-radius: 10px; background: var(--ink-1); border: 1px solid var(--line); }
.comp-abil span { font: 600 10px var(--font-mono); color: var(--text-3); }
.comp-abil b { font: 700 17px var(--font-display); }
.comp-abil em { font: 600 11px var(--font-mono); font-style: normal; color: var(--violet-2); }
.comp-empty { display: grid; place-content: center; justify-items: center; gap: 8px; padding: 30px 16px; color: var(--text-4); text-align: center; }
.comp-empty.big { height: 100%; }
.comp-empty svg { width: 28px; height: 28px; }
.comp-empty small { max-width: 420px; font-size: 11px; }

/* Formulaires de contenu maison */
.hb-kinds { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px; }
.hb-kinds button { display: grid; gap: 3px; text-align: left; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line-2); background: var(--ink-2); color: var(--text); }
.hb-kinds button:hover { border-color: var(--violet); }
.hb-kinds b { font: 700 14px var(--font-display); }
.hb-kinds span { font-size: 12px; color: var(--text-3); }
.hb-form { max-height: min(62vh, 640px); overflow-y: auto; padding-right: 4px; }
.hb-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.hb-field { display: grid; gap: 6px; align-content: start; }
.hb-field.wide { grid-column: 1 / -1; }
.hb-field > span { font: 600 10.5px var(--font-ui); letter-spacing: .1em; text-transform: uppercase; color: var(--text-3); }
.hb-field input, .hb-field select, .hb-field textarea, .hb-row input, .hb-row textarea { width: 100%; height: 36px; border-radius: 9px; border: 1px solid var(--line-2); background: var(--ink-1); color: var(--text); padding: 0 10px; font: 400 13px var(--font-ui); }
.hb-field textarea, .hb-row textarea { height: auto; padding: 8px 10px; resize: vertical; line-height: 1.45; }
.hb-field input[type=checkbox], .hb-checks input { width: auto; height: auto; accent-color: var(--violet); }
.hb-checks { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12.5px; color: var(--text-2); }
.hb-checks label { display: flex; align-items: center; gap: 6px; }
.hb-bonus { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.hb-bonus label { display: grid; gap: 4px; font: 600 10.5px var(--font-mono); color: var(--text-3); text-align: center; }
.hb-rows { display: grid; gap: 8px; }
.hb-row { display: grid; grid-template-columns: 64px minmax(0, 1fr) 30px; grid-template-areas: "lvl name del" "desc desc desc"; gap: 6px; padding: 8px; border-radius: 10px; border: 1px solid var(--line); background: var(--ink-2); }
.hb-row:not(:has([data-rf="level"])) { grid-template-columns: minmax(0, 1fr) 30px; grid-template-areas: "name del" "desc desc"; }
.hb-row [data-rf="level"] { grid-area: lvl; }
.hb-row [data-rf="name"] { grid-area: name; }
.hb-row [data-rf="desc"] { grid-area: desc; }
.hb-row .icon-btn { grid-area: del; }
.hb-rows > .btn { justify-self: start; }

@media (max-width: 860px) {
  .comp-body { grid-template-columns: minmax(0, 1fr); }
  .comp-detail { display: none; }
  .compendium.show-detail .comp-list-col { display: none; }
  .compendium.show-detail .comp-detail { display: block; }
  .comp-back { display: inline-flex; align-items: center; gap: 4px; height: 30px; padding: 0 10px; margin-bottom: 10px; border-radius: 8px; border: 1px solid var(--line-2); background: var(--ink-2); color: var(--text-2); font-size: 12px; }
  .hb-grid { grid-template-columns: 1fr; }
  .comp-statline { grid-template-columns: repeat(2, 1fr); }
  .comp-abil { grid-template-columns: repeat(3, 1fr); }
}

.comp-row .srcs { display: flex; gap: 3px; align-self: center; }
.comp-en { margin: -6px 0 6px; font-size: 12px; color: var(--text-3); font-style: italic; }
.comp-text details.comp-sub-block { border: 1px solid var(--line-2); border-radius: 10px; padding: 4px 10px; margin: 6px 0; }
.comp-text details.comp-sub-block > summary { font-weight: 600; cursor: pointer; padding: 4px 0; }
.comp-text details.comp-sub-block[open] > summary { margin-bottom: 4px; }
