/* editor.css — Stage 2 editor. Re-uses the Stage 1 palette variables. */
.editor { position: fixed; inset: 0; z-index: 20; display: grid; grid-template-rows: auto minmax(0,1fr); background: var(--bg); min-width: 0; overflow: hidden; }
.editor[hidden] { display: none; }
.ed-top { display: flex; align-items: center; gap: 8px; padding: 5px 12px; min-height: 44px; flex-wrap: wrap; row-gap: 5px; background: var(--panel); border-bottom: 1px solid var(--border); overflow: visible; white-space: nowrap; position: relative; z-index: 30; max-width: 100vw; }
.ed-top button, .ed-top select { padding: 4px 10px; }
.ed-top select { font: inherit; color: var(--text); background: var(--panel-2); border: 1px solid var(--border); border-radius: 4px; max-width: 200px; }
.ed-name { width: 180px; min-width: 100px; flex: 0 1 180px; font: inherit; font-weight: 600; color: var(--text); background: transparent; border: 1px solid transparent; border-radius: 4px; padding: 4px 8px; }
.ed-name:hover, .ed-name:focus { border-color: var(--border); background: var(--panel-2); outline: none; }
.sep { width: 1px; height: 20px; background: var(--border); margin: 0 2px; }
.spacer, .grow { flex: 1; min-width: 0; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 4px; overflow: hidden; }
.seg button { border: 0; border-radius: 0; background: var(--panel-2); }
.seg button + button { border-left: 1px solid var(--border); }
.seg button.active { background: var(--accent-dim); color: #fff; box-shadow: inset 0 -2px 0 var(--accent); }
.seg.wide { display: flex; } .seg.wide button { flex: 1; padding: 4px 6px; }
.chk { display: inline-flex; align-items: center; gap: 5px; cursor: pointer; color: var(--text); }
input[type=range] { accent-color: var(--accent); }
#edTplOpacity { width: 70px; }

.ed-main { --lw: 250px; --rw: 290px; display: grid; grid-template-columns: var(--lw) 5px minmax(0,1fr) 5px var(--rw); min-height: 0; min-width: 0; overflow: hidden; }
.ed-left, .ed-right { min-width: 0; overflow-x: hidden; }
.ed-right { overflow-y: hidden; }
.ed-right .layers { flex: 0 1 38%; min-height: 90px; }
.ed-right .props { flex: 1 1 0; min-height: 80px; }
.ed-resizer { position: relative; z-index: 5; cursor: col-resize; background: var(--border); touch-action: none; user-select: none; transition: background .12s; }
.ed-resizer::before { content: ""; position: absolute; inset: 0 -4px; }
.ed-resizer:hover, .ed-resizer.dragging { background: var(--accent); }
body.ed-resizing, body.ed-resizing * { cursor: col-resize !important; user-select: none !important; }
.ed-left, .ed-right { border: 0 !important; }
.ed-top .menu-list.right { left: auto; right: 0; max-width: 92vw; max-height: 80vh; overflow-y: auto; }
.ed-status { min-width: 0; }
.ed-status > span.dim { overflow: hidden; text-overflow: ellipsis; min-width: 0; flex: 0 1 auto; }
@media (max-width: 1100px) { .ed-top { padding: 4px 8px; gap: 6px; } .ed-top button, .ed-top select { padding: 3px 7px; } }
.ed-left, .ed-right { display: flex; flex-direction: column; min-height: 0; overflow-y: auto; background: var(--panel); }
.ed-left { border-right: 1px solid var(--border); } .ed-right { border-left: 1px solid var(--border); }
.ed-left .panel-title, .ed-right .panel-title { border-top: 1px solid var(--border); flex: none; }
.ed-left .panel-title:first-child, .ed-right .panel-title:first-child { border-top: 0; }
.small-btn { padding: 1px 8px !important; font-size: 11px; text-transform: none; letter-spacing: 0; }
.muted { color: var(--muted); } .small { font-size: 11px; } .pad { padding: 10px 12px; } .dim { color: var(--muted); }

.tools { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 10px; }
.tool { display: flex; align-items: center; justify-content: space-between; padding: 7px 10px; }
.tool.active { background: var(--accent-dim); border-color: var(--accent); }
kbd { font: 10px var(--font); color: var(--muted); border: 1px solid var(--border); border-radius: 3px; padding: 0 4px; }
.tool-opts { padding: 0 10px 10px; display: flex; flex-direction: column; gap: 6px; }
.tool-opts > div { display: flex; flex-direction: column; gap: 6px; }
.tool-opts[hidden], .tool-opts > div[hidden] { display: none; }
.decals { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; padding: 10px; }
.decal { aspect-ratio: 1; padding: 4px; display: flex; align-items: center; justify-content: center;
  background: conic-gradient(#2b2c31 25%, #222328 0 50%, #2b2c31 0 75%, #222328 0) 0 0 / 10px 10px; }
.decal img, .upload img { max-width: 100%; max-height: 100%; object-fit: contain; pointer-events: none; }
.uploads { display: flex; flex-direction: column; gap: 4px; padding: 8px 10px 14px; }
.upload { display: flex; align-items: center; gap: 8px; text-align: left; padding: 4px; }
.upload img { width: 38px; height: 38px; flex: none; background: conic-gradient(#2b2c31 25%, #222328 0 50%, #2b2c31 0 75%, #222328 0) 0 0 / 10px 10px; }
.upload .meta { display: flex; flex-direction: column; min-width: 0; }

.ed-center { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.ed-viewport { position: relative; flex: 1; min-height: 0; overflow: hidden; background: #141518; }
.ed-viewport canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.ed-status { display: flex; gap: 18px; white-space: nowrap; overflow: hidden; }
.ed-status > span { font-variant-numeric: tabular-nums; }

.layers { min-height: 120px; max-height: 38%; overflow-y: auto; flex: none; padding: 4px; }
.layer { display: flex; align-items: center; gap: 2px; padding: 3px 4px; border: 1px solid transparent; border-radius: 4px; cursor: pointer; }
.layer:hover { background: var(--panel-2); }
.layer.selected { background: var(--accent-dim); border-color: var(--accent); }
.layer.hidden .lname, .layer.hidden .ltype { opacity: .4; text-decoration: line-through; }
.layer.off { opacity: .45; }
.ltype { font-size: 9px; color: var(--muted); border: 1px solid var(--border); border-radius: 3px; padding: 0 3px; margin: 0 4px; }
.lname { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lname-edit { flex: 1; min-width: 0; font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--accent); border-radius: 3px; padding: 1px 4px; }
.ico { border: 0; background: none; padding: 1px 5px; color: var(--muted); font-size: 11px; line-height: 1.2; }
.ico:hover:not(:disabled) { color: var(--text); background: none !important; }
.ico.on { color: var(--accent); } .ico.del:hover:not(:disabled) { color: var(--bad) !important; }
.ico:disabled { opacity: .25; }

.props { flex: 1; overflow-y: auto; padding: 8px 10px 16px; }
.pfields { border: 0; margin: 0; padding: 0; min-width: 0; }
.pfields:disabled { opacity: .5; }
.pgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 8px; margin-bottom: 6px; }
.prop { display: flex; flex-direction: column; gap: 2px; font-size: 11px; }
.prop .plabel { color: var(--muted); text-transform: uppercase; letter-spacing: .4px; font-size: 10px; }
.tool-opts .prop { flex-direction: row; align-items: center; gap: 8px; }
.props input[type=number], .props select, .props textarea { width: 100%; font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--border); border-radius: 4px; padding: 3px 6px; }
.props input[type=number]:focus, .props select:focus, .props textarea:focus { outline: 1px solid var(--accent); }
.props input[type=color] { width: 100%; height: 26px; padding: 1px; background: var(--bg); border: 1px solid var(--border); border-radius: 4px; }
.props textarea { resize: vertical; margin-bottom: 6px; }
.psec { margin: 10px 0 6px; padding-top: 8px; border-top: 1px solid var(--border); font-size: 10px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); }
.pbtns { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.pbtns button { padding: 3px 9px; }
body.editor-open { overflow: hidden; }

/* GapFix dialog */
#edGapFix.active { background: var(--accent-dim); border-color: var(--accent); }
.gf-modal { position: fixed; inset: 0; z-index: 40; display: flex; align-items: center; justify-content: center; background: rgba(0,0,0,.6); }
.gf-modal[hidden] { display: none; }
.gf-card { width: min(1180px, 96vw); max-height: 94vh; overflow: auto; background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 16px 18px; display: flex; flex-direction: column; gap: 10px; }
.gf-card h3 { margin: 0; font-size: 15px; } .gf-card h3 small { font-weight: 400; color: var(--muted); margin-left: 8px; }
.gf-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.gf-table th, .gf-table td { text-align: left; padding: 4px 8px; border-bottom: 1px solid var(--border); }
.gf-table input { width: 80px; font: inherit; color: var(--text); background: var(--panel-2); border: 1px solid var(--border); border-radius: 4px; padding: 2px 6px; }
.gf-reason { color: var(--muted); }
.gf-badge { padding: 1px 7px; border-radius: 9px; font-size: 11px; background: var(--panel-2); }
.gf-badge.high { color: var(--ok); } .gf-badge.uncertain { color: #f0b43c; } .gf-badge.none { color: var(--muted); }
.gf-pad input { width: 64px; font: inherit; color: var(--text); background: var(--panel-2); border: 1px solid var(--border); border-radius: 4px; padding: 2px 6px; }
.gf-prev canvas { display: block; width: 100%; max-width: 100%; margin: 4px 0 10px; border: 1px solid var(--border); background: #16171a; }
.gf-r { color: #e06c6c; } .gf-a { color: #f0b43c; } .gf-g { color: var(--ok); }
.gf-actions { display: flex; gap: 8px; align-items: center; }

/* precision: align block */
.palign .agrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; margin-top: 6px; }
.palign .agrid button { padding: 3px 4px; font-size: 11px; }
.snap-row { display: flex; align-items: center; gap: 6px; padding: 2px 0 8px; font-size: 12px; }
/* Shift+drag on the canvas must never extend a page text selection (a later drag would turn into a native text drag and cancel the pointer) */
.ed-viewport, #edCanvas { -webkit-user-select: none; user-select: none; }

/* multi-selection / groups */
.layer.grouped { box-shadow: inset 3px 0 0 var(--gcol, #b980ff); }
.lgrp { font-size: 9px; font-weight: 600; color: var(--gcol, #b980ff); border: 1px solid var(--gcol, #b980ff); border-radius: 3px; padding: 0 3px; margin-right: 4px; }
.pmulti .mhead { font-weight: 600; margin: 2px 0 4px; } .pmulti .mnote { margin-bottom: 8px; }

/* font picker + layer header */
.pgrid .prop.wide { grid-column: 1 / -1; }
.fontbtn { width: 100%; text-align: left; padding: 4px 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; background: var(--bg); font-size: 14px; }
.fontlist { position: fixed; z-index: 80; display: flex; flex-direction: column; background: var(--panel-2); border: 1px solid var(--border); border-radius: 6px; box-shadow: 0 8px 24px rgba(0,0,0,.5); }
.fontlist input { margin: 6px; padding: 4px 8px; font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--border); border-radius: 4px; }
.fontitems { overflow-y: auto; min-height: 0; padding-bottom: 4px; }
.fontitem { display: flex; flex-direction: column; align-items: flex-start; width: 100%; border: 0; border-radius: 0; background: none; padding: 5px 12px; text-align: left; }
.fontitem:hover:not(:disabled) { background: var(--accent-dim); }
.fontitem.active { background: var(--accent-dim); box-shadow: inset 3px 0 0 var(--accent); }
.fsample { font-size: 22px; line-height: 1.25; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; color: var(--text); }
.fontitem small { color: var(--muted); font-size: 10px; }
.fgrp { padding: 6px 12px 2px; font-size: 10px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); }
