/* =========================================================================
   Éditeur (thème clair)
   ========================================================================= */
body.editor { display: grid; grid-template-columns: 264px 1fr 340px; grid-template-rows: 54px 1fr; grid-template-areas: "top top top" "left view right"; height: 100vh; overflow: hidden; background: var(--bg); }

/* ---------- barre du haut ---------- */
#topbar { grid-area: top; display: flex; align-items: center; gap: 6px; padding: 0 10px; background: var(--surface); border-bottom: 1px solid var(--line); overflow-x: auto; overflow-y: hidden; white-space: nowrap; position: relative; z-index: 3; }
#topbar .grow { flex: 1; min-width: 4px; }
#topbar .sep { width: 1px; height: 24px; background: var(--line); margin: 0 4px; flex: none; }
#topbar .btn { padding: 6px 10px; font-size: .84rem; flex: none; }
#topbar .btn.icon { padding: 0; width: 32px; height: 32px; }
#topbar .home { width: 34px; height: 34px; padding: 0; border-radius: 9px; background: var(--text); border: none; color: #fff; box-shadow: none; }
#topbar .home:hover { background: #2b3242; color: #fff; }
#topbar input[type=text], #topbar select { height: 32px; flex: none; }
#world-name { font-weight: 650; background: transparent; border-color: transparent; width: 200px; }
#world-name:hover { border-color: var(--line2); background: var(--surface2); }
#world-name:focus { background: var(--surface); }
.zone-pick { display: inline-flex; align-items: center; gap: 2px; padding: 2px; border-radius: 10px; background: var(--surface3); flex: none; }
.zone-pick select { border-color: transparent; background-color: transparent; width: 160px; font-weight: 550; }
.zone-pick select:hover { background-color: var(--surface); }
.zone-pick .btn { box-shadow: none; }

.seg { display: inline-flex; gap: 2px; padding: 3px; border-radius: 10px; background: var(--surface3); flex: none; }
.seg .btn { background: transparent; border-color: transparent; box-shadow: none; padding: 5px 10px !important; border-radius: 7px; color: var(--muted); }
.seg .btn:hover { color: var(--text); background: rgba(255, 255, 255, .6); }
.seg .btn.on { color: var(--accent); background: var(--surface); box-shadow: var(--shadow-xs); }
.toggle.on { background: var(--accent-soft) !important; color: var(--accent) !important; }
#status { font-size: .76rem; min-width: 0; flex: 0 1 auto; overflow: hidden; text-overflow: ellipsis; text-align: right; color: var(--faint); display: inline-flex; align-items: center; gap: 6px; }
#status::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: #22c55e; flex: none; }
#status.dirty::before { background: #f59e0b; }
#status.err::before { background: var(--danger); }

/* ---------- panneaux latéraux ---------- */
#left, #right { background: var(--surface); overflow-y: auto; min-height: 0; }
#left { grid-area: left; border-right: 1px solid var(--line); display: flex; flex-direction: column; }
#right { grid-area: right; border-left: 1px solid var(--line); padding: 4px 16px 28px; }
.panel-sec { padding: 12px 14px; border-bottom: 1px solid var(--line); }
.panel-sec.grow { flex: 1; min-height: 0; display: flex; flex-direction: column; border-bottom: none; }
.ph { display: flex; align-items: center; gap: 8px; margin: 2px 0 10px; font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .085em; color: var(--faint); }
.ph .n { font-weight: 650; letter-spacing: .02em; background: var(--surface3); color: var(--muted); padding: 1px 7px; border-radius: 99px; }
.ph .grow { flex: 1; }
#right h3 { display: flex; align-items: center; gap: 10px; margin: 16px 0 10px; font-size: 1rem; font-weight: 700; color: var(--text); letter-spacing: -.01em; }
#right h3 .i { width: 30px; height: 30px; border-radius: 9px; background: var(--accent-soft); color: var(--accent); }
#right h3 small { display: block; font-size: .74rem; font-weight: 500; color: var(--faint); letter-spacing: 0; }

