:root {
    color-scheme: dark;
    --bg: #101613;
    --panel: #171e1a;
    --panel-light: #202923;
    --line: #344039;
    --line-soft: #29332d;
    --text: #ece9df;
    --muted: #9ca89f;
    --gold: #d1b46a;
    --gold-dark: #8f7741;
    --green: #617e66;
    --danger: #b36b60;
    --shadow: 0 18px 60px #0008;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font-size: 13px; overflow: hidden; }
button, input, select, textarea { font: inherit; }
button { color: inherit; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
button:disabled { opacity: .4; cursor: not-allowed; }
[hidden] { display: none !important; }
.app-shell { height: 100vh; display: flex; flex-direction: column; }
.topbar { position: relative; height: 70px; flex: 0 0 70px; display: flex; align-items: center; justify-content: space-between; padding: 0 22px; background: #151c18; border-bottom: 1px solid var(--line); z-index: 5; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark, .empty-mark { width: 38px; height: 42px; display: grid; place-items: center; border: 1px solid var(--gold-dark); color: var(--gold); font-family: Georgia, serif; font-size: 13px; letter-spacing: 1px; clip-path: polygon(50% 0, 100% 15%, 100% 80%, 50% 100%, 0 80%, 0 15%); background: #d1b46a0b; }
.brand strong { display: block; font-family: Georgia, serif; letter-spacing: 2px; font-size: 15px; font-weight: 500; }
.brand span:last-child { display: block; color: var(--muted); font-size: 10px; letter-spacing: 1.5px; text-transform: uppercase; margin-top: 3px; }
.topbar-actions { display: flex; gap: 7px; }
.button { border: 1px solid var(--line); border-radius: 4px; background: transparent; padding: 9px 13px; cursor: pointer; font-weight: 600; font-size: 12px; transition: background .15s, border-color .15s; }
.button:hover { background: #ffffff09; border-color: #637168; }
.button.primary { background: var(--gold); border-color: var(--gold); color: #1c211c; }
.button.primary:hover { background: #dfc581; }
.button.secondary { background: #28332c; border-color: #3c4a41; }
.button.ghost { color: #c2cbc4; }
.button.danger { color: #e8b0a7; border-color: #784b44; background: #5d332e22; }
.full-width { width: 100%; }
.workspace { flex: 1; min-height: 0; display: grid; grid-template-columns: 270px minmax(360px, 1fr) 300px; }
.panel { min-height: 0; background: var(--panel); padding: 18px 15px; display: flex; flex-direction: column; }
.tile-panel { border-right: 1px solid var(--line); }
.inspector-panel { border-left: 1px solid var(--line); overflow-y: auto; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 17px; }
.panel-actions { display: flex; gap: 6px; }
.panel-heading h2, .map-heading h1, .dialog-header h2 { font-family: Georgia, serif; font-weight: 400; margin: 2px 0 0; }
.panel-heading h2 { font-size: 22px; }
.eyebrow { color: var(--gold); font-size: 9px; letter-spacing: 1.8px; font-weight: 700; }
.icon-button { border: 1px solid var(--line); border-radius: 4px; background: transparent; width: 32px; height: 32px; cursor: pointer; font-size: 19px; }
.search-box { position: relative; }
.search-box span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
input, select, textarea { width: 100%; color: var(--text); background: #111713; border: 1px solid var(--line); border-radius: 4px; padding: 9px 10px; min-width: 0; }
input[type="color"] { height: 40px; padding: 3px; }
input[type="checkbox"] { width: auto; accent-color: var(--gold); }
textarea { resize: vertical; }
.palette-meta { display: flex; justify-content: space-between; color: var(--muted); font-size: 10px; padding: 11px 2px; }
.palette-filters { display: flex; flex-wrap: wrap; gap: 5px; padding: 4px 0 2px; }
/* Onglets de la bibliothèque (Tuiles / Éléments) : l'onglet actif décide du comportement
   des clics sur la carte (pose de tuiles vs pose/sélection du décor). */
.palette-tabs { display: flex; border-bottom: 1px solid var(--line); margin: 0 0 12px; }
.palette-tabs .tab { flex: 1; text-align: center; }
#palette-tiles, #palette-decor { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.filter-chip { border: 1px solid var(--line-soft); background: #111713; color: #b9c2bb; border-radius: 999px; padding: 3px 9px; font-size: 10px; cursor: pointer; transition: border .12s, color .12s; }
.filter-chip:hover { border-color: #758376; }
.filter-chip.active { border-color: var(--gold); color: var(--gold); box-shadow: 0 0 0 1px var(--gold); }
.tile-list { min-height: 0; overflow-y: auto; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; align-content: start; padding: 2px 3px 12px; flex: 1; }
/* Palette du calque décoratif (assets/Imgs) : miniatures de l'onglet « Éléments » ;
   le conteneur occupe la hauteur disponible de l'onglet. */
.decor-palette { display: flex; flex-direction: column; min-height: 0; }
.decor-list { flex: 1; min-height: 0; overflow-y: auto; display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; align-content: start; padding: 2px 3px 8px; }
.decor-card { position: relative; border: 1px solid var(--line-soft); background: #111713; border-radius: 5px; padding: 4px; cursor: pointer; min-width: 0; transition: border .12s, transform .12s; aspect-ratio: 1; display: flex; align-items: center; justify-content: center; }
.decor-card img { max-width: 100%; max-height: 100%; object-fit: contain; image-rendering: auto; }
.decor-card:hover { border-color: #758376; transform: translateY(-1px); }
.decor-card.active { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold); }
.decor-card span { position: absolute; left: 0; right: 0; bottom: 0; padding: 2px 4px; font-size: 8px; color: #cfd8cf; background: #0d130fd9; border-radius: 0 0 4px 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile-card { position: relative; border: 1px solid var(--line-soft); background: #111713; border-radius: 5px; padding: 4px; cursor: pointer; min-width: 0; transition: border .12s, transform .12s; }
.tile-card:hover { border-color: #758376; transform: translateY(-1px); }
.tile-card.active { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold); }
.tile-card img { width: 100%; height: 80px; object-fit: contain; display: block; filter: drop-shadow(0 5px 5px #0007); pointer-events: none; }
.tile-card span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 10px; color: #b9c2bb; padding: 3px 2px 2px; }
.tile-card .tile-type-dot { position: absolute; width: 7px; height: 7px; border-radius: 50%; top: 8px; right: 8px; box-shadow: 0 0 0 2px #111713; }
.map-workspace { min-width: 0; min-height: 0; display: flex; flex-direction: column; background: #101612; }
.map-heading { height: 70px; flex: 0 0 70px; display: flex; justify-content: space-between; align-items: center; padding: 0 20px; }
.map-heading h1 { font-size: 23px; }
.save-state { color: var(--muted); font-size: 11px; }
.tool-toolbar { min-height: 47px; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 6px 15px; border-top: 1px solid var(--line-soft); border-bottom: 1px solid var(--line-soft); background: #151c18; }
.tool-group { display: flex; gap: 3px; }
.tool { border: 1px solid transparent; border-radius: 3px; background: transparent; color: var(--muted); padding: 7px 10px; font-size: 11px; cursor: pointer; }
.tool:hover { color: var(--text); background: #ffffff08; }
.tool.active { color: #1b211c; background: var(--gold); }
.right-tools .tool { border-color: var(--line); }
.compact-select { max-width: 160px; padding: 6px; }
.canvas-container { position: relative; flex: 1; min-height: 0; overflow: hidden; background-color: #0d130f; background-image: radial-gradient(#2c3930 1px, transparent 1px); background-size: 20px 20px; }
#map-canvas { display: block; width: 100%; height: 100%; cursor: crosshair; }
#map-canvas.panning { cursor: grabbing; }
.canvas-hint { position: absolute; bottom: 13px; left: 50%; transform: translateX(-50%); color: #b5bdb5; background: #111713dc; border: 1px solid #344039aa; border-radius: 4px; padding: 7px 12px; font-size: 10px; pointer-events: none; white-space: nowrap; opacity: .8; }
.empty-map { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; background: #101612ee; }
.empty-map .empty-mark { width: 62px; height: 70px; font-size: 19px; }
.empty-map h2 { font: 28px Georgia, serif; margin: 22px 0 6px; }
.empty-map p { color: var(--muted); max-width: 360px; line-height: 1.6; margin: 0 0 20px; }
.map-statusbar { flex: 0 0 31px; display: flex; align-items: center; justify-content: space-between; padding: 0 13px; color: var(--muted); font-size: 10px; border-top: 1px solid var(--line-soft); }
.zoom-controls { display: flex; gap: 8px; align-items: center; }
.zoom-controls button { border: 0; background: transparent; cursor: pointer; color: var(--text); font-size: 16px; }
.inspector-empty { text-align: center; color: var(--muted); padding: 35px 20px; line-height: 1.6; }
.hex-placeholder { width: 70px; height: 78px; margin: auto; border: 1px dashed #526157; clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%); background: #ffffff04; }
.selected-tile-preview { display: flex; align-items: center; gap: 10px; padding: 8px; border: 1px solid var(--line-soft); background: #111713; border-radius: 5px; }
.selected-tile-preview img { width: 52px; height: 70px; object-fit: contain; }
.selected-tile-preview strong, .selected-tile-preview span { display: block; }
.selected-tile-preview strong { font-size: 11px; margin-bottom: 6px; }
.selected-tile-preview span { color: var(--muted); font-size: 10px; }
.inspector-section { border-bottom: 1px solid var(--line-soft); padding: 15px 0; }
.inspector-section h3 { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; margin: 0 0 12px; color: #cbd2cc; }
.field { display: block; margin-bottom: 12px; min-width: 0; }
.field > span { display: block; color: var(--muted); font-size: 10px; margin-bottom: 6px; }
.inspector-panel .field select { padding: 8px; font-size: 11px; }
.bonus-summary { display: flex; flex-wrap: wrap; gap: 5px; }
.bonus-pill { border: 1px solid var(--line); color: #b9c5bc; padding: 4px 6px; border-radius: 3px; font-size: 9px; }
.bonus-pill.positive { color: #acd3a8; }
.bonus-pill.negative { color: #e2a298; }
.inline-form { display: flex; gap: 6px; }
.inline-form .button { padding: 7px; }
.section-title { display: flex; justify-content: space-between; }
.section-title > span { color: var(--gold); }
.unit-add-form { display: grid; grid-template-columns: 1fr 60px 33px; gap: 5px; }
.unit-add-form input, .unit-add-form select { padding: 7px; font-size: 10px; }
.unit-add-form .button { padding: 5px; }
.stack-list { margin-top: 8px; }
.stack-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 6px 7px; background: #111713; margin-bottom: 4px; border-radius: 3px; color: #bbc4bd; font-size: 10px; }
.stack-row button { border: 0; background: none; color: #d39288; cursor: pointer; }
.help-text, .form-note { color: var(--muted); font-size: 11px; line-height: 1.5; }
.form-note { margin: 0 0 14px; }
#inspector-content > .button { margin: 15px 0 4px; }
.dialog { color: var(--text); background: var(--panel); border: 1px solid #526058; border-radius: 8px; padding: 0; box-shadow: var(--shadow); max-height: 90vh; overflow: hidden; display: flex; flex-direction: column; position: relative; }
/* Toast greffé sur une dialog ouverte (top layer) : ancré en bas à droite de la dialog. */
.dialog > .toast { position: absolute; right: 16px; bottom: 16px; z-index: 6; }
/* La règle auteur ci-dessus écrase la feuille navigateur (dialog:not([open]) { display: none }) :
   une dialog fermée resterait visible. On rétablit explicitement son masquage. */
.dialog:not([open]) { display: none; }
.dialog::backdrop { background: #050806c7; backdrop-filter: blur(3px); }
.small-dialog { width: min(470px, 92vw); }
.medium-dialog { width: min(800px, 94vw); }
.large-dialog { width: min(850px, 95vw); }
.wide-dialog { width: min(1080px, 96vw); }
.dialog-header { height: 72px; display: flex; align-items: center; justify-content: space-between; padding: 0 22px; border-bottom: 1px solid var(--line); flex: none; }
.dialog-header h2 { font-size: 23px; }
.dialog-close { border: 0; background: none; font-size: 25px; color: var(--muted); cursor: pointer; }
.dialog-body { padding: 20px; overflow-y: auto; }
.dialog > .dialog-body { flex: 1 1 auto; min-height: 0; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.span-2 { grid-column: span 2; }
.span-4 { grid-column: span 4; }
.checkbox-field { display: flex; gap: 9px; align-items: center; color: #c2cbc4; margin: 2px 0 15px; font-size: 11px; }
.game-timers-field { margin: 10px 0 0; padding: 7px 9px; border: 1px dashed var(--line-soft); border-radius: 4px; color: var(--muted); cursor: pointer; }
.game-timers-field:hover { color: var(--text); border-color: var(--line); }
.game-timers-field input { width: auto; accent-color: var(--gold); cursor: pointer; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 10px; }
.dialog-actions .danger { margin-right: auto; }
.maps-layout { display: grid; grid-template-columns: 220px 1fr; max-height: calc(90vh - 72px); }
.maps-sidebar { padding: 16px; border-right: 1px solid var(--line); overflow-y: auto; }
.maps-list { margin-top: 14px; }
.map-list-item { display: block; width: 100%; text-align: left; border: 1px solid transparent; background: transparent; padding: 11px; border-radius: 4px; cursor: pointer; margin-bottom: 5px; }
.map-list-item.active, .map-list-item:hover { border-color: var(--line); background: #ffffff06; }
.map-list-item strong, .map-list-item span { display: block; }
.map-list-item span { font-size: 10px; color: var(--muted); margin-top: 4px; }
.tile-form-preview { grid-column: span 2; width: 100%; height: 145px; object-fit: contain; }
.manager-layout { display: grid; grid-template-columns: 230px 1fr; max-height: calc(90vh - 72px); }
.manager-list { border-right: 1px solid var(--line); padding: 16px; overflow-y: auto; }
.manager-list-item { width: 100%; display: flex; align-items: center; gap: 9px; padding: 10px 8px; border: 0; border-bottom: 1px solid var(--line-soft); background: transparent; text-align: left; cursor: pointer; }
.manager-list-item.active { background: #d1b46a12; color: var(--gold); }
.manager-list-item img { width: 35px; height: 35px; object-fit: cover; border-radius: 50%; }
.manager-list-item .terrain-swatch { width: 13px; height: 13px; border-radius: 50%; flex: 0 0 13px; }
.manager-list-item span { overflow: hidden; text-overflow: ellipsis; }
.manager-list-item small { margin-left: auto; color: var(--muted); }
.manager-layout > .dialog-body { max-height: calc(90vh - 72px); }
.unit-manager { grid-template-columns: 180px 1fr; }
.unit-editor { padding: 17px 20px; overflow-y: auto; max-height: calc(90vh - 72px); }
.unit-general { grid-template-columns: 1.6fr 1fr 1fr 1.2fr auto; }
.unit-general .span-4 { grid-column: 1 / -1; }
.align-end { align-self: end; margin-bottom: 12px; }
.unit-tabs { display: flex; border-bottom: 1px solid var(--line); margin: 5px 0 15px; }
.tab { border: 0; border-bottom: 2px solid transparent; background: none; padding: 9px 13px; color: var(--muted); cursor: pointer; }
.tab.active { color: var(--gold); border-bottom-color: var(--gold); }
#unit-sprites-panel { position: relative; padding-right: 205px; }
#unit-sprites-panel > .section-title { align-items: center; }
.sprites-content { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }
.sprite-list { max-height: 225px; overflow-y: auto; }
.sprite-list-item { border: 1px solid var(--line-soft); background: #111713; padding: 8px; border-radius: 4px; margin-bottom: 5px; cursor: pointer; }
.sprite-list-item.active { border-color: var(--gold-dark); }
.sprite-list-item strong { display: block; font-size: 11px; }
.sprite-list-item span { display: block; color: var(--muted); font-size: 9px; margin-top: 4px; }
.sprite-form { padding: 5px 0; }
.sprite-form .field > span { font-size: 9px; }
.sprite-form input, .sprite-form select { padding: 7px; font-size: 10px; }
.sprite-actions { display: flex; gap: 5px; }
.sprite-actions .button { font-size: 10px; padding: 7px; }
.animation-preview { position: absolute; right: 0; top: 80px; width: 190px; display: flex; flex-direction: column; align-items: center; color: var(--muted); font-size: 10px; pointer-events: none; }
#sprite-preview { width: 190px; height: 190px; image-rendering: pixelated; background: #0f1511; border: 1px solid var(--line-soft); border-radius: 5px; margin-bottom: 5px; }
/* Aperçu animé du décor sélectionné (mêmes réglages que le rendu carte : ancrage
   centre-bas, échelle, miroir, balancement/planche). */
.decor-preview-wrap { display: flex; flex-direction: column; align-items: center; gap: 4px; margin-bottom: 10px; color: var(--muted); font-size: 10px; }
#decor-anim-preview { width: 180px; height: 180px; background: radial-gradient(circle at 50% 62%, #1a241c 0%, #0d130f 75%); border: 1px solid var(--line-soft); border-radius: 5px; }
.matchup-row { display: grid; grid-template-columns: 1fr 100px 100px; align-items: center; gap: 10px; border-bottom: 1px solid var(--line-soft); padding: 8px 0; }
.matchup-row label { color: var(--muted); font-size: 9px; }
.matchup-row input { margin-top: 3px; padding: 6px; }
.character-top { display: flex; gap: 16px; }
#character-photo-preview { width: 175px; height: 175px; object-fit: cover; border-radius: 5px; border: 1px solid var(--line); background: #111713; }
.flex-one { flex: 1; }
.ability-box { border: 1px solid var(--line); border-radius: 4px; margin: 4px 0 13px; padding: 10px 12px; }
.ability-box legend { color: var(--gold); font-size: 10px; padding: 0 6px; }
.timings-group-title { margin: 8px 0 2px; color: var(--gold); font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .12em; }
.sound-picker { display: flex; gap: 6px; align-items: center; }
.sound-picker select { flex: 1; min-width: 0; }
.sound-preview { flex: none; padding: 6px 10px; }
.brick-list { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }
.brick-group h4 { margin: 6px 0 2px; color: var(--gold); font-size: 10px; text-transform: uppercase; letter-spacing: .12em; }
.toast-container { position: fixed; z-index: 100; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 8px; }
.toast { background: #26332b; border: 1px solid #52675a; border-left: 3px solid var(--gold); box-shadow: var(--shadow); border-radius: 4px; padding: 12px 16px; min-width: 260px; max-width: 420px; animation: toast-in .2s ease-out; }
.toast.error { border-left-color: var(--danger); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }
a.button { text-decoration: none; display: inline-block; }
.map-tooltip { position: absolute; z-index: 10; width: 280px; pointer-events: none; background: #111713f2; border: 1px solid #6c785f; border-radius: 5px; box-shadow: 0 8px 30px #000a; padding: 13px; font-size: 13px; }
.map-tooltip strong { display: block; font-family: Georgia, serif; color: #f0e7cd; margin-bottom: 5px; font-size: 16px; }
.map-tooltip > span { display: block; color: var(--muted); font-size: 12px; margin-bottom: 9px; }
.tooltip-bonuses { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 5px; }
.tooltip-bonuses span { background: #ffffff08; padding: 7px 4px; text-align: center; font-size: 11px; border-radius: 3px; }
.tooltip-warning { color: #e5a399 !important; margin-top: 7px; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #3b4840; border-radius: 5px; }
::-webkit-scrollbar-track { background: transparent; }
@media (max-width: 1180px) { .workspace { grid-template-columns: 225px minmax(340px, 1fr) 260px; } .topbar-actions .button { padding: 8px; font-size: 10px; } .canvas-hint { display: none; } }
@media (max-width: 900px) { body { overflow: auto; } .app-shell { min-width: 850px; } .topbar { padding: 0 10px; } .brand span:last-child { display: none; } .workspace { grid-template-columns: 200px minmax(400px, 1fr); } .inspector-panel { display: none; } }


/* Cartes de l'atelier : rangée avec badges et actions (publier/dépublier, dupliquer). */
.map-list-row { display: flex; align-items: stretch; gap: 6px; }
.map-list-row .map-list-item { flex: 1; min-width: 0; }
.map-list-row.active .map-list-item { border-color: var(--gold); }
.map-row-actions { display: flex; flex-direction: column; gap: 5px; justify-content: center; }
.map-row-actions .icon-button { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; padding: 0; color: var(--muted); }
.map-row-actions .icon-button:hover { color: var(--gold); border-color: var(--gold); }
.map-badges { display: inline-flex; align-items: baseline; gap: 6px; margin-top: 4px; flex-wrap: wrap; }
.map-badge { font-size: 10px; text-transform: uppercase; letter-spacing: .05em; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); }
.map-badge.published { color: #9fd08a; border-color: #9fd08a55; }
.map-badge.draft { color: #d8b46a; border-color: #d8b46a55; }
.map-legacy { font-size: 10px; color: var(--muted); }

/* Étoile du statut administrateur dans le chip utilisateur. */
.admin-star { color: var(--gold); }

/* Case « cartes publiques » sous le bouton Nouvelle carte de la dialog Cartes. */
.maps-public-toggle { margin: 8px 0; font-size: 11px; }
