:root {
  color-scheme: light;
  --bg: #f5eddf;
  --panel: #fffdf8;
  --panel-raised: #eff7ff;
  --panel-soft: #deeffc;
  --border: #d0e1ed;
  --border-strong: #86b9d8;
  --text: #193d62;
  --muted: #4e7090;
  --subtle: #627e94;
  --accent: #147bd1;
  --accent-dark: #0866b8;
  --accent-ink: #173d62;
  --sunshine: #ffe46c;
  --sunshine-border: #e4b834;
  --mint: #d8f4e7;
  --mint-ink: #23684f;
  --danger: #c94d52;
  --excel: #42bb82;
  --json: #d7c2fa;
  --surface-input: #ffffff;
  --workbench: #f1d6af;
  /* Presentation only. ArtConfig colours and IDs are never themed. */
  --board-empty: #fbfcfc;
  --board-alternate: #f3f6f7;
  --board-ruler: #eaf3fa;
  --board-grid: rgba(88, 113, 130, .23);
  --board-grid-major: rgba(76, 104, 125, .4);
  --board-hatch: rgba(80, 114, 139, .18);
  --wood-border: #d6b486;
  --wood-grain: repeating-linear-gradient(0deg, transparent 0 5px, #b9854010 5px 6px, transparent 6px 17px, #ffffff28 17px 18px);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --shadow-control: inset 0 1px 0 #ffffff, 0 2px 2px #3d709515;
  --shadow-panel: 0 3px 12px #97754512;
  --shadow-float: 0 20px 70px #557f9933;
  font-size: 14px;
  line-height: 1.45;
  font-family: Inter, "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; background: var(--bg); color: var(--text); }
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(--accent); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

.app-shell { height: 100%; display: grid; grid-template-rows: 68px minmax(0, 1fr); }
.app-header { position: relative; isolation: isolate; display: flex; align-items: center; gap: 12px; min-width: 0; padding: 0 18px; border-bottom: 3px solid #fff8e9; background: linear-gradient(#ffffff38, #ffffff18), url("./assets/workshop/sunny-sky-v1.webp") center / cover, #b8e7f8; box-shadow: 0 2px 8px #b09b7d26; z-index: 5; }
.brand { width: 178px; display: flex; align-items: center; gap: 9px; flex: 0 0 auto; }
.brand-mark { width: 43px; height: 43px; flex-shrink: 0; display: block; background: url("./assets/workshop/tools/pig.png") center / contain no-repeat; }
.brand-mark i { display: none; }
.brand strong { display: block; font-size: 22px; font-weight: 850; letter-spacing: -.04em; color: #20486f; }
.brand small { display: block; color: var(--muted); font-size: 11px; letter-spacing: .1em; }
.project-name { flex: 1 1 230px; min-width: 130px; max-width: 360px; }
.project-name input { width: 100%; height: 40px; padding: 0 13px; color: var(--text); background: #f3fbffeb; border: 1px solid #ffffff; border-radius: var(--radius-md); font-size: 14px; font-weight: 700; box-shadow: 0 3px 5px #478cba20, inset 0 1px 0 #ffffff; }
.project-name input:hover, .project-name input:focus { background: var(--panel-raised); border-color: var(--border-strong); }
.header-status { display: flex; align-items: center; gap: 7px; min-width: 0; max-width: 160px; color: var(--muted); font-size: 11px; white-space: nowrap; }
#saveStatus { overflow: hidden; text-overflow: ellipsis; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--excel); box-shadow: 0 0 0 3px rgba(65,194,125,.12); }
.header-status.saving .status-dot { background: #b47b0e; box-shadow: 0 0 0 3px rgba(247,201,72,.12); }
.account-button { margin-left: auto; flex: 0 0 auto; display: flex; align-items: center; gap: 10px; max-width: 210px; padding: 6px 11px; border: 1px solid #fff; border-radius: var(--radius-lg); background: var(--panel); box-shadow: var(--shadow-control); cursor: pointer; text-align: left; }
.account-button:hover { border-color: var(--accent-dark); }
.account-avatar { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0; overflow: hidden; background: #d6edbb; color: #477031; font-weight: 750; }
.account-avatar img { width: 100%; height: 100%; object-fit: cover; }
.account-copy { display: grid; gap: 2px; min-width: 0; }
.account-copy strong { font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.account-copy small { font-size: 12px; color: var(--muted); }
.app-header > .mode-switch, .app-header > .layer-switch, .app-header > #newBtn { flex-shrink: 0; white-space: nowrap; }
.app-header .layer-switch button { white-space: nowrap; }
.modal-card.profile-card { width: min(580px, 100%); }
.profile-card fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
.profile-avatar-row { display: flex; align-items: center; gap: 20px; margin: 16px 0 24px; }
.profile-avatar { width: 88px; height: 88px; font-size: 32px; border: 1px solid var(--border-strong); }
.profile-avatar-row .file-button { display: inline-flex; }
.profile-field { display: grid; gap: 8px; margin: 16px 0; color: var(--text); font-size: 13px; }
.profile-field input, .profile-field textarea { width: 100%; padding: 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text); background: var(--surface-input); }
.profile-field textarea { resize: vertical; min-height: 90px; max-height: 220px; }
.profile-field input[readonly] { color: var(--muted); }
.profile-field small { font-size: 13px; color: var(--muted); }
.profile-bindings { margin-top: 20px; padding-top: 14px; border-top: 1px solid var(--border); }
.profile-bindings h3 { margin: 0; font-size: 14px; }
.profile-bindings > div { display: flex; align-items: center; justify-content: space-between; padding: 14px 0; }
.profile-bindings span { display: grid; gap: 5px; font-size: 13px; }
.profile-bindings small { color: var(--muted); font-size: 13px; }
@media (max-width: 1400px) { .app-header { gap: 12px; } .account-copy { max-width: 90px; } .account-button { gap: 5px; padding: 4px 6px; } }
@media (max-width: 1100px) { .account-copy { display: none; } }
@media (max-width: 600px) { .profile-avatar-row { gap: 12px; } .profile-avatar { width: 64px; height: 64px; } }
.layer-switch { display: inline-flex; padding: 3px; background: #ffffffb8; border: 1px solid #fff; border-radius: var(--radius-md); box-shadow: var(--shadow-control); }
.mode-switch { display: inline-flex; padding: 3px; background: #ffffffdd; border: 1px solid #fff; border-radius: var(--radius-md); box-shadow: var(--shadow-control); }
.mode-switch button { height: 34px; padding: 0 14px; border: 0; border-radius: var(--radius-sm); color: var(--muted); background: transparent; cursor: pointer; font-size: 13px; }
.mode-switch button, #fitBtn { white-space: nowrap; }
.mode-switch button.active { color: var(--accent-ink); background: linear-gradient(#ffed91, var(--sunshine)); box-shadow: inset 0 1px 0 #fff9dc, 0 2px 3px #bd9d3833; font-weight: 800; }
.layer-switch button { height: 34px; padding: 0 10px; border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--muted); cursor: pointer; font-size: 13px; }
.layer-switch button b { margin-right: 5px; color: var(--subtle); font-family: Consolas, monospace; font-size: 12px; }
.layer-switch button.active { color: var(--accent-ink); background: linear-gradient(#ffed91, var(--sunshine)); box-shadow: inset 0 1px 0 #fff9dc, 0 2px 3px #bd9d3833; }
.layer-switch button.active b { color: var(--accent-ink); }

.workspace { min-height: 0; display: grid; grid-template-columns: 252px minmax(360px, 1fr) 308px; }
.panel { min-height: 0; overflow: auto; padding: 9px; background: #f8f2e8; scrollbar-width: thin; scrollbar-color: #c5cfd4 transparent; scrollbar-gutter: stable; }
.left-panel { display: flex; flex-direction: column; border-right: 1px solid #eadbc4; border-radius: 18px 18px 0 0; }
.left-panel > .panel-section { flex: 0 0 auto; }
.view-section { order: 1; }
.right-panel { border-left: 1px solid #eadbc4; border-radius: 18px 18px 0 0; }
.panel-section { padding: 13px; margin-bottom: 9px; border: 1px solid #ffffff; border-radius: var(--radius-lg); background: var(--panel); box-shadow: var(--shadow-panel); }
.props-only, .turret-only { display: none; }
body[data-mode="props"] .pattern-only, body[data-mode="props"] .turret-only { display: none; }
body[data-mode="props"] .props-only { display: block; }
body[data-mode="turrets"] .pattern-only, body[data-mode="turrets"] .props-only, body[data-mode="turrets"] .pattern-props-only { display: none; }
body[data-mode="turrets"] .turret-only { display: block; }
body[data-mode="turrets"] .layer-switch { display: none; }
body[data-mode="turrets"] .left-panel > .turret-only { display: flex; flex-direction: column; flex: 1 0 auto; }
body[data-mode="turrets"] .left-panel > .turret-only > :not(.deck-balance) { flex-shrink: 0; }
body[data-mode="turrets"] .left-panel > .workshop-note { flex: 0 0 auto; margin-top: 0; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.section-heading span { color: var(--text); font-size: 14px; font-weight: 800; letter-spacing: .015em; }
.section-heading em { color: var(--muted); font-size: 11px; font-style: normal; }
.helper { margin: 8px 0 0; color: var(--subtle); font-size: 12px; line-height: 1.65; }

.dimension-grid { display: grid; grid-template-columns: 1fr 14px 1fr; align-items: end; gap: 7px; margin-bottom: 9px; }
.dimension-grid > span { padding-bottom: 9px; color: var(--subtle); text-align: center; }
.dimension-grid label, .select-label { display: grid; gap: 6px; color: var(--muted); font-size: 12px; }
.dimension-grid input, select { min-width: 0; width: 100%; height: 38px; padding: 0 9px; border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text); background: var(--surface-input); font-size: 13px; }
input[type=number] { font-family: Consolas, monospace; font-weight: 700; }

.button, .icon-button, .zoom-value, .tool { border: 1px solid #bfdcf1; background: linear-gradient(#fbfeff, #e9f4ff); color: var(--text); cursor: pointer; transition: border-color .15s, background .15s, box-shadow .15s; }
.button:hover, .icon-button:hover, .zoom-value:hover, .tool:hover { border-color: var(--border-strong); background: var(--panel-soft); }
.button:active, .icon-button:active, .tool:active { box-shadow: inset 0 2px 4px #6d9fc333; }
.button { min-height: 38px; padding: 7px 12px; border-radius: var(--radius-sm); font-size: 13px; font-weight: 600; line-height: 1.4; box-shadow: var(--shadow-control); }
.button.full { width: 100%; }
.button.compact { min-height: 34px; }
.button.primary { color: var(--accent-ink); border-color: var(--sunshine-border); background: linear-gradient(#ffed85, #ffdc4d); box-shadow: inset 0 1px 0 #fff9d0, 0 2px 3px #bb922927; }
.button.primary:hover { background: #ffed87; border-color: #c39418; }
.button.secondary { background: linear-gradient(#fbfeff, #e7f3fe); color: var(--accent-dark); }
.button.ghost { background: linear-gradient(#ffffff, #edf6fd); }
.button:disabled { opacity: .48; cursor: not-allowed; box-shadow: none; }
.danger-text { color: var(--danger); border-color: #efcbcc; background: #fff1f1; }
.file-button { display: flex; align-items: center; justify-content: center; cursor: pointer; }
.file-button input { display: block; position: absolute; width: 1px; height: 1px; opacity: 0; }

.tool-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.tool { position: relative; min-height: 62px; display: grid; grid-template-columns: 30px 1fr; align-items: center; gap: 7px; padding: 9px; border-radius: var(--radius-md); text-align: left; box-shadow: var(--shadow-control); }
.tool.active { border-color: #59b894; background: linear-gradient(#e2f8ea, #bcebd2); box-shadow: inset 0 0 0 1px #83cea5, 0 2px 3px #65967b22; color: #19593e; }
.tool-icon { display: grid; place-items: center; width: 30px; height: 34px; }
.tool.active .tool-icon { color: var(--mint-ink); }
.tool b { font-size: 13px; }
.tool kbd { position: absolute; right: 7px; bottom: 4px; color: var(--muted); font: 10px Consolas, monospace; }
.prop-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; margin-bottom: 9px; }
.prop-card { min-width: 0; min-height: 110px; display: grid; grid-template-columns: 1fr; justify-items: center; align-content: center; gap: 4px; padding: 10px 4px; border: 1px solid var(--border); border-radius: var(--radius-md); color: var(--text); background: var(--panel-raised); cursor: pointer; text-align: center; }
.prop-card:hover, .prop-card.active { border-color: #68bb94; background: #e4f7ea; }
.prop-card:disabled { opacity: .35; cursor: not-allowed; filter: grayscale(.65); }
.prop-card:disabled:hover { border-color: var(--border); background: var(--panel-raised); }
.prop-card i { width: 42px; height: 42px; display: grid; place-items: center; border-radius: var(--radius-md); background-color: var(--surface-input); }
.prop-card-icon { background-repeat: no-repeat; background-position: center; background-size: 38px 38px; }
.prop-icon-life { background-image: url('./assets/props/life.png'); }
.prop-icon-snake { background-image: url('./assets/props/snake.png'); }
.prop-icon-stretch { background-image: url('./assets/props/stretch.png'); }
.prop-icon-vomit { background-image: url('./assets/props/vomit.png'); }
.prop-icon-question { background-image: url('./assets/props/question.png'); }
.prop-icon-question-large { background-image: url('./assets/props/question-large.png'); }
.prop-icon-key { background-image: url('./assets/props/key.png'); }
.prop-icon-spike { background-image: url('./assets/props/spike.png'); }
.prop-card b { min-width: 0; font-size: 13px; }
.prop-card small { color: var(--muted); font-size: 10px; white-space: nowrap; }
.action-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.range-row { display: grid; grid-template-columns: auto 1fr 32px; align-items: center; gap: 8px; margin: 12px 0; color: var(--muted); font-size: 12px; }
.range-row input { accent-color: var(--accent); min-width: 0; }
.range-row output { color: var(--text); font-family: Consolas, monospace; text-align: right; }
.toggle-row { position: relative; display: flex; align-items: center; justify-content: space-between; min-height: 36px; gap: 8px; color: var(--muted); font-size: 13px; cursor: pointer; }
.toggle-row input { position: absolute; right: 0; width: 34px; height: 20px; opacity: 0; }
.toggle-row i { position: relative; width: 34px; height: 20px; flex-shrink: 0; border-radius: 12px; background: #c8d5df; box-shadow: inset 0 1px 2px #66819926; pointer-events: none; }
.toggle-row i::after { content: ""; position: absolute; width: 14px; height: 14px; left: 3px; top: 3px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px #547c9e38; transition: left .15s; }
.toggle-row input:checked + i { background: linear-gradient(100deg, #4cd1b5, #36bd86); }
.toggle-row input:checked + i::after { left: 17px; background: #fff; }

.editor-area { min-width: 0; min-height: 0; display: grid; grid-template-rows: 56px minmax(0, 1fr) 34px; background: var(--workbench); }
.command-bar { display: flex; align-items: center; gap: 10px; padding: 0 14px; border: 1px solid #fff9ed; border-bottom-color: #e9ccaa; background: linear-gradient(#fffaf2, #faf0df); }
.command-group, .zoom-controls { display: flex; align-items: center; gap: 5px; }
.icon-button, .zoom-value { min-width: 34px; height: 34px; border-radius: var(--radius-sm); }
.zoom-value { min-width: 55px; color: var(--muted); font: 11px Consolas, monospace; }
.divider { width: 1px; height: 22px; background: var(--border); }
.canvas-meta { display: grid; gap: 2px; min-width: 0; }
.canvas-meta strong { font-size: 13px; }
.canvas-meta span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font: 11px Consolas, monospace; }
.zoom-controls { margin-left: auto; }
.canvas-viewport { position: relative; isolation: isolate; min-width: 0; min-height: 0; overflow: auto; overscroll-behavior: contain; background: linear-gradient(#fff8ef1a, #fff8ef1a), url("./assets/workshop/sunny-desk-v1.webp") center / 100% 100% no-repeat, var(--workbench); scrollbar-color: #c7a57d #f5dfc1; }
.canvas-viewport.panning { cursor: grabbing; user-select: none; }
.canvas-stage { position: relative; z-index: 1; width: max-content; height: max-content; min-width: 100%; min-height: 100%; display: grid; place-items: center; padding: 48px; }
#editorCanvas { display: block; image-rendering: pixelated; border-radius: 3px; box-shadow: 0 0 0 1px #bfcdd5, 0 0 0 7px #fffaf0, 0 2px 5px 8px #9b703628; background: var(--board-empty); cursor: crosshair; touch-action: none; }
.deck-workspace { min-width: 0; min-height: 0; overflow: auto; padding: 22px; background: var(--wood-grain), linear-gradient(120deg, #f7e3c7, #edcfaa); scrollbar-color: #c7a57d #f5dfc1; }
.deck-workspace[hidden] { display: none; }
.deck-intro { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px 16px; margin: 0 0 20px; }
.deck-intro b { font-size: 18px; }
.deck-intro span { color: var(--muted); font-size: 12px; }
.deck-columns { --turret-scale: 1; --deck-gap: max(10px, calc(16px * var(--turret-scale))); --deck-column-min: max(200px, calc(264px * var(--turret-scale))); --deck-column-max: max(220px, calc(320px * var(--turret-scale))); --lock-size: max(30px, calc(40px * var(--turret-scale))); position: relative; isolation: isolate; width: 100%; min-width: calc(var(--deck-cols, 3) * var(--deck-column-min) + (var(--deck-cols, 3) - 1) * var(--deck-gap)); max-width: calc(var(--deck-cols, 3) * var(--deck-column-max) + (var(--deck-cols, 3) - 1) * var(--deck-gap)); margin: 0 auto; padding-top: var(--chain-space, 0px); display: grid; grid-template-columns: repeat(var(--deck-cols, 3), minmax(0, 1fr)); gap: var(--deck-gap); align-items: start; }
.deck-column { position: relative; min-width: 0; padding: calc(12px * var(--turret-scale)); border: 1px solid #fff; border-radius: var(--radius-lg); background: #fff9ed; box-shadow: 0 3px 0 #d8bb94, 0 8px 14px #926b3720; }
.deck-chain-overlay { position: absolute; inset: 0; z-index: 10; width: 100%; height: 100%; pointer-events: none; filter: drop-shadow(0 1px 1px #65441c38); }
.deck-column-header { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 4px; margin-bottom: 14px; color: var(--muted); font-size: 11px; }
.deck-column-header b { color: var(--text); font-size: 14px; }
.pig-list { display: grid; gap: max(6px, calc(12px * var(--turret-scale))); min-height: 64px; }
.pig-card { position: relative; z-index: 3; min-height: 0; display: grid; grid-template-columns: calc(88px * var(--turret-scale)) minmax(0, 1fr) var(--lock-size); align-items: center; gap: max(4px, calc(7px * var(--turret-scale))); padding: max(7px, calc(10px * var(--turret-scale))); border: 1px solid #c8dfef; border-radius: var(--radius-md); background: linear-gradient(#fff, #edf7ff); box-shadow: inset 0 1px 0 #fff, 0 3px 0 #c9dce8, 0 5px 8px #527c9420; cursor: grab; }
.pig-card.chained { padding-top: max(20px, calc(22px * var(--turret-scale))); }
.pig-card.masked, .pig-card.frozen { padding-top: max(24px, calc(22px * var(--turret-scale))); }
.pig-card:hover, .pig-card.selected { border-color: var(--accent); }
.pig-card.selected { outline: 2px solid var(--accent); outline-offset: 2px; }
.pig-card.locked { border-color: #d4ab48; box-shadow: inset 0 0 0 1px #f1d080, 0 3px 0 #dfc98f; cursor: not-allowed; }
.pig-card.masked { border-color: #b6a0db; background: linear-gradient(135deg, #f7f1ff, #ede1fa); }
.pig-lock { position: static; grid-column: 3; grid-row: 1; align-self: center; justify-self: end; width: var(--lock-size); height: var(--lock-size); padding: 2px; border: 0; border-radius: var(--radius-sm); background: transparent; box-shadow: none; cursor: pointer; }
.pig-lock:hover { background: transparent; filter: drop-shadow(0 1px 3px #5a839955); }
.pig-lock-toggle.active { border-color: #b47b0e; color: #b47b0e; }
.pig-icon { grid-column: 1; grid-row: 1; position: relative; display: grid; place-items: center; width: calc(88px * var(--turret-scale)); height: calc(96px * var(--turret-scale)); border: 0; background: transparent; font-style: normal; }
.deck-lock-card { border-color: #e3bd67; background: linear-gradient(#fff9e7, #fff0c3); }
.deck-lock-icon { grid-column: 1; grid-row: 1; display: grid; place-items: center; width: calc(88px * var(--turret-scale)); height: calc(96px * var(--turret-scale)); font-style: normal; }
.deck-lock-inspector { display: flex; align-items: center; gap: 10px; padding: 10px; border: 1px solid rgba(247,201,72,.42); border-radius: var(--radius-sm); background: rgba(247,201,72,.07); }
.deck-lock-inspector > i { width: 34px; height: 34px; display: grid; place-items: center; border-radius: var(--radius-sm); color: #b47b0e; background: #ffebae; font-size: 19px; font-style: normal; }
.deck-lock-inspector b { display: block; color: #946811; font-size: 12px; }
.deck-lock-inspector p { margin: 3px 0 0; color: var(--muted); font: 11px Consolas, monospace; }
.pig-ammo-badge { position: absolute; left: 50%; bottom: 0; transform: translateX(-50%); min-width: 30px; height: 24px; padding: 0 6px; display: grid; place-items: center; border: 2px solid #fff; border-radius: 12px; color: #fff; background: #254967; box-shadow: 0 2px 4px #38516c30; font: 800 13px/1 Consolas, monospace; pointer-events: none; }
.pig-copy { grid-column: 2; grid-row: 1; min-width: 0; display: grid; gap: calc(7px * var(--turret-scale)); align-content: center; }
.pig-copy b { font-size: clamp(12px, calc(14px * var(--turret-scale)), 23px); line-height: 1.4; overflow-wrap: anywhere; }
.pig-copy small { color: var(--text); font-size: clamp(12px, calc(12px * var(--turret-scale)), 20px); line-height: 1.5; }
.pig-chain-badge { position: absolute; top: 4px; left: 8px; color: var(--accent); font: 11px Consolas, monospace; }
.pig-key-pair { position: absolute; right: 5px; bottom: 4px; color: #b47b0e; font: 800 11px Consolas, monospace; }
.pig-mask-toggle.active { border-color: #9b8cff; color: #7752ac; background: rgba(155,140,255,.10); }
.key-pair-hint { margin: 0; padding: 8px 9px; border: 1px solid rgba(247,201,72,.34); border-radius: var(--radius-sm); color: #8d6416; background: rgba(247,201,72,.06); font-size: 12px; line-height: 1.45; }
.deck-add { width: 100%; min-height: 40px; margin-top: 14px; border: 1px dashed #8fb6d1; border-radius: var(--radius-md); color: var(--accent-dark); background: #eef8ff; font-size: 13px; font-weight: 700; cursor: pointer; }
.deck-add:hover { color: var(--accent-dark); border-color: var(--accent); background: #deefff; }
.empty-hint { position: absolute; z-index: 2; left: 50%; top: 50%; width: max-content; max-width: 85%; display: grid; gap: 7px; transform: translate(-50%, -50%); padding: 18px 24px; border: 1px solid #fff; border-radius: var(--radius-lg); color: var(--text); background: #fffdf6f2; text-align: center; pointer-events: none; box-shadow: var(--shadow-float); }
.empty-hint strong { font-size: 14px; }
.empty-hint span { color: var(--subtle); font-size: 12px; }
.empty-hint::before { content: ""; display: block; width: 108px; height: 88px; margin: -8px auto 0; background: url('./assets/workshop/empty-tray-v1.webp') center / contain no-repeat; }
.empty-hint.hidden { display: none; }
.editor-statusbar { display: flex; align-items: center; gap: 16px; min-width: 0; padding: 0 14px; border-top: 1px solid #dce8ed; color: var(--muted); background: #f2f9fd; font-size: 11px; }
.editor-statusbar > span { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.editor-statusbar .status-tip { margin-left: auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; color: var(--subtle); }
.status-swatch { width: 12px; height: 12px; border: 1px solid rgba(255,255,255,.35); border-radius: 3px; }

.palette-section { position: relative; padding-bottom: 13px; }
.palette-section .section-heading { padding-right: 30px; }
.palette-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 7px; }
.swatch { position: relative; aspect-ratio: 1; padding: 0; border: 1px solid #8195a326; border-radius: 8px; cursor: pointer; box-shadow: inset 0 2px 0 #ffffff80, inset 0 -2px 0 #00000016, 0 2px 3px #54738e24; }
.swatch:hover { z-index: 1; outline: 2px solid var(--text); outline-offset: 2px; }
.swatch.active { outline: 2px solid var(--accent); outline-offset: 2px; z-index: 2; }
.swatch span { position: absolute; right: 2px; bottom: 2px; font: 800 10px/1.3 Consolas, monospace; }
.swatch-add { position: absolute; top: 10px; right: 12px; width: 25px; height: 25px; border: 1px dashed var(--border-strong); border-radius: var(--radius-sm); color: var(--accent); background: #f4faff; cursor: pointer; font-size: 20px; line-height: 1; }
.swatch-add:hover { border-color: var(--accent); background: rgba(211,236,130,.08); }
.batch-section { background: var(--panel); }
.replace-arrow { height: 12px; display: grid; place-items: center; color: var(--accent); font-size: 12px; }
.check-row { display: flex; align-items: center; gap: 8px; margin: 12px 0; color: var(--muted); font-size: 13px; }
.check-row input { accent-color: var(--accent); }
.stats-list { max-height: 135px; overflow: auto; scrollbar-width: thin; }
.stat-row { display: grid; grid-template-columns: 14px minmax(48px, 1fr) minmax(38px, .8fr) 30px; align-items: center; gap: 7px; min-height: 27px; padding: 2px 4px; border-radius: 5px; color: var(--muted); font-size: 12px; cursor: pointer; }
.stat-row:hover { background: var(--panel-soft); }
.stat-row i { width: 12px; height: 12px; border-radius: 3px; border: 1px solid rgba(255,255,255,.2); }
.stat-row b { color: var(--text); font-family: Consolas, monospace; }
.empty-copy { color: var(--subtle); font-size: 12px; text-align: center; padding: 12px 0; }
.inspector-form { display: grid; gap: 10px; }
.inspector-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.inspector-form label { display: grid; gap: 5px; color: var(--muted); font-size: 12px; }
.inspector-form input, .inspector-form select { min-width: 0; width: 100%; height: 38px; padding: 0 8px; border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text); background: var(--surface-input); font-size: 13px; }
.inspector-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.stage-list { display: grid; gap: 7px; }
.stage-row { display: grid; grid-template-columns: 1fr 72px 28px; gap: 6px; align-items: end; padding: 7px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: rgba(255,255,255,.02); }
.path-tools, .chain-tools { display: flex; flex-wrap: wrap; gap: 5px; }
.path-tools .button, .chain-tools .button { flex: 1 1 42px; padding: 0 7px; }
.export-section { display: grid; gap: 8px; }
.export-section .section-heading { margin-bottom: 4px; }
.reference-image-actions { display: grid; gap: 7px; }
.button.excel, .button.json { min-height: 42px; display: grid; grid-template-columns: 46px 1fr; align-items: center; padding: 0; text-align: left; overflow: hidden; }
.button.excel span, .button.json span { height: 100%; display: grid; place-items: center; color: #101b14; background: var(--excel); font: 11px Consolas, monospace; }
.button.json span { color: #161127; background: var(--json); }
.button.excel b, .button.json b { padding-left: 11px; font-size: 13px; }
.random-deck-button { margin-top: 10px; }
.random-deck-button span { margin-right: 5px; font-size: 15px; }
.turret-ammo-toggle { margin-top: 11px; }
.turret-size-control { grid-template-columns: minmax(0, 1fr) 48px; }
.turret-size-control input { grid-column: 1 / -1; width: 100%; margin: 0; }
.deck-balance { display: flex; flex-direction: column; flex: 1 1 220px; min-height: 180px; margin-top: 12px; overflow: hidden; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-input); }
.deck-balance-summary { flex: 0 0 auto; padding: 9px 10px; color: var(--muted); font-size: 12px; font-weight: 700; line-height: 1.45; }
.deck-balance.ok { border-color: rgba(65,194,125,.5); }
.deck-balance.ok .deck-balance-summary { color: #258357; background: rgba(65,194,125,.07); }
.deck-balance.warning { border-color: rgba(255,107,103,.55); }
.deck-balance.warning .deck-balance-summary { color: #c44c51; background: rgba(255,107,103,.08); }
.deck-balance-list { flex: 1 1 0; min-height: 100px; overflow: auto; border-top: 1px solid var(--border); }
.deck-balance-list:empty { display: none; }
.deck-balance-row { display: grid; grid-template-columns: 12px minmax(0, 1fr) auto 26px; align-items: center; gap: 6px; min-height: 52px; padding: 7px 6px; border-bottom: 1px solid var(--border); color: var(--muted); font-size: 12px; }
.deck-balance-row:last-child { border-bottom: 0; }
.deck-balance-row i { width: 11px; height: 11px; border: 1px solid rgba(255,255,255,.22); border-radius: 3px; }
.deck-balance-row span { min-width: 0; white-space: normal; overflow-wrap: anywhere; }
.deck-balance-copy { display: grid; gap: 2px; line-height: 1.4; }
.deck-balance-copy > span:last-child { font-size: 11px; }
.deck-balance-row b { color: var(--text); font: 11px Consolas, monospace; white-space: nowrap; }
.deck-balance-row.shortage b { color: #c44c51; }
.deck-balance-row.excess b { color: #b47b0e; }
.deck-balance-row.locked { background: rgba(247,201,72,.06); }
.deck-balance-row.key-lock-mismatch { color: #b74448; background: rgba(255,107,103,.06); }
.deck-balance-row.key-lock-mismatch i { display: grid; place-items: center; border: 0; font-style: normal; }
.deck-balance-row.key-lock-mismatch b { color: #c44c51; }
.deck-color-lock { width: 24px; height: 23px; padding: 0; border: 1px solid transparent; border-radius: 4px; background: rgba(255,255,255,.04); color: var(--text); cursor: pointer; font-size: 13px; }
.deck-color-lock img { width: 20px; height: 20px; object-fit: contain; vertical-align: middle; }
.deck-color-lock:hover, .deck-balance-row.locked .deck-color-lock { border-color: rgba(247,201,72,.55); background: rgba(247,201,72,.10); }

.toast { position: fixed; left: 50%; bottom: 44px; z-index: 20; max-width: 520px; padding: 10px 15px; border: 1px solid #4a5158; border-radius: var(--radius-sm); color: #fff; background: rgba(29,33,36,.96); box-shadow: 0 12px 35px rgba(0,0,0,.4); font-size: 12px; transform: translate(-50%, 18px); opacity: 0; pointer-events: none; transition: .2s; }
.toast.show { transform: translate(-50%, 0); opacity: 1; }
.toast.error { border-color: rgba(255,107,103,.7); }

.cloud-button { flex: 0 0 auto; white-space: nowrap; }
.publish-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.publish-actions .button { min-width: 0; padding: 0 8px; }
.difficulty-section { display: grid; grid-template-columns: minmax(0, 1fr) 72px; gap: 0 7px; background: var(--panel); }
.difficulty-section .section-heading { grid-column: 1 / -1; }
.difficulty-section .difficulty-overview { min-height: 60px; padding: 8px; margin-bottom: 0; gap: 4px; }
.difficulty-section .difficulty-overview > b { min-width: 20px; font-size: 18px; }
.difficulty-section .button { padding: 5px; }
.difficulty-overview { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 10px; min-height: 64px; margin-bottom: 9px; padding: 10px 11px; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface-input); }
.difficulty-overview div, .difficulty-overview span, .difficulty-overview small { display: block; }
.difficulty-overview span { color: var(--text); font-size: 12px; font-weight: 780; }
.difficulty-overview small { margin-top: 4px; color: var(--subtle); font-size: 12px; line-height: 1.4; }
.difficulty-overview > b { min-width: 46px; color: var(--muted); font: 800 22px/1 Consolas, monospace; text-align: right; }
.difficulty-overview.simple { border-color: rgba(65,194,125,.55); background: rgba(65,194,125,.06); }
.difficulty-overview.simple > b { color: #258357; }
.difficulty-overview.medium { border-color: rgba(247,201,72,.55); background: rgba(247,201,72,.055); }
.difficulty-overview.medium > b { color: #b47b0e; }
.difficulty-overview.hard, .difficulty-overview.impossible { border-color: rgba(255,107,103,.58); background: rgba(255,107,103,.06); }
.difficulty-overview.hard > b, .difficulty-overview.impossible > b { color: #c5484e; }
.modal-backdrop { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 24px; background: #43688555; backdrop-filter: blur(5px); }
.modal-backdrop[hidden] { display: none; }
.auth-backdrop { z-index: 80; background: radial-gradient(ellipse at 15% 15%, #fffefa, transparent 60%), linear-gradient(135deg, #b9e8fa, #e5f6ff 60%, #fff2d9); }
.modal-card { width: min(680px, 100%); max-height: min(820px, calc(100vh - 48px)); overflow: auto; padding: 24px; border: 1px solid #fff; border-radius: var(--radius-lg); background: var(--panel); box-shadow: var(--shadow-float); }
.compact-modal { width: min(410px, 100%); }
.auth-card { width: min(860px, 100%); display: grid; grid-template-columns: minmax(0, .9fr) minmax(0, 1fr); padding: 0; }
.auth-form-panel { min-width: 0; padding: 28px; }
.auth-welcome { position: relative; min-width: 0; display: flex; flex-direction: column; justify-content: center; padding: 32px; border-right: 1px solid var(--border); background: radial-gradient(ellipse at 50% 65%, #fff9df, transparent 68%), linear-gradient(145deg, #d6f0fd, #e8f8ff); }
.auth-welcome-label { color: var(--accent); font-size: 11px; font-weight: 700; letter-spacing: .12em; }
.auth-welcome h2 { margin: 22px 0 12px; color: var(--text); font-size: 30px; line-height: 1.45; letter-spacing: .025em; }
.auth-welcome p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.9; }
.auth-welcome-art { flex: 1 0 290px; min-height: 290px; margin: 0 -22px; background: url('./assets/workshop/welcome-v1.webp') center / contain no-repeat; pointer-events: none; }
.auth-welcome-caption { color: var(--muted); font-size: 11px; letter-spacing: .04em; text-align: center; }
@media (max-width: 760px), (max-height: 620px) {
  .auth-card { width: min(440px, 100%); grid-template-columns: minmax(0, 1fr); }
  .auth-welcome { display: none; }
  .auth-form-panel { padding: 24px; }
}
.modal-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.modal-brand .brand-mark { flex: 0 0 auto; }
.modal-brand b, .modal-brand small { display: block; }
.modal-brand b { font-size: 15px; }
.modal-brand small { margin-top: 3px; color: var(--muted); font-size: 12px; }
.modal-brand > div { min-width: 0; flex: 1; }
.auth-cancel { flex: 0 0 auto; margin-left: auto; }
.modal-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 3px; padding: 3px; margin-bottom: 20px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-input); }
.modal-tabs button { height: 34px; border: 0; border-radius: var(--radius-sm); color: var(--muted); background: transparent; cursor: pointer; }
.modal-tabs button.active { color: var(--accent-ink); background: var(--sunshine); font-weight: 750; box-shadow: var(--shadow-control); }
.modal-form { display: grid; gap: 13px; }
.modal-form h2, .modal-heading h2 { margin: 0; font-size: 16px; }
.auth-copy { margin: -4px 0 1px; color: var(--muted); font-size: 12px; line-height: 1.55; }
.modal-form label, .color-picker-row label { display: grid; gap: 6px; color: var(--muted); font-size: 12px; }
.modal-form input, .modal-form textarea, .color-picker-row input[type=text], .color-picker-row label input { width: 100%; height: 38px; padding: 0 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text); background: var(--surface-input); }
.modal-form textarea { height: auto; min-height: 84px; padding: 9px 10px; resize: vertical; line-height: 1.5; }
.form-error { min-height: 16px; margin: -2px 0 0; color: var(--danger); font-size: 12px; }
.auth-divider { position: relative; display: grid; place-items: center; margin: 18px 0 13px; color: var(--subtle); font-size: 12px; }
.auth-divider::before { content: ""; position: absolute; inset: 50% 0 auto; height: 1px; background: var(--border); }
.auth-divider span { position: relative; padding: 0 10px; background: var(--panel); }
.auth-provider-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.auth-provider { display: flex; align-items: center; justify-content: center; gap: 8px; color: var(--text); background: var(--surface-input); border-color: var(--border); }
.auth-provider:hover { border-color: var(--border-strong); background: var(--panel-raised); }
.auth-provider i { width: 18px; height: 18px; display: grid; place-items: center; font-style: normal; font-weight: 900; }
.google-mark { color: #4285f4; font-family: Arial, sans-serif; }
.apple-mark { color: var(--text); font-size: 12px; }
.auth-guest { margin-top: 10px; }
.auth-footnote { margin: 12px 0 0; color: var(--subtle); font-size: 12px; line-height: 1.5; text-align: center; }
.modal-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 18px; }
.modal-heading p { margin: 5px 0 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
.modal-close { width: 30px; height: 30px; border: 0; border-radius: var(--radius-sm); color: var(--muted); background: transparent; cursor: pointer; font-size: 21px; }
.modal-close:hover { color: var(--accent-dark); background: var(--panel-soft); }
.color-picker-row { display: grid; grid-template-columns: 82px 1fr; align-items: end; gap: 12px; }
.color-picker-row input[type=color] { width: 82px; height: 62px; padding: 3px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-input); cursor: pointer; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }
.crop-card { width: min(840px, 100%); }
.crop-stage { position: relative; min-height: 250px; display: grid; place-items: center; overflow: hidden; padding: 14px; border: 1px solid var(--border); border-radius: 10px; background-color: #e8eff4; background-image: linear-gradient(45deg, rgba(255,255,255,.035) 25%, transparent 25%), linear-gradient(-45deg, rgba(255,255,255,.035) 25%, transparent 25%), linear-gradient(45deg, transparent 75%, rgba(255,255,255,.035) 75%), linear-gradient(-45deg, transparent 75%, rgba(255,255,255,.035) 75%); background-position: 0 0, 0 8px, 8px -8px, -8px 0; background-size: 16px 16px; }
#referenceCropCanvas { display: block; width: auto; height: auto; max-width: 100%; max-height: min(52vh, 500px); border: 2px solid var(--accent); border-radius: 3px; background: #fff; box-shadow: var(--shadow-panel); cursor: grab; touch-action: none; }
#referenceCropCanvas.dragging { cursor: grabbing; }
.crop-drag-tip { position: absolute; right: 22px; bottom: 20px; padding: 5px 8px; border-radius: var(--radius-sm); color: rgba(255,255,255,.74); background: rgba(7,9,10,.72); font-size: 12px; pointer-events: none; }
.crop-controls { display: grid; grid-template-columns: 32px minmax(120px, 1fr) 32px 54px auto; align-items: center; gap: 9px; margin-top: 13px; }
.crop-controls input[type=range] { width: 100%; accent-color: var(--accent); }
.crop-controls output { color: var(--text); font: 11px Consolas, monospace; text-align: center; }
.crop-palette-panel { margin-top: 13px; overflow: hidden; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface-input); }
.crop-palette-toggle { min-height: 54px; display: grid; grid-template-columns: minmax(0, 1fr) 38px; align-items: center; gap: 12px; padding: 9px 12px; cursor: pointer; }
.crop-palette-toggle span, .crop-palette-toggle b, .crop-palette-toggle small { display: block; }
.crop-palette-toggle b { color: var(--text); font-size: 13px; }
.crop-palette-toggle small { margin-top: 3px; color: var(--muted); font-size: 12px; line-height: 1.4; }
.crop-palette-toggle input { position: absolute; opacity: 0; pointer-events: none; }
.crop-palette-toggle i { position: relative; width: 36px; height: 20px; border-radius: 12px; background: #c8d5df; transition: .18s; }
.crop-palette-toggle i::after { content: ""; position: absolute; top: 3px; left: 3px; width: 14px; height: 14px; border-radius: 50%; background: #fff; transition: .18s; }
.crop-palette-toggle input:checked + i { background: var(--accent-dark); }
.crop-palette-toggle input:checked + i::after { left: 19px; background: var(--accent); }
.crop-palette-toggle input:focus-visible + i { outline: 2px solid var(--accent); outline-offset: 2px; }
.crop-palette-options { padding: 11px 12px 12px; border-top: 1px solid var(--border); }
.crop-palette-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 9px; }
.crop-palette-heading span { color: var(--muted); font-size: 12px; font-weight: 700; }
.crop-palette-grid { display: grid; grid-template-columns: repeat(auto-fill, 36px); justify-content: start; gap: 7px; }
.crop-palette-color { position: relative; width: 36px; height: 36px; padding: 0; border: 2px solid transparent; border-radius: var(--radius-sm); background: var(--crop-color); box-shadow: inset 0 0 0 1px rgba(255,255,255,.22); cursor: pointer; }
.crop-palette-color span { position: absolute; right: 2px; bottom: 2px; padding: 1px 2px; border-radius: 3px; color: #fff; background: rgba(0,0,0,.58); font: 11px Consolas, monospace; }
.crop-palette-color.selected { border-color: var(--accent); box-shadow: 0 0 0 1px #111, 0 0 0 3px rgba(211,236,130,.28); }
.crop-palette-color.selected::after { content: "✓"; position: absolute; top: 2px; right: 2px; width: 14px; height: 14px; display: grid; place-items: center; border-radius: 50%; color: #111; background: var(--accent); box-shadow: 0 1px 4px rgba(0,0,0,.55); font: 900 11px/1 Arial, sans-serif; }
.crop-palette-options p { margin: 9px 0 0; color: var(--subtle); font-size: 12px; line-height: 1.45; }
.cloud-card { width: min(1320px, 100%); height: min(980px, calc(100dvh - 64px)); max-height: calc(100dvh - 64px); padding: 28px; display: flex; flex-direction: column; overflow: hidden; }
.cloud-card .modal-heading h2 { font-size: 22px; }
.cloud-card .modal-heading p { font-size: 13px; }
.cloud-card > :not(.cloud-list) { flex-shrink: 0; }
.cloud-search-row { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.cloud-search { flex: 1; min-width: 0; }
.cloud-search input, .cloud-sort select { width: 100%; height: 40px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); padding: 0 12px; background: var(--surface-input); color: var(--text); }
.cloud-sort { flex: 0 0 126px; }
.cloud-result-count { color: var(--muted); font-size: 12px; margin-bottom: 14px; }
.cloud-error { margin: 0 0 10px; padding: 10px; color: #b74448; background: rgba(255,107,103,.08); border-radius: var(--radius-sm); font-size: 12px; }
.cloud-pagination { display: flex; align-items: center; justify-content: center; gap: 18px; margin-top: 14px; font-size: 12px; color: var(--muted); }
.cloud-pagination button:disabled { opacity: .4; cursor: default; }
.cloud-toolbar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.cloud-list { flex: 1; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); align-content: start; gap: 12px; min-height: 80px; overflow: auto; padding: 3px; }
.cloud-list > .empty-copy { grid-column: 1 / -1; padding: 28px 12px; text-align: center; }
.cloud-list > .cloud-empty::before { content: ""; display: block; width: 140px; height: 116px; margin: 8px auto 14px; background: url('./assets/workshop/empty-tray-v1.webp') center / contain no-repeat; pointer-events: none; }
.cloud-project { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: start; gap: 4px; padding: 6px; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface-input); }
.cloud-project:hover { border-color: var(--border-strong); background: var(--panel-raised); }
.cloud-project-open { display: flex; gap: 12px; align-items: center; min-width: 0; padding: 8px; border: 0; border-radius: var(--radius-sm); text-align: left; color: var(--text); background: transparent; cursor: pointer; }
.cloud-project-open:disabled { cursor: default; }
.cloud-project-preview { display: grid; place-items: center; flex: 0 0 148px; height: 148px; overflow: hidden; border: 1px solid var(--border); border-radius: var(--radius-md); color: var(--muted); background: var(--surface-input); font-size: 12px; }
.cloud-project-preview img { width: 100%; height: 100%; object-fit: contain; }
.cloud-current-label { color: var(--accent); font-size: 13px; }
.cloud-project.current { border-color: var(--accent-dark); background: rgba(211,236,130,.045); }
.cloud-project-copy { min-width: 0; display: grid; gap: 12px; }
.cloud-project-copy b { overflow-wrap: anywhere; font-size: 18px; line-height: 1.4; }
.cloud-project-copy small { color: var(--muted); font-size: 12px; }
.cloud-delete { width: 30px; height: 30px; border: 0; border-radius: var(--radius-sm); color: var(--danger); background: transparent; cursor: pointer; }
.cloud-delete:hover { background: rgba(255,107,103,.09); }
@media (max-width: 1199px) {
  .cloud-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .cloud-list { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 600px) {
  .cloud-card { padding: 16px; max-height: calc(100dvh - 24px); }
  #cloudDialog { padding: 12px; }
  .cloud-list { grid-template-columns: minmax(0, 1fr); }
  .cloud-search-row { flex-wrap: wrap; }
  .cloud-sort { flex-basis: 100%; }
  .cloud-toolbar .button { font-size: 12px; padding: 0 8px; }
  .cloud-project-open { gap: 12px; padding: 4px; }
  .cloud-project-preview { flex-basis: 92px; height: 92px; }
  .cloud-project-copy b { font-size: 15px; }
  .cloud-project-copy small { font-size: 13px; }
}
.modal-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 17px; padding-top: 14px; border-top: 1px solid var(--border); color: var(--muted); font-size: 12px; }
.release-card { width: min(650px, 100%); }
.difficulty-modal { width: min(900px, 100%); }
.difficulty-loading { min-height: 260px; display: grid; place-items: center; align-content: center; gap: 9px; color: var(--muted); text-align: center; }
.difficulty-loading i { width: 30px; height: 30px; border: 3px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: difficulty-spin .8s linear infinite; }
.difficulty-loading strong { color: var(--text); font-size: 13px; }
.difficulty-loading span { color: var(--subtle); font-size: 12px; }
@keyframes difficulty-spin { to { transform: rotate(360deg); } }
.difficulty-result { display: grid; gap: 14px; }
.difficulty-hero { display: grid; grid-template-columns: 118px minmax(0, 1fr); gap: 18px; align-items: center; padding: 17px; border: 1px solid var(--border); border-radius: 10px; background: linear-gradient(135deg, rgba(141,127,255,.08), rgba(18,21,23,.88) 55%); }
.difficulty-score-card { height: 102px; display: grid; place-items: center; align-content: center; border: 1px solid #4a5158; border-radius: var(--radius-md); background: var(--surface-input); }
.difficulty-score-card b { font: 850 34px/1 Consolas, monospace; }
.difficulty-score-card span { margin-top: 6px; color: var(--muted); font-size: 12px; }
.difficulty-score-card.simple b { color: #258357; }
.difficulty-score-card.medium b { color: #b47b0e; }
.difficulty-score-card.hard b, .difficulty-score-card.impossible b { color: #c5484e; }
.difficulty-hero-copy h3 { margin: 0; font-size: 20px; }
.difficulty-hero-copy p { margin: 7px 0 0; color: var(--muted); font-size: 13px; line-height: 1.65; }
.difficulty-badge { display: inline-flex; margin-top: 10px; padding: 4px 7px; border: 1px solid var(--border); border-radius: 999px; color: var(--accent); background: rgba(211,236,130,.045); font-size: 12px; }
.difficulty-metrics { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
.difficulty-metric { min-height: 68px; display: grid; align-content: center; gap: 5px; padding: 10px 11px; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface-input); }
.difficulty-metric span { color: var(--subtle); font-size: 12px; }
.difficulty-metric b { overflow: hidden; color: var(--text); font: 750 15px/1.25 Consolas, monospace; text-overflow: ellipsis; white-space: nowrap; }
.difficulty-explanation, .difficulty-warning { padding: 11px 13px; border: 1px solid var(--border); border-radius: var(--radius-md); color: var(--muted); background: rgba(255,255,255,.018); font-size: 12px; line-height: 1.6; }
.difficulty-warning { border-color: rgba(247,201,72,.42); color: #866019; background: rgba(247,201,72,.045); }
.difficulty-path-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-top: 2px; }
.difficulty-path-heading h3 { margin: 0; font-size: 13px; }
.difficulty-path-heading span { color: var(--subtle); font-size: 12px; }
.difficulty-path-list { display: grid; gap: 7px; max-height: 330px; overflow: auto; padding-right: 3px; }
.difficulty-path { border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface-input); }
.difficulty-path[open] { border-color: var(--border-strong); }
.difficulty-path summary { min-height: 38px; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 11px; color: var(--text); cursor: pointer; font-size: 12px; font-weight: 720; }
.difficulty-path summary span { color: var(--subtle); font: 11px Consolas, monospace; }
.difficulty-path-steps { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 10px 11px; border-top: 1px solid rgba(255,255,255,.045); }
.difficulty-step { flex: 1 1 210px; min-width: 0; display: grid; grid-template-columns: 24px minmax(0, 1fr); align-items: center; gap: 7px; padding: 7px 8px; border: 1px solid rgba(255,255,255,.06); border-radius: var(--radius-sm); color: var(--muted); background: rgba(255,255,255,.018); font-size: 12px; line-height: 1.4; }
.difficulty-step b { width: 22px; height: 22px; display: grid; place-items: center; border-radius: 50%; color: #fff; background: var(--accent); font: 800 11px Consolas, monospace; }
.difficulty-empty { min-height: 180px; display: grid; place-items: center; align-content: center; gap: 8px; padding: 25px; border: 1px dashed var(--border-strong); border-radius: var(--radius-md); color: var(--muted); text-align: center; }
.difficulty-empty strong { color: var(--text); font-size: 14px; }
.difficulty-empty span { max-width: 460px; font-size: 12px; line-height: 1.6; }
.release-status { margin-bottom: 14px; padding: 13px 14px; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface-input); }
.release-status strong { display: block; margin-bottom: 4px; font-size: 13px; }
.release-status p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.55; }
.release-status.passed { border-color: rgba(65,194,125,.55); background: rgba(65,194,125,.06); }
.release-status.waiting { border-color: rgba(247,201,72,.5); background: rgba(247,201,72,.05); }
.map-identity { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 10px; margin-bottom: 14px; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.map-identity span { color: var(--muted); font-size: 12px; }
.map-identity code { overflow: hidden; color: var(--accent); font: 11px Consolas, monospace; text-overflow: ellipsis; white-space: nowrap; }
.release-checklist { display: grid; gap: 7px; }
.release-check { display: grid; grid-template-columns: 24px 1fr; align-items: center; gap: 8px; min-height: 38px; padding: 7px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: rgba(255,255,255,.018); font-size: 13px; }
.release-check i { width: 20px; height: 20px; display: grid; place-items: center; border-radius: 50%; color: #07130c; background: var(--excel); font-style: normal; font-weight: 900; }
.release-check.failed i { color: #fff; background: var(--danger); }
.release-check.pending i { color: #1d1604; background: #b47b0e; }
.release-check span { color: var(--muted); line-height: 1.45; }
.release-check b { color: var(--text); }
.publish-layout { display: grid; grid-template-columns: 180px minmax(0, 1fr); gap: 18px; margin-bottom: 17px; }
.thumbnail-preview { position: relative; min-height: 180px; display: grid; place-items: center; overflow: hidden; border: 1px dashed #4a5158; border-radius: var(--radius-md); background: var(--surface-input); }
.thumbnail-preview img { width: 100%; height: 100%; display: block; object-fit: contain; image-rendering: auto; }
.thumbnail-preview img:not([src]) { display: none; }
.thumbnail-preview span { max-width: 130px; color: var(--subtle); font-size: 12px; line-height: 1.5; text-align: center; }
.publish-category { min-width: 0; margin: 0; padding: 0; border: 0; }
.publish-category legend { margin-bottom: 7px; color: var(--muted); font-size: 12px; }
.publish-category-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.publish-category-options label { position: relative; display: block; cursor: pointer; }
.publish-category-options input { position: absolute; opacity: 0; pointer-events: none; }
.publish-category-options span { min-height: 58px; display: grid; align-content: center; gap: 3px; padding: 9px 11px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: rgba(255,255,255,.018); transition: border-color .15s ease, background .15s ease; }
.publish-category-options strong { color: var(--text); font-size: 13px; }
.publish-category-options small { color: var(--muted); font-size: 12px; line-height: 1.35; }
.publish-category-options input:checked + span { border-color: var(--accent); background: rgba(211,236,130,.08); box-shadow: inset 0 0 0 1px rgba(211,236,130,.12); }
.publish-category-options input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }


/* The frame is outside the canvas: no change to cell geometry or pointer mapping. */
.board-frame { position: relative; isolation: isolate; width: max-content; height: max-content; }
.board-frame::before { content: ""; position: absolute; z-index: -1; inset: -44px; border: 44px solid transparent; border-image: url("./assets/workshop/wood-frame-v1.webp") 115 / 44px / 0 stretch; pointer-events: none; }
.app-header::before { content: ""; position: absolute; z-index: -1; inset: 0; background: radial-gradient(ellipse 65px 24px at 3% 110%, #ffffffab 98%, transparent), radial-gradient(ellipse 90px 38px at 90% 115%, #ffffff8c 98%, transparent); pointer-events: none; }
.tool-icon img { display: block; width: 32px; height: 32px; object-fit: contain; }
.section-help { margin-top: 8px; color: var(--subtle); font-size: 12px; }
.section-help summary { cursor: pointer; color: var(--muted); }
.section-help summary:hover { color: var(--accent); }
.section-help[open] summary { margin-bottom: 5px; }
.section-help p { margin-top: 0; }
.reference-image-actions #editImageCropBtn:disabled { display: none; }
#resizeBtn { color: #fff; border-color: #2184d3; background: linear-gradient(#44a9f7, #1884e6); box-shadow: inset 0 1px 0 #ffffff8c, 0 2px 3px #3489c430; }
#resizeBtn:hover { background: #147bd1; }
#publishMapBtn { color: #285821; border-color: #99ca65; background: linear-gradient(#d8f597, #b9e774); }
.button.json { color: #674399; background: #f3ecfc; border-color: #dccbf1; }
.stat-meter { height: 7px; overflow: hidden; border-radius: 6px; background: #e7eff4; }
.stat-meter em { display: block; height: 100%; width: var(--stat-width); border-radius: inherit; background: var(--stat-color); }
.workshop-note { order: 2; display: flex; align-items: center; gap: 10px; margin: auto 3px 4px; padding: 10px 12px; border: 1px solid #f2dc9d; border-radius: 12px; background: #fff6d6; color: #715b2d; }
.workshop-note img { width: 42px; height: 42px; object-fit: contain; }
.workshop-note b, .workshop-note small { display: block; }
.workshop-note b { font-size: 12px; }
.workshop-note small { margin-top: 3px; font-size: 11px; }
@media (max-width: 1100px) {
  .command-bar { flex-wrap: wrap; align-content: center; }
  .editor-area { grid-template-rows: 88px minmax(0, 1fr) 34px; }
  .zoom-controls { width: 100%; justify-content: flex-end; }
}

@media (max-width: 1280px) {
  .app-shell { grid-template-rows: 108px minmax(0, 1fr); }
  .app-header { display: grid; grid-template-columns: 180px minmax(130px, 1fr) auto auto auto; grid-template-rows: 50px 42px; gap: 0 12px; padding: 6px 16px 10px; }
  .brand { width: auto; }
  .project-name { max-width: none; }
  .header-status { grid-column: 3; }
  #cloudProjectsBtn { grid-column: 4; }
  .account-button { grid-column: 5; grid-row: 1; }
  .app-header .mode-switch { grid-column: 1 / 3; grid-row: 2; justify-self: start; }
  .app-header .layer-switch { grid-column: 3 / 5; grid-row: 2; justify-self: end; }
  #newBtn { grid-column: 5; grid-row: 2; }
  .workspace { grid-template-columns: 232px minmax(350px, 1fr) 284px; }
  .panel-section { padding: 12px; }
  .palette-grid { gap: 7px; }
  .action-grid .button { padding: 7px 4px; font-size: 12px; }
  .command-bar { padding: 0 10px; gap: 8px; flex-wrap: wrap; align-content: center; }
  .canvas-meta { flex: 1; }
  .zoom-controls { flex-shrink: 0; }
}

@media (max-width: 720px) {
  .publish-layout { grid-template-columns: 1fr; }
  .thumbnail-preview { min-height: 150px; }
  .crop-stage { min-height: 180px; padding: 9px; }
  .crop-controls { grid-template-columns: 32px minmax(90px, 1fr) 32px 48px; }
  .crop-controls .button { grid-column: 1 / -1; }
  .crop-palette-grid { grid-template-columns: repeat(auto-fill, 34px); gap: 6px; }
  .crop-palette-color { width: 34px; height: 34px; }
  .difficulty-hero { grid-template-columns: 1fr; }
  .difficulty-score-card { height: 82px; }
  .difficulty-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 900px) {
  html, body { overflow-x: auto; }
  .app-shell { min-width: 900px; }
}

/* Status badges leave the original body colour and ammo visible to editors. */
.pig-card.frozen { border-color: #59badd; background: linear-gradient(135deg, #f0fcff, #ccefff); box-shadow: inset 0 0 0 1px #b0e6f3, 0 3px 0 #92cfe1, 0 5px 8px #527c9420; }
.pig-ice-toggle.active { border-color: #69bfd5; color: #176787; background: #e3f8ff; }

/* Shared interactive states: never alter the centre of a business colour sample. */
.swatch.active::after { content: "✓"; position: absolute; left: -5px; top: -5px; width: 16px; height: 16px; display: grid; place-items: center; border: 1px solid #fff; border-radius: 50%; color: #fff; background: var(--accent); font: 800 11px/1 sans-serif; }
.toggle-row input:focus-visible + i { outline: 2px solid var(--accent); outline-offset: 3px; }
.toggle-row:has(input:disabled) { opacity: .45; cursor: not-allowed; }
.file-button:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.icon-button:disabled { opacity: .4; cursor: not-allowed; }
.prop-card.active { border-color: var(--accent); box-shadow: inset 0 -3px var(--accent); }
.pig-card.dragging { opacity: .45; }
.pig-card.drop-target { outline: 2px dashed var(--accent); outline-offset: 3px; }
.deck-column.drop-target { border-color: var(--accent); }
.pig-card:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
body[data-mode="turrets"] .zoom-controls { display: none; }
@media (max-width: 1280px) { body[data-mode="turrets"] .editor-area { grid-template-rows: 56px minmax(0, 1fr) 34px; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; } }


/* Portrait skin carries gameplay colour; the separate swatch remains exact. */
.pig-portrait { display: block; width: calc(96px * var(--turret-scale)); height: calc(96px * var(--turret-scale)); object-fit: contain; pointer-events: none; }
.pig-lock img { width: 100%; height: 100%; object-fit: contain; pointer-events: none; }
.deck-lock-icon img { width: calc(82px * var(--turret-scale)); height: calc(88px * var(--turret-scale)); object-fit: contain; pointer-events: none; }
.pig-copy small strong { font-size: max(14px, calc(20px * var(--turret-scale))); line-height: 1; }
.pig-copy small em { display: inline-block; margin-left: 3px; font-size: clamp(11px, calc(11px * var(--turret-scale)), 18px); font-style: normal; color: var(--muted); white-space: nowrap; }
.pig-color-row { display: flex; align-items: flex-start; gap: 6px; color: var(--muted); font-size: clamp(12px, calc(12px * var(--turret-scale)), 20px); line-height: 1.4; }
.pig-color-row span { min-width: 0; overflow-wrap: anywhere; }
.pig-color-row i { display: inline-block; flex: 0 0 calc(24px * var(--turret-scale)); width: calc(24px * var(--turret-scale)); height: calc(18px * var(--turret-scale)); border: 1px solid #7994a752; border-radius: 5px; }
.pig-state { display: inline-block; justify-self: start; max-width: 100%; padding: 3px 7px; border-radius: 7px; font-size: 12px; font-weight: 750; line-height: 1.4; overflow-wrap: anywhere; }
.pig-state-corner { position: absolute; top: 4px; right: 6px; max-width: calc(100% - 90px); padding: 1px 6px; border-radius: 6px; font-size: 11px; line-height: 16px; white-space: nowrap; }
.pig-state.mask { color: #633690; background: #e0c9f4; border: 1px solid #c3a1e3; }
.pig-state.ice { color: #075c85; background: #a9e2f7; border: 1px solid #79c9e6; }
.pig-state.position-lock { color: #805611; background: #ffebaf; border: 1px solid #e8c76c; font-size: 11px; }
.state-control-art { width: 30px; height: 30px; object-fit: contain; vertical-align: middle; margin-right: 5px; pointer-events: none; }