#viewport { grid-area: view; position: relative; min-width: 0; min-height: 0; background: #dfe4ee; overflow: hidden; }
#viewport canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; outline: none; }
#viewport.orbiting canvas { cursor: grabbing; }
#viewport.hover canvas { cursor: pointer; }
#viewport.grab canvas { cursor: grab; }
#viewport.moving canvas { cursor: grabbing; }
#viewport.on-handle canvas { cursor: move; }
/* matières : vignettes */
.swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(46px, 1fr)); gap: 6px; }
.swatches button { position: relative; aspect-ratio: 1; border-radius: 9px; border: 2px solid var(--line); background: var(--surface) center / cover no-repeat; cursor: pointer; padding: 0; overflow: hidden; }
.swatches button.loading, .layer-thumb.loading { background-image: linear-gradient(110deg, var(--surface) 30%, var(--line) 50%, var(--surface) 70%); background-size: 250% 100%; animation: swatch-wait 1.1s linear infinite; }
@keyframes swatch-wait { from { background-position: 120% 0; } to { background-position: -120% 0; } }
.swatches button:hover { border-color: var(--line2); transform: translateY(-1px); }
.swatches button.on { border-color: var(--accent, #0f6b7a); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent, #0f6b7a) 25%, transparent); }
.swatches button span { position: absolute; inset: auto 0 0 0; font-size: .6rem; line-height: 1.3; padding: 1px 2px; background: rgba(0,0,0,.55); color: #fff; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.swatches button.none { display: grid; place-items: center; font-size: .66rem; color: var(--text2); }
.tex-preview { display: flex; align-items: center; gap: 8px; }
.tex-preview img { width: 42px; height: 42px; object-fit: cover; border-radius: 7px; border: 1px solid var(--line); }
#viewport.drop::after { content: 'Déposez vos fichiers 3D ou images ici'; position: absolute; inset: 12px; border: 2px dashed var(--accent); border-radius: 16px; display: grid; place-items: center; background: rgba(238, 240, 255, .7); color: var(--accent); font-weight: 650; pointer-events: none; }

/* outils de vue */
.view-tools { position: absolute; top: 12px; right: 12px; display: flex; flex-direction: column; gap: 2px; padding: 4px; border-radius: 13px; z-index: 2; }
.view-tools .btn { width: 34px; height: 34px; padding: 0; background: transparent; border-color: transparent; box-shadow: none; color: var(--text2); }
.view-tools .btn:hover { background: rgba(22, 26, 37, .06); }
.view-tools hr { border: none; height: 1px; background: var(--line); margin: 2px 4px; }
.glass { background: var(--glass); border: 1px solid var(--glass-line); box-shadow: 0 6px 20px -10px rgba(22, 26, 37, .3); backdrop-filter: blur(12px) saturate(1.3); -webkit-backdrop-filter: blur(12px) saturate(1.3); }

/* barre d'état */
#statusbar { position: absolute; left: 12px; right: 58px; bottom: 12px; display: flex; gap: 10px; align-items: center; pointer-events: none; z-index: 2; }
#statusbar > * { pointer-events: auto; }
#selinfo { padding: 6px 12px; border-radius: 10px; font-size: .78rem; color: var(--text2); font-variant-numeric: tabular-nums; white-space: nowrap; }
#selinfo b { color: var(--text); }
#selinfo:empty { display: none; }
#hint { flex: 1; min-width: 0; padding: 6px 12px; border-radius: 10px; font-size: .74rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#hint kbd { font-size: .68rem; }
#marquee { position: absolute; border: 1.5px solid var(--accent); background: rgba(15, 107, 122, .08); border-radius: 3px; pointer-events: none; z-index: 3; }
#hover-label { position: absolute; z-index: 3; pointer-events: none; padding: 3px 8px; border-radius: 7px; background: rgba(22, 26, 37, .82); color: #fff; font-size: .74rem; font-weight: 550; transform: translate(14px, 10px); white-space: nowrap; }

/* ---------- palette d'ajout ---------- */
.lib-cta { width: 100%; justify-content: flex-start; padding: 10px 12px; border-radius: 12px; margin-bottom: 10px; gap: 10px; }
.lib-cta .i { width: 30px; height: 30px; border-radius: 9px; background: rgba(255, 255, 255, .2); }
.lib-cta small { display: block; font-weight: 450; opacity: .85; font-size: .74rem; }
#palette { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
#palette button { display: flex; flex-direction: column; align-items: center; gap: 5px; padding: 9px 4px 7px; border-radius: 11px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-size: .72rem; font-weight: 550; color: var(--text2); line-height: 1.15; text-align: center; transition: border-color .15s, background .15s, transform .15s var(--ease), box-shadow .15s; }
#palette button:hover { border-color: var(--accent-line); background: var(--accent-soft); color: var(--accent); transform: translateY(-1px); box-shadow: var(--shadow-sm); }
#palette button .i { width: 30px; height: 30px; border-radius: 9px; background: var(--surface3); color: var(--text2); transition: background .15s, color .15s; }
#palette button:hover .i { background: var(--surface); color: var(--accent); }

/* ---------- liste des éléments ---------- */
#outliner-search { height: 32px; margin-bottom: 8px; padding-left: 32px;
  background: var(--surface2) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='13' height='13' viewBox='0 0 24 24' fill='none' stroke='%238d95a7' stroke-width='2.4' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='M20 20l-3.5-3.5'/%3E%3C/svg%3E") no-repeat 11px center; }
#outliner { display: flex; flex-direction: column; gap: 1px; overflow-y: auto; min-height: 0; flex: 1; margin: 0 -6px; padding: 0 6px 8px; }
.orow { display: flex; align-items: center; gap: 7px; padding: 4px 4px 4px 7px; border-radius: 8px; font-size: .83rem; color: var(--text2); cursor: pointer; border: 1px solid transparent; user-select: none; min-height: 30px; }
.orow:hover { background: var(--surface2); }
.orow.sel { background: var(--accent-soft); color: var(--text); border-color: rgba(15, 107, 122, .22); }
.orow.dim { opacity: .5; }
.orow .ico { color: var(--muted); flex: none; }
.orow.sel .ico { color: var(--accent); }
.orow .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.orow .nm input { height: 24px; padding: 2px 6px; font-size: .83rem; }
.orow .tg { flex: none; width: 24px; height: 24px; border-radius: 6px; border: none; background: transparent; color: var(--faint); cursor: pointer; display: grid; place-items: center; opacity: 0; transition: opacity .12s, background .12s; padding: 0; }
.orow:hover .tg, .orow .tg.act { opacity: 1; }
.orow .tg:hover { background: rgba(22, 26, 37, .07); color: var(--text); }
.orow .tg.act { color: var(--accent); }
.orow.group { font-weight: 650; color: var(--text); }
.orow.group .ico { color: var(--accent-2); }
.orow .tw { flex: none; width: 16px; display: grid; place-items: center; color: var(--faint); transition: transform .15s; margin-left: -4px; }
.orow .tw.open { transform: rotate(90deg); }
.orow .cnt { font-size: .7rem; color: var(--faint); font-weight: 600; }
.orow.child { padding-left: 24px; }
.outliner-empty { color: var(--faint); font-size: .8rem; padding: 14px 6px; text-align: center; line-height: 1.5; }

/* ---------- inspecteur ---------- */
.field { display: grid; grid-template-columns: 84px minmax(0, 1fr); gap: 10px; align-items: center; margin: 7px 0; font-size: .83rem; }
.field > label { color: var(--muted); font-weight: 500; }
.vec { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.vec.lockable { grid-template-columns: repeat(3, 1fr) 28px; }
.vec input { padding: 5px 4px 5px 14px; min-width: 0; font-variant-numeric: tabular-nums; font-size: .78rem; background-repeat: no-repeat; background-position: 5px center; background-size: 6px 6px; }
.vec input:nth-of-type(1) { background-image: radial-gradient(circle, #e5484d 60%, transparent 62%); }
.vec input:nth-of-type(2) { background-image: radial-gradient(circle, #30a46c 60%, transparent 62%); }
.vec input:nth-of-type(3) { background-image: radial-gradient(circle, #3e63dd 60%, transparent 62%); }
.vec .lk { width: 28px; height: 30px; border-radius: var(--r-sm); border: 1px solid var(--line2); background: var(--surface); color: var(--faint); cursor: pointer; display: grid; place-items: center; padding: 0; }
.vec .lk.on { color: var(--accent); background: var(--accent-soft); border-color: var(--accent-line); }
.field input[type=range] { width: 100%; }
.range-wrap { display: flex; align-items: center; gap: 8px; }
.range-wrap output { font-size: .75rem; color: var(--muted); min-width: 34px; text-align: right; font-variant-numeric: tabular-nums; }
.field.check { grid-template-columns: 1fr; }
.field.check label { color: var(--text2); display: flex; align-items: center; gap: 9px; cursor: pointer; }
.field .inline { display: flex; gap: 6px; align-items: center; }
.note { color: var(--faint); font-size: .76rem; line-height: 1.5; margin: 6px 0 10px; }
.problems { background: var(--warn-soft); border: 1px solid rgba(178, 106, 0, .25); border-radius: var(--r); padding: 10px 12px; margin-top: 16px; font-size: .8rem; color: #7a4a00; }
.problems button { background: none; border: none; color: #8a5300; cursor: pointer; text-align: left; padding: 3px 0; display: block; }
.problems button:hover { text-decoration: underline; }
.actions-row { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 12px; }
.actions-row .btn { padding: 6px 10px; font-size: .8rem; }
.sec-title { display: flex; align-items: center; gap: 8px; margin: 20px 0 8px; font-weight: 700; font-size: .7rem; text-transform: uppercase; letter-spacing: .085em; color: var(--faint); }
.sec-title::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: .76rem; font-weight: 600; padding: 4px 9px; border-radius: 8px; background: var(--surface3); color: var(--text2); }
.group-box { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 9px 10px; border-radius: 11px; background: var(--surface2); border: 1px solid var(--line2); margin: 10px 0 4px; font-size: .8rem; color: var(--text2); }
.group-box .btn { padding: 4px 8px; font-size: .76rem; }
.tool-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; }
.tool-grid .btn { padding: 0; height: 34px; }
.big-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 12px; }
.big-actions .btn { padding: 8px 10px; font-size: .82rem; justify-content: flex-start; }
.big-actions .btn.wide { grid-column: 1 / -1; }
.dims { font-size: .78rem; color: var(--muted); background: var(--surface2); border: 1px solid var(--line); border-radius: 9px; padding: 7px 10px; font-variant-numeric: tabular-nums; margin: 8px 0; }
.dims b { color: var(--text); }
.empty-sel { text-align: center; padding: 8px 4px 2px; }
.tips { display: grid; gap: 6px; margin-top: 8px; font-size: .78rem; color: var(--muted); }
.tips div { display: flex; justify-content: space-between; gap: 10px; }

@media (max-width: 1400px) { #topbar .btn .lbl { display: none; } #topbar .btn.primary .lbl { display: inline; } }
@media (max-width: 1180px) { body.editor { grid-template-columns: 220px 1fr 290px; } #palette { grid-template-columns: repeat(2, 1fr); } #world-name { width: 140px; } .zone-pick select { width: 120px; } }

/* faces décorées */
.chips { display: flex; flex-wrap: wrap; gap: 5px; }
.chip { border: 1px solid var(--line2); background: var(--surface); color: var(--text2); border-radius: 999px; padding: 3px 10px; font-size: .74rem; cursor: pointer; }
.chip.on { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent); font-weight: 600; }
.weather-chips { margin-bottom: 8px; }
.weather-chips .chip { display: inline-flex; align-items: center; gap: 4px; }
.weather-chips .wx { font-size: .9rem; line-height: 1; }
/* point fixe de la taille */
.anchor-row { display: flex; align-items: center; gap: 10px; margin-top: 6px; font-size: .74rem; color: var(--text2); line-height: 1.25; }
.anchor-row small { color: var(--faint); }
.anchor-grid { display: grid; grid-template-columns: repeat(3, 14px); gap: 3px; padding: 4px; border: 1px solid var(--line2); border-radius: 7px; background: var(--surface); flex: none; }
.anchor-grid button { width: 14px; height: 14px; border-radius: 3px; border: 1px solid var(--line2); background: transparent; padding: 0; cursor: pointer; }
.anchor-grid button.on { background: var(--accent); border-color: var(--accent); }

/* ---------- terrain ---------- */
#viewport.sculpt canvas { cursor: crosshair; }
.brush-tools { display: grid; grid-template-columns: repeat(auto-fill, minmax(78px, 1fr)); gap: 6px; margin-bottom: 10px; }
.brush-tools .btn { flex-direction: column; gap: 2px; padding: 7px 4px; font-size: .74rem; justify-content: center; }
.brush-tools .btn b { font-size: 1rem; line-height: 1; font-weight: 600; }
.paint-layers { display: flex; gap: 6px; flex-wrap: wrap; }
.paint-layers .btn { min-width: 44px; height: 44px; padding: 0 8px; font-size: .74rem; }
.paint-layers .btn.swatch { position: relative; width: 44px; padding: 0; background: center / cover no-repeat; border: 2px solid var(--line); }
.paint-layers .btn.swatch.on { border-color: var(--accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 25%, transparent); }
.paint-layers .btn.swatch span { position: absolute; right: 2px; bottom: 2px; font-size: .62rem; line-height: 1; padding: 2px 4px; border-radius: 5px; background: rgba(0,0,0,.6); color: #fff; }
.layer-pick { display: flex; gap: 8px; align-items: center; }
.layer-pick select { flex: 1; min-width: 0; }
.layer-thumb { display: inline-block; flex: none; width: 30px; height: 30px; border-radius: 7px; border: 1px solid var(--line); background: center / cover no-repeat; }
.terrain-sum { display: flex; flex-direction: column; gap: 6px; font-size: .8rem; color: var(--text2); }
.swatch-row { display: flex; gap: 4px; }

/* fiche d'information : blocs de contenu (js/edit/info-editor.js) */
.ib-list { display: grid; gap: 8px; margin: 8px 0; }
.ib-card { border: 1px solid var(--line); border-radius: 12px; padding: 8px 10px 4px; background: var(--surface); }
.ib-card textarea, .ib-card input[type=text] { width: 100%; box-sizing: border-box; }
.ib-card textarea.code { font: 12px/1.45 ui-monospace, SFMono-Regular, Menlo, monospace; tab-size: 2; white-space: pre; }
.ib-card .field { grid-template-columns: 74px minmax(0, 1fr); }
.ib-head { display: flex; align-items: center; gap: 6px; font-size: .78rem; color: var(--text2); margin-bottom: 6px; }
.ib-head .sp { flex: 1; }
.ib-tool { border: 0; background: transparent; color: var(--muted); cursor: pointer; padding: 2px 6px; border-radius: 6px; font-size: .85rem; display: inline-flex; align-items: center; }
.ib-tool:hover:not(:disabled) { background: rgba(22, 26, 37, .06); color: var(--text); }
.ib-tool:disabled { opacity: .3; cursor: default; }
.ib-tool.danger:hover { color: #c0392b; }
.ib-row { display: flex; gap: 6px; align-items: center; }
.ib-row input { flex: 1; min-width: 0; }
.ib-row .btn { white-space: nowrap; }
.ib-add { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; margin: 6px 0 10px; }
.ib-add .note { margin: 0 4px 0 0; }
.ib-add .btn { padding: 4px 8px; font-size: .74rem; }
.note.warn { color: #b35a00; }
.info-preview .dialog { max-width: 780px; }
.info-preview .body { max-height: 64vh; overflow-y: auto; margin-top: 6px; }

/* fenêtre « Nouvelle zone » : modèles de zone */
.zp-box { width: min(860px, 100%); }
.zp-box .lib-head input.zp-name { flex: 1; min-width: 180px; height: 36px; padding-left: 12px; background-image: none; }
.zp-hint { margin: 0; padding: 10px 16px 0; font-size: .84rem; color: var(--muted); background: var(--surface2); }
.zp-grid { grid-template-columns: repeat(auto-fill, minmax(176px, 1fr)); }
.zp-card { font: inherit; color: inherit; }
.zp-card strong { font-size: .9rem; padding: 0 2px; }
.zp-card small { font-size: .76rem; color: var(--muted); padding: 0 2px 2px; line-height: 1.35; }
.zp-thumb { aspect-ratio: 3 / 2; border-radius: 9px; overflow: hidden; background: var(--surface3); }
.zp-thumb svg { display: block; width: 100%; height: 100%; transition: transform .35s var(--ease); }
.zp-card:hover .zp-thumb svg { transform: scale(1.05); }

/* pastilles de raccourci sur les boutons Déplacer / Tourner / Taille */
#topbar .kb { min-width: 1.5em; margin-left: 6px; padding: 0 4px; font-size: .62rem; line-height: 1.4; opacity: .75; pointer-events: none; }
#topbar .btn.on .kb { opacity: 1; }
@media (max-width: 1400px) { #topbar .btn .kb { display: none; } }

/* ---------- musique de fond (panneau Monde) ---------- */
.music-list { display: grid; gap: 4px; margin: 6px 0 8px; }
.music-row { display: flex; align-items: center; gap: 4px; padding: 4px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); }
.music-row .btn.icon { padding: 5px 7px; min-width: 0; }
.mr-name { flex: 1; min-width: 0; display: grid; font-size: .8rem; }
.mr-name b, .mr-name small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mr-name small { color: var(--faint); font-size: .7rem; }
.music-form { display: grid; gap: 6px; margin: 6px 0; }
.music-form input, .music-form select { width: 100%; box-sizing: border-box; }
.music-libs { margin: 8px 0; font-size: .8rem; }
.music-libs summary { cursor: pointer; color: var(--text2); font-weight: 500; }
.music-libs ul { margin: 4px 0 0; padding-left: 18px; line-height: 1.6; }
.music-libs small { color: var(--faint); }

/* fenêtre « Nouvelle zone » : bibliothèque de jeux */
.zp-body { flex: 1; min-height: 0; overflow-y: auto; background: var(--surface2); }
.zp-body .zp-grid { overflow: visible; }
.zp-sub { margin: 0; padding: 14px 16px 0; font-size: .95rem; background: var(--surface2); }
.zp-game { display: flex; flex-direction: column; gap: 10px; padding-bottom: 16px; }
.zp-game > * { margin-left: 16px; margin-right: 16px; }
.zp-game .zp-hint { margin: 0; padding: 10px 0 0; }
.zp-questions { width: auto; font: .84rem/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: inherit; resize: vertical; min-height: 150px; }
.zp-setting { display: flex; align-items: center; gap: 10px; font-size: .86rem; }
.zp-setting input { width: 80px; }
.zp-msg { margin: 0 16px; min-height: 1.2em; font-size: .84rem; color: #b3261e; }
.zp-actions { display: flex; justify-content: space-between; gap: 8px; }
.zp-setting select { flex: 1; min-width: 0; height: 34px; }
