/* Codex (codex-ui.js) : onglets Donjons / Temples / Zones (+ raccourci Bestiaire), liste filtrable à gauche, fiche à droite ;
   sur téléphone, une vue à la fois (comme le Bestiaire). */
#codex-dialog{padding:0;border:0;background:transparent;max-width:none;max-height:none;overflow:visible}
#codex-dialog::backdrop{background:#0d0a0599;backdrop-filter:blur(2px)}:where(html[data-theme="nuit"]) #codex-dialog::backdrop{background:#06080c99}
#codex-dialog .cx-window{width:min(1020px,calc(100vw - 24px));height:min(700px,calc(100dvh - 24px));overflow:hidden}
#codex-dialog header .cx-count{font:700 11.5px var(--font-ui,sans-serif);opacity:.75;margin-right:6px;white-space:nowrap}
#codex-dialog .cx-tabs{display:flex;gap:4px;padding:7px 10px 0;background:linear-gradient(#00000014,#0000);border-bottom:2px solid #c9a35a;overflow-x:auto;scrollbar-width:none}
#codex-dialog .cx-tabs::-webkit-scrollbar{display:none}
#codex-dialog .cx-tabs button{flex:none;display:flex;align-items:center;gap:6px;min-height:34px;padding:0 12px 0 8px;border:1px solid #c9a35a;border-bottom:0;border-radius:9px 9px 0 0;background:#efe5c4;color:#4a3a1c;font:800 12.5px var(--font-ui,sans-serif);cursor:pointer;position:relative;top:2px}
#codex-dialog .cx-tabs button img{width:20px;height:20px;object-fit:contain}
#codex-dialog .cx-tabs button small{min-width:18px;padding:0 5px;border-radius:999px;background:#0000001a;font:800 10.5px/16px var(--font-ui,sans-serif);text-align:center}
#codex-dialog .cx-tabs button small:empty{display:none}
#codex-dialog .cx-tabs button i{font-style:normal;opacity:.6;font-size:11px}
#codex-dialog .cx-tabs button:hover{background:#fff3d6}
#codex-dialog .cx-tabs button[aria-selected=true]{background:var(--window-paper,#ddd6b4);border-color:var(--qa-orange,#e8780c);box-shadow:inset 0 3px 0 var(--qa-orange,#e8780c);color:#2f2a1e;z-index:1}
#codex-dialog .cx-tabs button[aria-selected=true] small{background:var(--qa-orange,#e8780c);color:#fff}
#codex-dialog .cx-body{flex:1;min-height:0;display:grid;grid-template-columns:310px 1fr}
#codex-dialog .cx-side{display:flex;flex-direction:column;min-height:0;border-right:1px solid #0002;background:#0000000a}
#codex-dialog .cx-filters{display:grid;gap:6px;padding:10px;border-bottom:1px solid #0002}
#codex-dialog .cx-search,#codex-dialog .cx-region{width:100%;min-height:34px;padding:0 10px;border:1px solid #9c916f;border-radius:8px;background:#fffaf0;color:#2f2a1e;font:600 13px var(--font-ui,sans-serif);box-sizing:border-box}
#codex-dialog .cx-search:focus,#codex-dialog .cx-region:focus{outline:2px solid var(--qa-orange,#e8780c);outline-offset:0}
#codex-dialog [hidden]{display:none!important}
#codex-dialog .cx-levels{display:flex;gap:3px;padding:3px;border-radius:9px;background:#00000014}
#codex-dialog .cx-levels button{flex:1;min-height:26px;padding:0 4px;border:0;border-radius:7px;background:transparent;color:inherit;font:800 11px var(--font-ui,sans-serif);cursor:pointer;white-space:nowrap}
#codex-dialog .cx-levels button[aria-pressed=true]{background:var(--qa-orange,#e8780c);color:#fff;box-shadow:0 1px 3px #0004}
#codex-dialog .cx-list{flex:1;min-height:0;overflow:auto;list-style:none;margin:0;padding:6px;display:grid;align-content:start;gap:3px}
#codex-dialog .cx-list button{width:100%;display:grid;grid-template-columns:44px 1fr auto;gap:8px;align-items:center;padding:4px 8px 4px 4px;border:1px solid transparent;border-radius:9px;background:transparent;color:inherit;text-align:left;cursor:pointer}
#codex-dialog .cx-list button:hover{background:#fff7e0aa;border-color:#c9b98a}
#codex-dialog .cx-list button[aria-pressed=true]{background:#fff3d6;border-color:var(--qa-orange,#e8780c);box-shadow:inset 3px 0 0 var(--qa-orange,#e8780c)}
#codex-dialog .cx-list button.is-city{background:linear-gradient(90deg,#e9dcff66,#0000)}
#codex-dialog .cx-list img{width:44px;height:44px;object-fit:contain;border-radius:8px;background:radial-gradient(circle at 50% 60%,#fff8,#0000 70%)}
#codex-dialog .cx-list span{min-width:0}
#codex-dialog .cx-list b{display:block;font:800 13px var(--font-ui,sans-serif);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
#codex-dialog .cx-list small{display:block;font-size:11.5px;color:#6d6248;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
#codex-dialog .cx-done{font-style:normal;font-weight:900;color:#fff;background:#3f8a2a;border-radius:999px;width:20px;height:20px;display:grid;place-items:center;font-size:12px}
#codex-dialog .cx-mine{font-style:normal;font-weight:900;color:#c48a14}
#codex-dialog .cx-zaap{font-style:normal;font-weight:800;color:#2d6fa8}
#codex-dialog .cx-empty{padding:18px;text-align:center;color:#6d6248}
#codex-dialog .cx-empty button{margin-top:8px;min-height:30px;padding:0 12px;border:1px solid #6e3a05;border-radius:8px;background:var(--qa-orange,#e8780c);color:#fff;font-weight:800;cursor:pointer}
#codex-dialog .cx-detail{min-height:0;overflow:auto;padding:14px 16px 18px}
#codex-dialog .cx-placeholder{height:100%;display:grid;place-content:center;justify-items:center;gap:10px;text-align:center;color:#6d6248;padding:0 20px}
#codex-dialog .cx-placeholder img{width:56px;opacity:.45}
#codex-dialog .cx-back{display:none}
#codex-dialog .cx-hero{display:grid;grid-template-columns:112px 1fr;gap:14px;align-items:center;padding:12px;border-radius:14px;background:radial-gradient(ellipse at 20% 40%,#6b3a2a,#26140f);color:#f3ecd2;box-shadow:inset 0 0 0 1px #ffffff1f,0 4px 14px #0003}:where(html[data-theme="nuit"]) #codex-dialog .cx-hero{background:radial-gradient(ellipse at 20% 40%,#334462,#121823)}
#codex-dialog .cx-hero.cx-temple{background:radial-gradient(ellipse at 20% 40%,#3a4f7a,#121a2c)}
#codex-dialog .cx-hero.cx-zone{background:radial-gradient(ellipse at 20% 40%,#4d6b3a,#1b2614)}
#codex-dialog .cx-hero.cx-zone.is-city{background:radial-gradient(ellipse at 20% 40%,#5a3f7a,#1e1430)}
#codex-dialog .cx-portrait{width:112px;height:112px;display:grid;place-items:center;border-radius:50%;background:radial-gradient(circle at 50% 62%,#f4e9c4 0,#c9b98a 55%,#7d6a3f 100%);box-shadow:inset 0 2px 8px #0006,0 0 0 3px #d9b45a;overflow:hidden}
#codex-dialog .cx-portrait img{width:96px;height:96px;object-fit:contain;filter:drop-shadow(0 3px 3px #0006)}
#codex-dialog .cx-hero h3{margin:0;font:800 22px/1.1 var(--font-title,var(--font-ui,serif));color:#ffe9b0;text-shadow:0 2px 0 #0007}
#codex-dialog .cx-hero p{margin:4px 0 0;font-size:12.5px;opacity:.92}
#codex-dialog .cx-where b{color:#ffe9b0}
#codex-dialog .cx-where span{font-weight:800;color:#ffd08a}
#codex-dialog .cx-warn{font-style:normal;font-weight:800;color:#ffb39a}
#codex-dialog .cx-hero .cx-mine{color:#ffd76a}
#codex-dialog .cx-actions{display:flex;flex-wrap:wrap;gap:6px;margin-top:8px}
#codex-dialog .cx-map{min-height:30px;padding:0 12px;border:1px solid #6e3a05;border-radius:999px;background:var(--qa-orange,#e8780c);color:#fff;font:800 12px var(--font-ui,sans-serif);cursor:pointer;box-shadow:0 1px 3px #0004;white-space:nowrap}
#codex-dialog .cx-map{display:inline-flex;align-items:center;gap:6px}
#codex-dialog .cx-map img{position:static!important;flex:none;width:18px!important;height:18px!important;min-width:0!important;margin:0!important;padding:0!important;border:0!important;background:none!important;box-shadow:none!important;transform:none!important;object-fit:contain;filter:drop-shadow(0 1px 0 #0006)}
#codex-dialog .cx-map.is-icon{width:34px;min-width:34px;padding:0;justify-content:center}
#codex-dialog .cx-map:hover{filter:brightness(1.08)}
#codex-dialog .cx-desc{margin:12px 2px 0;font-size:13px;line-height:1.45}
#codex-dialog .cx-status{margin:8px 0 0;padding:6px 10px;border-radius:9px;background:#fffaf0;border:1px solid #e0d3a8;font:700 12.5px var(--font-ui,sans-serif);color:#5a4a2a}
#codex-dialog .cx-status.is-done{background:#e9f6e4;border-color:#8fc27a;color:#2f6a1e}
#codex-dialog .cx-status.is-muted{color:#7d7262;font-weight:600}
#codex-dialog .cx-record{margin:6px 0 0;font-size:12.5px;color:#5a4a2a}
#codex-dialog .cx-block{margin-top:14px}
#codex-dialog .cx-block h4{display:flex;align-items:center;gap:8px;margin:0 0 7px;font:800 12px var(--font-ui,sans-serif);letter-spacing:.06em;text-transform:uppercase;color:#7a5520}
#codex-dialog .cx-block h4 small{text-transform:none;letter-spacing:0;font-weight:600;color:#6d6248}
#codex-dialog .cx-muted{margin:0;color:#6d6248;font-size:12.5px}
#codex-dialog .cx-chips,#codex-dialog .cx-svc{list-style:none;margin:0;padding:0;display:grid;grid-template-columns:repeat(auto-fill,minmax(190px,1fr));gap:5px}
#codex-dialog .cx-chips li,#codex-dialog .cx-svc li{display:grid;grid-template-columns:34px 1fr;align-items:center;gap:7px;min-width:0;padding:4px 9px 4px 4px;border-radius:9px;background:#fffaf0;border:1px solid #e0d3a8}
#codex-dialog .cx-svc li{grid-template-columns:30px 1fr auto}
#codex-dialog .cx-chips img,#codex-dialog .cx-svc img{width:34px;height:34px;object-fit:contain}
#codex-dialog .cx-svc img{width:28px;height:28px}
#codex-dialog .cx-chips li>span,#codex-dialog .cx-svc li>span{min-width:0;font-size:12.5px;font-weight:700;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
#codex-dialog .cx-chips small,#codex-dialog .cx-svc small{display:block;font-size:11px;font-weight:600;color:#7d7262;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
#codex-dialog .cx-svc b{font-size:12.5px}
#codex-dialog .cx-svc .cx-map{min-height:30px}
#codex-dialog .cx-noicon{width:30px;height:30px;border-radius:6px;background:#e9dfc0}
#codex-dialog .cx-chips.cx-boss li{border-color:#d99886;background:#fbeee9}
#codex-dialog .cx-chips.cx-loot li{border-left:3px solid #8a3fc4}
#codex-dialog .cx-chips.cx-res li{border-left:3px solid #6b9a30}
#codex-dialog .cx-chips.cx-parts li{grid-template-columns:1fr;padding-left:10px;border-left:3px solid #8a3fc4}
#codex-dialog [data-cx-mon],#codex-dialog [data-cx-goto]{cursor:pointer;transition:background .12s,box-shadow .12s}
#codex-dialog [data-cx-mon]:hover,#codex-dialog [data-cx-goto]:hover,#codex-dialog [data-cx-mon]:focus-visible,#codex-dialog [data-cx-goto]:focus-visible{background:#fff3d6;box-shadow:0 0 0 1px var(--qa-orange,#e8780c);outline:none}
#codex-dialog .cx-rooms{list-style:none;margin:0;padding:0;display:grid;gap:4px;counter-reset:room}
#codex-dialog .cx-rooms li{display:grid;grid-template-columns:26px minmax(0,1fr) auto;align-items:center;gap:8px;padding:4px 8px;border-radius:9px;background:#fffaf0;border:1px solid #e0d3a8;counter-increment:room}
#codex-dialog .cx-rooms li::before{content:counter(room);display:grid;place-items:center;width:24px;height:24px;border-radius:50%;background:#7a5520;color:#fff;font:800 11.5px var(--font-ui,sans-serif)}:where(html[data-theme="nuit"]) #codex-dialog .cx-rooms li::before{background:#324668}
#codex-dialog .cx-rooms li.is-boss{border-color:#d99886;background:#fbeee9}
#codex-dialog .cx-rooms li.is-boss::before{background:#a3250f}
#codex-dialog .cx-rooms b{font-size:12.5px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
#codex-dialog .cx-rooms span{display:flex;align-items:center;gap:1px}
#codex-dialog .cx-rooms span img{width:28px;height:28px;object-fit:contain}
#codex-dialog .cx-rooms span small{font-size:10.5px;font-weight:700;color:#7d7262;margin-left:4px;white-space:nowrap}
#codex-dialog .cx-npcs{list-style:none;margin:0;padding:0;display:grid;gap:6px}
#codex-dialog .cx-npcs>li{display:grid;grid-template-columns:42px 1fr;gap:10px;align-items:start;padding:8px 10px;border-radius:10px;background:#fffaf0;border:1px solid #e0d3a8}
#codex-dialog .cx-npcs>li>img{width:42px;height:42px;object-fit:contain}
#codex-dialog .cx-npcs b{font-size:13.5px}
#codex-dialog .cx-npcs small{display:block;font-size:11.5px;color:#7d7262}
#codex-dialog .cx-npcs p{margin:5px 0 0;font-size:12.5px;line-height:1.4}
#codex-dialog .cx-prov{display:flex;flex-wrap:wrap;gap:4px}
#codex-dialog .cx-prov span{display:inline-flex;align-items:center;gap:4px;padding:2px 8px 2px 3px;border-radius:999px;background:#efe5c4;font-weight:700;font-size:12px}
#codex-dialog .cx-prov img{width:24px;height:24px;object-fit:contain}
#codex-dialog .cx-npcs .cx-status{display:inline-block}
@media (max-width:700px){
 #codex-dialog .cx-window{width:100vw;height:100dvh;border-radius:0}
 #codex-dialog .cx-tabs{padding:6px 6px 0;gap:3px}
 #codex-dialog .cx-tabs button{flex:1 1 0;justify-content:center;min-width:0;padding:0 6px;gap:4px;font-size:12px}
 #codex-dialog .cx-tabs button img{width:18px;height:18px}
 #codex-dialog .cx-tabs button small,#codex-dialog .cx-tabs button i{display:none}
 #codex-dialog .cx-body{grid-template-columns:1fr}
 #codex-dialog .cx-side{border-right:0}
 #codex-dialog .cx-detail{display:none;padding:10px 10px 16px}
 #codex-dialog.show-detail .cx-side{display:none}
 #codex-dialog.show-detail .cx-detail{display:block}
 #codex-dialog .cx-back{display:inline-flex;margin:0 0 8px;min-height:32px;padding:0 12px;border:1px solid #9c916f;border-radius:8px;background:#fffaf0;color:#2f2a1e;font:800 12.5px var(--font-ui,sans-serif);cursor:pointer;align-items:center}
 #codex-dialog .cx-hero{grid-template-columns:76px 1fr;gap:10px;padding:10px}
 #codex-dialog .cx-portrait{width:76px;height:76px}#codex-dialog .cx-portrait img{width:64px;height:64px}
 #codex-dialog .cx-hero h3{font-size:18px}
 #codex-dialog .cx-chips,#codex-dialog .cx-svc{grid-template-columns:repeat(auto-fill,minmax(150px,1fr))}
 #codex-dialog .cx-svc{grid-template-columns:1fr}
 #codex-dialog header .cx-count{display:none}
}
