/* Focused generation controls: prompt, composition and visual reference form one compact input rail. */
.prompt-field textarea { min-height: 152px !important; resize: vertical; }
.composition-control { padding: 10px 12px !important; }
.composition-row { display: flex; gap: 10px; align-items: center; }
.composition-select { flex: 1; min-width: 0; min-height: 42px; border: 1px solid #b9cdbb; border-radius: 8px; background: #fffef9; color: var(--ink-950); padding: 0 12px; font: inherit; font-weight: 700; }
.default-composition { display: flex !important; grid-template-columns: none !important; align-items: center; gap: 7px; white-space: nowrap; font-size: 12px !important; color: var(--ink-600); }
.default-composition input { width: auto !important; min-height: 0 !important; margin: 0; }
.reference-picker { padding: 12px; border: 1px dashed #a8c5aa; border-radius: 10px; background: #f4f8ef; }
.reference-heading { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 9px; }
.reference-heading strong { font-size: 13px; }
.reference-count { color: var(--ink-600); font-size: 11px; }
.file-picker { display: inline-flex !important; width: auto; position: relative; overflow: hidden; align-items: center; min-height: 36px; padding: 0 11px; border: 1px solid #8eac91; border-radius: 7px; background: #fffef9; color: var(--spruce-800); cursor: pointer; }
.file-picker input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.reference-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(82px, 1fr)); gap: 8px; margin-top: 10px; }
.reference-thumb { position: relative; min-width: 0; aspect-ratio: 1; border: 1px solid #cddccb; border-radius: 8px; overflow: hidden; background: repeating-conic-gradient(#e8eee5 0 25%,#fbfdf9 0 50%) 50% / 12px 12px; }
.reference-thumb img { display: block; width: 100%; height: 100%; object-fit: contain; image-rendering: pixelated; }
.reference-thumb button { position: absolute; top: 4px; right: 4px; display: grid; place-items: center; width: 22px; height: 22px; min-height: 0; padding: 0; border: 0; border-radius: 50%; background: rgba(19, 43, 35, .88); color: #fff; font-size: 16px; line-height: 1; }
.reference-thumb span { position: absolute; right: 0; bottom: 0; left: 0; padding: 3px 5px; overflow: hidden; color: #fff; background: rgba(19, 43, 35, .76); font-size: 9px; line-height: 1.25; text-overflow: ellipsis; white-space: nowrap; }

#pixel-editor { width: min(1080px, calc(100vw - 36px)); max-width: none; padding: 0; background: #f8f7ee; }
#pixel-editor::backdrop { background: rgba(11, 30, 23, .42); backdrop-filter: blur(3px); }
.editor-head { display: flex; justify-content: space-between; align-items: start; padding: 18px 22px; border-bottom: 1px solid #d8ded2; }
.editor-head h2 { margin: 0; font-size: 21px; }
.editor-head p { margin: 3px 0 0; color: var(--ink-600); font-size: 12px; }
.editor-head > button { width: 32px; min-height: 32px; padding: 0; border: 0; background: transparent; font-size: 24px; }
.editor-layout { display: grid; grid-template-columns: minmax(0, 1fr) 250px; min-height: 610px; }
.editor-canvas-area { display: grid; place-content: center; gap: 12px; min-width: 0; padding: 28px; background: #edf1e8; }
.canvas-workspace { display: grid; grid-template-columns: 28px auto; grid-template-rows: 28px auto; align-items: start; justify-items: start; }
.ruler-corner { grid-column: 1; grid-row: 1; width: 28px; height: 28px; border-right: 1px solid #b8c9b7; border-bottom: 1px solid #b8c9b7; background: #e3eade; }
.pixel-ruler { position: relative; overflow: hidden; color: #5d725f; background: #e9f0e6; font: 10px ui-monospace, Consolas, monospace; user-select: none; }
.pixel-ruler.horizontal { grid-column: 2; grid-row: 1; height: 28px; width: 100%; border-bottom: 1px solid #b8c9b7; cursor: col-resize; }
.pixel-ruler.vertical { grid-column: 1; grid-row: 2; width: 28px; height: 100%; border-right: 1px solid #b8c9b7; cursor: row-resize; }
.ruler-mark { position: absolute; opacity: .8; pointer-events: none; }
.horizontal .ruler-mark { bottom: 3px; transform: translateX(-50%); }
.vertical .ruler-mark { right: 3px; transform: translateY(-50%); }
.pixel-stage { --pixel-size: 16px; grid-column: 2; grid-row: 2; position: relative; width: calc(32 * var(--pixel-size)); height: calc(32 * var(--pixel-size)); overflow: hidden; border: 1px solid #9eb8a0; background: repeating-conic-gradient(#e4ebe2 0 25%, #fbfdf9 0 50%) 50% / calc(2 * var(--pixel-size)) calc(2 * var(--pixel-size)); box-shadow: 0 18px 40px rgba(30, 61, 44, .14); }
.pixel-stage::after { content: ""; position: absolute; inset: 0; pointer-events: none; background-image: linear-gradient(to right, rgba(35, 72, 51, .18) 1px, transparent 1px), linear-gradient(to bottom, rgba(35, 72, 51, .18) 1px, transparent 1px); background-size: var(--pixel-size) var(--pixel-size); }
.pixel-stage:not(.show-grid)::after { display: none; }
#pixel-canvas { display: block; width: 100%; height: 100%; image-rendering: pixelated; cursor: crosshair; }
.editor-coordinates { justify-self: center; padding: 4px 8px; border-radius: 999px; color: var(--ink-600); background: #f8f9f1; font: 12px ui-monospace, Consolas, monospace; }
.editor-sidebar { display: grid; align-content: start; gap: 16px; padding: 20px; border-left: 1px solid #d8ded2; background: #fcfbf4; }
.editor-sidebar h3 { margin: 0 0 8px; color: var(--ink-600); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; }
.tool-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; }
.tool-grid button { min-height: 34px; padding: 5px 7px; font-size: 12px; }
.tool-grid button.active { border-color: var(--spruce-800); color: #fff; background: var(--spruce-800); }
#editor-zoom { width: 100%; }
#palette-swatches { display: grid; grid-template-columns: repeat(8, 1fr); gap: 3px; }
.swatch { width: 24px; height: 24px; min-height: 0; padding: 0; border-radius: 3px; }
.swatch.active { outline: 2px solid var(--spruce-800); outline-offset: 2px; }
#save-editor { width: 100%; min-height: 42px; }
@media (max-width: 720px) { .composition-row { align-items: stretch; flex-direction: column; } .editor-layout { grid-template-columns: 1fr; } .editor-sidebar { border-top: 1px solid #d8ded2; border-left: 0; } .editor-canvas-area { padding: 16px; overflow: auto; } }

/* Aseprite-like working surface: tools and palette stay left, canvas gets the room. */
html, body { overflow-x: hidden; }
.mosaic-option { display: flex !important; grid-template-columns: none !important; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid #cfddcd; border-radius: 8px; background: #f7faf3; color: var(--spruce-800); }
.mosaic-option input { width: auto !important; min-height: 0 !important; margin: 0; }
.mosaic-candidates { grid-template-columns: repeat(4, minmax(0, 1fr)) !important; align-content: start; }
.mosaic-candidates { gap: 8px !important; max-width: 570px; }
.mosaic-candidates .candidate { position: relative; grid-column: auto !important; min-width: 0; aspect-ratio: 1 / 1; padding: 4px !important; }
.mosaic-candidates .candidate img { display: block; width: 100%; height: 100% !important; aspect-ratio: 1 / 1; max-height: none !important; object-fit: contain; }
.mosaic-candidates .transform-actions { display: none !important; }
.generation-count { display: flex !important; grid-template-columns: none !important; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid #cfddcd; border-radius: 8px; background: #f7faf3; color: var(--spruce-800); font-weight: 700; }
.generation-count select { flex: 1; min-height: 34px; border: 1px solid #b9cdbb; border-radius: 6px; background: #fffef9; color: var(--ink-950); padding: 0 8px; font: inherit; }
.multi-item-fields { display: grid; gap: 10px; }
.multi-item-card { padding: 11px; border: 1px solid #cfddcd; border-radius: 8px; background: #fbfcf7; }
.multi-item-card > strong { display: block; margin-bottom: 8px; color: var(--spruce-800); font-size: 12px; }
.reference-picker.disabled { opacity: .48; filter: grayscale(.2); }
.reference-picker.disabled::after { content: '多物品生成时不可使用参考图'; display: block; margin-top: 8px; color: #9a625c; font-size: 12px; }
.candidate-check { position: absolute !important; right: 8px; bottom: 8px; display: grid !important; place-items: center; width: 24px; height: 24px; padding: 0 !important; border: 1px solid rgba(255,255,255,.82); border-radius: 6px; background: rgba(17, 47, 35, .8); color: white; cursor: pointer; box-shadow: 0 1px 4px rgba(0,0,0,.2); }
.candidate-check input { position: absolute; opacity: 0; pointer-events: none; }
.candidate-check span { font-size: 15px; line-height: 1; opacity: .45; }
.candidate.selected-for-edit .candidate-check { background: var(--spruce-800); }
.candidate.selected-for-edit .candidate-check span { opacity: 1; }
.candidate-batch { display: flex; align-items: center; gap: 7px; max-width: 570px; margin-top: 8px; }
.candidate-batch label { display: flex !important; grid-template-columns: none !important; align-items: center; gap: 4px; font-size: 11px !important; white-space: nowrap; }
.candidate-batch input { width: auto !important; min-height: 0 !important; margin: 0; }
.candidate-batch button { margin-left: auto; min-height: 32px; padding: 5px 9px; border-radius: 7px; font-size: 11px; }
.candidate.selected-for-edit { outline: 3px solid var(--amber-400); outline-offset: -3px; background: #fff9e7 !important; }
.processed-result-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(90px, 1fr)); gap: 8px; width: min(100%, 570px); margin-bottom: 10px; }
.processed-result-grid img { width: 100%; aspect-ratio: 1; object-fit: contain; image-rendering: pixelated; border: 1px solid #cbd8c9; border-radius: 7px; background: #f2f3e7; }
.asset-library article { position: relative; }
.import-assets { position: relative; display: inline-flex !important; align-items: center; justify-content: center; min-height: 34px; padding: 0 10px; overflow: hidden; border: 1px solid #a8c3ad; border-radius: 7px; color: var(--spruce-800); background: #fffef9; font-size: 12px !important; cursor: pointer; }
.import-assets input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.asset-library.drag-over { outline: 3px dashed #d9b65b; outline-offset: 6px; background: #fffbe9; }
.pixel-selection { position: absolute; z-index: 4; box-sizing: border-box; pointer-events: none; border: 2px dashed #d9b65b; background: rgba(217, 182, 91, .14); box-shadow: 0 0 0 1px rgba(42, 89, 66, .45); animation: selection-march .85s steps(2) infinite; }
.pixel-selection[hidden] { display: none; }
@keyframes selection-march { to { border-color: #2a5942; } }
.pixel-guide { position: absolute; z-index: 6; background: #df6b5d; box-shadow: 0 0 0 1px rgba(255, 251, 237, .82); opacity: .94; }
.pixel-guide.vertical { top: 0; bottom: 0; width: 1px; cursor: col-resize; }
.pixel-guide.horizontal { right: 0; left: 0; height: 1px; cursor: row-resize; }
.pixel-guide::after { content: attr(data-position); position: absolute; padding: 1px 3px; border-radius: 2px; color: #fff; background: #c55249; font: 10px ui-monospace, Consolas, monospace; opacity: 0; transition: opacity .12s ease; }
.pixel-guide:hover::after { opacity: 1; }
.pixel-guide.vertical::after { top: 2px; left: 3px; }
.pixel-guide.horizontal::after { top: 3px; left: 2px; }
.guide-menu { position: fixed; z-index: 1000; margin: 0; padding: 4px; border: 1px solid #b9cdbb; border-radius: 6px; background: #fffef9; box-shadow: 0 10px 22px rgba(30, 61, 44, .18); }
.guide-menu button { min-height: 30px; padding: 0 9px; border: 0; border-radius: 4px; color: #9a3f38; background: transparent; font-size: 12px; }
.guide-menu button:hover { background: #fff0ed; }
.add-to-collection, .download-asset, .rename-asset, .delete-asset { position: absolute; top: 6px; display: grid; place-items: center; width: 26px; min-height: 26px; padding: 0; border: 0; border-radius: 50%; color: #fff; font-size: 16px; line-height: 1; opacity: 0; }
.add-to-collection { right: 102px; background: rgba(86, 105, 166, .92); }
.download-asset { right: 70px; background: rgba(25, 89, 61, .9); }
.rename-asset { right: 38px; background: rgba(139, 104, 50, .92); }
.delete-asset { right: 6px; background: rgba(111, 42, 35, .9); font-size: 18px; }
.asset-library article:hover .delete-asset, .asset-library article:hover .download-asset, .asset-library article:hover .rename-asset, .asset-library article:hover .add-to-collection, .asset-library article:focus-within .delete-asset, .asset-library article:focus-within .download-asset, .asset-library article:focus-within .rename-asset, .asset-library article:focus-within .add-to-collection { opacity: 1; }
.asset-dialog { width: min(440px, calc(100vw - 32px)); padding: 0; border: 1px solid #d8ded2; border-radius: 12px; color: var(--ink-950); background: #fcfbf4; box-shadow: 0 20px 60px rgba(8, 28, 20, .25); }
.asset-dialog::backdrop { background: rgba(11, 30, 23, .34); }
.asset-dialog form { display: grid; gap: 14px; padding: 22px; }
.asset-dialog h2, .asset-dialog p { margin: 0; }
.asset-dialog p { color: var(--ink-600); font-size: 13px; }
.asset-dialog label { display: grid !important; gap: 6px; color: var(--ink-600); font-size: 12px; }
.asset-dialog input { min-height: 38px; }
.collection-list { display: grid; gap: 7px; max-height: 220px; overflow: auto; }
.collection-list button { display: flex; align-items: center; justify-content: space-between; min-height: 40px; text-align: left; }
.collection-list button span { color: var(--ink-600); font-size: 12px; }
.collection-empty { padding: 10px 0; }
.delete-confirm { width: min(360px, calc(100vw - 32px)); padding: 0; border: 1px solid #d8ded2; border-radius: 12px; color: var(--ink-950); background: #fcfbf4; box-shadow: 0 20px 60px rgba(8, 28, 20, .25); }
.delete-confirm::backdrop { background: rgba(11, 30, 23, .34); }
.delete-confirm form { display: grid; gap: 14px; padding: 22px; }
.delete-confirm h2, .delete-confirm p { margin: 0; }
.delete-confirm p { color: var(--ink-600); }
.delete-confirm label { display: flex; align-items: center; gap: 8px; }
.delete-confirm .actions { display: flex; justify-content: end; gap: 8px; margin-top: 4px; }
.delete-confirm .danger { color: white; border-color: #7a332d; background: #9b4038; }
.pixel-stage.multi-canvas::before { content: ""; position: absolute; inset: 0; z-index: 2; pointer-events: none; background-image: linear-gradient(to right, transparent calc(100% - 2px), rgba(24, 69, 49, .85) calc(100% - 2px)), linear-gradient(to bottom, transparent calc(100% - 2px), rgba(24, 69, 49, .85) calc(100% - 2px)); background-size: calc(100% / var(--canvas-cols)) 100%, 100% calc(100% / var(--canvas-rows)); }

#pixel-editor { width: min(1580px, calc(100vw - 32px)); max-height: calc(100vh - 32px); overflow: hidden; }
.editor-layout { grid-template-columns: 270px minmax(0, 1fr) 220px; min-height: 0; height: min(790px, calc(100vh - 145px)); }
.editor-leftbar { display: grid; align-content: start; gap: 18px; padding: 18px; overflow: auto; border-right: 1px solid #d8ded2; background: #fcfbf4; }
.editor-leftbar h3 { margin: 0 0 8px; color: var(--ink-600); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; }
.palette-panel { display: grid; gap: 9px; }
#palette-preset { min-height: 34px; border: 1px solid #b9cdbb; border-radius: 7px; background: #fffef9; padding: 0 8px; color: var(--ink-950); font: inherit; font-size: 12px; }
.palette-import { position: relative; display: flex !important; grid-template-columns: none !important; align-items: center; justify-content: center; min-height: 34px; overflow: hidden; border: 1px dashed #90ad91; border-radius: 7px; color: var(--spruce-800); font-size: 12px !important; cursor: pointer; }
.palette-import input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.tool-icons { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.tool-icons button { display: grid; place-items: center; min-height: 42px; padding: 0; border-radius: 7px; font-size: 20px; }
.tool-icons button.active { color: #fff; border-color: var(--spruce-800); background: var(--spruce-800); }
.editor-canvas-area { min-width: 0; min-height: 0; overflow: hidden; padding: 24px; background: #edf1e8; }
.pixel-stage { --pixel-size: 18px; flex: 0 0 auto; transition: transform .06s linear; }
.editor-sidebar { min-height: 0; overflow: auto; border-left: 1px solid #d8ded2; }
.editor-help { margin: 8px 0 0; color: var(--ink-600); font-size: 11px; line-height: 1.55; }
#palette-swatches { grid-template-columns: repeat(8, 1fr); max-height: 330px; overflow-x: hidden; overflow-y: auto; padding: 3px; }
.swatch { width: 20px; height: 20px; }
#page-composer .composer-panel { width: 100%; max-width: none !important; min-height: calc(100vh - 150px) !important; }
#page-composer .composer { height: calc(100vh - 315px) !important; min-height: 560px; grid-template-columns: 300px minmax(0, 1fr) !important; }
#page-composer .atlas-wrap { display: grid; place-items: center; overflow: auto; }
@media (max-width: 980px) { .editor-layout { grid-template-columns: 220px minmax(0, 1fr); } .editor-sidebar { grid-column: 1 / -1; display: flex; align-items: start; gap: 14px; border-top: 1px solid #d8ded2; border-left: 0; } .mosaic-candidates { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; } }
