/* Shared local workflow and editor layout, loaded after style.css.
   data-view chooses setup, editor or save. Setup/save cards use their content height;
   the editor uses the available viewport and packs measured groups into pages. */

/* Backup RAM editor uses the ROM editor's panels, palette and typography. */
.save-editor-dialog { width: min(1240px,calc(100vw - 24px)); height: min(960px,calc(100dvh - 24px)); max-width: none; max-height: none; padding: 0; border: 2px solid #16808b; border-radius: 6px; background: #000810; color: #e8e8da; box-sizing: border-box; overflow: hidden; }
.save-editor-dialog::backdrop, .carryover-dialog::backdrop { background: #000b; backdrop-filter: blur(3px); }
.save-editor-shell { --edge: 5px; --frame: url('./runtime-panel-frame.svg?v=20261113-alicecopies1'); --ed-text: #e8e8da; --ed-muted: #a9bcaa; --ed-cyan: #9fd7e6; --ed-rail: #16808b; --ed-gold: #e9d870; --ed-modified: #fff19b; --ed-primary: 16px; --ed-label: 14px; --ed-name: 20px; --ed-field: 16px; --ed-control: 40px; --ed-pad: 8px; display: flex; flex-direction: column; height: 100%; min-width: 0; min-height: 0; font-family: var(--font-editor,inherit); }
.save-editor-shell p { margin: 4px 0; line-height: 1.5; overflow-wrap: anywhere; }
.save-editor-header { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex: 0 0 auto; padding: 8px 16px; border-bottom: 1px solid var(--ed-rail); background: #02101a; }
.save-editor-header-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.save-carryover-open { min-height: 30px; padding: 4px 10px; font-size: 12px; color: var(--ed-cyan); border-color: #204c5a; background: #041723; white-space: nowrap; }
.save-carryover-open:hover { border-color: var(--ed-cyan); color: var(--ed-text); background: #072233; }
.save-editor-header h2 { margin: 2px 0 0; font-size: 20px; color: var(--ed-gold); }
.save-eyebrow { font-size: 11px; letter-spacing: .07em; color: var(--ed-muted); }
.save-editor-content { flex: 1 1 0; min-height: 0; overflow: hidden; padding: 10px 16px 8px; display: flex; flex-direction: column; gap: 8px; }
.save-file-selection { flex: 0 0 auto; min-width: 0; display: grid; gap: 5px; }
.save-file-guide { margin: 0; color: var(--ed-muted); font-size: 12px; }
#saveEditorDialog[data-has-save="true"] #saveFileGuide { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.save-file-toolbar { display: flex; align-items: center; gap: 10px; flex: 0 0 auto; }
.save-fast-preview { flex: 0 0 auto; padding: 8px 12px; border: 1px solid var(--ed-rail); border-radius: 3px; background: #041723; color: var(--ed-text); font-size: 12px; }
.save-fast-preview ul { margin: 4px 0 0; padding-inline-start: 18px; }
.save-fast-preview ul:empty { display: none; }
.save-file-info { flex: 1; min-width: 0; }
.save-file-info strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.save-file-info span { color: var(--ed-muted); font-size: 12px; }
.save-slot-select-label { display: grid; grid-template-columns: auto minmax(0,1fr); align-items: center; gap: 8px; width: min(300px,42vw); flex-shrink: 0; color: var(--ed-muted); font-size: 12px; }
.save-file-picker { position: relative; display: inline-flex; align-items: center; min-height: 36px; padding: 0 12px; cursor: pointer; white-space: nowrap; flex-shrink: 0; }
.save-file-picker input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.save-file-picker:focus-within { outline: 2px solid var(--ed-gold); outline-offset: 2px; }
.save-editor-shell select, .save-editor-shell input[type=number] { width: 100%; min-height: 40px; box-sizing: border-box; border: 1px solid var(--ed-rail); border-radius: 3px; background: #00121c; color: var(--ed-text); padding: 7px 10px; font: inherit; }
.save-editor-shell .save-slot-select-label select { min-height: 36px; }
.save-editor-shell input[aria-invalid=true] { color: #ffa9a9; }
.save-editor-shell button:disabled, .save-editor-shell input:disabled, .save-editor-shell select:disabled { opacity: .5; }
.save-context-stack { flex: 0 0 auto; display: flex; flex-direction: column; gap: 6px; min-height: 0; }
.save-context-stack:has(.save-slot-browser[open]) { flex: 1 1 0; min-height: 0; }
.save-slot-summary { display: flex; gap: 16px; align-items: center; justify-content: space-between; flex: 0 0 auto; border: 1px solid var(--ed-rail); border-left: 3px solid var(--ed-gold); border-radius: 2px; padding: 8px 12px; background: #071c23; }
.save-slot-heading { min-width: 0; flex: 1; }
.save-slot-heading > div { display: flex; align-items: baseline; gap: 10px; margin-top: 2px; flex-wrap: wrap; }
.save-slot-heading strong { font-size: 17px; color: var(--ed-gold); white-space: nowrap; }
#saveSlotTitle { font-size: 14px; overflow-wrap: anywhere; }
.save-slot-summary dl { display: flex; gap: 18px; margin: 0; flex-shrink: 0; }
.save-slot-summary dt { color: var(--ed-muted); font-size: 11px; }
.save-slot-summary dd { margin: 2px 0 0; font-size: 13px; }
.save-utility-bar { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 6px 8px; flex: 0 0 auto; min-height: 0; }
.save-utility-bar:has(> .save-slot-browser[open]) { flex: 1 1 0; min-height: 0; flex-direction: column; align-items: stretch; }
.save-utility-bar:has(> .save-slot-browser[open]) > .save-check { display: none; }
.save-slot-browser { flex: 0 0 auto; border: 1px solid var(--ed-rail); border-radius: 3px; background: #061823; }
.save-slot-browser > summary { cursor: pointer; padding: 5px 11px; color: var(--ed-gold); font-size: 12px; font-weight: 600; list-style-position: inside; user-select: none; }
.save-slot-browser[open] { flex: 1 1 0; width: 100%; min-height: 0; display: grid; grid-template-rows: auto auto minmax(0,1fr) auto; gap: 8px; padding: 8px 12px 10px; box-sizing: border-box; overflow: hidden; }
.save-slot-browser[open]::details-content { display: contents; }
.save-slot-browser[open] > summary { padding: 0 0 6px; border-bottom: 1px solid var(--ed-rail); }
.save-slot-filters { display: flex; gap: 12px; margin: 0; }
.save-slot-filters > input { flex: 1; min-width: 0; }
.save-slot-filters > label { display: flex; gap: 8px; align-items: center; font-size: 12px; white-space: nowrap; }
.save-slot-cards { display: grid; grid-template-columns: repeat(auto-fit,minmax(220px,1fr)); grid-auto-rows: 132px; align-content: start; gap: 8px; min-height: 0; align-self: stretch; overflow: hidden; padding: 0; }
.save-slot-card { display: grid; gap: 5px; height: 132px; box-sizing: border-box; padding: 12px; text-align: left; min-width: 0; background: #00121c; color: var(--ed-text); border: 1px solid var(--ed-rail); font: inherit; cursor: pointer; overflow: hidden; overflow-wrap: anywhere; }
.save-slot-card[aria-pressed=true] { border-color: var(--ed-gold); background: #143826; }
.save-slot-card small { color: var(--ed-muted); font-size: 11px; }
.save-slot-card strong { font-size: 16px; }
.save-slot-card > span { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; font-size: 13px; }
.save-slot-card:focus-visible { outline: 2px solid var(--ed-gold); outline-offset: 1px; }
.save-check { flex: 0 1 auto; border: 1px solid var(--ed-rail); border-radius: 3px; background: #041723; }
.save-check > summary { cursor: pointer; padding: 5px 11px; font-size: 12px; font-weight: 600; color: #9cdca0; list-style-position: inside; user-select: none; }
.save-check.is-error { border-color: #a94444; background: #1c0b10; }
.save-check.is-error > summary { color: #ff8e8e; }
.save-check.is-warn { border-color: #9e812b; background: #191506; }
.save-check.is-warn > summary { color: #ffe066; }
.save-check[open] { flex: 1 1 100%; width: 100%; padding: 8px 12px 10px; box-sizing: border-box; }
.save-check[open] > summary { padding: 0 0 6px; border-bottom: 1px solid var(--ed-rail); margin-bottom: 6px; }
.save-check-body { display: grid; gap: 6px; }
.save-check-lead { margin: 0; }
.save-inline-help { font-size: 11px; color: var(--ed-muted); }
.save-inline-help > summary { cursor: pointer; color: var(--ed-cyan); font-size: 11px; }
.save-check-body ul { margin: 2px 0; padding-left: 18px; max-height: min(150px,22dvh); overflow: auto; font-size: 12px; line-height: 1.45; }
.save-check-body ul:empty { display: none; }
.save-check-body li.is-error { color: #ff9a9a; }
.save-check-body li.is-warn { color: #ffe9a0; }
.save-check-actions { display: flex; gap: 8px; flex-wrap: wrap; }
#saveEditorStatus { flex: 0 0 auto; margin: 0; padding: 5px 10px; border-left: 3px solid var(--ed-rail); background: #03111a; color: var(--ed-muted); font-size: 12px; line-height: 1.4; max-height: 44px; overflow: hidden; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
#saveEditorStatus.is-error { color: #ffa9a9; border-left-color: #d05858; background: #190a0e; }
.save-editor-body { flex: 1 1 0; min-height: 210px; display: grid; grid-template-columns: minmax(0,1fr) auto; grid-template-rows: auto minmax(0,1fr) auto; grid-template-areas: "tabs add" "records records"; gap: 8px 10px; }
.save-game-toolbar { grid-area: tabs; display: flex; align-items: center; justify-content: space-between; gap: 10px; min-width: 0; }
.save-game-toolbar .editor-tab-row { flex: 1 1 auto; flex-direction: row; width: auto; min-width: 0; gap: 5px; }
.save-game-toolbar .editor-tab { min-height: 38px; padding: 6px 16px; }
.save-game-toolbar .editor-tab[aria-pressed=true] { color: var(--ed-gold); border-color: var(--ed-gold); background: #143826; }
#saveRecordNote { font-size: 11px; color: var(--ed-muted); white-space: nowrap; }
.save-editor-shell .save-record-layout { grid-area: records; display: flex; flex: 1; min-width: 0; min-height: 0; gap: 14px; overflow: hidden; }
.save-record-sidebar { display: grid; grid-template-rows: auto 40px minmax(0,1fr) 32px; gap: 8px; width: 260px; flex-shrink: 0; height: 100%; min-height: 0; overflow: hidden; }
.save-list-heading { display: flex; justify-content: space-between; align-items: center; font-size: 13px; padding: 0 3px; }
#saveListCount { color: var(--ed-muted); font-size: 11px; }
.save-editor-shell #saveRecordList { display: grid; grid-auto-rows: 52px; gap: 6px; align-content: start; flex: 1; min-height: 0; max-height: none; overflow: hidden; }
.save-editor-shell .record-option { width: 100%; font: inherit; color: inherit; cursor: pointer; text-align: left; background: transparent; min-height: 0; height: 52px; padding: 9px 12px; box-sizing: border-box; }
.save-editor-shell .record-option-meta { font-size: 11px; color: var(--ed-muted); }
.save-editor-shell .record-option.is-selected { background: #143826; color: var(--ed-gold); border-left: 3px solid #39d467; }
.save-detail { flex: 1; min-width: 0; min-height: 0; overflow: hidden; }
.save-selected-panel { height: 100%; max-height: 100%; min-height: 0; padding: 12px; box-sizing: border-box; overflow: hidden; }
.save-selected-heading { margin-bottom: 10px; border-bottom: 1px solid var(--ed-rail); padding-bottom: 8px; }
.save-selected-heading h3 { margin: 0; font-size: 21px; color: var(--ed-gold); }
.save-selected-heading p { font-size: 11px; color: var(--ed-muted); }
.save-number-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 14px; }
.save-number-grid label, .save-common-fields label { display: grid; gap: 6px; min-width: 0; font-size: 13px; }
.save-number-grid p { grid-column: 1/-1; }
.save-number-grid h4 { grid-column: 1/-1; margin: 10px 0 0; padding-bottom: 7px; border-bottom: 1px solid var(--ed-rail); font-size: 13px; color: var(--ed-gold); }
.save-number-grid h4:first-child { margin-top: 0; }
.save-help, #saveNameNote { color: var(--ed-muted); font-size: 12px; }
#saveNameNote { grid-column: 1/-1; grid-row: 3; margin: 0; }
#saveUnitNote { padding-top: 16px; }
.save-back-list { display: none; }
.save-add-unit { grid-area: add; align-self: center; background: #061823; padding: 0; border: 1px solid var(--ed-rail); border-radius: 3px; }
.save-add-unit > summary { cursor: pointer; padding: 7px 13px; font-size: 13px; font-weight: 600; color: var(--ed-gold); white-space: nowrap; list-style: none; }
.save-add-unit-fields { display: grid; grid-template-columns: 1fr 1fr 1.2fr auto; align-items: end; gap: 10px; margin: 10px 0; }
.save-add-unit-fields label { display: grid; gap: 5px; font-size: 12px; min-width: 0; }
.save-add-unit small { font-size: 11px; color: var(--ed-muted); }
.save-add-unit[open] { position: static; grid-area: records; align-self: stretch; width: 100%; height: 100%; min-height: 0; padding: 12px 14px; box-sizing: border-box; overflow-y: auto; box-shadow: none; }
.save-add-unit[open] > summary { padding: 0 0 8px; border-bottom: 1px solid var(--ed-rail); }
.save-common-fields { grid-area: records; display: grid; grid-template-columns: minmax(0,1fr); grid-template-rows: auto minmax(0,1fr); gap: 12px; align-content: start; min-height: 0; overflow: hidden; }
.save-common-tabs { grid-column: 1/-1; grid-row: 1; margin: 0; align-self: start; }
.save-common-fields > .game-panel { grid-column: 1; grid-row: 2; align-self: start; margin: 0; padding: 18px; }
.save-common-fields h3 { margin: 0 0 14px; font-size: 18px; color: var(--ed-gold); }
.save-common-fields .save-help { margin-top: 12px; }
.save-editor-footer { flex: 0 0 auto; display: grid; grid-template-columns: minmax(0,1fr) auto; align-items: center; gap: 8px 14px; padding: 9px 16px 11px; border-top: 1px solid var(--ed-rail); background: #02101a; }
.save-diff { position: relative; }
.save-diff > summary { display: inline-flex; align-items: center; min-height: 34px; padding: 0 11px; border: 1px solid var(--ed-rail); border-radius: 3px; background: #041723; cursor: pointer; font-size: 12px; color: var(--ed-gold); list-style: none; }
.save-editor-actions { display: flex; align-items: center; gap: 10px; margin: 0; }
.save-editor-actions button { min-height: 38px; }
.save-game-bundle { grid-column: 1/-1; min-width: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 8px 12px; border: 1px solid #8a6c37; border-left: 3px solid var(--ed-gold); border-radius: 4px; background: #141208; color: #ffdfab; font-size: 12px; overflow-wrap: anywhere; }
.save-bundle-badge { display: inline-flex; align-items: center; padding: 2px 7px; border: 1px solid #c49b45; border-radius: 3px; background: #2c220c; color: var(--ed-gold); font-size: 11px; font-weight: 700; white-space: nowrap; }
.save-game-bundle p { margin: 0; flex: 1 1 240px; }
.save-game-bundle-links:not([hidden]) { display: flex; flex-wrap: wrap; gap: 6px; margin-left: auto; }
.save-bundle-cta { display: inline-flex; align-items: center; min-height: 36px; padding: 0 14px; text-decoration: none; border-color: #6bbd58; background: #28612f; color: #fff6b0; font-weight: 700; border-radius: 3px; }
.save-editor-actions:has(#saveDownload[data-paired="true"]) .save-footer-note { display: none; }
.save-footer-note { flex: 1; font-size: 11px; color: var(--ed-muted); margin-right: 6px; }
#saveDownload:not(:disabled) { background: #28612f; color: #fff6b0; border-color: #6bbd58; font-weight: 600; }
.save-empty { flex: 1 1 0; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; justify-content: center; gap: 14px; padding: 18px 22px; }
.save-empty-header h3 { margin: 0 0 4px; font-size: 20px; color: var(--ed-gold); }
.save-empty-header p { margin: 0; font-size: 13px; color: var(--ed-text); }
.save-empty-flow { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 10px; margin: 0; padding: 0; list-style: none; }
.save-empty-card { display: grid; gap: 4px; align-content: start; padding: 11px 12px; border: 1px solid var(--ed-rail); border-radius: 3px; background: #041723; }
.save-empty-card strong { color: var(--ed-gold); font-size: 13px; }
.save-empty-card span { color: var(--ed-muted); font-size: 12px; line-height: 1.45; }
.save-empty-shortcuts { display: flex; flex-wrap: wrap; gap: 8px 18px; padding: 8px 12px; border: 1px solid #204c5a; border-radius: 3px; background: #03121b; font-size: 12px; color: var(--ed-muted); }
.save-empty-shortcuts strong { color: var(--ed-cyan); font-weight: 600; }
.save-empty-notes { border: 1px solid #204c5a; border-radius: 3px; background: #020e17; padding: 7px 11px; }
.save-empty-notes > summary { cursor: pointer; font-size: 12px; color: var(--ed-cyan); }
.save-empty-notes p { margin: 6px 0 4px; font-size: 12px; color: var(--ed-text); }
.save-empty-notes small { display: block; color: var(--ed-muted); font-size: 11px; line-height: 1.45; }

/* Save identity and stage controls share the game's pixel-art treatment. */
.save-record-art { display: flex; justify-content: space-between; align-items: center; gap: 12px; min-height: 82px; padding: 6px 12px; margin-bottom: 8px; background: linear-gradient(180deg,#071f2c,#020a15); border: 1px solid var(--ed-rail); }
.save-record-art figure { margin: 0; display: grid; align-content: center; justify-items: center; min-width: 0; gap: 5px; }
.save-unit-art { flex: 1; }
.save-pilot-art { width: 94px; flex-shrink: 0; border-left: 1px solid var(--ed-rail); padding-left: 10px; }
.save-record-art canvas { image-rendering: pixelated; object-fit: contain; max-width: 100%; }
.save-unit-art canvas { width: auto; height: 72px; max-width: 190px; }
.save-pilot-art canvas { width: auto; height: 60px; max-width: 80px; }
.save-record-art figcaption { font-size: 11px; color: var(--ed-muted); text-align: center; line-height: 1.4; }
.save-detail-tabs { display: flex; gap: 5px; margin: 0 0 14px; border-bottom: 1px solid var(--ed-rail); padding-bottom: 8px; }
.save-detail-tabs button { flex: 1; min-height: 36px; background: #041723; color: var(--ed-muted); font: inherit; font-size: 13px; border: 1px solid var(--ed-rail); cursor: pointer; }
.save-detail-tabs button[aria-pressed=true] { color: var(--ed-gold); background: #143826; border-color: var(--ed-gold); }
.save-upgrade-control { grid-column: 1/-1; min-width: 0; }
.save-upgrade-label { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 6px; font-size: 14px; }
.save-upgrade-label output { white-space: nowrap; color: var(--ed-gold); font-variant-numeric: tabular-nums; font-size: 13px; }
.save-upgrade-body { display: flex; align-items: stretch; gap: 7px; }
.save-upgrade-body > button { width: 32px; min-height: 32px; flex-shrink: 0; padding: 0; background: #031520; border: 1px solid var(--ed-rail); color: var(--ed-gold); font: inherit; cursor: pointer; }
.save-upgrade-track { flex: 1; min-width: 0; display: grid; grid-template-columns: repeat(10,minmax(0,1fr)); gap: 3px; padding: 4px; border: 1px solid #577d86; background: #00030a; cursor: pointer; }
.save-upgrade-track:focus-visible { outline: 2px solid var(--ed-gold); outline-offset: 3px; }
.save-upgrade-box { min-height: 22px; border: 1px solid #355761; background: #10212c; box-shadow: inset 0 0 0 1px #030c12; }
.save-upgrade-box.is-filled { background: #6bbd58; border-color: #c2ed7c; box-shadow: inset 0 2px #9dd969,inset 0 -2px #2d773b; }
.save-upgrade-box.is-locked { background: repeating-linear-gradient(135deg,#12202a,#12202a 3px,#1b2a31 3px,#1b2a31 5px); opacity: .48; }
.save-upgrade-box.is-filled.is-locked { background: #bf9c46; opacity: 1; }
.save-upgrade-track[aria-disabled=true] { cursor: default; opacity: .5; }
.save-upgrade-control.is-over-limit output, .save-field-message { color: #ffa9a9; }
.save-field-message { font-size: 12px; line-height: 1.5; }

/* Save pages reserve their own navigation; no editor area requires vertical scrolling. */
.save-pager { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; min-height: 32px; }
.save-pager button { font: inherit; font-size: 12px; min-height: 32px; padding: 4px 9px; cursor: pointer; border: 1px solid var(--ed-rail); background: #041723; color: var(--ed-gold); }
.save-pager button:first-child { justify-self: start; }
.save-pager button:last-child { justify-self: end; }
.save-pager span { font-size: 12px; color: var(--ed-muted); white-space: nowrap; }
.save-editor-shell #saveRecordList .record-option.has-portrait { grid-template-columns: 32px minmax(0,1fr); grid-template-rows: 18px 14px; grid-template-areas: "portrait name" "portrait meta"; gap: 2px 9px; padding: 8px 10px; }
.save-editor-shell #saveRecordList .has-portrait .record-option-name { grid-area: name; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; line-height: 18px; font-size: 14px; }
.save-editor-shell #saveRecordList .has-portrait .record-option-meta { grid-area: meta; line-height: 14px; font-size: 11px; }
.save-list-portrait { grid-area: portrait; position: relative; width: 32px; height: 32px; overflow: hidden; border: 1px solid #285164; background: #071b29; box-sizing: border-box; }
.save-list-portrait::after { content: "?"; display: grid; place-items: center; height: 100%; color: var(--ed-muted); font-size: 15px; }
.save-list-portrait.has-image::after { display: none; }
.save-list-portrait canvas { display: block; width: 100%; height: 100%; object-fit: contain; image-rendering: pixelated; }
.save-list-portrait canvas[hidden] { display: none; }
#saveUnitFields { display: flex; flex-direction: column; gap: 8px; min-height: 0; overflow: hidden; }
#saveUnitFields > * { flex: 0 0 auto; }
.save-parts-row { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 12px; }
#savePilotFields { align-content: start; align-items: start; min-height: 0; }
#saveUnitPager { grid-column: 1/-1; grid-row: 3; }
#saveUnitNote { display: none; }
.save-upgrade-label > span { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
.save-change-panel { position: absolute; z-index: 8; bottom: calc(100% + 12px); left: 0; display: grid; gap: 10px; width: min(720px,calc(100vw - 48px)); box-sizing: border-box; padding: 14px; background: #061823; border: 1px solid var(--ed-rail); box-shadow: 0 -6px 20px #000b; }
.save-diff:not([open]) .save-change-panel { display: none; }
.save-diff .save-change-panel #saveChanges { position: static; width: auto; max-height: none; min-height: 0; overflow: hidden; margin: 0; padding: 0 0 0 20px; background: none; border: 0; box-shadow: none; }
#saveChanges li { margin-bottom: 8px; line-height: 1.4; overflow-wrap: anywhere; }
#saveChanges .save-draft-link { max-width: 100%; text-align: left; white-space: normal; }

/* Dedicated F -> Final SRW4 carryover tool dialog. */
.carryover-dialog { width: min(720px,calc(100vw - 24px)); max-height: calc(100dvh - 24px); max-width: none; padding: 0; border: 2px solid #16808b; border-radius: 6px; background: #000810; color: #e8e8da; box-sizing: border-box; overflow: hidden; }
.carryover-shell { --ed-text: #e8e8da; --ed-muted: #a9bcaa; --ed-cyan: #9fd7e6; --ed-rail: #16808b; --ed-gold: #e9d870; display: flex; flex-direction: column; max-height: inherit; min-width: 0; min-height: 0; font-family: var(--font-editor,inherit); }
.carryover-header { display: flex; justify-content: space-between; align-items: center; flex: 0 0 auto; padding: 10px 16px; border-bottom: 1px solid var(--ed-rail); background: #02101a; }
.carryover-header h2 { margin: 2px 0 0; font-size: 19px; color: var(--ed-gold); }
.carryover-content { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 14px 16px 16px; display: grid; gap: 12px; }
.carryover-intro { margin: 0; font-size: 13px; line-height: 1.5; color: var(--ed-text); }
.carryover-stage { display: grid; gap: 10px; padding: 12px 14px; border: 1px solid var(--ed-rail); border-radius: 4px; background: #061823; }
.carryover-stage h3 { margin: 0; font-size: 15px; color: var(--ed-gold); }
.carryover-fields { display: grid; gap: 8px; }
.carryover-file-field { display: grid; gap: 5px; font-size: 12px; color: var(--ed-text); min-width: 0; }
.carryover-file-field input[type="file"] { width: 100%; min-width: 0; max-width: 100%; padding: 6px 8px; border: 1px solid var(--ed-rail); border-radius: 3px; background: #00121c; color: var(--ed-text); box-sizing: border-box; font: inherit; }
.carryover-attest { display: flex; align-items: flex-start; gap: 8px; font-size: 12px; color: var(--ed-text); line-height: 1.45; cursor: pointer; }
.carryover-attest input { flex: 0 0 auto; width: 16px; height: 16px; margin: 2px 0 0; accent-color: #6bbd58; }
.carryover-help { border: 1px solid #204c5a; border-radius: 3px; background: #03111a; padding: 6px 10px; font-size: 12px; }
.carryover-help > summary { cursor: pointer; color: var(--ed-cyan); font-size: 12px; }
.carryover-help p { margin: 6px 0 4px; color: var(--ed-muted); line-height: 1.45; }
.carryover-help small { display: block; color: var(--ed-muted); font-size: 11px; line-height: 1.45; }
.carryover-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.carryover-shell .record-tool.is-primary { border-color: #6bbd58; background: #28612f; color: #fff6b0; font-weight: 600; }
.carryover-shell button:disabled, .carryover-shell input:disabled, .carryover-shell select:disabled { opacity: .5; }
.carryover-status { margin: 0; padding: 7px 10px; border-left: 3px solid var(--ed-rail); background: #03111a; color: var(--ed-muted); font-size: 12px; line-height: 1.45; }
.carryover-status.is-error { color: #ffa9a9; border-left-color: #d05858; background: #190a0e; }
.carryover-slot-row { display: grid; grid-template-columns: minmax(0,1fr) auto; align-items: end; gap: 10px; }
.carryover-slot-field { display: grid; gap: 5px; font-size: 12px; color: var(--ed-text); min-width: 0; }
.carryover-slot-field select { width: 100%; min-height: 40px; box-sizing: border-box; border: 1px solid var(--ed-rail); border-radius: 3px; background: #00121c; color: var(--ed-text); padding: 7px 10px; font: inherit; }
.carryover-result { border-color: #6bbd58; background: #071b16; }
#srw4CarryoverEdits { margin: 0; padding-left: 20px; max-height: 140px; overflow-y: auto; font-size: 12px; line-height: 1.5; }
.carryover-warning { margin: 0; padding: 8px 10px; border: 1px solid #8a6c37; border-radius: 3px; background: #141208; color: #ffdfab; font-size: 12px; line-height: 1.5; }
.carryover-download { display: inline-flex; align-items: center; justify-content: center; justify-self: start; min-height: 40px; padding: 0 16px; text-decoration: none; border-color: #6bbd58; background: #28612f; color: #fff6b0; font-weight: 700; }

/* Desktop save workspace: compact identity, full-width stage rows, one working viewport. */
@media (min-width: 901px) {
  .save-editor-dialog { width: min(1440px,calc(100vw - 24px)); height: calc(100dvh - 24px); }
  .save-editor-header > div:first-child { display: flex; align-items: baseline; gap: 12px; }
  .save-editor-header h2 { margin: 0; }
  .save-selected-panel.game-panel { --save-identity-height: 128px; display: grid; grid-template-columns: 228px minmax(0,1fr); grid-template-rows: var(--save-identity-height) minmax(0,1fr) 36px; align-content: start; gap: 12px 18px; padding: 16px; margin: 0; }
  .save-selected-panel.game-panel:has(#savePilotFields:not([hidden])) { grid-template-rows: var(--save-identity-height,128px) minmax(0,1fr); }
  .save-detail { height: 100%; }
  .save-record-art { grid-column: 1; grid-row: 1; min-height: 0; margin: 0; padding: 6px 8px; gap: 6px; box-sizing: border-box; }
  .save-unit-art { flex: 0 1 126px; }
  .save-unit-art canvas { height: 96px; max-width: 126px; }
  .save-unit-art figcaption { display: none; }
  .save-pilot-art { width: 74px; padding-left: 6px; }
  .save-pilot-art canvas { height: 64px; max-width: 68px; }
  .save-record-art figcaption { font-size: 12px; }
  .save-selected-heading { grid-column: 2; grid-row: 1; align-self: start; margin: 0; padding: 8px 0 0; border: 0; }
  .save-selected-panel .save-selected-heading h3 { font-size: 24px; color: var(--ed-gold); }
  .save-selected-heading p { font-size: 12px; }
  .save-selected-panel .save-detail-tabs { grid-column: 2; grid-row: 1; align-self: end; margin: 0; padding: 0; border: 0; }
  .save-detail-tabs button { min-height: 38px; font-size: 14px; }
  #savePilotFields, #saveUnitFields { grid-column: 1/-1; grid-row: 2; gap: 8px; }
  #saveUnitNote { grid-column: 1/-1; grid-row: 3; padding: 0; margin: 0; }
  .save-selected-panel:has(#saveUnitPartsTab[aria-pressed=false]) #saveUnitNote { display: none; }
  .save-upgrade-control { display: grid; grid-template-columns: 122px minmax(0,1fr) 76px; align-items: center; gap: 12px; }
  .save-upgrade-label { display: contents; }
  .save-upgrade-label > span { grid-column: 1; grid-row: 1; font-size: 15px; line-height: 1.35; overflow-wrap: anywhere; }
  .save-upgrade-label output { grid-column: 3; grid-row: 1; text-align: right; font-size: 14px; }
  .save-upgrade-body { grid-column: 2; grid-row: 1; min-height: 38px; }
  .save-upgrade-body > button { width: 34px; }
  .save-upgrade-box { min-height: 28px; }
  .save-diff ul { position: absolute; z-index: 8; bottom: 100%; left: 0; width: min(720px,70vw); max-height: 180px; box-sizing: border-box; margin: 0 0 12px; padding: 14px 18px 14px 32px; background: #061823; border: 1px solid var(--ed-rail); box-shadow: 0 -6px 20px #000b; }
}
@media (min-width: 901px) and (max-height: 850px) {
  .save-selected-panel.game-panel { --save-identity-height: 104px; grid-template-rows: var(--save-identity-height) minmax(0,1fr) 36px; gap: 10px 16px; padding: 12px; }
  .save-unit-art canvas { height: 80px; }
  .save-upgrade-body { min-height: 32px; }
  .save-upgrade-box { min-height: 22px; }
}
@media (min-width: 901px) and (max-height: 680px) {
  .save-selected-panel.game-panel { --save-identity-height: 72px; grid-template-columns: 176px minmax(0,1fr); gap: 8px 12px; padding: 10px; }
  .save-unit-art { flex-basis: 94px; }
  .save-unit-art canvas { height: 56px; max-width: 94px; }
  .save-pilot-art { width: 58px; padding-left: 4px; }
  .save-pilot-art canvas { height: 40px; max-width: 48px; }
  .save-pilot-art figcaption { font-size: 10px; }
  .save-selected-heading { padding-top: 0; }
  .save-selected-panel .save-selected-heading h3 { font-size: 19px; }
  .save-selected-heading p { font-size: 10px; }
  .save-detail-tabs button { min-height: 30px; font-size: 12px; }
  #savePilotFields { gap: 8px; }
  #savePilotFields label { gap: 4px; }
  #savePilotFields input { min-height: 34px; padding-block: 4px; }
  #savePilotFields .save-help { margin: 0; font-size: 10px; }
}

@media (max-width: 900px) {
  .save-editor-dialog { width: calc(100vw - 16px); height: calc(100dvh - 16px); }
  .save-editor-header { flex-wrap: wrap; gap: 6px 8px; }
  .save-editor-header-actions { gap: 6px; margin-left: auto; }
  .save-carryover-open { padding: 3px 8px; }
  .save-editor-header .save-eyebrow { display: none; }
  .save-editor-header h2 { font-size: 18px; }
  .save-editor-content { gap: 6px; padding: 8px 12px; }
  .save-file-toolbar { flex-wrap: wrap; gap: 6px 8px; }
  .save-file-info { flex-basis: 150px; }
  .save-file-info strong { font-size: 12px; }
  .save-file-info span { font-size: 10px; }
  .save-slot-select-label { width: 100%; }
  .save-slot-summary { flex-direction: column; align-items: stretch; padding: 7px 10px; gap: 5px; }
  .save-slot-summary dl { width: 100%; gap: 8px; justify-content: space-between; }
  .save-slot-summary dl > div { display: flex; align-items: baseline; gap: 5px; }
  .save-slot-summary dt { font-size: 10px; }
  .save-slot-summary dd { margin: 0; font-size: 11px; }
  .save-slot-heading .save-eyebrow { display: none; }
  .save-slot-heading strong { font-size: 15px; }
  #saveSlotTitle { font-size: 12px; }
  .save-slot-filters { flex-direction: column; gap: 6px; }
  .save-slot-filters > label { justify-content: flex-end; }
  .save-slot-filters select { width: 150px; min-height: 36px; }
  .save-slot-cards { grid-template-columns: 1fr; }
  .save-empty { justify-content: flex-start; padding: 14px; gap: 10px; }
  .save-empty-flow { grid-template-columns: 1fr; }
  .save-editor-body { grid-template-columns: minmax(0,1fr); grid-template-rows: auto auto minmax(0,1fr) auto; grid-template-areas: "tabs" "add" "records"; gap: 6px; min-height: 0; }
  #saveNameNote { grid-row: 4; }
  .save-game-toolbar .editor-tab { min-height: 36px; padding: 5px 8px; font-size: 12px; }
  #saveRecordNote { display: none; }
  .save-add-unit > summary { padding: 5px 10px; font-size: 12px; }
  .save-add-unit-fields { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .save-editor-shell .save-record-layout { min-height: 0; height: 100%; overflow: hidden; flex: none; }
  .save-record-sidebar { width: 100%; min-height: 0; }
  .save-record-layout[data-mobile-view=list] .save-detail { display: none; }
  .save-record-layout[data-mobile-view=detail] .save-record-sidebar { display: none; }
  .save-detail { height: 100%; display: grid; grid-template-rows: 30px minmax(0,1fr); gap: 5px; overflow: hidden; }
  .save-back-list { display: inline-flex; min-height: 30px; margin: 0; padding: 4px 8px; align-self: start; justify-self: start; font-size: 12px; }
  .save-selected-panel.game-panel { --save-identity-height: 80px; display: grid; grid-template-columns: 136px minmax(0,1fr); grid-template-rows: var(--save-identity-height) 34px minmax(0,1fr) 32px; gap: 6px; padding: 8px; margin: 0; }
  .save-selected-panel.game-panel:has(#savePilotFields:not([hidden])) { grid-template-rows: var(--save-identity-height) minmax(0,1fr); }
  .save-record-art { grid-column: 1; grid-row: 1; min-height: 0; gap: 3px; padding: 3px; margin: 0; }
  .save-unit-art canvas { height: 60px; max-width: 76px; }
  .save-unit-art figcaption { display: none; }
  .save-pilot-art { width: 47px; padding-left: 3px; }
  .save-pilot-art canvas { height: 40px; max-width: 44px; }
  .save-pilot-art figcaption { font-size: 9px; line-height: 1.2; }
  .save-selected-heading { grid-column: 2; grid-row: 1; align-self: center; margin: 0; padding: 0; border: 0; }
  .save-selected-panel .save-selected-heading h3 { font-size: 16px; color: var(--ed-gold); }
  .save-selected-heading p { font-size: 10px; }
  .save-selected-panel .save-detail-tabs { grid-column: 1/-1; grid-row: 2; margin: 0; padding: 0; border: 0; gap: 4px; }
  .save-detail-tabs button { min-height: 32px; font-size: 11px; }
  #saveUnitFields { grid-column: 1/-1; grid-row: 3; }
  #saveUnitPager { grid-row: 4; }
  #savePilotFields { grid-column: 1/-1; grid-row: 2; }
  .save-upgrade-label { font-size: 12px; margin-bottom: 3px; }
  .save-upgrade-label > span { -webkit-line-clamp: 1; }
  .save-upgrade-label output { font-size: 11px; }
  .save-upgrade-body > button { min-height: 32px; }
  .save-upgrade-box { min-height: 22px; }
  .save-common-fields { align-content: start; min-height: 0; gap: 8px; }
  .save-common-fields .game-panel { padding: 10px; }
  .save-common-fields h3 { font-size: 15px; margin-bottom: 8px; }
  .save-common-fields .save-help { font-size: 10px; margin-top: 6px; }
  .save-editor-footer { gap: 6px 8px; padding: 7px 12px 9px; }
  .save-footer-note { display: none; }
  .save-editor-actions { justify-content: flex-end; }
  .save-editor-actions button { min-height: 34px; }
}
@media (max-width: 600px) {
  .save-editor-dialog, .carryover-dialog { width: 100vw; height: 100dvh; max-height: 100dvh; margin: 0; border: 0; border-radius: 0; }
  .carryover-shell { height: 100%; }
  .save-add-unit-fields, .carryover-slot-row { grid-template-columns: 1fr; }
}
@media (max-width: 900px) and (max-height: 740px) {
  .save-editor-header { padding: 5px 10px; }
  .save-editor-header .record-tool { min-height: 30px; }
  .save-file-info { display: none; }
  .save-file-toolbar { flex-wrap: nowrap; }
  .save-slot-select-label { width: auto; min-width: 0; flex: 1; gap: 4px; font-size: 10px; }
  .save-file-picker { min-height: 32px; font-size: 11px; }
  .save-slot-select-label select { min-height: 32px; font-size: 11px; padding-inline: 5px; }
  .save-add-unit > summary { padding: 4px 8px; font-size: 11px; }
  .save-detail { grid-template-rows: 26px minmax(0,1fr); gap: 3px; }
  .save-back-list { min-height: 26px; padding: 3px 6px; }
  .save-selected-panel.game-panel { --save-identity-height: 64px; grid-template-rows: var(--save-identity-height) 32px minmax(0,1fr) 30px; padding: 6px; gap: 4px; }
  .save-unit-art canvas { height: 48px; }
  .save-pilot-art canvas { height: 34px; }
  .save-pager, .save-pager button { min-height: 30px; }
  #savePilotFields { gap: 6px; }
  #savePilotFields label { gap: 3px; }
  #savePilotFields input { min-height: 34px; padding-block: 4px; }
  #savePilotFields .save-help { margin: 0; font-size: 10px; }
}
@media (max-height: 680px) {
  .save-editor-content { overflow-y: auto; }
  .save-context-stack:has(.save-slot-browser[open]) { flex: 1 0 auto; }
  .save-slot-browser[open] { flex: 1 0 264px; min-height: 264px; }
  .save-editor-body { flex: 1 0 340px; min-height: 340px; }
  .save-editor-shell .save-common-fields { overflow-y: auto; }
}
.save-editor-content:has(#saveCheckPanel[open]) { overflow-y: auto; }
.save-editor-content:has(#saveCheckPanel[open]) .save-editor-body { flex: 1 0 340px; min-height: 340px; }

/* Mode bar ---------------------------------------------------------------------------------------- */

.mode-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  grid-column: 1 / -1;
}

.mode-switch {
  display: inline-flex;
  flex: 0 0 auto;
  padding: 3px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--white);
}

.mode-switch-button {
  min-height: 32px;
  padding: 0 16px;
  border: 0;
  border-radius: 999px;
  color: var(--ink-soft);
  background: transparent;
  font: inherit;
  font-size: var(--fs-primary);
  font-weight: 850;
  cursor: pointer;
}

.mode-switch-button[aria-pressed="true"] {
  color: var(--white);
  background: var(--blue);
}

.mode-switch-button:not([aria-pressed="true"]):not(:disabled):hover {
  color: var(--blue-deep);
  background: rgba(39, 93, 225, 0.08);
}

/* The other mode's job is still running: a small pulsing dot says so without changing the label. */
.mode-switch-button[data-busy="true"]::after {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-left: 7px;
  border-radius: 50%;
  background: var(--blue);
  animation: mode-busy-pulse 1.1s ease-in-out infinite;
  vertical-align: 1px;
}

@keyframes mode-busy-pulse {
  50% {
    opacity: 0.3;
  }
}

@media (prefers-reduced-motion: reduce) {
  .mode-switch-button[data-busy="true"]::after {
    animation: none;
  }
}

.mode-switch-button:disabled,
.mode-setup-toggle:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

/* The origin line of the open editor session: what is being edited, then what saving does. */
.mode-summary {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
}

.mode-summary p {
  margin: 0;
  overflow-wrap: anywhere;
}

.origin-line {
  color: var(--ink);
  font-size: clamp(13px, 12px + 0.2vw, 16px);
  font-weight: 850;
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.origin-note {
  color: var(--ink-soft);
  font-size: var(--fs-label);
  font-weight: 700;
  line-height: 1.35;
}

.mode-setup-toggle {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  color: var(--ink);
  background: var(--white);
  font: inherit;
  font-size: var(--fs-label);
  font-weight: 800;
  cursor: pointer;
}

.mode-setup-toggle:not(:disabled):hover {
  border-color: var(--blue);
  color: var(--blue-deep);
}

.mode-setup-toggle[aria-expanded="true"] > span:last-child {
  transform: rotate(180deg);
}

.mode-setup-toggle .toggle-short {
  display: none;
}

/* Every card sits in the row under the bar; the narrow layout lets the grid place them in order. */
.patch-workspace {
  grid-template-rows: auto minmax(0, 1fr);
}

/* Side by side (every desktop width): the three cards of the row are equally wide in both modes (they are already as
   tall as the row). */
@media (min-width: 761px) {
  .patch-workspace {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.patch-workspace > :not(.mode-bar) {
  grid-row: 2;
}
#editorSourceRegion { grid-column: 1; }
#releaseRegion { grid-column: 2; }
#editorEntryRegion { grid-column: 3; }
body[data-view="save"] #workflowSaveRegion { grid-column: 1 / -1; grid-row: 2; }
.workflow-save { display: grid; align-content: start; align-self: start; height: auto; max-height: 100%; gap: 12px; padding: 20px; width: 100%; max-width: 760px; justify-self: center; overflow: auto; }
.workflow-save:focus { outline: none; }
.workflow-save:focus-visible { outline: 3px solid var(--blue); outline-offset: -3px; }
.workflow-save > * { margin: 0; }
.workflow-save h3 { font-size: 18px; line-height: 1.4; }
.workflow-save p { font-size: 14px; line-height: 1.5; }
#workflowSaveSummary { white-space: normal; overflow-wrap: anywhere; font-weight: 700; color: var(--ink); }
.editor-fallback-note {
  min-width: 0;
  margin: 6px 0;
  padding: 9px 11px;
  color: #5c3b00;
  background: #fff6db;
  border: 1px solid #dfb456;
  border-left: 4px solid #c9860a;
  border-radius: 6px;
  font-size: 12px;
  line-height: 1.55;
  white-space: pre-line;
  overflow-wrap: anywhere;
}
body[data-view="setup"] #editorSourceRegion .editor-fallback-note {
  color: #ffefc4;
  background: rgba(196, 146, 46, 0.2);
  border-color: rgba(242, 198, 92, 0.55);
  border-left-color: #f2c65c;
}
.workflow-save .editor-intro { font-size: 12px; color: var(--ink-soft); }
.workflow-save-navigation { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-top: 4px; padding-top: 10px; border-top: 1px solid var(--line); }
.workflow-save-navigation .workflow-folder-save {
  margin-right: auto;
  min-height: 40px;
  padding: 6px 12px;
  border: 1px solid var(--blue);
  border-radius: 8px;
  color: var(--blue-deep);
  background: rgba(39, 93, 225, 0.08);
  font-size: 13px;
  font-weight: 750;
  text-decoration: none;
}
.workflow-save-navigation .workflow-folder-save:not(:disabled):hover {
  background: rgba(39, 93, 225, 0.16);
}
.workflow-save .editor-download-actions { display: flex; flex-direction: row; flex-wrap: wrap; gap: 8px; }
.workflow-save .editor-download-actions[hidden] { display: none; }
.workflow-output-methods { flex: 0 0 100%; margin: 0; color: var(--ink-soft); font-size: var(--fs-label); line-height: 1.5; }
.workflow-save .editor-download-actions > span { flex: 1 1 180px; min-width: 0; align-self: center; white-space: normal; overflow-wrap: anywhere; position: static; width: auto; height: auto; max-height: none; overflow: visible; clip: auto; color: var(--ink-soft); order: 2; }
.workflow-save .editor-download-actions > a { flex: 1 1 calc(50% - 8px); }
.workflow-copy-hash { order: 2; flex: 0 0 90px; min-height: 36px; padding: 4px; border: 1px solid var(--line); border-radius: 6px; background: var(--white); color: var(--ink); font: inherit; font-size: 12px; cursor: pointer; white-space: nowrap; }
summary:focus-visible { outline: 3px solid var(--yellow); outline-offset: 2px; }
#workflowSaveFeedback:not(:has(> :not([hidden]))) { display: none; }
.release-card[data-patch-choices="false"] :is(.selector-grid, .font-preview-row, .patch-note-toggle, .release-facts) { display: none; }
.release-card .card-heading h3 { display: block; }
#release-heading { white-space: nowrap; }
@media (min-width: 761px) and (max-width: 1100px) {
  .card-heading h3, .zone-heading h3 { font-size: var(--fs-primary); }
  .release-card .card-heading { min-height: calc(1.6 * var(--fs-label) + 10px); }
}
@media (min-width: 761px) and (max-width: 1100px), (max-width: 760px) and (max-height: 480px) and (min-width: 520px) {
  #workflowPatchState { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0,0,0,0); }
}
@media (max-width: 760px) and (max-height: 480px) and (min-width: 520px) {
  .release-card .card-heading { min-height: calc(1.6 * var(--fs-label) + 8px); }
}
.workflow-language { border: 0; padding: 0; margin: 8px 0; display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 8px; }
.workflow-language legend { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
.workflow-language label { display: flex; align-items: center; gap: 6px; min-height: 44px; padding: 6px; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; font-size: 14px; line-height: 1.4; }
.workflow-language label:has(input:checked) { border-color: var(--blue); background: rgba(39,93,225,.06); }
.workflow-language label:has(input:disabled) { cursor: default; }
.workflow-language label:has(input:focus-visible) { outline: 2px solid var(--blue); outline-offset: 2px; }
.workflow-language span { min-width: 0; white-space: nowrap; }
.workflow-language input { flex: 0 0 18px; width: 18px; height: 18px; margin: 0; accent-color: var(--blue); }
.workflow-language p { grid-column: 1 / -1; margin: 0; font-size: 12px; line-height: 1.5; }
body[data-view="setup"] .mode-bar { display: none; }
body[data-view="setup"] .patch-workspace { grid-template-rows: auto; align-content: start; gap: 16px; padding: 12px 22px 24px; background: transparent; }
body[data-view="setup"][data-patch-settings="skip"] .patch-workspace { grid-template-columns: repeat(2, minmax(0, 1fr)); }
body[data-view="setup"][data-patch-settings="skip"] #editorEntryRegion { grid-column: 2; }
body:is([data-view="setup"], [data-view="save"]) .patch-console { align-self: start; height: auto; max-height: 100%; }
body:is([data-view="setup"], [data-view="save"]) .patch-workspace { height: auto; max-height: 100%; }
body[data-view="setup"] .patch-workspace > .workflow-zone { grid-row: 1; height: auto; max-height: 100%; align-self: stretch; }
body[data-view="setup"] .source-zone-body { margin-block: 0; }
body[data-view="setup"] #editorSourceRegion { align-content: start; }
body[data-view="setup"] .card-feedback:not(:has(> :not([hidden]))) { display: none; }
body[data-view="setup"] #editorEntryRegion { flex: 0 0 auto; }
.saturn-mini-frame {
  position: relative;
  width: 200px;
  height: 128px;
  flex: 0 0 auto;
  overflow: hidden;
  pointer-events: none;
  user-select: none;
  -webkit-user-select: none;
}
.saturn-mini-frame *, .saturn-mini-frame *::before, .saturn-mini-frame *::after { box-sizing: border-box; }
.saturn-mini-art {
  position: absolute;
  inset: 0 auto auto 0;
  width: 800px;
  height: 510px;
  transform: scale(.25);
  transform-origin: 0 0;
}
.saturn-mini-pad {
  --saturn-mini-outline: path("M 400 48 C 342 48 281 16 214 17 C 131 10 73 63 33 153 C 7 212 -4 304 9 361 C 18 407 54 435 99 438 C 148 440 178 409 224 388 C 281 361 342 346 400 346 C 458 346 519 361 576 388 C 622 409 652 440 701 438 C 746 435 782 407 791 361 C 804 304 793 212 767 153 C 727 63 669 10 586 17 C 519 16 458 48 400 48 Z");
  --saturn-mini-face: path("M 400 80 C 319 79 254 60 190 67 C 119 74 73 126 53 196 C 32 268 31 333 63 367 C 99 407 145 404 196 379 C 265 345 331 331 400 331 C 469 331 535 345 604 379 C 655 404 701 407 737 367 C 769 333 768 268 747 196 C 727 126 681 74 610 67 C 546 60 481 79 400 80 Z");
  position: absolute;
  left: 0;
  top: 61px;
  width: 800px;
  height: 450px;
  filter: drop-shadow(0 12px 8px #30312f32);
}
.saturn-mini-cord { position: absolute; left: 389px; top: -66px; width: 16px; height: 93px; border-radius: 9px; background: linear-gradient(90deg, #353735, #737471 40%, #353735); transform: rotate(-7deg); }
.saturn-mini-cord::after { content: ""; position: absolute; left: -8px; bottom: -21px; width: 30px; height: 58px; border-radius: 7px; background: repeating-linear-gradient(0deg, #383937 0 5px, #767874 5px 7px, #323331 8px 10px); }
.saturn-mini-shoulder { position: absolute; top: 4px; width: 168px; height: 60px; border-radius: 64% 62% 19% 19% / 92% 90% 14% 14%; background: linear-gradient(#b7c5ed, #7890d4 25%, #4c67b7 70%, #334b87); box-shadow: inset 0 2px 1px #e0e5f4, 0 3px 3px #515450; }
.saturn-mini-l { left: 88px; transform: rotate(-14deg); }
.saturn-mini-r { right: 88px; transform: rotate(14deg); }
.saturn-mini-shell, .saturn-mini-face { position: absolute; inset: 0; }
.saturn-mini-shell::before, .saturn-mini-shell::after { content: ""; position: absolute; inset: 0; clip-path: var(--saturn-mini-outline); }
.saturn-mini-shell::before { transform: translateY(8px); background: linear-gradient(90deg, #767873, #afb0ac 20%, #81837e 50%, #b0b2ad 80%, #71746f); }
.saturn-mini-shell::after { background: radial-gradient(ellipse at 25% 0, #d6d8d399, transparent 55%), linear-gradient(140deg, #a3a6a0, #b6b8b3 34%, #9c9f97 69%, #a9aca5); }
.saturn-mini-face { clip-path: var(--saturn-mini-face); background: linear-gradient(147deg, #caccc7, #a6a8a3 38%, #adb0a9 80%, #ced0ca); }
.saturn-mini-face::after { content: ""; position: absolute; inset: 0; clip-path: var(--saturn-mini-face); transform: scale(.991, .984); transform-origin: 400px 235px; background: linear-gradient(125deg, #ffffff30, transparent 35%, #afb1ab33 70%, #e0e1de33), #9fa29b; }
.saturn-mini-logo { position: absolute; top: 106px; left: 331px; width: 138px; color: #4e534f; font: italic 900 49px/1 "Arial Black", Arial, sans-serif; letter-spacing: -5px; text-align: center; }
.saturn-mini-logo::after { content: "SEGA"; position: absolute; inset: 0; color: transparent; -webkit-text-stroke: 1px #b4b7b0; transform: scale(.88, .69); }
.saturn-mini-dpad { position: absolute; top: 142px; left: 80px; width: 193px; height: 193px; border-radius: 50%; background: radial-gradient(circle, #52564f 57%, #91958d 61%, #d6d8d2 71%, #979a93 74%); box-shadow: -3px -3px 5px #f2f2f188, 3px 4px 5px #52564e66; }
.saturn-mini-dpad::before { content: ""; position: absolute; inset: 18px; border-radius: 50%; background: linear-gradient(140deg, #5f625d, #353936); box-shadow: inset 1px 3px 3px #9ea19855, inset -2px -4px 3px #1d211e, 0 2px 1px #bfc2ba61; }
.saturn-mini-dpad::after { content: ""; position: absolute; inset: 27px; clip-path: polygon(34% 0, 66% 0, 66% 25%, 75% 34%, 100% 34%, 100% 66%, 75% 66%, 66% 75%, 66% 100%, 34% 100%, 34% 75%, 25% 66%, 0 66%, 0 34%, 25% 34%, 34% 25%); background: linear-gradient(145deg, #7e817a 0%, #575a55 18%, #3f433f 50%, #50544d 80%, #2f3530); }
.saturn-mini-hub { position: absolute; top: 85px; left: 85px; width: 24px; height: 24px; border-radius: 50%; background: radial-gradient(circle at 42% 35%, #6d7168, #444943); box-shadow: inset 1px 2px 2px #2b312d, 0 1px 1px #babdb677; z-index: 1; }
.saturn-mini-button { position: absolute; display: grid; place-items: center; width: 74px; height: 68px; border: 3px solid #4e524c; border-radius: 50%; color: #393e38; background: radial-gradient(ellipse at 45% 20%, #696c66, #4f544c 60%, #3a4038); box-shadow: inset 0 2px 2px #b3b7ae66, 0 5px 0 #303531, 0 7px 3px #2d322fc2, -2px -2px 2px #d8d9d599; font: italic 500 31px/1 Georgia, serif; text-shadow: 0 1px 1px #9a9e96; }
.saturn-mini-button.saturn-mini-small { width: 57px; height: 52px; border-color: #5b6a6f; color: #5d7da4; background: radial-gradient(ellipse at 45% 20%, #c0d0e9, #92acd1 45%, #6986b5); box-shadow: inset 0 2px 2px #e5ecfc, 0 4px 0 #4d6594, 0 6px 2px #344455aa, -2px -2px 2px #d5e2e7aa; font-size: 24px; text-shadow: 0 1px 0 #d6e2f4; }
.saturn-mini-x { left: 490px; top: 201px; }
.saturn-mini-y { left: 563px; top: 148px; }
.saturn-mini-z { left: 643px; top: 115px; }
.saturn-mini-a { left: 504px; top: 278px; }
.saturn-mini-b { left: 590px; top: 228px; }
.saturn-mini-c { left: 675px; top: 186px; }
.saturn-mini-start { position: absolute; top: 299px; left: 365px; width: 70px; height: 25px; border-radius: 50%; background: linear-gradient(#6599e1, #2c67bb 40%, #164b93); box-shadow: inset 0 1px 1px #c5d9ff99, 0 3px 1px #244579, 0 4px 2px #484f48, 0 0 0 8px #b6b9b282; }
.saturn-mini-start::before { content: "START"; position: absolute; top: -31px; left: 0; width: 100%; color: #8c9188; text-shadow: 0 1px 0 #dcded9; font: 16px/1 Arial, sans-serif; letter-spacing: 2px; text-align: center; }
.saturn-mini-frame { margin: 8px auto 0; opacity: .94; }
#editorEntryRegion:has(#workflowEditorFacts:not([hidden])) .saturn-mini-frame,
body[data-view="setup"] #editorEntryRegion[data-session-ready="true"] .saturn-mini-frame { display: none; }
body[data-view="setup"] #editorEntryRegion[data-session-ready="false"] > :not(.zone-heading, .saturn-mini-frame, #workflowSetupFeedback) { display: none; }
body[data-view="setup"] #editorEntryRegion[data-session-ready="false"] .saturn-mini-frame { margin: auto; max-width: 100%; }

.saturn-orbit { position: relative; width: 19px; height: 19px; border: 1.5px solid currentColor; border-radius: 50%; transform: rotate(-30deg); }
.saturn-orbit::after { content: ""; position: absolute; inset: 5px -6px; border: 1.5px solid currentColor; border-radius: 50%; background: #303845; }
.site-header .brand-copy span { color: #a9b4c4; font-weight: 500; }
.site-header .brand-copy strong { font-weight: 700; letter-spacing: -.035em; }
.site-header .user-guide-open { color: #dce3ee; border: 1px solid #596575; border-radius: 6px; background: #3c4654; box-shadow: inset 0 1px 0 #697383, 0 2px 0 #141b25; }
.site-header .user-guide-open:hover { color: #fff; background: #465365; }
.site-header .compatibility { color: #b7c6dd; }
.site-header .compatibility > span { color: #9dc797; }
.site-header .compatibility.is-unsupported { color: #f1b9b5; border-color: #845956; background: #4a3437; }
.site-header .compatibility.is-unsupported > span { color: #f1a49c; }
.saturn-fascia, .saturn-disc { display: none; }
html:has(body[data-view="setup"]) { height: auto; min-height: 100%; overflow-y: auto; }
body[data-view="setup"] { height: auto; min-height: 100dvh; overflow: visible; }
body[data-view="setup"] main { overflow: visible; }
body[data-view="setup"] .patch-section { width: min(100%, 1240px); height: auto; margin: 0 auto; padding: clamp(20px, 4.2vw, 60px) 24px 45px; }
body[data-view="setup"] .patch-console { position: relative; max-height: none; overflow: hidden; padding: 0 0 26px; border: 1px solid #aeb3ad; border-top-color: #e2e5df; border-radius: 24px 24px 40px 40px; background: linear-gradient(160deg, #c9cbc5 0%, #b3b7af 45%, #a5aaa3 100%); box-shadow: inset 0 2px 1px #e7e9e2, inset 0 -8px 1px #7d847a, 0 9px 0 #6d746a, 0 11px 0 #1a211a, 0 30px 70px #0b111d70; }
body[data-view="setup"] .patch-console::after { content: "POWER     ●                         SEGA SATURN"; display: block; margin: 0 32px; padding-top: 14px; border-top: 1px solid #899187; box-shadow: inset 0 1px 0 #d6ddd3; color: #475245; font-size: 9px; font-weight: 700; letter-spacing: .14em; line-height: 12px; text-shadow: 0 1px 0 #d6decc; }
body[data-view="setup"] .saturn-fascia { display: flex; align-items: center; gap: 26px; padding: 30px 32px 22px; min-height: 114px; }
.saturn-wordmark { display: flex; align-items: center; gap: 16px; color: #3a4954; flex: 0 0 auto; }
.saturn-wordmark > span:last-child { font-family: Arial, sans-serif; font-weight: 800; font-size: 12px; line-height: 1.1; letter-spacing: .15em; }
.saturn-wordmark > span:last-child > span { display: block; margin-top: 3px; font-weight: 800; font-size: 26px; letter-spacing: -.035em; }
.saturn-planet { position: relative; width: 41px; height: 41px; border: 2px solid #465761; border-radius: 50%; transform: rotate(-28deg); box-shadow: inset 5px 0 0 #819197, inset 9px 0 0 #b8c2bb; }
.saturn-planet::after { content: ""; position: absolute; inset: 13px -13px; border: 2px solid #465761; border-radius: 50%; background: #bac3b9; }
.saturn-fascia-copy { border-left: 1px solid #919d91; padding-left: 26px; text-shadow: 0 1px 0 #e4e8dc; }
.saturn-fascia-copy > span { display: block; color: #4d6057; font-size: 9px; letter-spacing: .2em; line-height: 1.5; }
.saturn-fascia-copy strong { display: block; margin-top: 6px; color: #354840; font-size: 16px; font-weight: 600; letter-spacing: -.035em; }
.saturn-vents { width: clamp(70px, 15vw, 174px); height: 26px; margin-left: auto; border-radius: 4px; background: repeating-linear-gradient(90deg, #6e7c6b 0 3px, #a6b09e 3px 5px, transparent 5px 9px); box-shadow: inset 0 2px 1px #5c6d5c4d, 0 1px 0 #e1e6d499; opacity: .85; }
body[data-view="setup"] .workflow-zone { min-height: 340px; padding: 22px; border-radius: 12px; border: 1px solid #7c8c7e; background: #d2d9cc; box-shadow: inset 0 2px 2px #fff8, 0 2px 0 #e2e6d9, 0 -2px 1px #6b7a686b; }
body[data-view="setup"] .workflow-zone::after { animation: none; opacity: 0; }
body[data-view="setup"] #patchWorkspace > .workflow-zone:is(.is-active, .is-busy, .is-prepared, .is-verifying) { border-color: #7c9cda; box-shadow: 0 0 0 1px #7c9cda80, inset 0 2px 2px #0e141f80, 0 2px 0 #e2e6d9; }
body[data-view="setup"] .workflow-zone.is-busy::after { opacity: 1; animation: workflow-border-flow 2.1s linear infinite; }
body[data-view="setup"] #patchWorkspace > .workflow-zone.is-complete { border-color: #659474; box-shadow: inset 0 0 0 1px #659474, 0 2px 0 #e2e6d9; }
body[data-view="setup"] #patchWorkspace > .workflow-zone.is-error { border-color: #b45350; box-shadow: inset 0 0 0 1px #b45350, 0 2px 0 #e2e6d9; }
body[data-view="setup"] :is(.card-heading, .zone-heading) { gap: 8px; padding-bottom: 14px; border-bottom: 1px solid #aebcab; }
body[data-view="setup"] :is(.card-heading, .zone-heading) h3 { font-size: clamp(14px, 1.22vw, 17px); font-weight: 650; }
body[data-view="setup"] :is(.zone-state, .state-chip) { padding: 4px 7px; border-radius: 4px; font-size: 11px; font-weight: 600; background: #b8c6b470; }
body[data-view="setup"] #editorSourceRegion { --ink: #e9eef5; --ink-soft: #afbac8; --white: #303944; --line: #526173; color: var(--ink); background: linear-gradient(145deg, #2b3440, #202731); border-color: #3c4c62; }
body[data-view="setup"] #editorSourceRegion .zone-heading { border-color: #4b586b; }
body[data-view="setup"] #editorSourceRegion .zone-state { color: #b9c8dd; background: #435269; }
body[data-view="setup"] #editorSourceRegion .source-zone-body { display: flex; flex-direction: column; }
body[data-view="setup"] #editorSourceRegion .source-zone-body > p { margin: 16px 0 14px; text-align: center; font-size: 12px; }
body[data-view="setup"] .saturn-disc { display: grid; flex: 0 0 auto; place-items: center; position: relative; width: 114px; height: 114px; margin: 20px auto 2px; border: 1px solid #758192; border-radius: 50%; background: conic-gradient(from 25deg, #5d6b7a, #b9c5c6 14%, #747b99 28%, #c4d4d1 38%, #657383 54%, #c0cad3 72%, #7885a7 84%, #5d6b7a); box-shadow: 0 0 0 7px #17212c, 0 0 0 8px #4a5767, 0 8px 14px #0e151b8c, inset 0 0 0 5px #b0bec447; }
.saturn-disc::before { content: ""; position: absolute; inset: 13px; border: 1px solid #e2e8e752; border-radius: 50%; box-shadow: 0 0 0 6px #d1e3e01a; }
.saturn-disc-hub { position: absolute; width: 31px; height: 31px; border: 7px solid #94a5b57d; border-radius: 50%; background: #252f3a; box-shadow: 0 0 0 1px #d7e2e4a3, inset 0 1px 3px #101923; }
.saturn-disc-label { position: absolute; top: 22px; color: #243e52; font: 700 8px Arial, sans-serif; letter-spacing: .06em; }
.saturn-disc-caption { position: absolute; bottom: 19px; color: #233849; font: 600 6px Arial, sans-serif; letter-spacing: .1em; }
body[data-view="setup"] #editorSourceRegion:has(.file-selection:not([hidden])) .saturn-disc,
body[data-view="setup"] #editorSourceRegion:has(.card-feedback > :not([hidden])) .saturn-disc { display: none; }
body[data-view="setup"] #editorSourceRegion .file-button { justify-content: center; width: 100%; min-height: 48px; margin-top: 0; border: 1px solid #81a1e9; border-bottom-color: #244787; border-radius: 7px; color: #fff; background: linear-gradient(180deg, #6387dc, #4166c2); box-shadow: inset 0 1px 0 #a8c2fd, 0 4px 0 #1e3c79, 0 6px 8px #101b2b80; text-align: center; font-weight: 650; }
body[data-view="setup"] #editorSourceRegion .file-button:not(:disabled):hover { background: linear-gradient(180deg, #7699ed, #5376d0); }
body[data-view="setup"] #editorSourceRegion .file-button:not(:disabled):active { transform: translateY(3px); box-shadow: inset 0 1px 0 #a8c2fd, 0 1px 0 #1e3c79; }
body[data-view="setup"] #editorSourceRegion .file-button:disabled { color: #8a96a7; border-color: #5e6b7d; background: #3b485b; box-shadow: none; }
body[data-view="setup"] #editorSourceRegion .button-symbol { color: inherit; }
body[data-view="setup"] #releaseRegion { background: radial-gradient(circle at 105% 110%, transparent 90px, #97a08f40 91px 92px, transparent 93px 103px, #97a08f30 104px 105px, transparent 106px 117px, #97a08f20 118px 119px, transparent 120px), linear-gradient(145deg, #dcdfd8, #c8cfc3); }
body[data-view="setup"] .workflow-language { margin-top: 20px; gap: 8px; }
body[data-view="setup"] .workflow-language label { padding: 9px 7px; border: 1px solid #9ba995; border-radius: 6px; background: #bdc8b8; box-shadow: inset 0 1px 3px #6c7e6040; }
body[data-view="setup"] .workflow-language label:has(input:checked) { border-color: #6889c3; color: #2b4679; background: #cfdbeb; box-shadow: inset 0 1px 3px #7792b840; }
body[data-view="setup"] .workflow-language p { margin-top: 5px; color: #53654c; }
body[data-view="setup"] #editorEntryRegion { color: #e1e7ed; border-color: #4d5b62; background: linear-gradient(155deg, #525e65, #3d4850); }
body[data-view="setup"] #editorEntryRegion .zone-heading { border-color: #78868a; }
body[data-view="setup"] #editorEntryRegion .zone-state { color: #d1d9df; background: #6c7b8170; }
body[data-view="setup"] #editorEntryRegion .workflow-status-strip {
  margin-top: 12px;
  padding: 7px 10px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 6px;
  background: rgba(20, 29, 35, 0.34);
}
body[data-view="setup"] #editorEntryRegion .workflow-status-strip[hidden] { display: none; }
body[data-view="setup"] #editorEntryRegion .workflow-detected-summary,
body[data-view="setup"] #editorEntryRegion .workflow-session-brief {
  margin: 0;
  color: #e4edf3;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.45;
  white-space: normal;
  overflow-wrap: anywhere;
}
body[data-view="setup"] #editorEntryRegion .workflow-action-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 12px;
}
body[data-view="setup"] #editorEntryRegion .workflow-action-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
body[data-view="setup"] #editorEntryRegion .workflow-action-item[hidden] { display: none; }
body[data-view="setup"] #editorEntryRegion .workflow-action-item.is-skip {
  margin-top: 2px;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.18);
}
body[data-view="setup"] #editorEntryRegion .primary-button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  text-align: center;
  min-height: 44px;
  margin-top: 0;
  padding: 8px 12px;
  border: 1px solid #879dbb;
  border-radius: 6px;
  color: #eff4fb;
  background: linear-gradient(#6687c1, #4265a5);
  box-shadow: inset 0 1px 0 #a1b7db, 0 3px 0 #283e61;
  font-size: 14px;
  font-weight: 650;
}
body[data-view="setup"] #editorEntryRegion .primary-button:not(:disabled):hover {
  background: linear-gradient(#7496d0, #4d72b5);
}
body[data-view="setup"] #editorEntryRegion .primary-button:disabled {
  color: #b4c1cb;
  border-color: #647583;
  background: linear-gradient(#5b6a79, #4e5e6e);
  box-shadow: inset 0 1px 0 #7a8996, 0 3px 0 #2e3b47;
}
body[data-view="setup"] #editorEntryRegion #saveEditorOpen:not(:disabled) {
  border-color: #6a999c;
  background: linear-gradient(#396973, #274a53);
  box-shadow: inset 0 1px 0 #8cc0c5, 0 3px 0 #173038;
}
body[data-view="setup"] #editorEntryRegion #saveEditorOpen:not(:disabled):hover {
  background: linear-gradient(#447984, #2f5963);
}
body[data-view="setup"] #editorEntryRegion #workflowSkipEditor {
  border: 1px solid #aebcc6;
  color: #eef4f8;
  background: rgba(255, 255, 255, 0.08);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.14);
}
body[data-view="setup"] #editorEntryRegion #workflowSkipEditor:not(:disabled):hover {
  border-color: #d4e1ea;
  background: rgba(255, 255, 255, 0.16);
}
body[data-view="setup"] #editorEntryRegion #workflowSkipEditor:disabled {
  color: #9ba8b2;
  border-color: #647583;
  background: rgba(255, 255, 255, 0.04);
  box-shadow: none;
}
body[data-view="setup"] #editorEntryRegion .workflow-action-desc {
  margin: 0;
  padding: 0 2px;
  color: #c7d4dd;
  font-size: 11.5px;
  line-height: 1.45;
  word-break: keep-all;
  overflow-wrap: anywhere;
}
body[data-view="setup"] #editorEntryRegion .workflow-link { min-height: 36px; padding: 10px 0 3px; color: #d4dee6; font-size: 11px; text-underline-offset: 3px; }
body[data-view="setup"] #editorEntryRegion .workflow-link:disabled { opacity: .68; }
body[data-view="setup"] #saveEditorOpen { display: flex; align-items: center; justify-content: center; text-align: center; }
body[data-view="setup"] #saveEditorOpen[hidden] { display: none; }
body[data-view="setup"] #editorEntryRegion .workflow-entry-details {
  margin-top: 12px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 6px;
  background: rgba(20, 29, 35, 0.32);
}
body[data-view="setup"] #editorEntryRegion .workflow-entry-details[hidden] { display: none; }
body[data-view="setup"] #editorEntryRegion .workflow-entry-details > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 36px;
  padding: 6px 10px;
  color: #dce7ef;
  font-size: 12px;
  font-weight: 650;
  cursor: pointer;
  list-style: none;
}
body[data-view="setup"] #editorEntryRegion .workflow-entry-details > summary::-webkit-details-marker { display: none; }
body[data-view="setup"] #editorEntryRegion .workflow-entry-details > summary::after { content: "▾"; font-size: 11px; color: #b7c8d4; }
body[data-view="setup"] #editorEntryRegion .workflow-entry-details[open] > summary::after { content: "▴"; }
body[data-view="setup"] #editorEntryRegion .workflow-entry-details-body {
  display: grid;
  gap: 6px;
  padding: 8px 10px 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.14);
}
body[data-view="setup"] #editorEntryRegion .workflow-entry-origin {
  margin: 0;
  color: #c5d4df;
  font-size: 11.5px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}
body[data-view="setup"] #editorEntryRegion .workflow-editor-facts { margin: 2px 0 0; color: #d8e2ea; }
body[data-view="setup"] #editorEntryRegion :is(button, summary):focus-visible { outline: 3px solid #ffe04e; outline-offset: 2px; }
body[data-view="setup"] #patchWorkspace .zone-state:is(.is-working, .is-ready, .is-prepared) { color: #304d78; background: #cfdbeb; }
body[data-view="setup"] #patchWorkspace :is(.zone-state.is-complete, .state-chip.is-ready) { color: #2c6045; background: #c5dfcc; }
body[data-view="setup"] #patchWorkspace .zone-state.is-error { color: #873a37; background: #efd4ce; }
body[data-view="setup"] #patchWorkspace .zone-state.is-personal { color: #4f5b6b; background: #d4dae2; }
@media (max-width: 1000px) and (min-width: 761px) {
  body[data-view="setup"] .workflow-zone { padding: 16px 12px; }
  body[data-view="setup"] .patch-workspace { gap: 10px; padding-inline: 16px; }
  body[data-view="setup"] :is(.card-heading, .zone-heading) h3 { font-size: 13px; }
  body[data-view="setup"] :is(.zone-state, .state-chip) { font-size: 10px; padding-inline: 4px; }
}
@media (max-width: 760px) {
  body[data-view="setup"] .site-header { padding: 12px 15px; }
  body[data-view="setup"] .patch-section { padding: 22px 12px 30px; }
  body[data-view="setup"] .patch-console { border-radius: 18px 18px 25px 25px; padding-bottom: 25px; }
  body[data-view="setup"] .saturn-fascia { min-height: 90px; padding: 23px 23px 20px; gap: 18px; }
  .saturn-wordmark { gap: 12px; }
  .saturn-wordmark > span:last-child { font-size: 9px; }
  .saturn-wordmark > span:last-child > span { font-size: 21px; }
  .saturn-planet { width: 30px; height: 30px; }
  .saturn-planet::after { inset: 9px -9px; }
  .saturn-fascia-copy { display: none; }
  .saturn-vents { width: 80px; height: 21px; }
  body[data-view="setup"] .patch-workspace { grid-template-columns: minmax(0, 1fr); gap: 13px; padding: 0 14px 20px; overflow: visible; }
  body[data-view="setup"][data-patch-settings="skip"] .patch-workspace { grid-template-columns: minmax(0, 1fr); }
  body[data-view="setup"][data-patch-settings="skip"] #editorEntryRegion { grid-column: 1; }
  body[data-view="setup"] .patch-workspace > #editorSourceRegion { order: 1; grid-column: 1; grid-row: auto; }
  body[data-view="setup"] .patch-workspace > #releaseRegion { order: 2; grid-column: 1; grid-row: auto; }
  body[data-view="setup"] .patch-workspace > #editorEntryRegion { order: 3; grid-column: 1; grid-row: auto; }
  body[data-view="setup"] .workflow-zone { min-height: 0; padding: 20px; }
  body[data-view="setup"] #editorSourceRegion { padding-bottom: 24px; }
  body[data-view="setup"] #editorSourceRegion .file-selection:not([hidden]) { display: grid !important; margin-top: 12px; }
  body[data-view="setup"] #editorSourceRegion .file-selection div > span { white-space: normal; overflow-wrap: anywhere; }
  body[data-view="setup"] #editorSourceRegion:not(:has(.file-selection:not([hidden]))):not(:has(.card-feedback > :not([hidden]))) .editor-source-help { display: block; }
  #release-heading { white-space: normal; }
  .origin-line { white-space: normal; overflow-wrap: anywhere; }
  body[data-view="setup"] :is(.card-heading, .zone-heading) h3 { font-size: 15px; }
  body[data-view="setup"] .saturn-disc { width: 98px; height: 98px; margin-top: 20px; }
  body[data-view="setup"] .patch-console::after { margin-inline: 23px; font-size: 8px; }
}
@media (prefers-reduced-motion: reduce) {
  body[data-view="setup"] .workflow-zone.is-busy::after { animation: none; }
}
body[data-view="save"] .origin-note,
body[data-view="editor"] .origin-note { display: none; }
.font-preview > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.source-zone .file-selection strong,
.source-zone .file-selection div > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.workflow-editor-facts { margin: 10px 0 0; display: grid; gap: 4px; font-size: 13px; line-height: 1.4; }
.workflow-editor-facts > div { display: flex; justify-content: space-between; gap: 12px; }
.workflow-editor-facts dd { margin: 0; font-variant-numeric: tabular-nums; }
.workflow-detected-summary { margin: 8px 0 0; color: var(--ink-soft); font-size: 12px; line-height: 1.5; white-space: normal; overflow-wrap: anywhere; }
body[data-mode="editor"] .release-card .selector-grid > div:first-child,
body[data-mode="editor"] .release-card .release-facts { display: none; }
.workflow-link { border: 0; background: transparent; color: inherit; text-decoration: underline; text-underline-offset: 4px; padding: 12px 4px; cursor: pointer; min-height: 44px; }
.workflow-link:disabled { opacity: .5; cursor: default; }
.source-zone .file-button { min-height: 44px; margin-top: 8px; padding-block: 8px; border-radius: 8px; line-height: 1.25; }
body[data-view="save"] .patch-workspace { display: grid; grid-template-columns: minmax(0,1fr); grid-template-rows: auto minmax(0,1fr); }
@media (max-width: 760px) and (min-height: 481px), (max-width: 519px) {
  body[data-view="setup"] #editorSourceRegion { order: 1; grid-column: 1 / -1; }
  body[data-view="setup"] #releaseRegion { order: 2; grid-column: 1 / -1; }
  body[data-view="setup"] #editorEntryRegion { order: 3; grid-column: 1 / -1; }
}
@media (max-width: 760px) {
  .workflow-save { padding: 12px; gap: 8px; }
  .workflow-language { margin-block: 8px; gap: 6px; }
}
@media (max-width: 760px) and (max-height: 480px) and (min-width: 520px) {
  #editorSourceSelection:not([hidden]) { display: flex !important; }
  #editorSourceSelection .file-type, #editorSourceSelection .file-check { display: none; }
  .workflow-save { grid-template-columns: minmax(0,1fr) minmax(0,1fr); column-gap: 16px; }
  .workflow-save h3 { grid-column: 1 / -1; }
  #workflowSaveFeedback { grid-column: 2; grid-row: 2 / span 4; }
  .workflow-save > :is(p, button, nav) { grid-column: 1; }
}


body[data-mode="editor"] #sourceRegion,
body[data-mode="editor"] #patchRegion {
  display: none;
}

/* Disc card states of the editor (a personal image is never shown as matching a public hash). */
.zone-state.is-personal {
  color: var(--ink-soft);
  background: rgba(64, 80, 99, 0.14);
}

.file-check.is-personal {
  color: var(--ink-soft);
  background: rgba(64, 80, 99, 0.14);
  font-style: italic;
}

.file-check.is-error {
  color: var(--red);
  background: rgba(200, 62, 67, 0.11);
}

/* Setup view of the editor ---------------------------------------------------------------------- */

/* The editor's folder card and entry card take the place of the patcher's folder card and patch card: same row, same
   columns, same shape, one button. Only the wording differs. */
.editor-entry {
  display: flex;
  flex-direction: column;
  padding: 18px;
}

.editor-entry .editor-intro {
  display: none;
}

.editor-entry .editor-intro + .editor-intro {
  margin-top: 0;
}

/* The editor's folder card names both kinds of folder, one per line, in the heading's own style. */
.heading-lines > span {
  display: block;
}

/* One sentence per line. */
.editor-source-help {
  white-space: pre-line;
}

.editor-entry .editor-entry-note {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0,0,0,0);
}

/* Progress, the wait note and errors of a folder card sit under its button, stacked in the normal flow (usually only
   one of them shows). Nothing in the slot is drawn over the rows above it: a longer message makes the slot taller. */
.card-feedback {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 8px;
  min-width: 0;
  padding-top: 10px;
}

.card-feedback > * {
  min-width: 0;
  margin: 0;
}

.card-feedback .progress-panel,
.card-feedback .message-panel {
  padding: 10px 13px;
  border-radius: 11px;
}

.card-feedback .message-panel {
  grid-template-columns: 35px minmax(0, 1fr);
}

.card-feedback .message-panel p {
  overflow-wrap: break-word;
}

.card-feedback .progress-kicker {
  display: none;
}

.card-feedback .progress-panel progress {
  margin: 8px 0 4px;
}

.card-feedback .progress-copy {
  align-items: center;
  gap: 10px;
}

.card-feedback .progress-copy strong {
  margin-top: 0;
  font-size: 13px;
  line-height: 1.35;
}

.card-feedback .progress-actions {
  flex: 0 0 auto;
  flex-direction: row;
}

.card-feedback #progressPercent {
  flex-shrink: 0;
  white-space: nowrap;
}

.card-feedback .cancel-button {
  white-space: nowrap;
}

.card-feedback .progress-panel p {
  margin: 0;
  font-size: 12px;
  line-height: 1.5;
}

/* The folder cards are vertically centred: the slot keeps a minimum height so a check that starts after a folder is
   chosen does not move the button. */
.source-zone .card-feedback {
  min-height: 112px;
}

/* Once a folder is chosen, refused or being checked, the card's general help gives way to what the card now says. */
.source-zone:has(.card-feedback > :not([hidden])) .source-zone-body > p,
.source-zone:has(.file-selection:not([hidden])) .source-zone-body > p {
  display: none;
}

/* Side by side, a folder card whose content is taller than the row (a long reason on a short window) scrolls inside the
   card; the centring gives way instead of pushing the top rows out of the card. */
@media (min-width: 761px) {
  .source-zone.workflow-zone {
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  .source-zone-body {
    align-self: auto;
    margin-block: auto;
  }
}

/* The glow ring stays inside a card that can scroll (its outer pixel would count as overflow). */
.source-zone.workflow-zone::after {
  inset: 0;
  padding: 1px;
}

/* A chosen file's name can be long: the folder button never grows past its card (its label ends in an ellipsis) and
   the file row under it shows the whole name. */
.source-zone .file-button {
  max-width: 100%;
}

.source-zone .file-selection strong {
  white-space: normal;
  overflow-wrap: anywhere;
}

.source-zone .file-selection div span {
  overflow-wrap: anywhere;
}

/* The editor's folder button carries a longer label than the patcher's: it takes the card's width and wraps instead of
   running out of the card. */
#editorSourceButton {
  width: 100%;
  max-width: 100%;
}

#editorSourceButton > span:last-child {
  overflow: visible;
  text-align: left;
  white-space: normal;
}

/* The file chip of a chosen folder keeps its place before and after a folder is chosen, so that choosing one moves nothing. */
@media (min-width: 761px) {
  .source-zone .file-selection[hidden] {
    display: grid !important;
    visibility: hidden;
  }
}

.card-wait {
  align-self: end;
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--ink-soft);
  background: rgba(16, 31, 47, 0.06);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.55;
}

/* Detected values of an opened patched file replace the game/version/font selectors (read only). */
.release-detected {
  margin-top: 4px;
}

.release-detected .detected-value {
  margin: 0;
  color: var(--ink);
  font-size: 15px;
  font-weight: 850;
  line-height: 1.45;
}

.release-detected .detected-note {
  margin: 8px 0 0;
  color: var(--ink-soft);
  font-size: 12px;
  line-height: 1.6;
  word-break: keep-all;
}

.release-card.is-detected .selector-grid,
.release-card.is-detected .patch-note-toggle,
.release-card.is-detected .release-facts {
  display: none;
}

.editor-feedback {
  display: grid;
  min-width: 0;
  gap: 8px;
}

.editor-feedback:not(:has(> :not([hidden]))) {
  display: none;
}

.editor-progress {
  padding: 12px 13px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #f7f9ff;
}

.editor-progress-topline,
.editor-progress-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.editor-progress-topline strong,
.editor-progress-topline span {
  font-size: 12px;
}

.editor-progress-topline span {
  font-variant-numeric: tabular-nums;
  font-weight: 800;
}

.editor-progress progress {
  width: 100%;
  height: 9px;
  margin: 10px 0 2px;
  accent-color: var(--blue);
}

.editor-progress-actions span {
  color: var(--ink-soft);
  font-size: var(--fs-label);
}

.editor-cancel-button {
  min-height: 34px;
  padding: 5px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  color: var(--ink-soft);
  background: var(--white);
  font: inherit;
  font-size: var(--fs-label);
  font-weight: 800;
  cursor: pointer;
}

.editor-cancel-button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

#workflowSetupFeedback:not(:has(.editor-error:not([hidden]))) { display: none; }

.editor-error {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 0;
  padding: 11px 13px;
  border: 1px solid rgba(200, 62, 67, 0.3);
  border-radius: 9px;
  color: #812b30;
  background: #fff1f0;
  font-size: 12px;
  line-height: 1.6;
  overflow-wrap: anywhere;
}

.editor-error-text {
  flex: 1 1 auto;
  min-width: 0;
}

.editor-error-close {
  flex: 0 0 auto;
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid rgba(200, 62, 67, 0.4);
  border-radius: 8px;
  color: #812b30;
  background: var(--white);
  font: inherit;
  font-size: var(--fs-label);
  font-weight: 800;
  cursor: pointer;
}

@media (max-width: 480px) {
  .editor-error { flex-wrap: wrap; }
  .editor-error-text { flex-basis: 100%; }
}

/* The editor screen itself only exists in the editor view. */
body[data-view="setup"] .editor-workspace {
  display: none;
}

/* Editor view: bar + editor fill the page -------------------------------------------------------- */

body[data-view="editor"] #releaseRegion,
body[data-view="editor"] #editorSourceRegion,
body[data-view="editor"] #editorEntryRegion {
  display: none;
}

/* The page is one screen tall when the editor fits and scrolls the document (never a hidden inner scroller)
   when the window is too short for it. */
html:has(body[data-view="editor"]) {
  height: auto;
  min-height: 100%;
  overflow-y: auto;
}

body[data-view="editor"] {
  display: flex;
  flex-direction: column;
  height: auto;
  min-height: 100dvh;
  overflow: visible;
}

body[data-view="editor"] main,
body[data-view="editor"] .patch-section,
body[data-view="editor"] .patch-console,
body[data-view="editor"] .patch-workspace,
body[data-view="editor"] .editor-region,
body[data-view="editor"] .editor-workspace {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  height: auto;
  min-height: 0;
  overflow: visible;
}

body[data-view="editor"] .patch-section {
  padding-block: 8px 10px;
}

body[data-view="editor"] .patch-workspace {
  gap: 6px;
  padding: 8px;
}

body[data-view="editor"] .mode-bar {
  flex: 0 0 auto;
}

/* Over the editor, a running save and its errors show as a panel over a dimmed editor (nothing moves under it, and
   nothing of the editor peeks out half covered); the panel's own close or stop button gives the editor back. */
body[data-view="editor"] .editor-feedback {
  position: absolute;
  z-index: 25;
  inset: 0;
  align-content: center;
  justify-items: center;
  padding: 12px;
  background: rgba(0, 6, 16, 0.78);
}

body[data-view="editor"] .editor-feedback > * {
  box-sizing: border-box;
  width: min(560px, 100%);
}

body[data-view="editor"] .editor-region {
  position: relative;
}

.editor-workspace {
  gap: 6px;
  color: #e1e8d4;
  color-scheme: dark;
}

/* Tabs, the record notice and the unused-records toggle share one row on wide screens. On narrow screens the
   notice takes a row of its own under the tabs. */
.editor-tab-bar {
  display: flex;
  flex: 0 0 auto;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 8px;
}

.editor-tab-row {
  display: flex;
  flex: 0 0 auto;
  gap: 4px;
  min-width: 0;
  width: 600px;
}

.editor-unused-toggle {
  display: inline-flex;
  flex: 0 0 auto;
  margin-left: auto;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid #26778a;
  border-radius: 2px;
  color: #cfe3e0;
  background: #051326;
  font-size: var(--fs-label);
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
}

.editor-unused-toggle input {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: #74dc53;
  cursor: pointer;
}

/* Record notice: why a record is read-only, or what is unusual about it. The detail opens as a floating panel
   so the screen below never moves. */
.editor-record-notice {
  display: flex;
  flex: 1 1 0;
  flex-wrap: nowrap;
  gap: 4px 8px;
  min-width: 0;
}

.notice-item {
  position: relative;
  min-width: 0;
  max-width: 100%;
  flex: 0 1 auto;
  border: 1px solid #5d4d1f;
  background: #1c1704;
  color: #f1dd74;
  font-size: var(--fs-label);
}

.notice-item.is-info {
  border-color: #1f5568;
  background: #05202c;
  color: #b8e1ee;
}

.notice-item > summary {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 30px;
  padding: 3px 10px;
  overflow: hidden;
  cursor: pointer;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.notice-badge {
  flex: 0 0 auto;
  padding: 1px 6px;
  border: 1px solid currentColor;
  font-size: var(--fs-label);
  font-weight: 800;
}

.notice-title {
  min-width: 0;
  overflow: hidden;
  font-weight: 700;
  text-overflow: ellipsis;
}

.notice-body {
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 30;
  box-sizing: border-box;
  width: min(480px, calc(100vw - 24px));
  margin: 2px 0 0;
  padding: 10px 12px;
  border: 1px solid #6e5f2b;
  color: #ece6d0;
  background: #14110a;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.5);
  font-size: 13px;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.notice-item.is-info .notice-body {
  border-color: #2b7088;
  background: #07171f;
}

.editor-tab {
  flex: 1 1 0;
  min-width: 0;
  min-height: 36px;
  padding: 4px 8px;
  border: 1px solid #26778a;
  border-radius: 2px;
  color: #b9d3d1;
  background: #051326;
  font: inherit;
  font-size: var(--fs-primary);
  font-weight: 750;
  cursor: pointer;
  white-space: nowrap;
}

.editor-tab[aria-selected="true"] {
  border-color: #74dc53;
  color: #04120d;
  background: linear-gradient(#a3e56b, #60bd49);
  box-shadow: inset 0 -2px 0 #32813d;
}

.editor-tab .tab-short { display: none; }

.editor-footer {
  display: grid;
  flex: 0 0 auto;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas: "status presets" "export export";
  align-items: center;
  gap: 6px 8px;
}

.editor-footer .editor-status { grid-area: status; }
.editor-footer > .editor-primary-button { grid-area: export; }

/* The status line wraps (it is never cut); the footer grows by a line when it must. */
.editor-footer .editor-status {
  display: flex;
  flex: 1 1 200px;
  align-items: center;
  min-width: 0;
  min-height: 36px;
  margin: 0;
  padding: 5px 10px;
  border: 1px solid #174a59;
  border-radius: 0;
  color: #a9bcaa;
  background: #03101d;
  font-size: var(--fs-label);
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.editor-preset-file-actions {
  grid-area: presets;
  display: flex;
  flex: 0 0 auto;
  gap: 6px;
}

.editor-preset-file-button {
  min-height: 40px;
  padding: 5px 12px;
  border: 1px solid #174a59;
  border-radius: 0;
  color: #dcf5ef;
  background: #03101d;
  font: inherit;
  font-size: var(--fs-label);
  white-space: nowrap;
  cursor: pointer;
}

.editor-preset-file-button:not(:disabled):hover {
  border-color: #2b8796;
  background: #092333;
}

.editor-preset-file-button:disabled {
  color: #7c8884;
  cursor: not-allowed;
}

.editor-preset-file-button:focus-visible {
  outline: 2px solid #ffe04e;
  outline-offset: 1px;
}

/* The complete phone footer uses two compact rows, including migration. */
@media (max-width: 760px) {
  body[data-view="editor"] .editor-footer {
    grid-template-columns: minmax(0,1fr) auto;
    grid-template-areas: "presets presets" "status export";
    gap: 3px;
  }
  body[data-view="editor"] .editor-preset-file-actions {
    display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 3px;
  }
  body[data-view="editor"] .editor-preset-file-actions button {
    min-width: 0; min-height: 30px; height: 30px; padding: 2px;
    font-size: 10px; line-height: 1; white-space: nowrap;
  }
  body[data-view="editor"] .editor-preset-file-button .preset-long { display: none; }
  body[data-view="editor"] .editor-preset-file-button .preset-short { display: inline; }
  body[data-view="editor"] .editor-footer .editor-status {
    min-height: 32px; height: 32px; padding: 3px 6px; overflow: hidden; font-size: 10px;
  }
  body[data-view="editor"] .editor-footer .editor-status > span {
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }
  body[data-view="editor"] .editor-footer > .editor-primary-button {
    min-height: 32px; height: 32px; padding: 3px 9px; font-size: 12px; border-radius: 4px;
  }
}

.editor-primary-button {
  min-height: 40px;
  padding: 8px 16px;
  border: 1px solid transparent;
  border-radius: 10px;
  color: var(--white);
  background: var(--blue);
  font: inherit;
  font-size: var(--fs-primary);
  font-weight: 800;
  cursor: pointer;
}

.editor-primary-button:not(:disabled):hover {
  background: var(--blue-deep);
}

.editor-primary-button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.editor-download-actions {
  display: contents;
}

.editor-download-actions .download-link {
  flex: 0 0 auto;
  min-height: 40px;
  padding: 6px 14px;
  border-radius: 2px;
  font-size: var(--fs-label);
}

.editor-download-actions > span {
  order: 2;
  flex: 1 0 100%;
  max-height: 2.6em;
  overflow: hidden;
  color: #a8c0ad;
  font-size: var(--fs-label);
  line-height: 1.3;
  overflow-wrap: anywhere;
}

/* Narrow screens ---------------------------------------------------------------------------------- */

@media (max-width: 980px) {
  .mode-setup-toggle .toggle-long {
    display: none;
  }

  .mode-setup-toggle .toggle-short {
    display: inline;
  }
}

@media (max-width: 760px) {
  /* The tabs share their row only with the record notice's badge. The unused-records switch only matters for the list,
     so it shows (on a line of its own) only while the list is on screen. */
  .editor-tab-row {
    flex: 1 1 auto;
    width: auto;
  }

  .editor-tab { padding-inline: 3px; font-size: 12px; min-height: 40px; }
  .editor-tab .tab-long { display: none; }
  .editor-tab .tab-short { display: inline; }

  /* The record notice keeps the tabs' row: only its badge shows (the title stays readable to assistive technology);
     tapping it opens the explanation. */
  .editor-record-notice {
    flex: 0 0 auto;
  }

  .editor-record-notice .notice-title {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
  }

  .editor-unused-toggle {
    flex: 1 1 100%;
    order: 4;
    margin-left: 0;
  }

  .editor-workspace:not(:has(> .editor-data-panel:not([hidden])[data-page="list"])) .editor-unused-toggle {
    display: none;
  }

  .notice-item > summary {
    min-height: 28px;
    padding-block: 2px;
  }

  /* The cards stack in one column under the bar, each as tall as its content, and the last card takes what is left (the
     editor's folder card and entry card take the place of the patcher's). Nothing scrolls inside a card: when a card
     needs more room (a refused folder's reason, a result), the cards around it give way. */
  .patch-workspace {
    display: flex;
    flex-direction: column;
  }

  .patch-workspace > .workflow-zone {
    flex: 0 0 auto;
    height: auto;
    max-height: none;
  }

  .patch-workspace > :is(#patchRegion, #editorEntryRegion) {
    flex: 1 1 auto;
  }

  /* The first card's captions are read out but not drawn on a phone: the choices say what they are. */
  .release-card .field-label {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
  }

  /* While a folder's reason, a running patch or its result needs the room, the first card keeps only its choices. */
  /* While a refused folder's reason shows, the patch card (still waiting for a source) keeps only its heading. */
  body[data-mode="patch"] .patch-workspace:has(#sourceRegion .card-feedback > .message-panel:not([hidden])) #patchRegion.is-pending .apply-actions {
    display: none;
  }

  .patch-workspace:has(#patchRegion:is(.is-busy, .is-complete, .is-error)) .release-card :is(.font-preview-row, .patch-note-toggle),
  body[data-mode="patch"] .patch-workspace:has(#sourceRegion .card-feedback > :not([hidden])) .release-card :is(.font-preview-row, .patch-note-toggle),
  body[data-mode="editor"] .patch-workspace:has(#editorSourceRegion .card-feedback > :not([hidden])) .release-card:not([data-patch-choices="true"]) :is(.font-preview-row, .patch-note-toggle) {
    display: none;
  }

  .editor-entry {
    padding: 7px 9px;
  }

  .editor-entry .editor-intro {
    display: none;
  }


  /* No room for a reserved slot on a phone: it exists only while something shows in it, and then it is as tight as it can be. */
  .card-feedback {
    padding-top: 4px;
  }

  .card-feedback .progress-panel,
  .card-feedback .message-panel {
    padding: 6px 10px;
  }

  .card-feedback .progress-panel progress {
    margin: 4px 0 0;
  }

  .card-feedback:not(:has(> :not([hidden]))) {
    display: none;
  }

  .source-zone .card-feedback {
    min-height: 0;
  }

  /* On a phone the card has no room for both: while a check runs its bar (with its own stop button) takes the place of
     the heading, the folder button and the file chip. */
  .source-zone:has(.card-feedback > .progress-panel:not([hidden])) .zone-heading,
  .source-zone:has(.card-feedback > .progress-panel:not([hidden])) .file-button,
  .source-zone:has(.card-feedback > .progress-panel:not([hidden])) .file-selection {
    display: none;
  }

  .card-feedback .progress-panel p {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
  }

  /* A folder the page refused needs room for its reason: the card's heading gives way to it, and so do the font
     pictures and the notes button of the first card (the choices themselves stay). */
  .source-zone:has(.card-feedback > .message-panel:not([hidden])) .zone-heading {
    display: none;
  }


  .mode-bar {
    flex-wrap: wrap;
    gap: 4px 8px;
  }

  .mode-switch-button {
    min-height: 34px;
    padding: 0 14px;
  }

  .mode-summary {
    order: 0;
    flex: 1 1 0;
    min-width: 0;
  }

  body[data-view="editor"] .patch-workspace {
    gap: 4px;
    padding: 4px;
  }

  .editor-footer .editor-status {
    flex-basis: 0;
    min-height: 40px;
    padding: 4px 8px;
  }

  .editor-primary-button,
  .editor-download-actions .download-link {
    min-height: 40px;
  }

  .editor-primary-button {
    flex: 0 0 auto;
    padding-inline: 12px;
    white-space: nowrap;
  }

  /* "BIN/CUE 만들기" on a phone; the full name stays the button's accessible name. */
  .export-label-lead {
    display: none;
  }

  /* After a save the row holds the two download links. The status is still read out; the save button comes back
     with the next change (a change also takes the links away). */
  .editor-footer:has(.editor-download-actions:not([hidden])) .editor-status {
    position: absolute;
    width: 1px;
    height: 1px;
    min-height: 0;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
  }

  .editor-footer:has(.editor-download-actions:not([hidden])) .editor-primary-button {
    display: none;
  }

  .editor-download-actions {
    display: flex;
    flex: 1 1 100%;
    gap: 6px;
  }

  .editor-download-actions .download-link {
    flex: 1 1 0;
  }

  /* The full result line stays readable to assistive technology and as a tooltip, not in the cramped footer. */
  .editor-download-actions > span {
    position: absolute;
    width: 1px;
    height: 1px;
    clip: rect(0, 0, 0, 0);
  }
}

/* The smallest phones: the entry card's general hint gives way while no file is open (the folder card above says the
   same in its heading); once a file is open the card names it. */
@media (max-width: 760px) and (max-height: 640px) {
  .editor-entry .editor-entry-note {
    display: none;
  }
}

/* A phone lower than 700px keeps the origin line and drops the line under it (the save button says what saving makes). */
@media (max-width: 760px) and (max-height: 700px) {
  body[data-view="editor"] .origin-note {
    display: none;
  }
}

/* Keep the editor's header compact at every viewport, including tall desktops. */
  body[data-view="editor"] .brand-copy > span:last-child {
    display: none;
  }

  body[data-view="editor"] .site-header {
    min-height: 44px;
    padding-block: 2px;
  }

  body[data-view="editor"] .brand-mark {
    width: 32px;
    height: 32px;
    font-size: 18px;
  }

/* Game screens ------------------------------------------------------------------------------------

   Every editor tab is
     [record bar]            previous / title / next, and the position in the list
     [page switch]           paged layouts: which part of the record shows
     [record pane | screen]  a scrolling list of records and the game screen of the selected record

   The window picks one of three layouts:
     wide    at least 1100 x 720    the list and every part of the record at once
     medium  761 wide or more, but narrower than 1100 or lower than 720
                                    the list beside one part of the record; the page switch shares the record bar's row
     narrow  760 wide or less       one thing at a time: the list, or one part of the record
   A part is the data-editor-section of a panel; the page switch sets data-page on the tab panel.
   A phone held sideways (narrow, at most 480 tall) moves the tabs into a rail on the left and puts the page switch in
   the record bar's row, so that the record keeps most of the short window.

   Type sizes grow with the window width only (vw, never the container), so a larger window never shows smaller type:
     --ed-primary  values, names, ability names     14px .. 18px
     --ed-label    captions, notes                  12px .. 15px
     --ed-name     record titles, weapon names      15px .. 21px
   A number box is as wide as its largest value (--digits, from its max or a negative min) and never narrower; the grids
   around it make room instead of cutting the value. Nothing holds variable content in a box of fixed height. */

.editor-workspace {
  --ed-primary: var(--fs-primary);
  --ed-label: var(--fs-label);
  --ed-name: var(--fs-name);
  --ed-field: var(--ed-primary);
  --ed-control: 40px;
  --ed-pad: 6px;
}

.editor-data-panel {
  --edge: 5px;
  --frame: url('./runtime-panel-frame.svg?v=20261113-alicecopies1');
  --ed-text: #e8e8da;
  --ed-muted: #a9bcaa;
  --ed-cyan: #9fd7e6;
  --ed-rail: #16808b;
  --ed-gold: #e9d870;
  --ed-modified: #fff19b;
  display: flex;
  flex: 1 1 0;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  min-height: 0;
  color: var(--ed-text);
}

.editor-panel-body {
  display: flex;
  flex: 1 1 0;
  gap: 6px;
  min-width: 0;
  min-height: 0;
}

/* Record bar ----------------------------------------------------------------------------------- */

.record-bar {
  box-sizing: border-box;
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 8px;
  min-height: 46px;
  padding: 3px 10px;
  border: 2px solid var(--ed-gold);
  outline: 1px solid #80652b;
  background: #000010;
}

.record-bar-label {
  flex: 0 0 auto;
  color: var(--ed-cyan);
  font-size: var(--ed-primary);
  font-weight: 600;
  white-space: nowrap;
}

/* A long name ends in an ellipsis; the whole name is in the title (and read out in full). */
.record-title {
  flex: 1 1 0;
  min-width: 0;
  margin: 0;
  overflow: hidden;
  font-size: var(--ed-name);
  font-weight: 650;
  line-height: 1.25;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.record-position {
  flex: 0 0 auto;
  min-width: 7ch;
  color: var(--ed-muted);
  font-size: var(--ed-label);
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}

#weaponAnimationButton { flex: 0 0 auto; white-space: nowrap; }
@media (max-width: 640px) {
  #weaponAnimationButton { font-size: 11px; padding-inline: 6px; }
}

.record-nav {
  flex: 0 0 auto;
  width: 40px;
  min-height: 40px;
  padding: 0;
  border: 1px solid var(--ed-rail);
  border-radius: 0;
  color: var(--ed-text);
  background: #00111d;
  font: inherit;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}

.record-nav:not(:disabled):hover {
  border-color: #74dc53;
  background: #0a2a1a;
}

.record-nav:disabled {
  color: #4f6366;
  border-color: #174048;
  cursor: not-allowed;
}

.record-nav:focus-visible,
.editor-page-button:focus-visible,
.record-list:focus-visible,
.editor-search:focus-visible,
.editor-game-screen :is(input, select, button):focus-visible,
.editor-scenario-panel :is(input, select, button, summary):focus-visible {
  outline: 2px solid #ffe04e;
  outline-offset: 1px;
}

/* Page switch (paged layouts only) */
.editor-page-switch {
  display: none;
  flex: 0 0 auto;
  gap: 4px;
  min-width: 0;
}

.editor-page-button {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 40px;
  padding: 4px 8px;
  border: 1px solid #26778a;
  border-radius: 0;
  color: #b9d3d1;
  background: #051326;
  font: inherit;
  font-size: var(--ed-primary);
  font-weight: 650;
  line-height: 1.2;
  word-break: keep-all;
  cursor: pointer;
}

.editor-page-button[aria-pressed="true"] {
  border-color: #74dc53;
  color: #04120d;
  background: linear-gradient(#a3e56b, #60bd49);
}

.editor-page-count:not(:empty)::before { content: "("; }
.editor-page-count:not(:empty)::after { content: ")"; }

/* Record pane: search and a scrolling list ---------------------------------------------------------- */

.record-pane {
  box-sizing: border-box;
  display: flex;
  flex: 0 0 var(--pane-width, clamp(220px, 21vw, 300px));
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  min-height: 0;
  padding: 8px;
  border: 2px solid var(--ed-gold);
  outline: 1px solid #80652b;
  background: #000010;
  font-size: var(--ed-primary);
}

.record-pane.is-weapons {
  --pane-width: clamp(300px, 29vw, 400px);
}

.editor-search {
  box-sizing: border-box;
  flex: 0 0 auto;
  width: 100%;
  min-height: 40px;
  margin: 0;
  padding: 6px 10px;
  border: 1px solid #227b8c;
  border-radius: 0;
  color: var(--ed-text);
  background: #000817;
  font: inherit;
}

.editor-search::placeholder {
  color: #7f99a2;
}

/* Conditions and bulk editing share the existing record pane. Extra controls open only on demand. */
.record-search-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px; flex: 0 0 auto; }
.record-search-row .editor-search { min-width: 0; padding-inline: 8px; font-size: 16px; }
.record-tool, .record-filter-chip, .record-note-button {
  box-sizing: border-box; min-height: 40px; padding: 4px 8px; border: 1px solid #227b8c; border-radius: 0;
  color: var(--ed-text); background: #000817; font: 500 14px/1.25 "Apple SD Gothic Neo", system-ui, sans-serif; cursor: pointer;
}
.record-tool { white-space: nowrap; }
.record-tool:disabled, .record-note-button:disabled { opacity: .5; cursor: not-allowed; }
.record-tool:focus-visible, .record-filter-chip:focus-visible, .record-note-button:focus-visible { outline: 2px solid #ffe04e; outline-offset: 1px; }
.record-filter-chips { display: flex; flex: 0 0 auto; flex-wrap: wrap; gap: 4px; min-width: 0; }
.record-filter-chip { min-height: 32px; max-width: 100%; font-size: 12px; word-break: keep-all; overflow-wrap: anywhere; text-align: left; }
.record-filter-chip.is-applied { border-color: #74dc53; }
.record-actions { display: flex; flex: 0 0 auto; align-items: center; justify-content: space-between; gap: 6px; }
.record-actions .record-count { min-width: 0; white-space: nowrap; font-size: 12px; }
.unit-construction-choice { min-width: 104px; width: 116px; flex: 0 0 116px; font-size: 12px; padding-inline: 5px; }
.unit-construction-choice option { background: #000817; color: var(--ed-text); }
#unitEditorPanel .record-pane { container-type: inline-size; container-name: unit-list; }
@container unit-list (max-width: 270px) {
  #unitListCount { display: none; }
  .unit-construction-choice { width: auto; flex: 1 1 auto; }
}
.record-bulk-note { flex: 0 0 auto; padding: 5px 7px; border-left: 2px solid #74dc53; background: #031822; font: 400 12px/1.35 "Apple SD Gothic Neo", system-ui, sans-serif; }
.record-bulk-result { display: block; }
.record-bulk-actions { display: flex; flex-wrap: wrap; gap: 4px; }
.record-note-button { min-height: 32px; padding: 3px 4px; border: 0; color: #8bd8df; background: transparent; font-size: 12px; }

.editor-search-dialog {
  position: fixed; inset: 12px 0 auto; width: min(680px, calc(100vw - 24px)); max-width: none;
  max-height: var(--editor-search-height, calc(100dvh - 24px)); margin: 0 auto; padding: 0; overflow: hidden;
  border: 2px solid #c5a850; border-radius: 0; color: #ece6d5; background: #000819;
  box-shadow: 0 0 0 3px #111627, 0 12px 48px rgba(0,0,0,.7);
  font: 500 14px/1.35 "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
}
.editor-search-dialog::backdrop { background: rgba(0,0,12,.72); }
.unit-upgrade-dialog { width: min(1040px, calc(100vw - 24px)); }
.unit-upgrade-dialog .editor-search-shell { max-height: calc(100dvh - 28px); }
.unit-upgrade-dialog .unit-upgrade-items { flex: 1 1 auto; min-height: 0; overflow: auto; overscroll-behavior: contain; }
.unit-upgrade-tools { display: flex; gap: 6px; flex-wrap: wrap; }
.unit-upgrade-group { margin-block: 5px; border: 1px solid #285460; }
.unit-upgrade-group summary { padding: 7px; color: #e7e593; background: #08292e; cursor: pointer; }
.unit-upgrade-head, .unit-upgrade-row { display: grid; grid-template-columns: minmax(145px, .9fr) repeat(3, minmax(0, 1fr)); gap: 8px; align-items: center; padding: 6px 8px; }
.unit-upgrade-head { position: sticky; top: 0; background: #001c25; color: #96bfc9; font-size: 12px; }
.unit-upgrade-row { border-top: 1px solid #1c3946; cursor: pointer; }
.unit-upgrade-name { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.unit-upgrade-name input { margin: 0; width: 18px; height: 18px; accent-color: #9ce453; }
.unit-upgrade-name small { width: 100%; color: #f7c87d; font-size: 11px; }
.unit-upgrade-value { overflow-wrap: anywhere; font-size: 12px; line-height: 1.5; }
.unit-upgrade-row > .unit-upgrade-value:nth-child(3) { color: #fff; }
.unit-upgrade-row > .unit-upgrade-value:last-child { color: #b5ef98; }
.unit-upgrade-row.is-custom { background: #171a26; }
.unit-upgrade-row.is-inactive { opacity: .45; cursor: default; }
@media (max-width: 600px) {
  .unit-upgrade-dialog { width: calc(100vw - 12px); inset-block-start: 6px; max-height: calc(100dvh - 12px); }
  .unit-upgrade-dialog .editor-search-shell { max-height: calc(100dvh - 16px); padding: 7px; gap: 5px; }
  .unit-upgrade-head { display: none; }
  .unit-upgrade-row { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 5px; padding: 7px; }
  .unit-upgrade-name { grid-column: 1 / -1; }
  .unit-upgrade-name small { width: auto; margin-left: auto; }
  .unit-upgrade-value::before { content: attr(data-caption); display: block; color: #82aab6; font-size: 11px; }
  .unit-upgrade-dialog .unit-upgrade-tools button { flex: 1; min-height: 36px; padding-inline: 4px; }
}
.editor-search-shell { display: flex; flex-direction: column; gap: 8px; max-height: inherit; padding: 10px 12px; border: 2px solid #155400; box-sizing: border-box; container-type: inline-size; }
.editor-search-shell > * { flex: 0 0 auto; min-width: 0; }
.editor-search-dialog.is-tight .editor-search-shell { gap: 4px; padding-block: 8px; }
.editor-search-dialog.is-tight .editor-bulk-preview-heading { margin-block: 2px; }
.editor-search-dialog.is-tight .editor-bulk-choose-tools { margin-top: 2px; }
.editor-search-dialog.is-target-selection .editor-bulk-fields { display: none; }
.editor-search-header { display: flex; align-items: center; gap: 8px; }
.editor-search-header h2 { flex: 1 1 auto; margin: 0; font-size: 18px; line-height: 1.2; font-weight: 650; white-space: nowrap; }
.editor-search-dialog button, .editor-search-dialog select, .editor-search-dialog input:not([type="checkbox"]) {
  box-sizing: border-box; min-width: 0; min-height: 40px; padding: 5px 8px; border: 1px solid #227b8c; border-radius: 0;
  color: #dcf5ef; background: #00111d; font: inherit;
}
.editor-search-dialog button { cursor: pointer; white-space: nowrap; }
.editor-search-dialog select, .editor-search-dialog input:not([type="checkbox"]) { width: 100%; font-size: 16px; }
.editor-search-dialog button:disabled { opacity: .48; cursor: not-allowed; }
.editor-search-dialog :is(button, select, input):focus-visible { outline: 2px solid #ffe04e; outline-offset: 1px; }
.editor-search-header button { flex: 0 0 40px; width: 40px; padding: 0; }
.editor-search-summary, .editor-bulk-summary, .editor-search-error { margin: 0; font-size: 12px; overflow-wrap: anywhere; }
.editor-search-summary { color: #b2c9ce; }
.editor-search-error { color: #ffbdb7; }
.editor-filter-conditions, .editor-bulk-targets { display: grid; gap: 6px; min-width: 0; }
.editor-filter-condition { display: grid; grid-template-columns: minmax(130px, 1fr) 76px 110px 40px; gap: 6px; }
.editor-filter-tools, .editor-bulk-choose-tools { display: flex; justify-content: space-between; gap: 6px; margin-top: 6px; }
.editor-bulk-fields { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 8px; }
.editor-bulk-fields label { display: grid; gap: 4px; color: #b2c9ce; font-size: 12px; }
.editor-bulk-summary { margin-top: 8px; }
.editor-bulk-preview-heading { display: flex; justify-content: space-between; align-items: center; gap: 6px; margin: 6px 0; font-size: 12px; }
.editor-bulk-preview-heading button { min-height: 36px; padding: 3px 5px; border: 0; color: #8bd8df; background: transparent; font-size: 12px; }
.editor-bulk-target { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 4px 8px; min-height: 40px; padding: 5px 0; border-bottom: 1px solid #18424e; }
.editor-bulk-target-name { display: flex; align-items: center; flex: 1 1 220px; gap: 7px; min-width: 0; overflow-wrap: anywhere; }
.editor-bulk-target-name input { flex: 0 0 auto; width: 18px; height: 18px; margin: 0; accent-color: #74dc53; }
.editor-bulk-target-value { margin-left: auto; white-space: nowrap; font-variant-numeric: tabular-nums; }
.editor-search-pager { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 44px; margin-top: 4px; font-variant-numeric: tabular-nums; }
.editor-search-pager button { width: 44px; padding: 0; font-size: 22px; }
.editor-search-actions { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 6px; }
.editor-search-actions .is-primary:not(:disabled) { border-color: #74dc53; color: #04120d; background: linear-gradient(#a3e56b,#60bd49); font-weight: 650; }
@container (min-width: 310px) and (max-width: 500px) {
  .editor-filter-condition { grid-template-columns: minmax(0,1fr) 48px 82px 40px; gap: 5px; }
  .editor-search-dialog .editor-filter-operator { padding-inline: 3px; }
}
@container (max-width: 310px) {
  .editor-filter-condition { grid-template-columns: 86px minmax(0,1fr) 40px; }
  .editor-filter-field { grid-column: 1 / 3; }
  .editor-filter-remove { grid-column: 3; grid-row: 1; }
  .editor-filter-operator { grid-column: 1; grid-row: 2; }
  .editor-filter-condition [data-condition-value] { grid-column: 2 / 4; grid-row: 2; }
}
@container (max-width: 500px) {
  .editor-filter-condition.is-membership { grid-template-columns: 86px minmax(0,1fr) 40px; }
  .editor-filter-condition.is-membership .editor-filter-field { grid-column: 1 / 3; }
  .editor-filter-condition.is-membership .editor-filter-remove { grid-column: 3; grid-row: 1; }
  .editor-filter-condition.is-membership .editor-filter-operator { grid-column: 1; grid-row: 2; }
  .editor-filter-condition.is-membership [data-condition-value] { grid-column: 2 / 4; grid-row: 2; }
}
@media (pointer: coarse) {
  .record-tool, .record-filter-chip, .record-note-button, .editor-search-dialog button,
  .editor-search-dialog select, .editor-search-dialog input:not([type="checkbox"]), .editor-bulk-target-name { min-height: 44px; }
}

.record-list {
  position: relative;
  flex: 1 1 0;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  border: 1px solid var(--ed-rail);
  background: #00060f;
  scrollbar-color: #41785a #06101a;
  -webkit-overflow-scrolling: touch;
}
.record-list:empty::before {
  content: "검색 결과가 없습니다.";
  display: block; padding: 16px 8px; color: var(--ed-muted); text-align: center; font-size: 14px; white-space: nowrap;
}

.record-count {
  flex: 0 0 auto;
  margin: 0;
  color: var(--ed-muted);
  font-size: var(--ed-label);
  line-height: 1.35;
}

.record-option {
  position: relative;
  box-sizing: border-box;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 0 8px;
  min-height: 44px;
  padding: 5px 14px 5px 10px;
  border-bottom: 1px solid #0b1f2b;
  border-left: 4px solid transparent;
  color: var(--ed-text);
  line-height: 1.3;
  cursor: pointer;
}

.record-option:hover {
  background: #0a2432;
}

.record-option.is-selected {
  border-left-color: #75c943;
  color: #fff;
  background: #00600a;
}

.record-option.is-read-only {
  color: #97a39a;
}

.record-option-name {
  min-width: 0;
  overflow-wrap: anywhere;
}

.record-option-meta {
  color: #a9c3cf;
  font-size: var(--ed-label);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.record-option.is-selected .record-option-meta {
  color: #d7f0d0;
}

/* The modified mark sits in the row's right padding, clear of the numbers. */
.record-option-dot {
  position: absolute;
  top: 2px;
  right: 2px;
  color: #ffe04e;
  font-size: 12px;
  line-height: 1;
}

.is-weapons .record-option {
  grid-template-columns: minmax(0, 1fr) 6ch 7.5ch 4.5ch;
  grid-template-areas:
    "name attack range hit"
    "meta meta meta meta";
  gap: 1px 6px;
  padding-block: 6px;
}

.is-weapons .record-option-name { grid-area: name; font-size: var(--ed-name); }
.is-weapons .record-option-meta { grid-area: meta; overflow-wrap: anywhere; white-space: normal; }
.is-weapons .record-option-stat { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.is-weapons .record-option-stat.is-attack { grid-area: attack; }
.is-weapons .record-option-stat.is-range { grid-area: range; color: #c9d6ca; }
.is-weapons .record-option-stat.is-hit { grid-area: hit; color: #c9d6ca; }

/* Game screen (shared) ------------------------------------------------------------------------- */

.game-screen-shell {
  display: flex;
  flex: 1 1 0;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  container-type: inline-size;
}

.editor-game-screen {
  --runtime-korean-face: "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
  --runtime-number-face: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  box-sizing: border-box;
  display: grid;
  flex: 1 1 auto;
  align-content: start;
  width: 100%;
  min-height: 0;
  margin: 0;
  padding: 0 var(--edge) var(--edge) 0;
  overflow: hidden;
  border: 2px solid var(--ed-gold);
  outline: 1px solid #80652b;
  background: #000010;
  color: var(--ed-text);
  font: 500 var(--ed-primary) / 1.25 var(--runtime-korean-face);
}

/* Panels draw their own full frame and overlap their neighbours' by the frame width, so no panel needs to know which
   side of the screen it is on. A panel grows with its content; the screen's grid gives every panel its room. */
.game-panel {
  box-sizing: border-box;
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--panel-gap, 6px);
  min-width: 0;
  margin: 0 calc(var(--edge) * -1) calc(var(--edge) * -1) 0;
  padding: calc(var(--edge) + 4px) calc(var(--edge) + 6px);
  /* The invisible hit layers of the small buttons may reach past the frame; they never widen the screen. */
  overflow: clip;
  border: var(--edge) solid transparent;
  border-image: var(--frame) 8 / 1 / 0 round;
  background: #000010;
}

.game-panel h3,
.game-panel h4 {
  display: flex;
  flex: 0 0 auto;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-start;
  gap: 4px 8px;
  margin: 0;
  color: var(--ed-cyan);
  font-size: var(--ed-label);
  font-weight: 600;
  line-height: 1.2;
}
.weapon-detail-tools { display: flex; flex: 0 0 auto; flex-wrap: wrap; align-items: center; gap: 4px 6px; }
.weapon-detail-tools h4 { margin-inline-end: auto; }
.weapon-dialogue-source { display:grid; grid-template-columns:minmax(90px,.8fr) minmax(0,1.2fr); gap:3px 6px; min-width:0; grid-column:1/-1; }
.weapon-dialogue-source input[type="search"] { min-width:0; width:100%; min-height:28px; padding:3px 5px; background:#f5f7f5; color:#122126; }
.weapon-dialogue-source select { min-width:0; width:100%; min-height:28px; cursor:pointer; font-size:11px; }
.weapon-dialogue-note { grid-column:1/-1; color:var(--ed-muted); font-size:10px; line-height:1.3; }
.weapon-dialogue-source > [data-dialogue-pilot] { grid-column:1/-1; }
.weapon-dialogue-lines { grid-column:1/-1; margin:0; padding:4px 5px 4px 21px; min-width:0; max-height:112px; overflow:auto; overscroll-behavior:contain; border:1px solid #35626a; color:#e6efe8; font-size:12px; line-height:1.45; }
.weapon-dialogue-lines:empty { display:none; }
.weapon-dialogue-lines li { white-space:pre-line; overflow-wrap:anywhere; }

.panel-count {
  margin-left: auto;
  color: var(--ed-muted);
  font-weight: 500;
}

/* The flag switch follows the heading's words (clear of the info buttons on the slots' corners below it). */
.panel-toggle {
  flex: 0 0 auto;
  min-height: 32px;
  margin-left: 8px;
  padding: 0 10px;
  border: 1px solid var(--ed-rail);
  border-radius: 0;
  color: #ade9ef;
  background: #00111d;
  font: 500 var(--ed-label) / 1.2 var(--runtime-korean-face);
  white-space: nowrap;
  cursor: pointer;
}

.panel-toggle[aria-pressed="true"] {
  border-color: #74dc53;
  color: #04120d;
  background: linear-gradient(#a3e56b, #60bd49);
}

.panel-note {
  margin: 0;
  color: var(--ed-muted);
  font-size: var(--ed-label);
  line-height: 1.4;
}

.panel-note.is-caution {
  color: #f1dd74;
}

.weapon-scope-note {
  grid-area: note;
  margin: 0;
  padding: 6px 12px;
  color: var(--ed-muted);
  font-size: var(--ed-label);
  line-height: 1.4;
}

/* Fields: a caption, the revert button (only for a changed value; its place is kept) and the value, in one row. Grids of
   small fields (.is-stacked, and every grid of a paged layout) put the caption and the revert button above the value. */
.editor-game-screen label {
  position: relative;
  display: flex;
  align-items: center;
  gap: 2px 6px;
  min-width: 0;
  min-height: var(--ed-control);
  color: var(--ed-text);
  font-size: var(--ed-field);
  line-height: 1.2;
}

.editor-game-screen label > .editor-field-name {
  flex: 1 1 auto;
  min-width: 0;
  word-break: keep-all;
}

.editor-game-screen label > .editor-diff-reset { flex: 0 0 auto; }

/* The last word of a caption and its info button never part (the button cannot drop under the words it follows). */
.caption-tail {
  white-space: nowrap;
}
.editor-game-screen label > select { flex: 0 1 auto; min-width: 0; }

.editor-game-screen input[data-editor-field],
.editor-game-screen select {
  box-sizing: border-box;
  min-width: 0;
  min-height: var(--ed-control);
  margin: 0;
  padding: 4px var(--ed-pad);
  border: 1px solid #17505a;
  border-radius: 0;
  color: var(--ed-text);
  background: #00101d;
  font: 600 var(--ed-primary) / 1.15 var(--runtime-number-face);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

/* Choices draw a small arrow inside their right padding, so the chosen text has the rest of the box. */
.editor-game-screen select {
  padding-right: 20px;
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: right 10px center, right 5px center;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  font-family: var(--runtime-korean-face);
  font-weight: 500;
  text-align: left;
}

/* A number box holds its largest value: max digits (or the minus sign and digits of a negative min), a caret's room,
   the padding and the border. */
.editor-game-screen input[type="number"] {
  --digits: 5;
  --number-width: calc(var(--digits) * 1ch + 0.6ch + 2 * var(--ed-pad) + 2px);
  flex: 0 0 auto;
  inline-size: var(--number-width);
  min-inline-size: var(--number-width);
  appearance: textfield;
}

.editor-game-screen input[type="number"][max="9999"],
.editor-game-screen input[type="number"][min="-99"] { --digits: 3; }
.editor-game-screen input[type="number"][max="255"] { --digits: 3; }
.editor-game-screen input[type="number"][max="99"],
.editor-game-screen input[type="number"][max="15"] { --digits: 2; }

.editor-game-screen input::-webkit-inner-spin-button {
  appearance: none;
}

.is-stacked label {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-rows: auto auto;
  align-items: end;
  gap: 2px 4px;
  min-height: 0;
}

/* Stacked number fields: the caption on top, the value with its revert button beside it below. */
.is-stacked label > .editor-field-name { grid-column: 1 / -1; grid-row: 1; font-size: var(--ed-label); }
.is-stacked label > .editor-diff-reset { grid-column: 2; grid-row: 2; align-self: center; }
.editor-game-screen .is-stacked label > :is(input[data-editor-field], select) { grid-column: 1; grid-row: 2; inline-size: 100%; text-align: center; }

.editor-game-screen [data-editor-field].is-modified,
.editor-game-screen .terrain-select.is-modified {
  color: var(--ed-modified);
  border-color: #e8cc39;
  background-color: #292307;
}

.editor-game-screen :is(input, select):disabled {
  color: #8f9a8d;
  cursor: not-allowed;
  opacity: 0.8;
}

.editor-diff-reset {
  position: relative;
  box-sizing: border-box;
  width: 20px;
  min-width: 20px;
  height: 20px;
  min-height: 0;
  margin: 0;
  padding: 0;
  border: 1px solid #ccb235;
  border-radius: 0;
  color: #ffed96;
  background: #252007;
  font: 500 14px / 1 var(--runtime-number-face);
  white-space: nowrap;
  cursor: pointer;
}

.editor-diff-reset.is-empty {
  visibility: hidden;
  pointer-events: none;
}

/* 20px plus 8px on every side: a 36px target. */
.editor-diff-reset::after {
  content: "";
  position: absolute;
  inset: -8px;
}

/* Terrain: four letter choices as on the game's screen; one line under them says what each letter is worth. */
.terrain-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 3em), 1fr));
  gap: 4px 10px;
  min-width: 0;
}

.editor-game-screen .terrain-grid label {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-rows: auto auto;
  align-items: end;
  gap: 2px 4px;
  min-height: 0;
}

.editor-game-screen .terrain-grid label > .editor-field-name { grid-column: 1; grid-row: 1; font-size: var(--ed-label); }
.editor-game-screen .terrain-grid label > .editor-diff-reset { grid-column: 2; grid-row: 1; }
.editor-game-screen .terrain-grid label > select { grid-column: 1 / -1; grid-row: 2; }

/* The legend shares the heading's line when it fits and wraps under it when not. */
.terrain-legend {
  order: 10;
  margin-left: auto;
  color: var(--ed-muted);
  font-size: var(--ed-label);
  font-weight: 500;
  line-height: 1.35;
}

.editor-game-screen .terrain-select {
  inline-size: 100%;
  min-inline-size: calc(2.5ch + 26px);
}


/* Number fields and their captions invite a click on a mouse: the pointer becomes a hand over them. */
@media (hover: hover) {
  .editor-game-screen label:has(> input[data-editor-field]),
  .editor-game-screen label:has(> input[data-editor-field]) > .editor-field-name,
  .editor-game-screen input[data-editor-field],
  .editor-game-screen select {
    cursor: pointer;
  }
}

/* Info buttons: a small circled i that sits at the top right of the end of its caption, like a superscript. The glyph
   stays small; an invisible layer enlarges the hit area for a finger or a mouse (26 x 26). */
.editor-help-button {
  position: relative;
  display: inline-block;
  box-sizing: border-box;
  width: 16px;
  min-width: 16px;
  height: 16px;
  min-height: 0;
  margin: 0 0 0 2px;
  padding: 0;
  border: 1px solid #74c8d7;
  border-radius: 50%;
  color: #b9e9f2;
  background: #102c3b;
  font: italic 700 12px / 14px Georgia, serif;
  text-align: center;
  vertical-align: top;
  cursor: help;
}

.editor-help-button::after {
  content: "";
  position: absolute;
  inset: -5px;
  border-radius: 50%;
}

.editor-field-name > .editor-help-button,
.record-title > .editor-help-button,
.game-panel h4 > .editor-help-button,
.pilot-mental-name > .editor-help-button,
.pilot-runtime-skill-name > .editor-help-button {
  position: relative;
  top: -0.3em;
}

.editor-help-button:focus-visible {
  outline: 2px solid #ffeb75;
  outline-offset: 2px;
}

/* Unit screen ------------------------------------------------------------------------------------ */

.unit-game-screen {
  grid-template-columns: minmax(0, 44fr) minmax(0, 30fr) minmax(0, 26fr);
  grid-template-rows: minmax(0, 1fr) auto;
  grid-template-areas:
    "abilities image weapons"
    "vitals core terrain";
}

.unit-info-panel { grid-area: abilities; }
.unit-image-panel { grid-area: image; }
.unit-weapons-panel { grid-area: weapons; }
.unit-vitals-panel { grid-area: vitals; }
.unit-core-panel { grid-area: core; }
.unit-terrain-panel { grid-area: terrain; }

/* Four ability slots: the choice, and its flag number when shown (beside the choice, never under it). */
.unit-special-list {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-content: start;
  gap: 8px;
  min-height: 0;
}

.unit-special-row {
  display: grid;
  grid-template-columns: 1.4ch minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.unit-special-slot-name {
  color: #83d5eb;
  font-size: var(--ed-label);
  text-align: center;
}

.unit-ability-remove {
  padding: 0;
  width: 32px;
  height: 32px;
  border: 1px solid var(--ed-rail);
  border-radius: 0;
  color: #ade9ef;
  background: #00111d;
  font: 500 22px / 1 var(--runtime-korean-face);
  cursor: pointer;
}

.unit-ability-remove:disabled { color: #6d7d7d; cursor: not-allowed; }

/* Keep help inside the choice, before its arrow, even when the revert button appears beside it. */
.editor-game-screen .unit-special-name-field {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  column-gap: 4px;
  min-height: 0;
}

.editor-game-screen .unit-special-name-field select {
  grid-column: 1;
  grid-row: 1;
  inline-size: 100%;
  padding-left: 4px;
  padding-right: 37px;
}

.editor-game-screen .unit-special-name-field > .editor-diff-reset {
  grid-column: 2;
  grid-row: 1;
  align-self: center;
}

.unit-special-name-field > .editor-help-button {
  grid-column: 1;
  grid-row: 1;
  align-self: center;
  justify-self: end;
  width: 14px;
  min-width: 14px;
  height: 14px;
  margin: 0 19px 0 0;
  font-size: 10px;
  line-height: 12px;
  z-index: 1;
}

.unit-special-name-field > .editor-help-button::after {
  inset: -5px -2px;
}

.editor-game-screen .unit-special-value-field {
  display: flex;
  min-height: 0;
  font-size: var(--ed-label);
}

.unit-event-condition {
  grid-column: 1 / -1;
  justify-self: start;
  margin: -4px 0 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: #a9d8d5;
  font: 500 var(--ed-label) / 1.4 var(--runtime-korean-face);
  white-space: nowrap;
  cursor: pointer;
}

.unit-event-condition:hover,
.unit-event-condition:focus-visible { color: #ffe88f; text-decoration: underline; }

/* Field grids hold as many fields per line as fit (a field never gets narrower than its caption, info button, revert
   button and largest value need: --cell) and wrap the rest to the next line. */
.unit-vitals-grid,
.unit-core-grid,
.pilot-combat-grid,
.pilot-points-grid,
.pilot-growth-grid,
.weapon-detail-grid {
  --cell: calc(7.5 * var(--ed-primary) + 60px);
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, var(--cell)), 1fr));
  min-width: 0;
  gap: 4px 12px;
}

/* A stacked field needs the wider of its two lines: the caption's longest word with the info button, and the largest
   value (about 0.6em a digit in the number face, plus caret room and padding) with the revert button beside it. */
.unit-vitals-grid,
.pilot-combat-grid { --stacked-cell: max(2 * var(--ed-label) + 22px, 3.4 * var(--ed-primary) + 38px); }
.pilot-points-grid { --stacked-cell: max(3 * var(--ed-label) + 22px, 3.4 * var(--ed-primary) + 38px); }
.pilot-growth-grid { --stacked-cell: max(2 * var(--ed-label) + 22px, 1.6 * var(--ed-primary) + 38px); }
.unit-core-grid,
.weapon-detail-grid { --stacked-cell: max(4 * var(--ed-label) + 22px, 3.4 * var(--ed-primary) + 38px); }

.weapon-detail-grid > label:not(.weapon-critical-field):has(select[data-editor-field="requiredSkill"]) {
  grid-column: span 2;
}

.unit-vitals-grid {
  grid-template-columns: minmax(0, 1fr);
}

.unit-secondary-grid { display: none !important; }

.is-stacked {
  --cell: var(--stacked-cell);
}

.editor-game-screen .unit-vital-row {
  flex-wrap: wrap;
}

.unit-vital-row > .unit-runtime-gauge {
  flex: 1 0 100%;
}

/* Shield and parry: two on/off choices side by side under HP / EN. */
.unit-flag-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px 12px;
  min-width: 0;
}

/* A value that cannot be edited for this record (a weapon without ammo) reads as information, not as a greyed box. */
.editor-game-screen label > .editor-field-info {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  color: var(--ed-muted);
  font-size: var(--ed-label);
}

.editor-game-screen label > .editor-field-info[hidden] {
  display: none;
}

.is-stacked label > .editor-field-info { grid-column: 1; grid-row: 2; }

.unit-vital-row .editor-field-name,
.unit-vital-row input {
  color: #a9df72;
  font-style: italic;
  font-weight: 700;
}

.unit-runtime-gauge {
  display: block;
  height: 6px;
  overflow: hidden;
  border: 1px solid #164a24;
  background: #00130b;
}

.unit-runtime-gauge > span {
  display: block;
  width: 100%;
  height: 100%;
  background: linear-gradient(#b6f978, #53c839 54%, #248b28);
}

/* Pictures: the game's own image, scaled by whole pixels as far as the panel allows, never under 64px. */
/* A picture cell leaves at least 64px for the picture inside its frame and padding. */
.editor-visual {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr) auto;
  place-items: center;
  min-width: calc(64px + 4 * var(--edge) + 12px);
  min-height: calc(64px + 4 * var(--edge) + 10px);
  margin: 0 calc(var(--edge) * -1) calc(var(--edge) * -1) 0;
  background: #000022;
}

.editor-visual canvas {
  display: block;
  max-width: 100%;
  image-rendering: pixelated;
  object-fit: contain;
}

#unitPreviewImage {
  inline-size: clamp(83px, 100%, 288px);
  aspect-ratio: 144 / 112;
}

#pilotPreviewImage {
  inline-size: clamp(64px, 100%, 160px);
  aspect-ratio: 1;
}

.editor-visual canvas[hidden] {
  display: none;
}

.editor-visual figcaption {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  color: #9ea99d;
  font-size: var(--ed-label);
  line-height: 1.3;
  text-align: center;
  overflow-wrap: anywhere;
}

/* Keep the existing cards; use the width and scroll only inside the list. */
.unit-weapons-panel .unit-weapon-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 210px), 1fr));
  align-content: start; gap: 4px; min-height: 0; min-width: 0;
  overflow-y: auto; overscroll-behavior: contain;
  scrollbar-color: #41785a #06101a;
}
.unit-weapon-list::-webkit-scrollbar { width: 7px; }
.unit-weapon-list::-webkit-scrollbar-track { background: #06101a; }
.unit-weapon-list::-webkit-scrollbar-thumb { background: #41785a; }
.unit-weapons-panel { container: unit-weapons / inline-size; }
.unit-weapon-workarea { display: grid; grid-template-columns: minmax(0,1fr); grid-template-rows: minmax(0,1fr); flex: 1 1 0; min-height: 0; min-width: 0; gap: 6px; }
.unit-weapon-detail { display: flex; flex-direction: column; min-height: 0; min-width: 0; gap: 4px; padding: 5px; border: 1px solid #397f8d; background: #00101d; }
.unit-weapon-detail[hidden] { display: none; }
.unit-weapon-detail-heading { display: flex; align-items: center; min-width: 0; gap: 4px; }
.unit-weapon-detail-heading h5 { flex: 1; min-width: 0; margin: 0; color: #fff19b; font-size: 12px; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.unit-weapon-detail button { min-width: 0; min-height: 26px; border: 1px solid #397f8d; padding: 1px 5px; background: #00101d; color: var(--ed-text); font: inherit; font-size: 10px; cursor: pointer; white-space: nowrap; }
.unit-weapon-detail button:disabled { cursor: default; opacity: .4; }
.unit-weapon-detail button.unit-weapon-detail-back { display: none; }
.unit-weapon-detail-scope { flex: 0 0 auto; margin: 0; color: #aac8c8; font-size: 10px; line-height: 1.3; }
.unit-weapon-detail-body { display: flex; flex-direction: column; flex: 1; min-height: 0; gap: 4px; overflow-y: auto; overscroll-behavior: contain; scrollbar-color: #41785a #06101a; }
.unit-weapon-section-title { flex: 0 0 auto; margin: 4px 0 0; padding-top: 6px; border-top: 1px solid #24525c; color: #83d5eb; font-size: 11px; font-weight: 600; line-height: 1.3; }
.unit-weapon-number-grid { display: grid; flex: 0 0 auto; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 4px 6px; }
.unit-weapon-number-grid > label { display: grid; grid-template-columns: minmax(0,1fr) auto; align-items: center; min-height: 0; gap: 3px; font-size: 11px; }
.unit-weapon-value { display: flex; align-items: center; min-width: 0; gap: 2px; }
.unit-weapon-detail :is(input,select) { box-sizing: border-box; min-width: 0; min-height: 28px; margin: 0; border: 1px solid #397f8d; border-radius: 0; padding: 2px 5px; background-color: #00101d; color: var(--ed-text); font: 500 12px/1.2 var(--runtime-korean-face); }
.unit-weapon-detail input { width: 7ch; text-align: right; font-variant-numeric: tabular-nums; }
.unit-weapon-detail :is(input,select):disabled { opacity: .5; }
.unit-weapon-detail input[hidden] { display: none; }
.unit-weapon-detail input[aria-invalid="true"] { color: #ffc1b9; border-color: #f18e7c; }
.unit-weapon-detail .is-modified { color: #fff19b; border-color: #e5d14d; }
.unit-weapon-detail .unit-weapon-field-reset { width: 18px; padding: 0; border: 0; min-height: 24px; color: #fff19b; }
.unit-weapon-detail .unit-weapon-field-reset[hidden], .unit-weapon-no-ammo[hidden] { display: none; }
.unit-weapon-no-ammo { min-width: 5ch; text-align: center; color: #aac8c8; font-size: 11px; }
.unit-weapon-choice-grid { display: grid; flex: 0 0 auto; grid-template-columns: minmax(0,1fr); gap: 6px; }
.unit-weapon-choice-grid > label, .unit-weapon-terrain-grid > label { display: grid; min-height: 0; min-width: 0; gap: 2px; font-size: 10px; }
.unit-weapon-choice-grid .unit-weapon-value, .unit-weapon-choice-grid select { width: 100%; }
.unit-weapon-dialogue-details { flex: 0 0 auto; min-width: 0; border-top: 1px solid #24525c; }
.unit-weapon-dialogue-details > summary { padding: 7px 2px; color: #9cdce5; cursor: pointer; font-size: 12px; }
.unit-weapon-dialogue-details[open] > summary { margin-bottom: 3px; }
.unit-weapon-dialogue-details > .unit-weapon-choice-grid { margin-bottom: 5px; grid-template-columns: minmax(0,1fr); }
.editor-game-screen .unit-weapon-detail select { padding-right: 20px; }
.unit-weapon-terrain-grid { display: grid; flex: 0 0 auto; grid-template-columns: repeat(4,minmax(0,1fr)) auto; gap: 4px; align-items: end; }
.unit-weapon-terrain-grid > label { grid-template-columns: auto minmax(0,1fr); align-items: center; gap: 3px; }
.unit-weapon-terrain-grid select { width: 100%; }
.unit-weapon-detail-status { flex: 0 0 auto; margin: 0; color: #ffc1b9; font-size: 11px; line-height: 1.3; }
.unit-weapon-detail-status:empty { display: none; }
.unit-weapon-row.is-selected { border-color: #f5df75; background: #183b27; }
.unit-weapon-row.is-selected > .unit-weapon-entry { color: #fff19b; }
@container unit-weapons (min-width: 580px) {
  .unit-weapon-workarea[data-weapon-detail="open"] { grid-template-columns: minmax(230px, 43%) minmax(0,1fr); }
  .unit-weapon-workarea[data-weapon-detail="open"] .unit-weapon-list { grid-template-columns: minmax(0,1fr); }
  .unit-weapon-choice-grid > label { grid-template-columns: auto minmax(0,1fr); align-items: center; gap: 4px; }
}
@container unit-weapons (max-width: 579px) {
  .unit-weapon-workarea[data-weapon-detail="open"] > .unit-weapon-list { display: none; }
  .unit-weapon-detail button.unit-weapon-detail-back { display: block; }
}
@media (max-height: 600px) {
  .unit-weapons-panel:has(.unit-weapon-workarea[data-weapon-detail="open"]) > :is(.unit-weapon-heading,.unit-weapon-toolbar) { display: none; }
  .unit-weapon-workarea[data-weapon-detail="open"] .unit-weapon-detail-back { display: block; }
}
.game-panel h4:is(.unit-weapon-heading,.editor-list-heading) { display: flex; flex-wrap: nowrap; align-items: center; gap: 6px; min-width: 0; }
:is(.unit-weapon-heading,.editor-list-heading) > :first-child, :is(.unit-weapon-heading,.editor-list-heading) > .panel-count { flex: 0 0 auto; white-space: nowrap; }
:is(.unit-weapon-heading,.editor-list-heading) > .panel-note { flex: 1 1 0; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 400; }
#unitAnimationButton { flex: 0 0 auto; min-height: 26px; padding: 2px 6px; font-size: 11px; white-space: nowrap; }
.unit-animation-panel { min-height: 0; min-width: 0; overflow: hidden; border: 1px solid #14505a; }
.unit-animation-panel[hidden] { display: none; }
.unit-game-screen { position: relative; }
.unit-game-screen > .unit-animation-panel { grid-area: preview; margin: 0; }
.unit-game-screen[data-unit-preview="mobile"] > .unit-animation-panel { position: absolute; grid-area: auto; inset: 2px; z-index: 4; background: #00101d; }
.unit-game-screen[data-unit-preview="mobile"] > :not(.unit-animation-panel) { visibility: hidden; }
.unit-game-screen[data-unit-preview="image"] > .unit-animation-panel { grid-area: image; position: relative; z-index: 1; box-sizing: border-box; margin: 0 calc(var(--edge) * -1) calc(var(--edge) * -1) 0; border: var(--edge) solid transparent; border-image: var(--frame) 8 / 1 / 0 round; background: #00101d; }
.unit-game-screen[data-unit-preview="image"] > .unit-image-panel { visibility: hidden; }
.editor-data-panel[data-auto-pages] .unit-game-screen:is([data-unit-preview="wide"],[data-unit-preview="compact"]) .unit-flag-grid label { display: grid; grid-template-columns: minmax(0,1fr) auto; grid-template-rows: auto auto; gap: 2px; }
.editor-data-panel[data-auto-pages] .unit-game-screen:is([data-unit-preview="wide"],[data-unit-preview="compact"]) .unit-flag-grid label > .editor-field-name { grid-column: 1/-1; grid-row: 1; }
.editor-data-panel[data-auto-pages] .unit-game-screen:is([data-unit-preview="wide"],[data-unit-preview="compact"]) .unit-flag-grid label > select { grid-column: 1; grid-row: 2; inline-size: 100%; }
.editor-data-panel[data-auto-pages] .unit-game-screen:is([data-unit-preview="wide"],[data-unit-preview="compact"]) .unit-flag-grid label > .editor-diff-reset { grid-column: 2; grid-row: 2; }

.editor-data-panel[data-auto-pages] .unit-game-screen[data-unit-preview="wide"] .unit-core-grid { grid-template-columns: repeat(3,minmax(0,1fr)); }
.editor-data-panel[data-auto-pages] .unit-game-screen[data-unit-preview="compact"] .unit-core-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
.editor-data-panel[data-auto-pages] .unit-game-screen:is([data-unit-preview="wide"],[data-unit-preview="compact"]) .unit-special-list { grid-template-columns: repeat(2,minmax(0,1fr)); }

.unit-animation-panel iframe { display: block; width: 100%; height: 100%; border: 0; }
.unit-weapon-row { display: grid; grid-template-columns: minmax(0,1fr) minmax(76px,.85fr) 26px; align-items: center; gap: 4px; min-width: 0; padding: 4px; border: 1px solid #14505a; background: #00101d; }
.unit-weapon-row > .unit-weapon-entry { grid-column: 1; min-width: 0; }
.unit-weapon-row > .unit-weapon-edit { grid-column: 2; min-width: 0; }
.unit-weapon-edit { display: grid; grid-template-columns: minmax(0, 1fr) 22px; gap: 2px; }
.unit-slot-preview { grid-column: 3; min-height: 30px; padding: 1px; border: 1px solid #14505a; color: #ade9ef; background: #00101d; font: inherit; font-size: 11px; cursor: pointer; }
.unit-weapon-list .unit-weapon-entry { min-height: 0; padding: 2px; border: 0; background: transparent; grid-template-columns: minmax(0,1fr); grid-template-areas: "name" "slot" "stats" "flags"; }
.unit-weapon-list .weapon-entry-slot { overflow: hidden; text-overflow: ellipsis; }
.unit-weapon-search { box-sizing: border-box; flex: 0 0 auto; min-width: 0; width: 100%; min-height: 32px; padding: 4px 8px; border: 1px solid #9fb8c2; border-radius: 0; color: #102b37; background: #fff; font: inherit; font-size: var(--ed-label); color-scheme: light; }
.unit-weapon-search::placeholder { color: #506571; opacity: 1; }
.unit-weapon-search[hidden] { display: none; }
.unit-weapon-toolbar { display: grid; grid-template-columns: minmax(calc(10 * var(--ed-label) + 18px),1fr) minmax(0,1.2fr) auto; gap: 4px; flex: 0 0 auto; min-width: 0; }
.unit-weapon-toolbar[hidden] { display: none; }
.unit-weapon-toolbar select, .unit-weapon-toolbar button { min-width: 0; min-height: 32px; font: inherit; font-size: var(--ed-label); border: 1px solid #14505a; color: var(--ed-text); background-color: #00101d; }
.unit-weapon-toolbar button:disabled { opacity: .5; }
.unit-weapon-edit select { min-width: 0; width: 100%; font: inherit; font-size: var(--ed-label); color: var(--ed-text); background-color: #00101d; border: 1px solid #14505a; min-height: 30px; }
.unit-weapon-edit button { min-width: 0; font: inherit; color: var(--ed-text); background: #00101d; border: 1px solid #14505a; }
.unit-weapon-list .unit-weapon-row.is-modified { border-color: #e5d14d; }

.unit-weapon-entry,
.owner-chip {
  box-sizing: border-box;
  display: grid;
  width: 100%;
  min-height: 40px;
  padding: 4px 8px;
  border: 1px solid #14505a;
  border-radius: 0;
  color: var(--ed-text);
  background: #00101d;
  font: inherit;
  font-size: var(--ed-primary);
  line-height: 1.25;
  text-align: left;
  cursor: pointer;
}

.unit-weapon-entry {
  grid-template-columns: auto minmax(0, 1fr);
  grid-template-areas:
    "slot slot"
    "name name"
    "stats stats"
    "flags flags";
  gap: 0 8px;
}

.unit-weapon-entry:not(:disabled):hover,
.owner-chip:hover {
  border-color: #74dc53;
  background: #0a2a1a;
}

.unit-weapon-entry:disabled {
  color: #8f9a8d;
  cursor: not-allowed;
}

.weapon-entry-slot {
  grid-area: slot;
  color: #83d5eb;
  font-size: var(--ed-label);
  white-space: nowrap;
}

.weapon-entry-name {
  grid-area: name;
  max-width: 100%;
  min-width: 0;
  font-size: var(--ed-name);
  overflow-wrap: anywhere;
}

.weapon-entry-stats {
  grid-area: stats;
  color: #c9d6ca;
  font-size: var(--ed-label);
}

.weapon-entry-flags {
  grid-area: flags;
  color: #f1dd74;
  font-size: var(--ed-label);
}

/* Pilot screen ------------------------------------------------------------------------------------ */

.pilot-game-screen {
  --panel-gap: 3px;
  grid-template-columns: minmax(0, 16fr) minmax(0, 46fr) minmax(0, 38fr);
  grid-template-areas:
    "portrait combat points"
    "mental mental skills"
    "growth growth terrain";
}
.pilot-game-screen[data-alice="true"] {
  grid-template-columns: minmax(40px, 18fr) minmax(0, 82fr);
  grid-template-areas: "portrait alice";
}
.pilot-game-screen[data-alice="true"] > :not(.pilot-portrait-panel):not(.alice-crew-panel) { display: none !important; }
.alice-crew-panel { grid-area: alice; min-width: 0; min-height: 0; overflow: auto; padding: 6px; }
.alice-crew-panel h4 { margin: 0 0 6px; }
.alice-crew-toggle { display: flex; align-items: center; gap: 4px; }
.alice-crew-note { margin: 5px 0; line-height: 1.4; overflow-wrap: anywhere; }
.alice-crew-error { color: #ffc1b9; }
.alice-crew-error:empty { display: none; }
.alice-sp-base { display: flex; align-items: center; gap: 6px; margin: 5px 0; }
.alice-sp-base input { width: 5em; }
.alice-spirit-grid { display: grid; gap: 4px; }
.alice-spirit-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px; }
.alice-spirit-row label { display: grid; gap: 2px; min-width: 0; }
.alice-spirit-row select { width: 100%; min-width: 0; }
.alice-spirit-row input { width: 4em; min-width: 0; }
.alice-crew-panel :is(select,input[type="number"]) { color: var(--ed-text); background: #001a2a; border: 1px solid #30647a; border-radius: 0; font: inherit; }
.alice-crew-panel :is(select,input)[aria-invalid="true"] { border-color: #f18e7c; }

.pilot-hero-links {
  flex: 0 0 auto;
  min-width: 0;
  margin: 0 0 6px;
  padding: 10px;
  color: var(--ed-text);
  font: 500 var(--ed-label) / 1.3 "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
}

.pilot-hero-links[hidden], .pilot-game-screen[hidden] { display: none !important; }

.pilot-hero-links-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}

.pilot-hero-links h4 { margin: 0; white-space: nowrap; }
.pilot-hero-links-header .record-tool { min-height: 36px; white-space: nowrap; }
.pilot-hero-targets { display: grid; gap: 10px; }
.pilot-hero-targets:empty { display: none; }
.pilot-hero-targets > .pilot-hero-target { margin-top: 8px; }
.pilot-hero-target-group { min-width: 0; }
.pilot-hero-target-group h4 { margin: 10px 0 6px; color: #a6d7e2; }
.pilot-hero-target-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.pilot-hero-target-grid > :only-child { grid-column: 1 / -1; }
.pilot-hero-target {
  min-width: 0;
  min-height: 44px;
  padding: 7px 6px;
  border: 1px solid #4c878f;
  background: #04151e;
  color: #eef4e6;
  font: inherit;
  white-space: nowrap;
  cursor: pointer;
}
.pilot-hero-target:hover, .pilot-hero-target:focus-visible { border-color: #a1e166; background: #13341f; }
.pilot-hero-target:disabled { color: #82918d; cursor: not-allowed; }
.pilot-hero-target-values { display: block; margin-top: 3px; color: #a9c3cf; font-size: 11px; font-weight: 400; }
.pilot-hero-links-note { margin: 8px 0 0; color: #a7b6ae; white-space: nowrap; }
.pilot-hero-links-note:empty { display: none; }
.pilot-hero-links[data-source] { display: flex; flex-direction: row; align-items: center; gap: 6px; padding: 6px; }
.pilot-hero-links[data-source] .pilot-hero-links-header,
.pilot-hero-links[data-source] .pilot-hero-targets { display: contents; }
.pilot-hero-links[data-source] h4 { flex: 1 1 auto; }
.pilot-hero-links[data-source] .pilot-hero-target { order: 2; min-height: 36px; margin: 0; }
.pilot-hero-links[data-source] #pilotHeroReturnButton { order: 3; }
.pilot-hero-links[data-source] .pilot-hero-links-note { display: none; }
.editor-data-panel[data-hero-view="slot"] .editor-page-switch [data-editor-page]:not([data-editor-page="list"]) { display: none; }
.pilot-game-screen[data-hero-source="list"] :is(.pilot-portrait-panel, .pilot-points-panel, .pilot-combat-panel, .pilot-growth-panel, .pilot-terrain-panel),
.pilot-game-screen[data-hero-source="identity"] > :not(.pilot-portrait-panel),
.pilot-game-screen[data-hero-source="head"] :is(.pilot-portrait-panel, .pilot-mental-panel, .pilot-special-panel) { display: none !important; }
.pilot-game-screen[data-hero-source="identity"] { grid-template-areas: "portrait"; grid-template-columns: minmax(0,1fr); align-content: start; }
.pilot-game-screen[data-hero-source="head"] {
  grid-template-areas: "combat combat points" "growth growth terrain";
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.pilot-game-screen[data-hero-source="list"] {
  grid-template-areas: "mental mental skills";
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr);
}

@container (max-width: 559px) {
  .pilot-game-screen[data-hero-source="head"] {
    grid-template-areas: "points" "combat" "growth" "terrain";
    grid-template-columns: minmax(0, 1fr);
  }
  .pilot-game-screen[data-hero-source="list"] {
    grid-template-areas: "mental" "skills";
    grid-template-columns: minmax(0, 1fr);
  }
}

.pilot-portrait-panel { grid-area: portrait; }
.pilot-combat-panel { grid-area: combat; }
.pilot-points-panel { grid-area: points; }
.pilot-mental-panel { grid-area: mental; }
.pilot-special-panel { grid-area: skills; }
.pilot-growth-panel { grid-area: growth; }
.pilot-terrain-panel { grid-area: terrain; }

/* The four sections of the lower half are grid items of the screen itself. */
.pilot-lower-panel {
  display: contents;
}

.pilot-mental-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  min-height: 0;
}

.pilot-mental-slot {
  display: grid;
  align-content: center;
  gap: 2px;
  min-width: 0;
  min-height: 40px;
  padding: 2px 5px;
  border: 1px solid #12404a;
  background: #00101d;
}

.pilot-mental-slot.is-empty {
  border-style: dashed;
  border-color: #0d2a31;
  background: transparent;
}

.pilot-mental-name {
  min-width: 0;
  font-size: var(--ed-primary);
  word-break: keep-all;
}

.pilot-mental-level {
  color: #a9d6ee;
  font: 400 var(--ed-label) / 1.1 var(--runtime-number-face);
}

.pilot-mental-none {
  grid-column: 1 / -1;
  align-self: center;
  color: #c8c6a8;
  font-size: var(--ed-primary);
}

/* Editable spirit slots: the name line is a select, the level line a level box and a delete button. The controls keep the
   text metrics of a read-only slot (no 40px control height), so an editable slot is as tall as a read-only one. */
.pilot-mental-name.is-choice,
.pilot-mental-level.is-edit {
  display: flex;
  align-items: baseline;
  gap: 4px;
  min-width: 0;
}

.pilot-mental-level.is-edit > label {
  font: inherit;
  min-height: 0;
  display: flex;
  align-items: baseline;
  gap: 3px;
  min-width: 0;
}

.editor-game-screen .pilot-mental-slot :is(select, input) {
  height: auto;
  min-width: 0;
  min-height: 0;
  margin: 0;
  padding: 0 2px;
  border: 0;
  border-bottom: 1px dashed #2b6f7a;
  border-radius: 0;
  color: inherit;
  background-color: transparent;
  font: inherit;
  line-height: 1.15;
}

.editor-game-screen .pilot-mental-slot select {
  flex: 1 1 auto;
  width: 100%;
  padding-right: 20px;
  text-align: left;
}

.editor-game-screen .pilot-mental-slot input {
  width: 3.4ch;
  text-align: center;
}

.pilot-mental-remove {
  margin-left: auto;
  padding: 0 4px;
  border: 0;
  color: #a9d6ee;
  background: transparent;
  font: inherit;
  line-height: 1.1;
  cursor: pointer;
}

.pilot-mental-remove:disabled {
  color: #4f6a70;
  cursor: not-allowed;
}

.pilot-mental-slot.is-modified {
  border-color: #e8cc39;
}

.pilot-mental-slot.is-locked .pilot-mental-level,
.pilot-mental-name.is-full {
  color: #8f9a8d;
}

/* Skills: one name per line, then the edit button under them (in the flow, never over a name). */
.pilot-runtime-skills {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 9em), 1fr));
  align-content: start;
  gap: 4px 12px;
}

.pilot-runtime-skill,
.pilot-special-empty {
  min-width: 0;
  font-size: var(--ed-primary);
  line-height: 1.3;
}

.pilot-runtime-skill-name {
  word-break: keep-all;
}

.pilot-skill-schedule-button {
  box-sizing: border-box;
  align-self: flex-start;
  min-height: 32px;
  padding: 4px 8px;
  border: 1px solid var(--ed-rail);
  border-radius: 0;
  color: #ade9ef;
  background: #00111d;
  font: 500 var(--ed-label) / 1.2 var(--runtime-korean-face);
  cursor: pointer;
  white-space: nowrap;
}

.pilot-skill-schedule-button:disabled {
  color: #6d7d7d;
  border-color: #27474c;
  cursor: not-allowed;
}

/* Weapon screen ----------------------------------------------------------------------------------- */

.weapon-game-screen {
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
  grid-template-rows: auto auto minmax(0, 1fr);
  grid-template-areas:
    "note note"
    "detail terrain"
    "owners owners";
}

.weapon-detail-panel { grid-area: detail; }
.weapon-terrain-panel { grid-area: terrain; }
.weapon-owner-panel { grid-area: owners; }
.weapon-animation-panel { grid-area: preview; min-height: 0; padding: 0; overflow: hidden; }
.weapon-animation-panel iframe { display:block; width:100%; height:100%; border:0; min-height:0; }
.weapon-game-screen:has(.weapon-animation-panel:not([hidden])) {
  grid-template-rows: auto minmax(184px,1fr) auto minmax(70px,.35fr);
  grid-template-areas: "note note" "detail preview" "terrain preview" "owners owners";
}
.weapon-game-screen:has(.weapon-animation-panel:not([hidden])) .weapon-detail-grid { grid-template-columns:repeat(5,minmax(0,1fr)); }
.weapon-game-screen:has(.weapon-animation-panel:not([hidden])) .weapon-detail-grid label:has([data-editor-field="requiredSkill"]) { grid-column:span 2; }
.weapon-game-screen:has(.weapon-animation-panel:not([hidden])) .weapon-owner-panel { padding-block:4px; gap:3px; }
.weapon-game-screen:has(.weapon-animation-panel:not([hidden])) .weapon-owner-panel h4 { margin:0; line-height:16px; }
.weapon-game-screen:has(.weapon-animation-panel:not([hidden])) .weapon-owner-panel .panel-note { margin:0; font-size:10px; line-height:12px; }
:is(#weaponAnimationButton,#unitAnimationButton)[aria-checked="true"] { color:var(--ed-gold); border-color:var(--ed-gold); }

.owner-chip-list {
  display: flex;
  flex: 1 1 0;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: 6px;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-color: #41785a #06101a;
}

.owner-chip-list > [role="listitem"] {
  display: contents;
}

.owner-chip {
  width: auto;
  min-width: 0;
  max-width: 100%;
  grid-template-columns: minmax(0, 1fr);
  gap: 0;
}

.owner-chip.is-unverified {
  border-style: dashed;
  color: #c8c6a8;
}

.owner-chip-name {
  font-size: var(--ed-primary);
  overflow-wrap: anywhere;
}

.owner-chip-meta {
  color: #a9c3cf;
  font-size: var(--ed-label);
}

/* Tab bar, footer and the page switch need larger targets on touch screens -------------------------- */

@media (pointer: coarse) {
  .editor-tab,
  .editor-primary-button,
  .editor-unused-toggle {
    min-height: 40px;
  }
}

/* Paged layouts (medium and narrow): one part of the record at a time ---------------------------------- */

.editor-data-panel[data-auto-pages] .editor-page-switch { display: flex; }

@media (max-width: 1099px), (max-height: 719px) {
  .editor-page-switch { display: flex; }
  .editor-data-panel:not([data-auto-pages]):not([data-page="main"]):not([data-page="list"]) [data-editor-section="main"],
  .editor-data-panel:not([data-auto-pages]):not([data-page="aux"]) [data-editor-section="aux"],
  .editor-data-panel:not([data-auto-pages]):not([data-page="extra"]) [data-editor-section="extra"] {
    display: none;
  }

  /* Every grid of small fields puts its captions above the values. */
  .editor-game-screen :is(.unit-vitals-grid, .unit-core-grid, .pilot-points-grid) label {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: auto auto;
    align-items: end;
    gap: 2px 4px;
    min-height: 0;
  }

  .editor-game-screen :is(.unit-vitals-grid, .unit-core-grid, .pilot-points-grid) label > .editor-field-name { grid-column: 1 / -1; grid-row: 1; font-size: var(--ed-label); }
  .editor-game-screen :is(.unit-vitals-grid, .unit-core-grid, .pilot-points-grid) label > .editor-diff-reset { grid-column: 2; grid-row: 2; align-self: center; }
  .editor-game-screen :is(.unit-vitals-grid, .unit-core-grid, .pilot-points-grid) label > input[data-editor-field] { grid-column: 1; grid-row: 2; inline-size: 100%; text-align: center; }

  .unit-runtime-gauge {
    display: none;
  }

  .unit-vitals-grid,
  .unit-core-grid,
  .pilot-combat-grid,
  .pilot-points-grid,
  .weapon-detail-grid {
    --cell: var(--stacked-cell);
    grid-template-columns: repeat(auto-fit, minmax(min(100%, var(--cell)), 1fr));
  }

  /* Unit, values: the picture beside HP/EN and the four values, the four terrains under them */
  .unit-game-screen {
    grid-template-columns: var(--portrait, clamp(150px, 34cqw, 300px)) minmax(0, 1fr);
    grid-template-rows: auto;
    grid-template-areas:
      "image vitals"
      "core core"
      "terrain terrain"
      "abilities abilities"
      "weapons weapons";
  }

  /* Unit, abilities: as many slots per line as fit (a slot is as wide as the longest ability name); a slot that shows
     its flag number takes a whole line, with the number beside the choice. */
  .unit-special-list {
    grid-template-columns: repeat(auto-fill, minmax(min(100%, calc(var(--ability-text, 8) * var(--ed-primary) + 64px)), 1fr));
    gap: 8px;
  }

  .unit-special-row:has(> .unit-special-value-field:not([hidden])) {
    grid-column: 1 / -1;
  }

  .unit-special-row {
    grid-template-columns: minmax(0, 1fr) auto auto;
  }

  .unit-special-slot-name {
    display: none;
  }

  .unit-weapons-panel {
    flex: 1 1 auto;
  }

  /* Pilot, abilities: the face beside the six combat values and SP / EXP */
  .pilot-game-screen {
    grid-template-columns: var(--portrait-pilot, clamp(96px, 24cqw, 200px)) minmax(0, 1fr);
    grid-template-areas:
      "portrait points"
      "combat combat"
      "growth growth"
      "terrain terrain"
      "mental mental"
      "skills skills";
  }

  /* Weapon: the values and the terrains, then the units that own the weapon on their own part */
  .weapon-game-screen {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto;
    grid-template-areas:
      "note"
      "detail"
      "terrain"
      "owners";
  }
  .weapon-game-screen:has(.weapon-animation-panel:not([hidden])) {
    grid-template-columns:minmax(0,1fr);
    grid-template-rows:auto minmax(92px,1fr) auto;
    grid-template-areas:"note" "preview" "detail";
  }
  .weapon-game-screen:has(.weapon-animation-panel:not([hidden])) .weapon-detail-grid { grid-template-columns:repeat(4,minmax(0,1fr)); }

  .weapon-owner-panel {
    flex: 1 1 auto;
  }

  .owner-chip-list {
    flex: 1 1 0;
  }

  /* A part that holds a list (the unit's weapons; a weapon's terrains and owners) gives the list the rest of the height. */
  .editor-data-panel[data-page="extra"] .unit-game-screen {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
    grid-template-areas:
      "terrain"
      "weapons";
  }

  .editor-data-panel[data-page="extra"] .unit-weapons-panel {
    min-height: 0;
  }

  .editor-data-panel[data-page="extra"] .weapon-game-screen {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
    grid-template-areas:
      "terrain"
      "owners";
  }

  .editor-data-panel[data-page="extra"] .weapon-owner-panel {
    min-height: 0;
  }

  /* Wider screens of a paged layout use the width: the values beside the terrains. */
  @container (min-width: 480px) {
    .unit-game-screen {
      grid-template-areas:
        "image vitals"
        "image core"
        "terrain terrain"
        "abilities abilities"
        "weapons weapons";
    }

    .pilot-game-screen {
      grid-template-columns: var(--portrait-pilot, clamp(96px, 24cqw, 200px)) minmax(0, 1fr);
      grid-template-areas:
        "portrait combat"
        "portrait points"
        "growth growth"
        "terrain terrain"
        "mental mental"
        "skills skills";
    }
  }

  @container (min-width: 560px) {
    .pilot-game-screen {
      grid-template-columns: var(--portrait-pilot, clamp(96px, 20cqw, 200px)) minmax(0, 1.4fr) minmax(0, 1fr);
      grid-template-areas:
        "portrait combat points"
        "growth growth growth"
        "terrain terrain terrain"
        "mental mental mental"
        "skills skills skills";
    }

  }



}

/* Medium: the list stays beside the record; the page switch shares the record bar's row. */
@media (min-width: 761px) and (max-width: 1099px), (min-width: 761px) and (max-height: 719px) {
  .editor-data-panel {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: auto minmax(0, 1fr);
    grid-template-areas:
      "bar switch"
      "body body";
    gap: 6px;
  }

  .editor-data-panel[hidden] {
    display: none;
  }

  .record-bar { grid-area: bar; }
  .editor-page-switch { grid-area: switch; }
  .editor-panel-body { grid-area: body; }

  .editor-page-button[data-editor-page="list"] {
    display: none;
  }

  .editor-page-button {
    min-width: 5.5em;
  }

  .record-bar-label {
    display: none;
  }
}

/* Narrow: one thing at a time ------------------------------------------------------------------------ */

@media (max-width: 760px) {
  .editor-data-panel {
    gap: 4px;
    --edge: 3px;
  }

  .game-panel h3,
  .game-panel h4 {
    line-height: 1.1;
  }

  .record-bar {
    min-height: 40px;
    gap: 6px;
    padding: 0 4px;
    border-width: 1px;
  }

  .record-nav {
    min-height: 36px;
  }

  .record-bar-label,
  .record-position {
    display: none;
  }

  .editor-page-button {
    padding: 4px 4px;
  }

  .editor-panel-body {
    flex-direction: column;
  }

  .record-pane {
    flex: 1 1 0;
    padding: 6px;
  }

  .record-pane.is-weapons {
    --pane-width: auto;
  }

  .is-weapons .record-option {
    grid-template-columns: minmax(0, 1fr) 5.5ch 6.5ch 4ch;
  }

  .editor-data-panel[data-page="list"] .game-screen-shell,
  .editor-data-panel:not([data-page="list"]) .record-pane {
    display: none;
  }

  .editor-game-screen {
    gap: 0;
  }

  .game-panel {
    gap: 4px;
    padding: calc(var(--edge) + 2px) calc(var(--edge) + 3px);
  }

  .unit-vitals-panel h4,
  .unit-core-panel h4,
  .pilot-combat-panel h4,
  .pilot-points-panel h4,
  .weapon-detail-panel h4 {
    display: none;
  }

  .unit-game-screen {
    --portrait: clamp(88px, 26cqw, 200px);
  }

  .pilot-game-screen {
    --portrait-pilot: clamp(88px, 26cqw, 150px);
  }

  .unit-vitals-grid,
  .unit-core-grid,
  .pilot-combat-grid,
  .pilot-points-grid,
  .pilot-growth-grid,
  .weapon-detail-grid,
  .terrain-grid {
    gap: 3px 4px;
  }

  /* Four core values share one row, including their reset buttons. At 320px
     each cell still holds the full five-digit value at the normal font size. */
  .unit-core-grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }

  .editor-game-screen .unit-core-grid label {
    grid-template-columns: minmax(0, 1fr) 16px;
    column-gap: 2px;
  }

  .editor-game-screen .unit-core-grid label > input[data-editor-field] {
    min-inline-size: 0;
    padding-inline: 1px;
  }

  .editor-game-screen .unit-core-grid label > .editor-diff-reset {
    width: 16px;
    min-width: 16px;
    height: var(--ed-control);
    min-height: var(--ed-control);
  }

  .editor-game-screen .unit-core-grid label > .editor-diff-reset::after {
    inset: -2px 0 -2px -8px;
  }

  /* Room between the ability heading and the slots, where the slots' info buttons stand on their corners. */
  .unit-info-panel {
    gap: 4px;
  }
}

/* A phone held sideways: the tabs make a rail on the left and the page switch joins the record bar. */
@media (max-width: 760px) and (max-height: 480px) and (min-width: 520px) {
  body[data-view="editor"] { height: 100dvh; min-height: 0; overflow: hidden; }
  body[data-view="editor"] .editor-workspace {
    display: grid;
    grid-template-columns: 124px minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) auto;
    grid-template-areas:
      "rail panel"
      "footer footer";
  }

  .editor-tab-bar {
    grid-area: rail;
    flex-direction: column;
    flex-wrap: nowrap;
    align-items: stretch;
    align-self: stretch;
    min-height: 0;
    overflow-y: auto;
  }

  .editor-tab-row {
    flex: 0 0 auto;
    flex-direction: column;
    width: auto;
    gap: 3px;
  }

  .editor-tab {
    flex: 0 0 auto;
  }

  /* Six map-editor tabs need more height than a short landscape rail has.
     One row leaves that height for the measured map and input pages. */
  body[data-view="editor"] .editor-workspace:has(> .editor-scenario-panel:not([hidden])) {
    display: flex;
  }

  .editor-workspace:has(> .editor-scenario-panel:not([hidden])) .editor-tab-bar {
    flex-direction: row;
    align-self: stretch;
  }

  .editor-workspace:has(> .editor-scenario-panel:not([hidden])) .editor-tab-row {
    flex-direction: row;
    width: 100%;
  }

  .editor-workspace:has(> .editor-scenario-panel:not([hidden])) .editor-tab {
    flex: 1 1 0;
  }

  /* The weapon tab's record bar has room for its label ("전체 무기 목록"), which replaces the weapon note. */
  #weaponEditorPanel .record-bar-label {
    display: inline;
  }

  .weapon-scope-note {
    display: none;
  }

  .editor-unused-toggle {
    margin-left: 0;
    white-space: normal;
  }

  .editor-record-notice {
    flex: 0 1 auto;
    flex-direction: column;
    order: 0;
  }

  .editor-data-panel {
    display: grid;
    grid-area: panel;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: auto minmax(0, 1fr);
    grid-template-areas:
      "bar switch"
      "body body";
  }

  .editor-data-panel[hidden] {
    display: none;
  }

  .record-bar { grid-area: bar; }
  .editor-page-switch { grid-area: switch; }
  .editor-panel-body { grid-area: body; }

  /* The status and the save button stand under the tabs, so the record keeps the window's height. */
  .editor-footer {
    grid-area: footer;
    flex-direction: column;
    flex-wrap: nowrap;
    align-items: stretch;
    align-self: end;
  }

  .editor-footer .editor-status {
    flex: 0 0 auto;
  }

  /* While the list shows, its own count line says enough; the status gives its room to the list switch. */
  .editor-workspace:has(> .editor-data-panel:not([hidden])[data-page="list"]) .editor-footer .editor-status {
    display: none;
  }

  .editor-download-actions {
    flex-direction: column;
  }

  /* Wide and low: the parts of a page sit side by side. */
  .unit-game-screen {
    grid-template-columns: minmax(0, 3fr) minmax(0, 2fr) minmax(0, 5fr);
    grid-template-areas:
      "image vitals vitals"
      "image core core"
      "abilities abilities abilities"
      "weapons weapons weapons";
  }

  .editor-tab,
  .record-nav {
    min-height: 28px;
  }

  body[data-view="editor"] .editor-footer {
    grid-template-columns: minmax(60px,1fr) minmax(220px,2fr) auto;
    grid-template-areas: "status presets export";
  }

  .mode-switch-button {
    min-height: 30px;
  }


  .pilot-game-screen {
    grid-template-columns: 96px minmax(0, 1.2fr) minmax(0, 1fr);
    grid-template-areas:
      "portrait combat points"
      "growth growth terrain"
      "mental mental skills";
  }

  .editor-data-panel[data-page="extra"] .unit-game-screen {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "terrain"
      "weapons";
  }
}

/* A phone held sideways: the three cards stand side by side as on a desktop (the window is wide but low). */
@media (max-width: 760px) and (max-height: 480px) and (min-width: 520px) {
  .patch-workspace {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    grid-template-rows: auto minmax(0, 1fr);
  }

  .patch-workspace > .workflow-zone {
    align-self: stretch;
    height: auto;
  }

  .brand-copy {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: baseline;
    column-gap: 10px;
  }

  .site-header {
    min-height: 36px;
    padding-block: 2px;
  }

  .compatibility {
    min-height: 28px;
    padding-block: 2px;
  }

  .brand-mark {
    width: 28px;
    height: 28px;
    font-size: 16px;
  }
}

/* A phone held sideways: the header and the bar above the editor keep to one line each. */
@media (max-width: 760px) and (max-height: 480px) {
  body[data-view="editor"] .mode-bar {
    flex-wrap: nowrap;
  }

  body[data-view="editor"] .mode-summary {
    order: 0;
    flex: 1 1 auto;
  }
}

@media (max-width: 760px) and (max-height: 480px) and (min-width: 520px) {
  .editor-footer { flex-direction: row; }
  .editor-footer .editor-status { flex: 1 1 0; min-width: 0; }
}

/* Help popover (top layer) ----------------------------------------------------------------------- */

.editor-gameplay-help {
  box-sizing: border-box;
  position: fixed;
  inset: auto;
  z-index: 10000;
  width: min(360px, calc(100vw - 24px));
  max-height: calc(100dvh - 24px);
  margin: 0;
  padding: 14px 40px 14px 16px;
  overflow: auto;
  border: 1px solid #63b5c6;
  border-radius: 12px;
  color: #edf7fa;
  background: #0d2031;
  box-shadow: 0 8px 30px #0008;
  font: 400 15px / 1.55 system-ui, sans-serif;
}

.editor-gameplay-help[hidden] {
  display: none;
}

.help-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 10px;
}

.help-title {
  color: #ffe88f;
  font-size: 16px;
}

.fact-badge {
  display: inline-block;
  padding: 0 8px;
  border: 1px solid currentColor;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.6;
  white-space: nowrap;
}

.fact-badge.is-verified { color: #8fe08a; }
.fact-badge.is-sourced { color: #7fc4ff; }
.fact-badge.is-inferred { color: #ffd166; }
.fact-badge.is-unknown { color: #c3c9cf; }

.help-effect {
  margin: 8px 0;
  overflow-wrap: anywhere;
}

.help-event-condition { margin-bottom: 10px; }
.help-event-title { color: #ffe88f; }
.help-event-step { margin: 8px 0; }
.help-event-step > b { color: #aeece8; }
.help-event-evidence { margin-top: 8px; color: #a9bfbe; font-size: 12px; }
.help-event-evidence summary { cursor: pointer; }
.help-event-evidence a { color: #aeece8; }

.help-params {
  width: 100%;
  margin: 6px 0;
  border-collapse: collapse;
  font-size: 14px;
}

.help-params th,
.help-params td {
  padding: 4px 0;
  border-top: 1px solid #1d4458;
  text-align: left;
  vertical-align: top;
}

.help-params th {
  width: 44%;
  padding-right: 8px;
  color: #cfe6ee;
  font-weight: 600;
}

.help-params td {
  font-variant-numeric: tabular-nums;
}

.help-note {
  display: block;
  color: #a3c1ce;
  font-size: 12px;
}

.help-cautions {
  display: grid;
  gap: 6px;
  margin: 8px 0;
  padding: 0;
  font-size: 13px;
  list-style: none;
}

.help-how {
  margin: 8px 0 0;
  padding-top: 8px;
  border-top: 1px solid #1d4458;
  color: #c4d8e0;
  font-size: 13px;
}

.help-game,
.help-scope {
  display: block;
  margin-top: 6px;
  color: #a3c1ce;
  font-size: 12px;
}

.editor-help-close {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 6px;
  color: #edf7fa;
  background: transparent;
  font-size: 24px;
  cursor: pointer;
}

/* Pilot skill dialog ------------------------------------------------------------------------------ */

.pilot-skill-dialog {
  --ed-ink: #ece6d5;
  --ed-muted: #aebbb9;
  --ed-rail: #13818c;
  width: min(760px, 94vw);
  top: var(--pilot-skill-viewport-top, 0px);
  bottom: var(--pilot-skill-viewport-bottom, 0px);
  max-width: none;
  max-height: min(calc(var(--pilot-skill-viewport-height, 100dvh) - 16px), 720px);
  padding: 0;
  overflow: hidden;
  border: 2px solid #c5a850;
  border-radius: 0;
  color: var(--ed-ink);
  background: #000819;
  box-shadow: 0 0 0 4px #111627, 0 24px 80px rgba(0, 0, 0, 0.75);
  font: 500 clamp(14px, 0.4vw + 11px, 16px) / 1.4 "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
}

.pilot-skill-dialog::backdrop {
  background: rgba(0, 0, 12, 0.78);
}

.pilot-skill-dialog-shell {
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: calc(min(var(--pilot-skill-viewport-height, 100dvh) - 16px, 720px) - 4px);
  padding: 12px 14px;
  border: 3px solid #155400;
  background: #000819;
}

.pilot-skill-dialog-header {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid #23720d;
}

.pilot-skill-dialog-header span {
  color: #82c5d1;
  font: 600 12px / 1.2 ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  letter-spacing: 0.08em;
}

.pilot-skill-dialog-header h2 {
  margin: 2px 0 0;
  color: #f2e9c9;
  font-size: clamp(17px, 0.6vw + 14px, 20px);
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pilot-skill-dialog-header > div { min-width: 0; }

.pilot-skill-dialog button:not(.editor-help-button):not(.editor-help-close),
.pilot-skill-dialog select,
.pilot-skill-dialog input {
  box-sizing: border-box;
  min-height: 40px;
  border: 1px solid var(--ed-rail);
  border-radius: 0;
  color: #dcf5ef;
  background: #00111d;
  font: inherit;
}

.pilot-skill-dialog button:not(.editor-help-button):not(.editor-help-close) {
  padding: 0 14px;
  cursor: pointer;
}

.pilot-skill-dialog button:not(.editor-help-button):not(.editor-help-close):disabled,
.pilot-skill-dialog select:disabled,
.pilot-skill-dialog input:disabled {
  color: #7c8884;
  border-color: #27474c;
  cursor: not-allowed;
}

.pilot-skill-dialog :is(button, select, input):focus-visible {
  outline: 2px solid #ffe04e;
  outline-offset: 1px;
}

.pilot-skill-dialog-note,
.pilot-skill-add-hint,
.pilot-skill-dialog-footnote {
  flex: 0 0 auto;
  margin: 0;
  color: var(--ed-muted);
  font-size: 14px;
  line-height: 1.45;
}

.pilot-skill-dialog-note {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 12px;
}

.pilot-skill-dialog-note > span,
.pilot-skill-status > span {
  white-space: nowrap;
}

.pilot-skill-dialog-footnote {
  padding-top: 8px;
  border-top: 1px solid #263d39;
  color: #a69c80;
  font-size: 13px;
}

.pilot-skill-status {
  display: flex;
  flex: 0 0 auto;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 2px 12px;
  padding: 6px 10px;
  border: 1px solid #14505a;
  color: #ade9ef;
  background: #00101d;
  font-variant-numeric: tabular-nums;
}

.pilot-skill-status:empty,
.pilot-skill-warning:empty {
  display: none;
}

.pilot-skill-warning {
  flex: 0 0 auto;
  margin: 0;
  padding: 8px 10px;
  border: 1px solid #b8932a;
  color: #f6df8a;
  background: #231c04;
}

.pilot-skill-schedule {
  display: grid;
  flex: 1 1 auto;
  align-content: start;
  gap: 6px;
  min-width: 0;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-color: #41785a #06101a;
}

.pilot-skill-group {
  --pilot-skill-columns: minmax(72px, 1fr) minmax(82px, 1fr) 64px 56px;
  min-width: 0;
  border: 1px solid #133f36;
  background: #000e1d;
}

.pilot-skill-group-header {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  padding: 6px 8px;
  color: #ece6d5;
  background: #07191e;
}

.pilot-skill-group-name {
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 650;
}

.pilot-skill-group-header > small {
  flex: 0 0 auto;
  margin-left: auto;
  color: #aebbb9;
  font-size: 12px;
  white-space: nowrap;
}

.pilot-skill-columns,
.pilot-skill-row {
  display: grid;
  grid-template-columns: var(--pilot-skill-columns);
  align-items: center;
  gap: 6px;
  min-width: 0;
  padding: 4px 6px;
}

.pilot-skill-columns {
  color: #aebbb9;
  font-size: 12px;
  line-height: 1.3;
  white-space: nowrap;
  text-align: center;
}

.pilot-skill-row {
  border: 1px solid #133f36;
  background: #000e1d;
}

.pilot-skill-row.is-new {
  border-color: #3f9c3a;
  background: rgba(40, 100, 30, 0.2);
}

.pilot-skill-row.is-modified {
  border-color: #e8cf4e;
  background: rgba(119, 91, 5, 0.16);
}

.pilot-skill-meta {
  display: block;
  grid-column: 1 / -1;
  min-width: 0;
  color: #f1dd74;
  font-size: 12px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.pilot-skill-rank-field,
.pilot-skill-level-field,
.pilot-skill-add-choice,
.pilot-skill-add-rank,
.pilot-skill-add-level {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  color: var(--ed-muted);
  font-size: 13px;
  white-space: nowrap;
}

.pilot-skill-rank-field {
  justify-content: center;
  font-variant-numeric: tabular-nums;
}

.pilot-skill-rank-field select,
.pilot-skill-level-field input {
  width: 100%;
  min-width: 0;
  padding: 4px 6px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.pilot-skill-add-rank select,
.pilot-skill-add-level input {
  min-width: 0;
  width: 4.5em;
  padding: 4px 6px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.pilot-skill-rank-field select.is-modified,
.pilot-skill-level-field input.is-modified {
  color: #fff1a0;
  border-color: #d2bd39;
}

.pilot-skill-dialog .pilot-skill-row button.pilot-skill-replace,
.pilot-skill-dialog .pilot-skill-row button.pilot-skill-remove {
  min-width: 0;
  width: 100%;
  padding: 0 4px;
  white-space: nowrap;
}

.pilot-skill-add-target {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 6px 8px;
  border: 1px solid #b8932a;
  color: #f6df8a;
  background: #231c04;
}

.pilot-skill-add-target > span {
  flex: 1 1 auto;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pilot-skill-add-target > button {
  flex: 0 0 auto;
}

.pilot-skill-add-target[hidden],
.pilot-skill-add-rank[hidden],
.pilot-skill-add[hidden] {
  display: none;
}

.pilot-skill-add {
  display: grid;
  flex: 0 0 auto;
  grid-template-columns: minmax(150px, 1fr) auto auto 96px;
  align-items: center;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px solid #23720d;
}

.pilot-skill-add:has(.pilot-skill-add-rank[hidden]) {
  grid-template-columns: minmax(150px, 1fr) auto 96px;
}

.pilot-skill-add-choice select {
  flex: 1 1 0;
  min-width: 0;
  padding: 4px 8px;
}

.pilot-skill-add-rank,
.pilot-skill-add-level {
  justify-content: flex-end;
}

.pilot-skill-add-button {
  min-width: 88px;
  color: #04120d;
  border-color: #74dc53;
  background: linear-gradient(#a3e56b, #60bd49);
  font-weight: 650;
  white-space: nowrap;
}

.pilot-skill-dialog .pilot-skill-add-button:not(.editor-help-button):not(.editor-help-close) {
  padding-inline: 6px;
}

.pilot-skill-dialog .pilot-skill-add-button:disabled {
  color: #7c8884;
  background: #00111d;
}

.pilot-skill-add-hint.is-caution {
  color: #f1dd74;
}

.pilot-skill-actions {
  display: flex;
  flex: 0 0 auto;
  justify-content: flex-end;
}

.pilot-skill-actions > button {
  max-width: 100%;
  white-space: nowrap;
}

.pilot-skill-pager {
  display: grid;
  flex: 0 0 auto;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  padding-top: 4px;
  border-top: 1px solid #133f36;
}

.pilot-skill-pager[hidden],
.pilot-skill-group[hidden],
.pilot-skill-row[hidden] {
  display: none;
}

.pilot-skill-pager > span {
  min-width: 4em;
  color: #ade9ef;
  font-variant-numeric: tabular-nums;
  text-align: center;
  white-space: nowrap;
}

.pilot-skill-pager > button {
  min-width: 0;
  white-space: nowrap;
}

.pilot-skill-dialog.is-paged {
  height: min(calc(var(--pilot-skill-viewport-height, 100dvh) - 20px), 716px);
}

.pilot-skill-dialog.is-paged .pilot-skill-dialog-shell {
  height: 100%;
  max-height: none;
}

.pilot-skill-dialog.is-paged .pilot-skill-schedule {
  overflow-y: hidden;
}

.pilot-skill-dialog.is-skill-scroll-required .pilot-skill-schedule {
  overflow-y: auto;
}

.pilot-skill-dialog.is-skill-controls-scroll .pilot-skill-dialog-shell {
  overflow-y: auto;
}

.pilot-skill-dialog.is-skill-controls-scroll .pilot-skill-schedule {
  flex: 0 0 auto;
  overflow-y: visible;
}

.pilot-skill-dialog.is-short-viewport .pilot-skill-dialog-note,
.pilot-skill-dialog.is-short-viewport .pilot-skill-dialog-footnote:not([open]) {
  display: none;
}

.pilot-skill-schedule-empty {
  margin: 0;
  padding: 12px;
  color: #aab0a7;
}

@media (max-width: 540px) {
  .pilot-skill-dialog {
    width: calc(100vw - 16px);
    max-width: calc(100vw - 16px);
    max-height: calc(var(--pilot-skill-viewport-height, 100dvh) - 16px);
    margin: auto;
  }

  .pilot-skill-dialog.is-paged {
    height: calc(var(--pilot-skill-viewport-height, 100dvh) - 20px);
  }

  .pilot-skill-dialog-shell {
    max-height: calc(var(--pilot-skill-viewport-height, 100dvh) - 20px);
    padding: 8px 10px;
    gap: 4px;
  }

  .pilot-skill-dialog-header {
    padding-bottom: 4px;
  }

  .pilot-skill-dialog-note,
  .pilot-skill-add-hint {
    font-size: 12px;
  }

  .pilot-skill-status {
    padding: 3px 6px;
    font-size: 12px;
  }

  .pilot-skill-group {
    --pilot-skill-columns: minmax(60px, 1fr) minmax(60px, 1fr) 48px 48px;
  }

  .pilot-skill-group-header {
    padding: 2px 6px;
  }

  .pilot-skill-columns,
  .pilot-skill-row {
    gap: 4px;
    padding: 2px 4px;
  }

  .pilot-skill-dialog-footnote {
    padding-top: 2px;
  }

  .pilot-skill-add,
  .pilot-skill-add:has(.pilot-skill-add-rank[hidden]) {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 4px 6px;
    padding-top: 4px;
  }

  .pilot-skill-add-choice {
    grid-column: 1;
    grid-row: 1;
  }

  .pilot-skill-add-rank {
    grid-column: 2;
    grid-row: 1;
  }

  .pilot-skill-add-level {
    grid-column: 1;
    grid-row: 2;
    justify-content: flex-start;
  }

  .pilot-skill-add-button {
    grid-column: 2;
    grid-row: 2;
  }

  .pilot-skill-add:has(.pilot-skill-add-rank[hidden]) .pilot-skill-add-choice {
    grid-column: 1 / -1;
  }

  .pilot-skill-add-target {
    padding: 4px 6px;
    font-size: 12px;
  }

  .pilot-skill-add-target > button {
    padding-inline: 8px;
  }
}

/* Change list and preset file ---------------------------------------------------------------------- */
/* The status line at the bottom is a button that opens the list of changed values; the dialog lies over the editor, so
   nothing here adds height to the page. The list scrolls inside the dialog. */

.editor-footer button.editor-status {
  font-family: inherit;
  text-align: start;
  cursor: pointer;
}

.editor-footer button.editor-status::after {
  content: " ▴";
  color: var(--ed-gold, #e9d870);
}

.editor-footer button.editor-status:hover {
  border-color: #2b8796;
  color: #dcefe2;
}

.editor-footer button.editor-status:focus-visible {
  outline: 2px solid #ffe04e;
  outline-offset: 1px;
}

.editor-changes-dialog {
  width: min(720px, 94vw);
  max-width: none;
  max-height: min(86dvh, 720px);
  padding: 0;
  overflow: hidden;
  border: 2px solid #c5a850;
  border-radius: 0;
  color: #ece6d5;
  background: #000819;
  box-shadow: 0 0 0 4px #111627, 0 24px 80px rgba(0, 0, 0, 0.75);
  font: 500 clamp(14px, 0.4vw + 11px, 16px) / 1.4 "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
}

.editor-changes-dialog::backdrop {
  background: rgba(0, 0, 12, 0.72);
}

.editor-changes-shell {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: inherit;
  padding: 12px 14px;
  border: 3px solid #155400;
  box-sizing: border-box;
}

.editor-changes-header {
  display: flex;
  flex: 0 0 auto;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid #23720d;
}

.editor-changes-header h2 {
  flex: 1 1 auto;
  margin: 0;
  color: #f2e9c9;
  font-size: clamp(17px, 0.6vw + 14px, 20px);
  line-height: 1.2;
}

.editor-preset-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.editor-changes-dialog button {
  box-sizing: border-box;
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid #13818c;
  border-radius: 0;
  color: #dcf5ef;
  background: #00111d;
  font: inherit;
  cursor: pointer;
}

.editor-changes-dialog button:disabled {
  color: #7c8884;
  border-color: #27474c;
  cursor: not-allowed;
}

.editor-changes-dialog :is(button, summary):focus-visible {
  outline: 2px solid #ffe04e;
  outline-offset: 1px;
}

.editor-changes-dialog .editor-changes-tool.is-primary:not(:disabled) {
  border-color: #74dc53;
  color: #04120d;
  background: linear-gradient(#a3e56b, #60bd49);
  font-weight: 750;
}

.editor-changes-dialog .editor-changes-close {
  min-width: 40px;
  padding: 0;
}

/* AI request/result tabs fit inside the existing editor dialog, including short windows. */
html:has(#editorAiDialog[open]) { overflow: hidden; }
.editor-ai-dialog { width: min(760px, 94vw); height: min(620px, calc(100dvh - 24px)); max-height: none; margin: auto; box-sizing: border-box; }
.editor-ai-shell { display: grid; grid-template-rows: auto auto auto minmax(0, 1fr) auto; gap: 8px; height: 100%; min-height: 0; padding: 12px; border: 3px solid #155400; box-sizing: border-box; }
.editor-ai-intro, .editor-ai-note { margin: 0; color: #b6ccca; font-size: 12px; }
.editor-ai-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
.editor-ai-tabs button[aria-selected="true"] { border-color: #8de354; color: #fff0a0; background: #143c2b; }
.editor-ai-panel { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; gap: 8px; min-width: 0; min-height: 0; }
.editor-ai-panel[hidden], .editor-ai-message[hidden] { display: none; }
.editor-ai-scope { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 10px; }
.editor-ai-dialog :is(select, textarea) { width: 100%; min-width: 0; box-sizing: border-box; padding: 8px; border: 1px solid #237a88; border-radius: 0; background: #03101d; color: #e3f1e9; font: inherit; }
.editor-ai-dialog select { min-height: 40px; }
.editor-ai-textarea-label { display: flex; flex-direction: column; gap: 5px; min-height: 0; font-size: 13px; }
.editor-ai-dialog textarea { flex: 1 1 auto; min-height: 0; resize: none; font-size: 13px; line-height: 1.45; }
.editor-ai-dialog textarea:focus-visible, .editor-ai-dialog select:focus-visible { outline: 2px solid #ffe04e; outline-offset: 1px; }
.editor-ai-actions, .editor-ai-summary { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-width: 0; }
.editor-ai-actions > span, .editor-ai-summary > span { color: #a8c6bd; font-size: 12px; }
.editor-ai-optional { display: flex; align-items: center; gap: 5px; color: #a8c6bd; font-size: 12px; }
.editor-ai-optional input { width: 17px; height: 17px; margin: 0; accent-color: #94d85c; }
.editor-ai-message { max-height: 3.6em; overflow-y: auto; margin: 0; color: #a9e6da; font-size: 12px; }
.editor-ai-message[data-error="true"] { color: #ffb9a4; }
@media (max-height: 500px) {
  .editor-ai-shell { gap: 4px; padding: 6px 10px; }
  .editor-ai-shell .editor-changes-header { padding-bottom: 4px; }
  .editor-ai-intro { display: none; }
  .editor-ai-shell { grid-template-rows: auto auto minmax(0, 1fr) auto; }
  .editor-ai-panel { gap: 4px; }
  .editor-ai-actions > span { display: none; }
  .editor-ai-dialog button, .editor-ai-dialog select { min-height: 32px; }
}
@media (max-width: 519px) {
  .editor-ai-dialog { width: calc(100vw - 16px); }
  .editor-ai-shell { padding: 8px; }
  .editor-ai-dialog button { padding-inline: 9px; font-size: 13px; }
  .editor-ai-actions > span { max-width: 45%; }
}

.editor-changes-message {
  flex: 0 0 auto;
  margin: 0;
  padding: 6px 10px;
  border: 1px solid #14505a;
  color: #ade9ef;
  background: #00101d;
  overflow-wrap: anywhere;
}

.editor-changes-message[data-tone="error"] {
  border-color: #a8483f;
  color: #ffc9bf;
}

.editor-changes-list,
.editor-preset-summary {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.editor-changes-empty {
  margin: 0;
  padding: 16px 12px;
  color: #aab0a7;
}

.editor-changes-group + .editor-changes-group {
  margin-top: 10px;
}

.editor-changes-heading {
  margin: 0 0 4px;
  color: #9fd7e6;
  font-size: 14px;
}

.editor-changes-items,
.editor-preset-counts,
.editor-preset-conflicts {
  margin: 0;
  padding: 0;
  list-style: none;
}

.editor-changes-dialog .editor-changes-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  width: 100%;
  min-height: 44px;
  padding: 6px 10px;
  border-color: #1c3d45;
  text-align: start;
}

.editor-changes-dialog .editor-changes-item:hover {
  border-color: #2b8796;
  background: #021a2b;
}

.editor-changes-items li + li {
  margin-top: 4px;
}

.editor-changes-name {
  color: #f2e9c9;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.editor-changes-detail {
  color: #fff19b;
  font-size: 14px;
  overflow-wrap: anywhere;
}

.editor-event-change-value { display: block; white-space: nowrap; }

.editor-preset-file {
  margin: 0 0 8px;
  color: #aebbb9;
  overflow-wrap: anywhere;
}

.editor-preset-count {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 10px;
  padding: 6px 10px;
  border-left: 3px solid #13818c;
  background: #00101d;
}

.editor-preset-count + .editor-preset-count {
  margin-top: 4px;
}

.editor-preset-count span {
  color: #aebbb9;
  font-size: 14px;
}

.editor-preset-count.is-conflict {
  border-left-color: #e9d870;
}

.editor-preset-count.is-skip {
  border-left-color: #a8483f;
}

.editor-preset-details {
  margin-top: 8px;
}

.editor-preset-details summary {
  min-height: 32px;
  color: #9fd7e6;
  cursor: pointer;
}

.editor-preset-conflicts li {
  padding: 4px 0;
  border-bottom: 1px solid #12303a;
  font-size: 14px;
  overflow-wrap: anywhere;
}

.editor-preset-actions {
  margin-top: 10px;
}

/* the field that a change list entry led to */
.is-change-target {
  outline: 2px solid #ffe04e;
  outline-offset: 2px;
}

@media (max-width: 540px) {
  .editor-changes-dialog:not(.editor-ai-dialog) {
    width: 100vw;
    max-width: 100vw;
    max-height: 100dvh;
    margin: 0;
    border-width: 0;
  }

  .editor-changes-shell {
    height: 100dvh;
    padding: 8px 10px;
  }

  .editor-preset-actions button {
    flex: 1 1 100%;
  }
}

.editor-range-error { color: #ffb5a7; font-size: 12px; grid-column: 1 / -1; }
.unit-special-row.is-locked { opacity: .8; }

.editor-data-panel[data-auto-pages] .editor-visual canvas { max-height: 128px; }

/* Unit-specific controls; numeric packing is shared by all three screens below. */
.editor-data-panel[data-auto-pages] .unit-vitals-panel h4,
.editor-data-panel[data-auto-pages] .unit-core-panel h4 { display: none; }
.editor-data-panel[data-auto-pages] .unit-runtime-gauge { display: none; }
.editor-data-panel[data-auto-pages] .unit-flag-grid label { display: flex; flex-wrap: nowrap; gap: 4px; }
.editor-data-panel[data-auto-pages] .unit-flag-grid label > .editor-field-name { flex: 0 1 auto; }
.editor-data-panel[data-auto-pages] .unit-flag-grid label > select { flex: 1 1 0; }
.editor-data-panel[data-auto-pages] .unit-flag-grid .editor-diff-reset.is-empty { display: none; }
.editor-data-panel[data-auto-pages] .unit-flag-grid select { min-inline-size: 48px; }
.editor-data-panel[data-auto-pages] .unit-flag-grid .caption-tail { white-space: normal; word-break: break-all; }
.editor-data-panel[data-auto-pages] .unit-image-panel { min-height: 82px; }
.editor-data-panel[data-auto-pages] .unit-image-panel canvas { max-height: 88px; }
.editor-data-panel[data-auto-pages] .unit-special-list { grid-template-columns: repeat(auto-fit,minmax(min(100%,90px),1fr)); gap: 4px; }
.editor-data-panel[data-auto-pages] .unit-special-list:has(.unit-special-row:not(.is-empty)) { grid-template-columns: repeat(2,minmax(0,1fr)); }
.editor-data-panel[data-auto-pages] .unit-special-row { grid-template-columns: minmax(0,1fr) auto auto; gap: 2px; }
.editor-data-panel[data-auto-pages] .unit-special-name-field .editor-diff-reset.is-empty { display: none; }
.editor-data-panel[data-auto-pages] .unit-ability-remove { width: 20px; height: 28px; font-size: 18px; }
/* A desktop with the player open uses measured pages. Keep the two ability
   rows readable while leaving the recovered height for the weapon list. */
@media (min-width: 1100px) {
  #unitEditorPanel[data-auto-pages] #unitStatsForm:not([data-unit-preview="stacked"]):has(#unitAnimationPanel:not([hidden])) .unit-info-panel { padding:4px 6px; gap:3px; }
  #unitEditorPanel[data-auto-pages] #unitStatsForm:not([data-unit-preview="stacked"]):has(#unitAnimationPanel:not([hidden])) .unit-info-panel h4 { min-height:22px; gap:4px; }
  #unitEditorPanel[data-auto-pages] #unitStatsForm:not([data-unit-preview="stacked"]):has(#unitAnimationPanel:not([hidden])) #unitFlagToggle { min-height:22px; padding:1px 4px; }
  #unitEditorPanel[data-auto-pages] #unitStatsForm:not([data-unit-preview="stacked"]):has(#unitAnimationPanel:not([hidden])) .unit-special-list { grid-template-columns:repeat(2,minmax(0,1fr)); gap:3px 5px; }
  #unitEditorPanel[data-auto-pages] #unitStatsForm:not([data-unit-preview="stacked"]):has(#unitAnimationPanel:not([hidden])) .unit-special-row { grid-template-columns:minmax(0,1fr) auto auto; gap:2px; }
  #unitEditorPanel[data-auto-pages] #unitStatsForm:not([data-unit-preview="stacked"]):has(#unitAnimationPanel:not([hidden])) .unit-special-slot-name { display:none; }
  #unitEditorPanel[data-auto-pages] #unitStatsForm:not([data-unit-preview="stacked"]):has(#unitAnimationPanel:not([hidden])) .unit-special-name-field select { min-height:26px; height:26px; }
  #unitEditorPanel[data-auto-pages] #unitStatsForm:not([data-unit-preview="stacked"]):has(#unitAnimationPanel:not([hidden])) .unit-ability-remove { width:20px; height:26px; }
  /* Flags share the existing two rows. Borrow width from the terrain column
     rather than adding a page or pushing the weapon list down. */
  #unitEditorPanel[data-auto-pages] #unitStatsForm:not([data-unit-preview="stacked"]):has(#unitAnimationPanel:not([hidden])):has(.unit-special-list.has-flags) { grid-template-columns:145px minmax(140px,18%) minmax(0,1fr) minmax(320px,42%) !important; }
  #unitEditorPanel[data-auto-pages] #unitStatsForm:not([data-unit-preview="stacked"]):has(#unitAnimationPanel:not([hidden])) .unit-special-list.has-flags .unit-special-value-field { align-items:center; gap:1px; min-width:0; }
  #unitEditorPanel[data-auto-pages] #unitStatsForm:not([data-unit-preview="stacked"]):has(#unitAnimationPanel:not([hidden])) .unit-special-list.has-flags .unit-special-value-field > .editor-field-name { font-size:0; line-height:0; }
  #unitEditorPanel[data-auto-pages] #unitStatsForm:not([data-unit-preview="stacked"]):has(#unitAnimationPanel:not([hidden])) .unit-special-list.has-flags .unit-special-value-field input { width:34px; min-width:34px; height:26px; min-height:26px; padding:1px; text-align:center; }
  #unitEditorPanel[data-auto-pages] #unitStatsForm:not([data-unit-preview="stacked"]):has(#unitAnimationPanel:not([hidden])) .unit-special-value-field > .editor-diff-reset.is-empty { display:none; }
  #unitEditorPanel[data-auto-pages] #unitStatsForm:not([data-unit-preview="stacked"]):has(#unitAnimationPanel:not([hidden])) .unit-special-value-field > .editor-diff-reset { width:14px; min-width:14px; }
  /* The flag's adjacent help button opens the same condition description. */
  #unitEditorPanel[data-auto-pages] #unitStatsForm:not([data-unit-preview="stacked"]):has(#unitAnimationPanel:not([hidden])) .unit-special-row:has(> .unit-special-value-field:not([hidden])) > .unit-event-condition { display:none; }
  #unitEditorPanel[data-auto-pages] #unitStatsForm:not([data-unit-preview="stacked"]):has(#unitAnimationPanel:not([hidden])) .unit-special-list.has-flags .unit-special-name-field select { padding-right:28px; }
  #unitEditorPanel[data-auto-pages] #unitStatsForm:not([data-unit-preview="stacked"]):has(#unitAnimationPanel:not([hidden])) .unit-special-list.has-flags .unit-special-name-field > .editor-help-button { margin-right:15px; }
  #unitEditorPanel[data-auto-pages] #unitStatsForm:not([data-unit-preview="stacked"]):has(#unitAnimationPanel:not([hidden])) .unit-terrain-panel { padding:4px 6px; gap:4px; align-content:center; }
  #unitEditorPanel[data-auto-pages] #unitStatsForm:not([data-unit-preview="stacked"]):has(#unitAnimationPanel:not([hidden])):has(.unit-special-list.has-flags) .unit-terrain-panel { grid-template-columns:minmax(0,1fr); }
  /* When flags are open, use the header line for terrain and give both
     ability rows the full width. All controls remain on the measured page. */
  #unitEditorPanel[data-auto-pages] #unitStatsForm:not([data-unit-preview="stacked"]):has(#unitAnimationPanel:not([hidden])):has(.unit-special-list.has-flags) .unit-info-panel { grid-column:1 / 4; grid-row:2; }
  #unitEditorPanel[data-auto-pages] #unitStatsForm:not([data-unit-preview="stacked"]):has(#unitAnimationPanel:not([hidden])):has(.unit-special-list.has-flags) .unit-terrain-panel { grid-column:1 / 4; grid-row:2; align-self:start; justify-self:end; width:min(310px,65%); height:34px; transform:translateY(-4px); box-sizing:border-box; border:1px solid #397f8d; border-image:none; z-index:2; grid-template-columns:auto minmax(0,1fr); gap:2px; padding:0 3px; }
  #unitEditorPanel[data-auto-pages] #unitStatsForm:not([data-unit-preview="stacked"]):has(#unitAnimationPanel:not([hidden])):has(.unit-special-list.has-flags) .unit-terrain-panel h4 { font-size:10px; gap:2px; }
  #unitEditorPanel[data-auto-pages] #unitStatsForm:not([data-unit-preview="stacked"]):has(#unitAnimationPanel:not([hidden])):has(.unit-special-list.has-flags) .unit-terrain-panel .terrain-grid { gap:2px; }
  #unitEditorPanel[data-auto-pages] #unitStatsForm:not([data-unit-preview="stacked"]):has(#unitAnimationPanel:not([hidden])):has(.unit-special-list.has-flags) .unit-terrain-panel select { min-height:22px; height:22px; font-size:10px; padding:0 12px 0 1px; }
  #unitEditorPanel[data-auto-pages] #unitStatsForm:not([data-unit-preview="stacked"]):has(#unitAnimationPanel:not([hidden])):has(.unit-special-list.has-flags) .unit-terrain-panel .editor-diff-reset { width:14px; min-width:14px; height:20px; min-height:20px; padding:0; font-size:10px; }
  #unitEditorPanel[data-auto-pages] #unitStatsForm:not([data-unit-preview="stacked"]):has(#unitAnimationPanel:not([hidden])):has(.unit-special-list.has-flags) .unit-terrain-panel .editor-help-button { width:10px; min-width:10px; height:10px; line-height:9px; font-size:8px; }
}
@media (min-width: 1100px) and (max-width: 1240px) {
  #unitEditorPanel[data-auto-pages] #unitStatsForm:not([data-unit-preview="stacked"]):has(#unitAnimationPanel:not([hidden])):has(.unit-special-list.has-flags) { grid-template-columns:125px minmax(140px,18%) minmax(0,1fr) minmax(320px,39%) !important; }
  #unitEditorPanel[data-auto-pages] #unitStatsForm:not([data-unit-preview="stacked"]):has(#unitAnimationPanel:not([hidden])) .unit-special-list.has-flags .unit-special-value-field input { width:26px; min-width:26px; }
  #unitEditorPanel[data-auto-pages] #unitStatsForm:not([data-unit-preview="stacked"]):has(#unitAnimationPanel:not([hidden])) .unit-special-list.has-flags .unit-special-value-field .editor-help-button { width:10px; min-width:10px; height:10px; line-height:9px; font-size:8px; }
  #unitEditorPanel[data-auto-pages] #unitStatsForm:not([data-unit-preview="stacked"]):has(#unitAnimationPanel:not([hidden])) .unit-special-list.has-flags .unit-ability-remove { width:16px; font-size:15px; }
  #unitEditorPanel[data-auto-pages] #unitStatsForm:not([data-unit-preview="stacked"]):has(#unitAnimationPanel:not([hidden])) .unit-special-list.has-flags .unit-special-name-field select { padding-left:2px; padding-right:23px; font-size:11px; }
  #unitEditorPanel[data-auto-pages] #unitStatsForm:not([data-unit-preview="stacked"]):has(#unitAnimationPanel:not([hidden])) .unit-special-list.has-flags .unit-special-name-field > .editor-help-button { width:10px; min-width:10px; height:10px; margin-right:12px; font-size:8px; line-height:9px; }
  #unitEditorPanel[data-auto-pages] #unitStatsForm:not([data-unit-preview="stacked"]):has(#unitAnimationPanel:not([hidden])):has(.unit-special-list.has-flags) .unit-core-grid { gap:3px; }
  #unitEditorPanel[data-auto-pages] #unitStatsForm:not([data-unit-preview="stacked"]):has(#unitAnimationPanel:not([hidden])):has(.unit-special-list.has-flags) .unit-core-grid > label { gap:2px; }
  #unitEditorPanel[data-auto-pages] #unitStatsForm:not([data-unit-preview="stacked"]):has(#unitAnimationPanel:not([hidden])):has(.unit-special-list.has-flags) .unit-core-grid .editor-field-name { font-size:10px; }
  #unitEditorPanel[data-auto-pages] #unitStatsForm:not([data-unit-preview="stacked"]):has(#unitAnimationPanel:not([hidden])):has(.unit-special-list.has-flags) .unit-core-grid .editor-help-button { width:10px; min-width:10px; height:10px; font-size:8px; line-height:9px; }
  #unitEditorPanel[data-auto-pages] #unitStatsForm:not([data-unit-preview="stacked"]):has(#unitAnimationPanel:not([hidden])):has(.unit-special-list.has-flags) .unit-core-grid input { --ed-pad:2px; font-size:11px; }
  #unitEditorPanel[data-auto-pages] #unitStatsForm:not([data-unit-preview="stacked"]):has(#unitAnimationPanel:not([hidden])) .unit-terrain-panel { grid-template-columns:minmax(0,1fr); }
}
@media (max-width: 760px) {
  .editor-data-panel[data-auto-pages] .unit-image-panel { min-height: 72px; }
  .editor-data-panel[data-auto-pages] .unit-image-panel canvas { max-height: 72px; }
  .editor-data-panel[data-auto-pages] .unit-flag-grid .editor-diff-reset.is-empty,
  .editor-data-panel[data-auto-pages] .unit-special-name-field .editor-diff-reset.is-empty { display: none; }
  .editor-data-panel[data-auto-pages] .unit-flag-grid select { min-inline-size: 48px; }
  .editor-data-panel[data-auto-pages] .unit-flag-grid .caption-tail { white-space: normal; word-break: break-all; }
  .editor-data-panel[data-auto-pages] .unit-special-list.has-flags { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .editor-data-panel[data-auto-pages] .unit-special-name-field select { font-size: 11px; text-overflow: ellipsis; }
  .editor-data-panel[data-auto-pages] .unit-ability-remove { width: 20px; height: 30px; font-size: 18px; }
  .editor-data-panel[data-auto-pages] .unit-weapon-detail-body { gap: 2px; }
}

/* Numeric fields consume their caption and maximum value, not a stretched cell. */
.editor-data-panel[data-editor-type] .editor-game-screen { --ed-control: 28px; --ed-primary: 14px; --ed-label: 11px; --ed-field: 12px; --ed-pad: 4px; }
.editor-data-panel[data-editor-type] .editor-game-screen .game-panel { padding: 3px 5px; gap: 3px; }
.editor-data-panel[data-editor-type] .editor-game-screen .game-panel h4 { min-height: 18px; margin: 0; gap: 3px 6px; }
.editor-data-panel[data-editor-type] .editor-game-screen :is(.record-tool,.pilot-skill-schedule-button,.panel-toggle) { min-height: 26px; padding: 2px 6px; }
.editor-data-panel .editor-game-screen :is(.unit-vitals-grid,.unit-core-grid,.pilot-combat-grid,.pilot-points-grid,.pilot-growth-grid,.weapon-detail-grid) { display: flex; flex-wrap: wrap; align-content: flex-start; gap: 4px 6px; min-inline-size: 0; }
.editor-data-panel .editor-game-screen :is(.unit-vitals-grid,.unit-core-grid,.pilot-combat-grid,.pilot-points-grid,.pilot-growth-grid,.weapon-detail-grid) > label { display: flex; flex: 0 1 auto; flex-wrap: nowrap; align-items: center; gap: 3px; min-height: 28px; max-inline-size: 100%; inline-size: max-content; }
.editor-data-panel .editor-game-screen :is(.unit-vitals-grid,.unit-core-grid,.pilot-combat-grid,.pilot-points-grid,.pilot-growth-grid,.weapon-detail-grid) > label > .editor-field-name { flex: 0 1 auto; font-size: 11px; }
.editor-data-panel .editor-game-screen :is(.unit-vitals-grid,.unit-core-grid,.pilot-combat-grid,.pilot-points-grid,.pilot-growth-grid,.weapon-detail-grid) > label > input[data-editor-field] { flex: 0 0 auto; inline-size: var(--number-width); min-inline-size: var(--number-width); min-height: 28px; padding: 2px var(--ed-pad); text-align: right; }
.editor-data-panel .editor-game-screen :is(.unit-vitals-grid,.unit-core-grid,.pilot-combat-grid,.pilot-points-grid,.pilot-growth-grid,.weapon-detail-grid) .editor-diff-reset.is-empty { display: none; }
.editor-data-panel .editor-game-screen :is(.unit-vitals-grid,.unit-core-grid,.pilot-combat-grid,.pilot-points-grid,.pilot-growth-grid,.weapon-detail-grid) .editor-diff-reset { flex: 0 0 16px; width: 16px; min-width: 16px; height: 22px; min-height: 22px; }
.editor-data-panel .editor-game-screen :is(.unit-vitals-grid,.unit-core-grid,.pilot-combat-grid,.pilot-points-grid,.pilot-growth-grid,.weapon-detail-grid) .editor-diff-reset::after { inset: -3px; }
.editor-data-panel .unit-secondary-stat > .editor-field-name { color: #c6b5ed; }
.editor-data-panel .unit-secondary-stat > input[data-editor-field]:not(.is-modified):not(:disabled) { color: #ded0ff; border-color: #796499; background-color: #191629; }
.editor-data-panel .editor-game-screen .weapon-detail-grid > label:not(.weapon-critical-field):has(select) { flex: 1 1 280px; inline-size: auto; }
.editor-data-panel .editor-game-screen .weapon-detail-grid > label:not(.weapon-critical-field):has(select) > .editor-field-name { flex: 0 0 auto; }
.editor-data-panel .editor-game-screen .weapon-detail-grid > label:not(.weapon-critical-field) > select { flex: 1 1 0; inline-size: 0; min-height: 28px; }
.editor-data-panel .editor-game-screen label > .editor-field-info { min-height: 28px; }
.editor-data-panel .editor-game-screen .editor-field-name .editor-help-button { width: 14px; min-width: 14px; height: 14px; margin-left: 1px; font-size: 10px; line-height: 12px; }
.editor-data-panel .editor-game-screen :is(.unit-terrain-panel,.pilot-terrain-panel,.weapon-terrain-panel) { display: grid; grid-template-columns: auto minmax(0,1fr); align-items: center; gap: 6px; }
.editor-data-panel .editor-game-screen :is(.unit-terrain-panel,.pilot-terrain-panel,.weapon-terrain-panel) h4 { flex-wrap: nowrap; white-space: nowrap; }
.editor-data-panel .editor-game-screen :is(.unit-terrain-panel,.pilot-terrain-panel,.weapon-terrain-panel) .terrain-legend { display: none; }
.editor-data-panel .editor-game-screen .terrain-grid { grid-template-columns: repeat(4,minmax(0,1fr)); gap: 4px; }
.editor-data-panel .editor-game-screen .terrain-grid label { display: grid; grid-template-columns: auto minmax(0,1fr) auto; grid-template-rows: auto; align-items: center; gap: 2px; }
.editor-data-panel .editor-game-screen .terrain-grid label > .editor-field-name { grid-column: 1; grid-row: 1; }
.editor-data-panel .editor-game-screen .terrain-grid label > select { grid-column: 2; grid-row: 1; inline-size: 100%; min-inline-size: 32px; min-height: 28px; padding-left: 3px; font-size: 12px; }
.editor-data-panel .editor-game-screen .terrain-grid label > .editor-diff-reset { grid-column: 3; grid-row: 1; }
.editor-data-panel .editor-game-screen .terrain-grid .editor-diff-reset.is-empty { display: none; }
.editor-data-panel .pilot-portrait-panel { min-height: 80px; }
.editor-data-panel[data-editor-type] .pilot-portrait-panel canvas { max-height: 80px; }
.editor-data-panel .pilot-mental-grid { gap: 4px; }
.editor-data-panel .pilot-mental-slot { min-height: 36px; padding: 2px 4px; }
.editor-data-panel .pilot-runtime-skills { grid-template-columns: repeat(auto-fit,minmax(min(100%,110px),1fr)); gap: 3px 8px; }
.editor-data-panel .unit-weapon-entry { min-height: 32px; }
.editor-data-panel .weapon-entry-name { font-size: var(--ed-primary); }
.editor-data-panel .unit-weapon-edit { grid-template-columns: minmax(0,1fr) 24px; }
.editor-data-panel .unit-weapon-edit select { min-height: 28px; }
.editor-data-panel .unit-weapon-number-grid { display: grid; grid-template-columns: repeat(auto-fit,minmax(min(100%,145px),1fr)); gap: 5px 8px; min-inline-size: 0; }
.editor-data-panel .unit-weapon-number-grid > label { display: grid; grid-template-columns: minmax(0,1fr) 64px; align-items: center; align-content: start; min-width: 0; gap: 4px; }
.editor-data-panel .unit-weapon-number-grid .unit-weapon-value { width: 100%; }
.editor-data-panel :is(.unit-vitals-grid,.unit-core-grid,.pilot-combat-grid,.pilot-points-grid,.pilot-growth-grid,.weapon-detail-grid,.unit-weapon-number-grid)::-webkit-scrollbar { height: 6px; }
.editor-data-panel :is(.unit-vitals-grid,.unit-core-grid,.pilot-combat-grid,.pilot-points-grid,.pilot-growth-grid,.weapon-detail-grid,.unit-weapon-number-grid)::-webkit-scrollbar-track { background: #06101a; }
.editor-data-panel :is(.unit-vitals-grid,.unit-core-grid,.pilot-combat-grid,.pilot-points-grid,.pilot-growth-grid,.weapon-detail-grid,.unit-weapon-number-grid)::-webkit-scrollbar-thumb { background: #41785a; }
.editor-data-panel .unit-weapon-number-grid input { flex: 1 1 0; inline-size: 100%; min-inline-size: 0; font: 500 14px/1.15 var(--runtime-number-face); }
.editor-data-panel .owner-chip { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 6px; min-height: 30px; padding: 3px 6px; }
.editor-data-panel .owner-chip-name { font-size: var(--ed-primary); }
.editor-data-panel .owner-chip-list { gap: 4px; }
.entity-art { display: inline-flex; flex: 0 0 auto; align-items: center; gap: 3px; vertical-align: middle; }
.entity-art canvas { display: block; flex: 0 0 auto; object-fit: contain; image-rendering: pixelated; }
.entity-art canvas[hidden] { display: none; }
.entity-unit-icon { width: 32px; height: 32px; }
.entity-sortie-slot { display:grid; place-items:center; flex:0 0 auto; width:32px; height:28px; border:1px solid #66c7ff; background:#07273d; color:#cbeaff; font-size:10px; white-space:nowrap; }
.entity-pilot-portrait { width: 24px; height: 26px; }
.entity-art-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.editor-data-panel .owner-chip:has(.entity-art) { display: grid; grid-template-columns: auto minmax(0,1fr); grid-template-rows: auto auto; gap: 0 6px; min-height: 36px; }
.owner-chip > .entity-art { grid-column: 1; grid-row: 1 / 3; }
.owner-chip:has(.entity-art) > .owner-chip-name { grid-column: 2; grid-row: 1; }
.owner-chip:has(.entity-art) > .owner-chip-meta { grid-column: 2; grid-row: 2; }
#rewardUsageList button { display: flex; align-items: center; gap: 6px; }
#rewardUsageList .entity-unit-icon { width: 24px; height: 24px; }
#rewardUsageList .entity-pilot-portrait { width: 22px; height: 24px; }
.scenario-entity-choice, .scenario-edit-group.scenario-entity-choice { display: flex; align-items: center; gap: 6px; min-width: 0; }
.scenario-entity-choice > select, .scenario-edit-group.scenario-entity-choice > select { flex: 1; width: 0; min-width: 0; }
.scenario-entity-choice > span { display: inline-flex; flex: 0 0 auto; }
.scenario-entity-choice > span:empty { display: none; }
.weapon-game-screen:not(:has(.weapon-animation-panel:not([hidden]))) { grid-template-columns: minmax(0,1fr); grid-template-rows: max-content max-content max-content minmax(0,1fr); grid-template-areas: "note" "detail" "terrain" "owners"; }
.weapon-scope-note { padding: 3px 6px; font-size: 11px; }
@media (max-width: 760px) {
  .editor-data-panel[data-editor-type] .editor-game-screen { --ed-primary: 13px; --ed-pad: 2px; }
  /* Keep related unit and weapon fields in readable rows on narrow screens. */
  .editor-data-panel .editor-game-screen .unit-vitals-grid { flex-wrap: nowrap; align-items: center; padding-block: 4px; overflow-x: auto; overflow-y: hidden; overscroll-behavior-x: contain; scrollbar-color: #41785a #06101a; gap: 6px; }
  .editor-data-panel .editor-game-screen .unit-vitals-grid > label { flex: 0 0 auto; max-inline-size: none; white-space: nowrap; }
  .editor-data-panel .editor-game-screen .unit-vitals-grid > label > .editor-field-name { flex: 0 0 auto; white-space: nowrap; }
  .editor-data-panel .editor-game-screen :is(.unit-core-grid,.weapon-detail-grid) { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:4px 6px; overflow:visible; }
  .editor-data-panel .editor-game-screen :is(.unit-core-grid,.weapon-detail-grid) > label:not(.weapon-critical-field) { display:grid; grid-template-columns:minmax(0,1fr) minmax(48px,6ch) auto; align-items:center; gap:2px; inline-size:auto; min-width:0; max-inline-size:none; }
  .editor-data-panel .editor-game-screen :is(.unit-core-grid,.weapon-detail-grid) > label:not(.weapon-critical-field) > .editor-field-name { min-width:0; white-space:normal; overflow-wrap:anywhere; }
  .editor-data-panel .editor-game-screen :is(.unit-core-grid,.weapon-detail-grid) > label:not(.weapon-critical-field) > input[data-editor-field] { inline-size:100%; min-inline-size:0; width:100%; }
  .editor-data-panel .editor-game-screen .weapon-detail-grid > label:has(select) { grid-column:1/-1; grid-template-columns:max-content minmax(0,1fr) auto; }
  .editor-data-panel .editor-game-screen .weapon-detail-grid > label:not(.weapon-critical-field) > select { inline-size:100%; width:100%; min-width:0; }
  .editor-data-panel .editor-game-screen :is(.pilot-combat-grid,.pilot-points-grid,.pilot-growth-grid) { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:4px 6px; overflow:visible; }
  .editor-data-panel .editor-game-screen :is(.pilot-combat-grid,.pilot-points-grid,.pilot-growth-grid) > label { display:grid; grid-template-columns:minmax(0,1fr) auto; grid-template-rows:auto 28px; align-content:start; gap:2px; inline-size:auto; max-inline-size:none; min-width:0; }
  .editor-data-panel .editor-game-screen :is(.pilot-combat-grid,.pilot-points-grid,.pilot-growth-grid) > label > .editor-field-name { grid-column:1/-1; grid-row:1; min-width:0; white-space:normal; }
  .editor-data-panel .editor-game-screen :is(.pilot-combat-grid,.pilot-points-grid,.pilot-growth-grid) > label > input[data-editor-field] { grid-column:1; grid-row:2; inline-size:100%; min-inline-size:0; width:100%; min-height:28px; text-align:center; }
  .editor-data-panel .editor-game-screen :is(.pilot-combat-grid,.pilot-points-grid,.pilot-growth-grid) > label > .editor-diff-reset { grid-column:2; grid-row:2; }

  /* Mobile: player/image at left, six fields in two columns at right. */
  .editor-data-panel[data-auto-pages] .unit-image-panel { min-height:156px; height:156px; align-self:stretch; }
  .editor-data-panel[data-auto-pages] .unit-image-panel canvas { max-height:132px; }
  .editor-data-panel[data-auto-pages] .unit-vitals-panel { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); grid-auto-rows:minmax(0,1fr); min-height:156px; height:156px; gap:3px 4px; }
  .editor-data-panel[data-auto-pages] .unit-vitals-panel :is(.unit-vitals-grid,.unit-flag-grid) { display: contents !important; }
  .editor-data-panel[data-auto-pages] .unit-vitals-panel :is(.unit-vitals-grid,.unit-flag-grid) > label { display:grid; grid-template-columns:minmax(0,1fr) auto; grid-template-rows:14px 26px; align-content:center; align-items:center; gap:2px; inline-size:auto; max-inline-size:100%; min-width:0; min-height:0; white-space:nowrap; }
  .editor-data-panel[data-auto-pages] .unit-vitals-panel label > .editor-field-name { grid-column:1/-1; grid-row:1; white-space:nowrap; font-size:10px; }
  .editor-data-panel[data-auto-pages] .unit-vitals-panel label > :is(input[data-editor-field],select) { grid-column:1; grid-row:2; inline-size:100%; min-inline-size:0; min-height:26px; height:26px; padding:1px 3px; font-size:12px; }
  .editor-data-panel[data-auto-pages] .unit-vitals-panel label > .editor-diff-reset { grid-column:2; grid-row:2; }
  .editor-data-panel[data-auto-pages] .unit-vitals-panel label > .editor-diff-reset.is-empty { display: none; }
  .editor-data-panel[data-auto-pages] .unit-special-list:not(:has(.unit-special-row:not(.is-empty))) { grid-template-columns: repeat(4,minmax(0,1fr)); }
  #unitEditorPanel[data-auto-pages] .unit-info-panel { display:grid; grid-template-columns:48px minmax(0,1fr); align-items:center; gap:4px; align-self:start; }
  #unitEditorPanel[data-auto-pages] .unit-info-panel h4 > span { display:none; }
  #unitEditorPanel[data-auto-pages] #unitFlagToggle { width:48px; min-height:26px; padding:1px; font-size:10px; white-space:nowrap; }
  #unitEditorPanel[data-auto-pages] .unit-special-list { grid-template-columns:repeat(4,minmax(0,1fr)); gap:3px; }
  #unitEditorPanel[data-auto-pages] .unit-special-name-field select { min-height:26px; height:26px; font-size:10px; padding-left:3px; padding-right:25px; }
  #unitEditorPanel[data-auto-pages] .unit-special-name-field > .editor-help-button { width:10px; min-width:10px; height:10px; margin-right:13px; font-size:8px; line-height:9px; }
  #unitEditorPanel[data-auto-pages] .unit-special-row { min-width:0; }
  #unitEditorPanel[data-auto-pages] .unit-terrain-panel { align-self:start; height:max-content; }
  #unitEditorPanel[data-auto-pages] .unit-core-panel { align-self:start; }
  #unitEditorPanel[data-auto-pages] .unit-core-grid { gap:4px 6px; }
  #unitEditorPanel[data-auto-pages] .unit-core-grid > label { grid-template-columns:minmax(0,1fr) auto; grid-template-rows:14px 28px; gap:2px; min-width:0; }
  #unitEditorPanel[data-auto-pages] .unit-core-grid > label > .editor-field-name { grid-column:1/-1; grid-row:1; font-size:10px; }
  #unitEditorPanel[data-auto-pages] .unit-core-grid > label > input[data-editor-field] { grid-column:1; grid-row:2; inline-size:100%; min-inline-size:0; min-height:28px; padding-inline:2px; text-align:center; font-size:12px; }
  #unitEditorPanel[data-auto-pages] .unit-core-grid > label > .editor-diff-reset { grid-column:2; grid-row:2; }
}
@media (max-width:480px) {
  #unitEditorPanel[data-auto-pages] .unit-special-list,
  #unitEditorPanel[data-auto-pages] .unit-special-list:not(:has(.unit-special-row:not(.is-empty))) { grid-template-columns:repeat(2,minmax(0,1fr)); }
}

/* Screenshot manual: scoped to its own dialog, with no changes to editor/session layout. */
.site-header { min-width: 0; }
.site-header .brand { min-width: 0; }
.site-header .brand-copy { min-width: 0; }
.site-header .header-status { flex-shrink: 0; }
.user-guide-open {
  flex: 0 0 auto;
  min-height: 32px;
  padding: 4px 11px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  color: var(--ink);
  background: var(--white);
  font-size: var(--fs-label);
  font-weight: 750;
  white-space: nowrap;
  cursor: pointer;
}
.user-guide-open:hover { border-color: var(--blue); color: var(--blue-deep); }
.user-guide-dialog {
  width: min(1100px, calc(100vw - 32px));
  height: min(860px, calc(100dvh - 32px));
  max-width: none;
  max-height: none;
  margin: auto;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 18px;
  color: var(--ink);
  background: var(--white);
  box-shadow: var(--shadow);
}
.user-guide-dialog::backdrop { background: rgba(16, 31, 47, .58); }
.user-guide-shell {
  display: grid;
  grid-template-rows: auto auto auto auto minmax(0, 1fr) auto auto;
  gap: 10px;
  height: 100%;
  min-height: 0;
  padding: 16px;
}
.user-guide-dialog[data-guide-group="2"] .user-guide-shell { grid-template-rows: auto auto auto auto auto minmax(0, 1fr) auto auto; }
.user-guide-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.user-guide-header h2 { margin: 0; font-size: 20px; line-height: 1.3; }
.user-guide-close,
.user-guide-footer button {
  min-height: 40px;
  padding: 6px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  color: var(--ink);
  background: var(--white);
  font-size: 14px;
  font-weight: 750;
  white-space: nowrap;
  cursor: pointer;
}
.user-guide-route { display: flex; align-items: center; gap: 12px; min-width: 0; font-size: 13px; font-weight: 700; }
.user-guide-route > span { flex: 0 0 auto; white-space: nowrap; }
.user-guide-route select {
  width: 260px;
  min-width: 0;
  min-height: 40px;
  padding: 6px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  color: var(--ink);
  background: var(--white);
  font-size: 14px;
}
.user-guide-steps { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 4px; }
.user-guide-steps button {
  min-width: 0;
  min-height: 40px;
  padding: 6px 4px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: var(--paper);
  color: var(--ink-soft);
  font-size: 14px;
  font-weight: 750;
  white-space: nowrap;
  cursor: pointer;
}
.user-guide-steps button[aria-current] { border-color: var(--blue); color: var(--blue-deep); background: #eef3ff; }
.user-guide-copy h3 { margin: 0 0 4px; font-size: 17px; line-height: 1.3; }
.user-guide-copy p { margin: 0; color: var(--ink-soft); font-size: 14px; line-height: 1.5; word-break: keep-all; overflow-wrap: break-word; }
.user-guide-figure {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  align-items: center;
  gap: 4px;
  min-width: 0;
  min-height: 0;
  margin: 0;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--paper);
}
.user-guide-figure picture { display: block; width: 100%; height: 100%; min-height: 0; }
.user-guide-figure img { display: block; width: 100%; height: 100%; object-fit: contain; }
.user-guide-figure figcaption { text-align: center; color: var(--ink-soft); font-size: 12px; line-height: 1.3; }
.user-guide-figure > p { margin: 0; padding: 12px; font-size: 14px; }
.user-guide-aux {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px 12px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--paper);
}
.user-guide-notice {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex: 1 1 280px;
  min-width: 0;
}
.user-guide-notice-badge {
  flex: 0 0 auto;
  padding: 1px 6px;
  border: 1px solid var(--blue);
  border-radius: 999px;
  color: var(--blue-deep);
  background: #eef3ff;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.3;
}
.user-guide-notice-body {
  margin: 0;
  color: var(--ink-soft);
  font-size: 12.5px;
  line-height: 1.45;
  word-break: keep-all;
  overflow-wrap: anywhere;
}
.user-guide-notice-body strong { color: var(--ink); font-weight: 750; }
.user-guide-tool-button {
  flex: 0 0 auto;
  min-height: 34px;
  padding: 5px 11px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  color: var(--ink);
  background: var(--white);
  font-size: 12px;
  font-weight: 750;
  white-space: nowrap;
  cursor: pointer;
}
.user-guide-tool-button:hover { border-color: var(--blue); color: var(--blue-deep); }
.user-guide-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.user-guide-footer > span { font-size: 13px; font-variant-numeric: tabular-nums; }
.user-guide-footer button:disabled { opacity: .4; cursor: default; }
@media (max-width: 760px) {
  .site-header .brand-copy strong { max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .site-header .compatibility { width: auto; gap: 0; padding-inline: 7px; font-size: 0; }
  .site-header .compatibility > span { font-size: 12px; }
  .site-header .header-status { gap: 6px; }
  .user-guide-open { padding-inline: 9px; }
  .user-guide-dialog { width: calc(100vw - 16px); height: calc(100dvh - 16px); margin: auto; border-radius: 14px; }
  .user-guide-shell { gap: 8px; padding: 10px; padding-bottom: max(10px, env(safe-area-inset-bottom)); }
  .user-guide-header h2 { font-size: 18px; }
  .user-guide-route { gap: 8px; }
  .user-guide-route select { flex: 1; width: 0; }
  .user-guide-steps button { font-size: 12px; min-height: 40px; }
  .user-guide-copy h3 { font-size: 16px; }
  .user-guide-copy p { font-size: 13px; }
  .user-guide-figure { padding: 4px; }
  .user-guide-aux { flex-direction: column; align-items: stretch; gap: 6px; padding: 7px 9px; }
  .user-guide-notice-body { font-size: 12px; }
  .user-guide-tool-button { width: 100%; }
}
@media (max-height: 480px) {
  .user-guide-shell { gap: 4px; padding: 6px 10px; }
  .user-guide-header h2 { font-size: 16px; }
  .user-guide-close, .user-guide-route select, .user-guide-steps button, .user-guide-footer button { min-height: 30px; padding-block: 2px; }
  .user-guide-copy h3 { font-size: 14px; }
  .user-guide-copy p { font-size: 12px; line-height: 1.35; }
  .user-guide-aux { padding: 4px 8px; gap: 4px 8px; }
  .user-guide-notice-body { font-size: 12px; line-height: 1.3; }
  .user-guide-tool-button { min-height: 30px; padding-block: 2px; }
}

/* Effect records use the same direct, vertical selection as units. */
.editor-reward-panel, .editor-terrain-panel {
  display: grid; flex: 0 0 auto; box-sizing: border-box; grid-area: panel; grid-template-columns: minmax(160px,24%) minmax(0,1fr);
  grid-template-rows: auto minmax(0,1fr); align-self: stretch; min-width: 0; min-height: 0; overflow: hidden;
}
.editor-reward-panel[hidden], .editor-terrain-panel[hidden] { display: none; }
.reward-toolbar, .terrain-toolbar { grid-column: 1/-1; grid-row: 1; }
.reward-toolbar { position: relative; display: grid; grid-template-columns: minmax(0,1fr) auto auto auto auto; align-items: center; gap: 6px; padding: 8px; color: #d5ebe7; background: #07192d; border: 1px solid #26778a; }
.reward-toolbar strong, .terrain-toolbar strong { font-size: var(--fs-label); }
.effect-record-rail { grid-column: 1; grid-row: 2; display: flex; flex-direction: column; gap: 6px; min-height: 0; min-width: 0; padding: 8px; border: 1px solid #26778a; border-top: 0; background: #00101d; }
.effect-record-rail > input { flex: 0 0 auto; width: 100%; min-width: 0; height: 34px; box-sizing: border-box; padding: 4px 6px; color: #effcf8; background: #061425; border: 1px solid #3c8193; font: inherit; font-size: 12px; }
.effect-record-list { min-height: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-color: #41785a #06101a; }
.effect-record { display: block; width: 100%; min-width: 0; min-height: 44px; padding: 8px; border: 0; border-bottom: 1px solid #25505a; color: #d5ebe7; background: transparent; text-align: left; font: inherit; font-size: 12px; line-height: 1.4; overflow-wrap: anywhere; cursor: pointer; }
.effect-record[aria-selected="true"] { color: #ffe88f; background: #163e31; box-shadow: inset 3px 0 #54dfa2; }
.effect-record:focus-visible { outline: 2px solid #a3e56b; outline-offset: -2px; }
.effect-record:disabled { cursor: default; opacity: .5; }
.effect-record-list > p { font-size: 12px; color: #b4c6d3; }
.reward-card, .terrain-card { grid-column: 2; grid-row: 2; min-width: 0; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.reward-pair select, .reward-pair input { width: 100%; min-width: 0; height: 40px; box-sizing: border-box; color: #effcf8; background: #061425; border: 1px solid #3c8193; padding: 0 8px; font: inherit; }
.reward-edit-column,.reward-use-column { display:contents; }
.reward-card { display: flex; flex-direction: column; overflow: hidden; padding: 12px; background: #07192d; border: 1px solid #26778a; border-top: 0; color: #d5ebe7; }
#rewardFields { display: grid; gap: 8px; grid-template-columns: repeat(auto-fit,minmax(min(100%,260px),1fr)); }
.reward-pair { display: grid; grid-template-columns: minmax(0,1fr) 92px; gap: 8px; }
.reward-pair label { display: grid; gap: 4px; min-width: 0; font-size: var(--fs-label); font-weight: 700; }
.reward-pair .is-modified { border-color: #f5cd67; color: #ffe39e; }
.reward-pair [aria-invalid="true"] { border-color: #ff8d8d; }
#rewardSummary { margin: 10px 0 4px; font-weight: 700; }
#rewardScope, .reward-timing { margin: 4px 0 0; font-size: var(--fs-help); line-height: 1.45; overflow-wrap: anywhere; }
.reward-usage-row { display: grid; flex: 1 1 0; min-height: 60px; grid-template-rows: minmax(0,1fr) auto; gap: 4px; margin-top: 6px; }
#rewardUsageList { display: grid; grid-auto-rows: 32px; align-content: start; min-height: 0; overflow: hidden; }
#rewardUsageList button { width: 100%; min-width: 0; padding: 3px 6px; border: 0; border-bottom: 1px solid #25505a; background: #061425; color: #effcf8; font: inherit; font-size: 12px; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; }
#rewardUsageList button:hover, #rewardUsageList button:focus-visible { color: #ffe88f; background: #163e31; }
#rewardUsagePager { justify-content: space-between; }
.reward-usage-row[hidden], .reward-usage-short, .reward-pair[hidden], .reward-pager[hidden] { display: none; }
.reward-pager { display: flex; align-items: center; gap: 2px; white-space: nowrap; }
.reward-pager button { height: 32px; width: 28px; padding: 0; border: 1px solid #3c8193; background: #061425; color: #effcf8; font: inherit; }
.reward-pager span { font-size: 12px; }
.reward-details summary { height: 32px; display: grid; align-items: center; box-sizing: border-box; padding: 0 7px; border: 1px solid #3c8193; font-size: 12px; cursor: pointer; white-space: nowrap; }
.reward-explanation { position: absolute; z-index: 20; top: calc(100% + 4px); right: 0; width: min(400px,90vw); max-height: var(--reward-help-max-height,max(80px,calc(100dvh - 220px))); box-sizing: border-box; padding: 10px; border: 1px solid #3c8193; background: #061425; overflow-y: auto; box-shadow: 0 4px 16px #0008; }
@media (max-width: 760px) {
  .editor-reward-panel, .editor-terrain-panel { grid-template-columns: minmax(100px,30%) minmax(0,1fr); }
  .reward-toolbar { padding: 4px; gap: 4px; }
  .effect-record-rail { padding: 4px; gap: 4px; }
  .effect-record { font-size: 11px; padding: 6px 4px; }
  .reward-card { padding: 6px; }
  .reward-pair { grid-template-columns: minmax(0,1fr); gap: 4px; }
}
.editor-reward-panel[data-compact="true"] .reward-toolbar { padding: 4px; gap: 4px; }
.editor-reward-panel[data-compact="true"] .reward-card { padding: 4px; overflow-y: auto; }
.editor-reward-panel[data-compact="true"] .reward-usage-row { min-height: 68px; }
.editor-reward-panel[data-compact="true"] .reward-pair label { font-size: 11px; gap: 2px; }
.editor-reward-panel[data-compact="true"] #rewardSummary { margin: 4px 0 0; font-size: 12px; }
/* A short reward view reserves a single footer row before deciding whether a second pair fits. */
@media (min-width: 761px) {
body[data-view="editor"]:has(.editor-effect-panel[data-compact="true"]:not([hidden])) .editor-footer {
  display: grid; grid-template-columns: 44px minmax(0, 1fr) minmax(0, 1.15fr) minmax(0, 1.2fr);
  grid-template-areas: "status save load export"; gap: 4px;
}
body[data-view="editor"]:has(.editor-effect-panel[data-compact="true"]:not([hidden])) .editor-preset-file-actions { display: contents; }
body[data-view="editor"]:has(.editor-effect-panel[data-compact="true"]:not([hidden])) #editorPresetSaveButton { grid-area: save; }
body[data-view="editor"]:has(.editor-effect-panel[data-compact="true"]:not([hidden])) #editorPresetLoadButton { grid-area: load; }
body[data-view="editor"]:has(.editor-effect-panel[data-compact="true"]:not([hidden])) .editor-footer button { min-height: 40px; height: 40px; padding: 4px; font-size: 11px; white-space: nowrap; }
body[data-view="editor"]:has(.editor-effect-panel[data-compact="true"]:not([hidden])) .editor-changes-button > span { position: absolute; width: 1px; height: 1px; clip-path: inset(50%); overflow: hidden; }
body[data-view="editor"]:has(.editor-effect-panel[data-compact="true"]:not([hidden])) .editor-changes-button::before { content: "변경 " attr(data-change-count); }
body[data-view="editor"]:has(.editor-effect-panel[data-compact="true"]:not([hidden])) .editor-changes-button::after { display: none; }

}

/* Map terrain effects use the same frame and field heights as the existing editor. */
.editor-terrain-panel { min-width: 0; min-height: 0; grid-area: panel; align-self: stretch; }
.editor-terrain-panel[hidden] { display: none; }
.terrain-toolbar { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 8px; padding: 8px; color: #d5ebe7; background: #07192d; border: 1px solid #26778a; }
.terrain-toolbar > label { font-weight: 700; font-size: var(--fs-label); white-space: nowrap; }
.terrain-toolbar select, .terrain-value { width: 100%; min-width: 0; height: 40px; box-sizing: border-box; color: #effcf8; background: #061425; border: 1px solid #3c8193; border-radius: 2px; font: inherit; }
.terrain-toolbar select { padding: 0 8px; }
.terrain-card { padding: 12px; background: #07192d; border: 1px solid #26778a; border-top: 0; color: #d5ebe7; }
#terrainFields { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
#terrainFields > label { display: grid; gap: 4px; min-width: 0; font-size: var(--fs-label); font-weight: 700; white-space: nowrap; }
.terrain-value { display: flex; align-items: center; }
.terrain-value input { width: 100%; min-width: 0; padding: 0 4px 0 8px; border: 0; background: transparent; color: inherit; font: inherit; }
.terrain-value > span { padding-right: 6px; font-size: 12px; }
.terrain-value:has(.is-modified) { border-color: #f5cd67; color: #ffe39e; }
.terrain-value:has([aria-invalid="true"]) { border-color: #ff8d8d; }
#terrainStatus:empty { display: none; }
#terrainStatus { margin: 4px 0 0; font-size: 12px; color: #ff8d8d; }
.terrain-toolbar .reward-explanation p, .scenario-toolbar .reward-explanation p { margin: 4px 0; font-size: var(--fs-help); line-height: 1.45; }
.scenario-explanation-content { display: grid; gap: 8px; }
.scenario-toolbar .scenario-explanation-content p { margin: 0; }
.scenario-explanation-pager { display: flex; align-items: center; gap: 6px; margin-top: 8px; }
.scenario-explanation-pager[hidden], .scenario-explanation-content > [hidden], .scenario-explanation-pager > [hidden] { display: none; }
.scenario-explanation-pager button { min-width: 36px; min-height: 36px; padding: 0 8px; border: 1px solid #3c8193; background: #061425; color: #effcf8; font-size: var(--fs-help); }
.scenario-explanation-pager button:last-child { margin-left: auto; }
.scenario-explanation-pager span { font-size: var(--fs-help); white-space: nowrap; }
@media (max-width: 760px) {
  .terrain-toolbar { grid-template-columns: minmax(0, 1fr) auto auto; gap: 4px 8px; }
  .terrain-toolbar > label { grid-column: 1 / -1; }
  .terrain-card { padding: 8px; }
  #terrainFields { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 8px; }
  #terrainFields > label { font-size: 11px; }
}
.editor-terrain-panel[data-compact="true"] .terrain-toolbar { padding: 4px; gap: 4px; grid-template-columns: minmax(0, 1fr) auto auto; }
.editor-terrain-panel[data-compact="true"] .terrain-toolbar > label { display: none; }
.editor-terrain-panel[data-compact="true"] .terrain-card { padding: 4px; }
.terrain-tile-examples { display: flex; gap: 6px; margin-bottom: 8px; --terrain-icon-size: 32px; }
.terrain-tile-examples[hidden] { display: none; }
.terrain-tile-examples button { display: flex; align-items: center; gap: 5px; min-width: 0; min-height: 40px; padding: 3px; color: #d5ebe7; background: #061425; border: 1px solid #3c8193; font: inherit; font-size: 11px; cursor: pointer; }
.terrain-tile-examples canvas { width: var(--terrain-icon-size); height: var(--terrain-icon-size); image-rendering: pixelated; flex: 0 0 auto; }
.terrain-tile-examples span { white-space: nowrap; }
.editor-terrain-panel[data-compact="true"] .terrain-tile-examples { gap: 4px; margin-bottom: 4px; }
.editor-terrain-panel[data-compact="true"] .terrain-toolbar { padding: 2px; }
.editor-terrain-panel[data-compact="true"] .terrain-toolbar select,
.editor-terrain-panel[data-compact="true"] .terrain-toolbar button,
.editor-terrain-panel[data-compact="true"] .terrain-toolbar summary,
.editor-terrain-panel[data-compact="true"] .terrain-value { height: 28px; min-height: 28px; font-size: 11px; }
.editor-terrain-panel[data-compact="true"] .terrain-card { padding: 2px; }
.editor-terrain-panel[data-compact="true"] #terrainFields > label { gap: 2px; font-size: 10px; line-height: 12px; }
.editor-terrain-panel[data-compact="true"] .terrain-tile-examples { --terrain-icon-size: 16px; }
.editor-terrain-panel[data-compact="true"] .terrain-tile-examples button { min-height: 24px; padding: 1px; }
.editor-terrain-panel[data-compact="true"] .terrain-card:has(#terrainStatus:not(:empty)) .terrain-tile-examples { display: none; }
.editor-terrain-panel[data-compact="true"] #terrainStatus:not(:empty) { min-height: 28px; display: flex; align-items: center; margin-bottom: 4px; }
@media (max-width: 400px) {
  .terrain-tile-examples button { flex: 1; gap: 3px; font-size: 10px; }
  .terrain-tile-examples { --terrain-icon-size: 16px; }
}
@media (min-width: 1100px) and (min-height: 800px) {
  .editor-terrain-panel:not([data-compact="true"]) .terrain-tile-examples { --terrain-icon-size: 64px; }
}

/* A map gets the actual remaining viewport; only a measured short view uses
   map/fields pages. The outer document never needs a tall map or empty rail. */
.editor-scenario-panel { grid-area: panel; min-width: 0; min-height: 0; height: var(--scenario-height, 520px); display: flex; flex-direction: column; color: #d5ebe7; background: #07192d; border: 1px solid #26778a; }
.editor-scenario-panel[hidden] { display: none; }
.scenario-toolbar { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 6px; padding: 6px; border-bottom: 1px solid #26778a; }
#scenarioSelector { width: 100%; min-width: 0; }
.scenario-mode-row { display: grid; grid-template-columns: repeat(6,minmax(0,1fr)); gap: 4px; width: min(500px, 48vw); min-width: 0; }
.scenario-mode-row button { min-width: 0; }
.scenario-mode-short { display:none; }
.scenario-context-row { grid-column: 1 / -1; display: flex; align-items: center; gap: 4px; min-width: 0; }
#scenarioEventSelector { flex: 1 1 0; width: 0; }
#scenarioFactionSelector { flex: 0 0 90px; width: 90px; min-width: 0; }
#scenarioFactionSelector[hidden] { display: none; }
#scenarioRelatedDeploymentButton { flex: 0 0 auto; white-space: nowrap; padding-inline: 7px; }
#scenarioRelatedDeploymentButton[hidden] { display: none; }
.scenario-context-row > details, .scenario-context-row > .scenario-view-pager { flex: 0 0 auto; }
.scenario-map-details[hidden] { display: none; }
.scenario-context-row > details > summary { height: 38px; min-height: 38px; display: grid; align-items: center; box-sizing: border-box; padding: 0 7px; border: 1px solid #3c8193; font-size: 12px; cursor: pointer; white-space: nowrap; }
.scenario-task-hint, .scenario-cell-context { margin: 0; font-size: 12px; line-height: 18px; white-space: nowrap; }
.scenario-task-hint:empty { display: none; }
.scenario-cell-context { text-align: right; }
.scenario-map-options { position: absolute; z-index: 20; top: calc(100% + 4px); right: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; width: min(340px, calc(100vw - 20px)); box-sizing: border-box; padding: 10px; border: 1px solid #3c8193; background: #061425; box-shadow: 0 4px 16px #0008; }
.scenario-map-options > label { display: grid; gap: 3px; font-size: 12px; white-space: nowrap; }
.scenario-map-options select { width: 100%; }
.scenario-map-options p { margin: 0; font-size: 11px; line-height: 1.4; }
#scenarioSelectionDescription { overflow-wrap: anywhere; }
.scenario-toolbar select, .scenario-inspector select, .scenario-position input, .scenario-combat-reward-values input, .scenario-map-caption select { min-width: 0; max-width: 100%; height: 38px; padding: 0 7px; color: #effcf8; background: #061425; border: 1px solid #3c8193; border-radius: 2px; font: inherit; font-size: 13px; box-sizing: border-box; }
.scenario-toolbar button, .scenario-inspector button { min-height: 38px; padding: 4px 8px; color: #d5ebe7; background: #061425; border: 1px solid #3c8193; border-radius: 2px; font: inherit; font-size: 12px; white-space: nowrap; cursor: pointer; }
.scenario-toolbar button[aria-pressed="true"], .scenario-inspector button[aria-pressed="true"] { color: #04120d; background: #a3e56b; border-color: #74dc53; }
.scenario-toolbar button:disabled, .scenario-inspector button:disabled { cursor: default; opacity: .5; }
.scenario-workarea { display: grid; grid-template-columns: minmax(0, 1fr) 300px; flex: 1; min-height: 0; min-width: 0; }
.editor-scenario-panel[data-mode="dialogue"] .scenario-workarea,
.editor-scenario-panel[data-mode="dialogue"] .scenario-cell-context { display: none; }
.scenario-dialogue-panel { display: grid; grid-template-columns: minmax(180px,30%) minmax(0,1fr); flex: 1; min-width: 0; min-height: 0; overflow: hidden; }
.scenario-dialogue-panel[hidden] { display: none; }
.scenario-dialogue-rail { display: flex; flex-direction: column; min-width: 0; min-height: 0; gap: 4px; padding: 6px; border-right: 1px solid #26778a; overflow: hidden; }
.scenario-dialogue-rail > input { min-width: 0; width: 100%; height: 32px; flex: 0 0 auto; box-sizing: border-box; padding: 3px 7px; border: 1px solid #8db4bc; border-radius: 0; background: #fff; color: #092235; font: inherit; font-size: 12px; }
#scenarioDialogueCount { flex: 0 0 auto; font-size: 11px; color: #b6cfcd; }
.scenario-dialogue-list { flex: 1; min-height: 0; overflow: auto; overscroll-behavior: contain; }
.scenario-dialogue-panel button { min-width: 0; padding: 4px 7px; min-height: 30px; border: 1px solid #3c8193; border-radius: 0; background: #061425; color: #d5ebe7; font: inherit; font-size: 12px; cursor: pointer; }
.scenario-dialogue-list button { display: block; width: 100%; padding: 6px; text-align: left; white-space: normal; overflow-wrap: anywhere; line-height: 1.35; border-bottom: 0; }
.scenario-dialogue-list button:last-child { border-bottom: 1px solid #3c8193; }
.scenario-dialogue-list button[aria-selected="true"] { background: #163d2d; border-color: #74dc53; box-shadow: inset 2px 0 #74dc53; }
.scenario-dialogue-panel .is-modified, #scenarioDialogueChanged { color: #ffe39e; }
.scenario-dialogue-editor { display: flex; flex-direction: column; min-height: 0; min-width: 0; gap: 5px; padding: 6px; overflow: hidden; }
.scenario-dialogue-heading { display: flex; gap: 4px; align-items: center; min-width: 0; flex: 0 0 auto; }
.scenario-dialogue-heading strong { flex: 1; min-width: 0; font-size: 12px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
#scenarioDialogueChanged { font-size: 11px; white-space: nowrap; }
.scenario-dialogue-heading button { flex: 0 0 auto; }
.scenario-dialogue-speaker { display:flex; align-items:center; gap:4px; min-width:0; flex:0 0 auto; }
.scenario-dialogue-speaker[hidden],#scenarioDialogueSpeakerArt[hidden],#scenarioDialogueSpeakerStatus[hidden] { display:none; }
.scenario-dialogue-sequence { display:flex; align-items:center; gap:4px; min-width:0; flex:0 0 auto; }
.scenario-dialogue-sequence[hidden],#scenarioDialoguePagesRow[hidden] { display:none; }
.scenario-dialogue-sequence label { flex:0 0 auto; font-size:11px; }
#scenarioDialogueSequence { flex:1; width:0; min-width:0; height:26px; padding:2px 18px 2px 5px; font:inherit; font-size:11px; border:1px solid #3c8193; border-radius:0; background:#061425; color:#d5ebe7; }
.scenario-dialogue-sequence button { min-height:26px; padding:2px 5px; font-size:11px; }
.scenario-dialogue-speaker label,#scenarioDialogueSpeakerVariant { flex:0 0 auto; font-size:11px; white-space:nowrap; }
#scenarioDialogueSpeaker { flex:1; min-width:0; width:0; height:30px; padding:2px 20px 2px 5px; font:inherit; font-size:12px; border:1px solid #3c8193; border-radius:0; background:#061425; color:#d5ebe7; cursor:pointer; }
#scenarioDialogueSpeaker:disabled { opacity:.6; cursor:default; }
#scenarioDialogueSpeakerArt { flex:0 0 28px; display:flex; align-items:center; justify-content:center; width:28px; height:28px; overflow:hidden; }
#scenarioDialogueSpeakerArt .entity-art { display:flex; align-items:center; justify-content:center; }
#scenarioDialogueSpeakerArt :is(canvas,img) { display:block; width:28px; height:28px; object-fit:contain; image-rendering:pixelated; }
#scenarioDialogueSpeakerStatus[data-invalid="true"] { color:#ffb6b6; }
.scenario-dialogue-panel button:disabled { opacity: .5; cursor: default; }
.scenario-dialogue-editor p { margin: 0; font-size: 11px; line-height: 1.4; overflow-wrap: anywhere; }
#scenarioDialogueOwners:empty { display: none; }
#scenarioDialogueText { flex: 1; min-height: 64px; min-width: 0; width: 100%; box-sizing: border-box; resize: none; padding: 8px; color: #effcf8; background: #020b15; border: 1px solid #3c8193; border-radius: 0; font: inherit; font-size: 14px; line-height: 1.7; overflow: auto; overscroll-behavior: contain; }
#scenarioDialogueText.is-modified { border-color: #f5cd67; }
#scenarioDialogueText[aria-invalid="true"] { border-color: #ff8d8d; }
.scenario-dialogue-meta { display: flex; gap: 6px; align-items: baseline; flex: 0 0 auto; min-width: 0; font-size: 11px; line-height: 1.4; }
#scenarioDialogueBytes { flex: 0 0 auto; font-variant-numeric: tabular-nums; color: #b6cfcd; }
#scenarioDialogueTokens { min-width: 0; overflow: auto; white-space: nowrap; }
#scenarioDialogueStatus { flex: 0 0 auto; color: #b6cfcd; }
#scenarioDialogueStatus[data-invalid="true"] { color: #ffb6b6; }
.scenario-map-area { display: flex; flex-direction: column; min-width: 0; min-height: 0; padding: 6px; gap: 4px; }
.scenario-map-caption { display: flex; align-items: center; gap: 6px; min-width: 0; min-height: 28px; font-size: 12px; white-space: nowrap; }
#scenarioMapSummary { flex: 1; min-width: 0; overflow:hidden; text-overflow:ellipsis; }
#scenarioMapLegend { font-size: 11px; }
#scenarioMapLegend:empty { display: none; }
.scenario-map-caption select { min-width: 56px; height: 28px; padding-inline: 3px; }
.scenario-map-viewport { position: relative; display: grid; place-items: start; align-content: start; min-height: 0; min-width: 0; flex: 1; overflow: auto; background: #020b15; overscroll-behavior: contain; }
.scenario-map-viewport[data-zoom="1"] { place-items: center; align-content: center; }
#scenarioMapCanvas { display: block; flex: 0 0 auto; cursor: crosshair; outline-offset: -3px; }
#scenarioCellInfo { min-height: 18px; color: #effcf8; }
.scenario-inspector { display: flex; flex-direction: column; min-width: 0; min-height: 0; padding: 8px; gap: 6px; border-left: 1px solid #26778a; }
.scenario-tools, .scenario-position, .scenario-action-row { display: flex; align-items: center; gap: 6px; min-width: 0; }
.scenario-combat-rewards { display: grid; gap: 4px; border-top: 1px solid #26778a; padding-top: 6px; }
.scenario-combat-rewards strong { flex: 1; font-size: 12px; }
.scenario-combat-reward-values { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 5px; }
.scenario-combat-reward-values label { display: grid; min-width: 0; gap: 2px; font-size: 11px; }
.scenario-combat-reward-values input { width: 100%; font-variant-numeric: tabular-nums; }
.scenario-combat-reward-note { margin: 0; font-size: 11px; line-height: 1.4; color: #aac8c8; overflow-wrap: anywhere; }
.scenario-combat-reward-values input:disabled { opacity: .5; }
.scenario-combat-reward-values input[aria-invalid="true"] { border-color: #ff8e8e; color: #ffb6b6; }
.scenario-tools:has(> .scenario-fields-pager[hidden]):not(:has(> button)) { display: none; }
.scenario-tools > .scenario-fields-pager { margin-left: auto; }
#scenarioDeploymentFields, #scenarioTileFields { display: grid; gap: 6px; min-width: 0; }
#scenarioDeploymentFields[hidden], #scenarioTileFields[hidden] { display: none; }
.scenario-inspector select { width: 100%; }
.scenario-tile-choice { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); gap: 6px; align-items: center; min-width: 0; }
.scenario-tile-sample { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 2px 6px; align-items: center; min-width: 0; }
.scenario-tile-sample > :first-child { grid-column: 1 / -1; font-size: 11px; color: #aac8c8; }
.scenario-tile-sample > span:last-child { min-width: 0; font-size: 12px; white-space: nowrap; }
#scenarioTilePreview, #scenarioCurrentTilePreview { flex: 0 0 auto; width: 38px; height: 38px; image-rendering: pixelated; border: 1px solid #3c8193; box-sizing: border-box; }
.editor-scenario-panel[data-compact="true"] #scenarioTilePreview, .editor-scenario-panel[data-compact="true"] #scenarioCurrentTilePreview { width: 28px; height: 28px; }
#scenarioTilePickerOpen { width: 100%; }
#scenarioTileSelector[hidden] { display: none; }
.scenario-position label { display: flex; align-items: center; gap: 4px; font-size: 12px; }
.scenario-position input { width: 48px; padding-inline: 3px; }
.scenario-position > button { flex: 1; padding-inline: 3px; }
#scenarioConditionRule { flex: 1; min-width: 0; font-size: 12px; white-space: nowrap; }
#scenarioEventFields[hidden], #scenarioEventChoice[hidden] { display: none; }
#scenarioDeploymentFields[data-objective-only="true"] > .scenario-edit-group:not(#scenarioObjectiveFields):not(#scenarioObjectiveDescription):not([data-scenario-criterion-group]) { display: none; }
#scenarioDeploymentFields[data-spawn-only="true"] > .scenario-edit-group:not(#scenarioSpawnChoice):not(#scenarioSpawnPosition):not(#scenarioSpawnNoteGroup) { display: none; }
#scenarioSpawnPilot { min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:12px; }
#scenarioSpawnChoice .scenario-action-row { margin-top:4px; }
#scenarioSpawnChoice button { flex:none; }
.scenario-spawn-search { display:flex; align-items:center; gap:4px; min-width:0; margin-bottom:4px; }
#scenarioSpawnSearch { flex:1; min-width:0; width:0; height:28px; padding:3px 6px; box-sizing:border-box; background:#fff; color:#152630; border:1px solid #3c8193; font-size:12px; }
#scenarioSpawnSearch::placeholder { color:#59666d; opacity:1; }
#scenarioSpawnSearchCount { flex:none; font-size:10px; white-space:nowrap; }
.scenario-spawn-identity { display:flex; align-items:center; gap:5px; min-width:0; }
.scenario-spawn-identity > div { display:grid; gap:4px; flex:1; min-width:0; }
.scenario-spawn-identity label { display:flex; align-items:center; gap:4px; min-width:0; font-size:11px; white-space:nowrap; }
.scenario-spawn-identity select { flex:1; width:0; min-width:0; height:30px; font-size:12px; }
#scenarioSpawnArt { flex:0 0 auto; }
#scenarioSpawnArt .entity-art { display:flex; align-items:center; gap:3px; }
#scenarioSpawnArt :is(canvas,img) { width:28px; height:28px; object-fit:contain; image-rendering:pixelated; }
.scenario-spawn-level { display:flex; align-items:center; gap:4px; margin-right:auto; font-size:12px; }
.scenario-spawn-level input { min-width:0; width:50px; height:30px; padding:0 4px; font:inherit; box-sizing:border-box; color:#effcf8; background:#061425; border:1px solid #3c8193; }
.scenario-spawn-coordinates > span { flex:0 0 48px; font-size:11px; white-space:nowrap; }
.scenario-spawn-coordinates { gap:4px; }
.scenario-spawn-coordinates input { width:41px; height:30px; }
.scenario-spawn-coordinates button { min-height:30px; padding:3px 5px; font-size:11px; }
#scenarioSpawnPosition { gap:4px; }
#scenarioSpawnNote { white-space:normal; overflow-wrap:anywhere; }
#scenarioDeploymentFields[data-event-only="true"] > .scenario-edit-group:not(#scenarioEventFields):not(#scenarioEventChoice):not([data-scenario-event-criterion-group]) { display: none; }
.scenario-reward-label { display: flex; align-items: center; gap: 6px; white-space: nowrap; font-size: 12px; }
.scenario-reward-label select { flex: 1; }
.scenario-action-row { justify-content: space-between; }
.scenario-action-row > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.scenario-action-row button { flex: 0 0 auto; }
#scenarioStatus { margin: 0; min-width: 0; font-size: 12px; line-height: 1.4; }
#scenarioStatus:empty { display: none; }
.scenario-inspector .is-modified { color: #ffe39e; border-color: #f5cd67; }
.scenario-inspector [aria-invalid="true"] { border-color: #ff8d8d; }
.scenario-view-pager { display: flex; gap: 3px; }
.scenario-view-pager[hidden] { display: none; }
@media (max-width: 759px) {
  .scenario-toolbar { grid-template-columns: minmax(0, 1fr) auto; gap: 3px; padding: 3px; }
  #scenarioSelector,.scenario-mode-row { grid-column:1/-1; }
  .scenario-dialogue-panel { grid-template-columns: minmax(0,1fr); grid-template-rows: minmax(72px,28%) minmax(0,1fr); }
  .scenario-dialogue-rail { display: grid; grid-template-columns: minmax(0,1fr) auto; grid-template-rows: 30px minmax(0,1fr); padding: 4px; border-right: 0; border-bottom: 1px solid #26778a; }
  .scenario-dialogue-rail > input { height: 30px; }
  #scenarioDialogueCount { align-self: center; font-size: 10px; white-space: nowrap; }
  .scenario-dialogue-list { grid-column: 1 / -1; }
  .scenario-dialogue-list button { padding: 4px 6px; font-size: 11px; }
  .scenario-dialogue-editor { padding: 4px; gap: 4px; }
  .scenario-dialogue-heading strong { font-size: 11px; }
  .scenario-dialogue-heading button { min-height: 28px; padding: 2px 6px; }
  #scenarioDialogueText { padding: 6px; font-size: 13px; line-height: 1.6; }
  .editor-scenario-panel[data-mode="dialogue"] #scenarioTaskHint { display: none; }
  .scenario-mode-row { width: 100%; grid-template-columns:repeat(6,minmax(0,1fr)); gap:3px; }
  .scenario-mode-long { display:none; }
  .scenario-mode-short { display:inline; }
  .scenario-cell-context { text-align:right; }
  .scenario-toolbar :is(select,button,summary) { height:30px; min-height:30px; padding:2px 3px; font-size:11px; }
  .scenario-context-row > details > summary { height:30px; min-height:30px; padding:2px 4px; font-size:11px; }
  .scenario-context-row { flex-wrap:nowrap; gap:3px; }
  #scenarioEventSelector { flex:1 1 0; width:0; }
  #scenarioFactionSelector { flex-basis:82px; width:82px; }
  .scenario-view-pager { flex:0 0 auto; gap:3px; }
  .scenario-view-pager button { flex:0 0 auto; padding-inline:4px; }
  .scenario-context-row:has(#scenarioEventSelector[hidden]):has(.scenario-view-pager[hidden]) { justify-content: flex-end; }
  .scenario-task-hint,.scenario-cell-context { min-width:0; overflow:hidden; text-overflow:ellipsis; font-size:10px; line-height:14px; }
  .scenario-workarea { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; }
  .scenario-inspector { border-left: 0; border-top: 1px solid #26778a; padding: 6px; }
  .scenario-position input { width: 62px; }
  .scenario-tools button { min-height: 34px; }
  .editor-scenario-panel[data-compact="true"] .scenario-toolbar select,
  .editor-scenario-panel[data-compact="true"] .scenario-toolbar summary,
  .editor-scenario-panel[data-compact="true"] .scenario-toolbar button { height:30px; min-height:30px; font-size:11px; }
  .editor-scenario-panel[data-paged="true"] .scenario-workarea { display: flex; flex-direction: column; }
  .editor-scenario-panel[data-paged="true"][data-page="map"] .scenario-inspector { display: none; }
  .editor-scenario-panel[data-paged="true"][data-page="fields"] .scenario-map-area { display: none; }
  .editor-scenario-panel[data-paged="true"] .scenario-map-area { flex: 1; }
  .editor-scenario-panel[data-paged="true"] .scenario-inspector { border-top: 0; }
  #scenarioMapSummary, #scenarioMapLegend { font-size: 10px; }
  .scenario-map-caption { gap: 4px; }
}
.scenario-tile-picker { width: min(640px, calc(100vw - 16px)); max-width: none; max-height: calc(100dvh - 16px); box-sizing: border-box; margin: auto; padding: 10px; color: #d5ebe7; background: #07192d; border: 1px solid #3c8193; border-radius: 4px; box-shadow: 0 8px 28px #0009; }
.scenario-tile-picker[open] { display: flex; flex-direction: column; gap: 8px; }
.scenario-tile-picker::backdrop { background: #020b15ba; }
.scenario-palette-heading, .scenario-palette-controls { display: flex; align-items: center; gap: 6px; min-width: 0; }
.scenario-palette-heading h2, .scenario-palette-heading h3, .scenario-palette-heading > strong { flex: 1; min-width: 0; margin: 0; font-size: 15px; line-height: 1.3; }
.scenario-tile-picker button, .scenario-tile-picker select { min-width: 0; min-height: 34px; padding: 4px 6px; color: #effcf8; background: #061425; border: 1px solid #3c8193; border-radius: 2px; box-sizing: border-box; font: inherit; font-size: 12px; white-space: nowrap; }
.scenario-tile-picker button { cursor: pointer; }
.scenario-tile-picker button:disabled { cursor: default; opacity: .45; }
.scenario-tile-picker :is(button, select):focus-visible { outline: 2px solid #d3ff8c; outline-offset: 2px; }
.scenario-palette-controls select { flex: 1; width: 0; }
.scenario-palette-controls > span { font-size: 12px; white-space: nowrap; }
.scenario-palette-controls button { flex: 0 0 34px; width: 34px; }
.scenario-palette-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; flex: 0 0 auto; min-width: 0; min-height: 0; }
.scenario-palette-grid button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-width: 0; min-height: 62px; padding: 4px 2px; }
.scenario-palette-grid canvas { width: 36px; height: 36px; image-rendering: pixelated; }
.scenario-palette-grid span { font-size: 11px; line-height: 14px; }
.scenario-palette-grid button[aria-pressed="true"] { color: #04120d; border-color: #a3e56b; background: #a3e56b; }
.scenario-palette-note { margin: 0; font-size: 11px; line-height: 1.4; }
@media (max-width: 759px) {
  .scenario-tile-picker { padding: 8px; }
  .scenario-palette-grid { gap: 4px; }
  .scenario-palette-grid button { min-height: 56px; }
  .scenario-palette-grid canvas { width: 32px; height: 32px; }
}

.scenario-edit-group { display: grid; gap: 6px; min-width: 0; }
.scenario-edit-group[hidden] { display: none; }
.scenario-fields-pager { display: flex; align-items: center; gap: 3px; font-size: 11px; white-space: nowrap; }
.scenario-fields-pager[hidden] { display: none; }
.scenario-fields-pager button { min-width: 20px; padding-inline: 3px; }
.editor-scenario-panel[data-compact="true"] .scenario-inspector { gap: 4px; padding: 4px; }
.editor-scenario-panel[data-compact="true"] #scenarioStatus:not(:empty) { order: -1; min-height: 28px; display: flex; align-items: center; }
.editor-scenario-panel[data-compact="true"] .scenario-inspector button, .editor-scenario-panel[data-compact="true"] .scenario-inspector input, .editor-scenario-panel[data-compact="true"] .scenario-inspector select { min-height: 28px; height: 28px; font-size: 11px; }
.editor-scenario-panel[data-compact="true"] .scenario-edit-group, .editor-scenario-panel[data-compact="true"] #scenarioDeploymentFields, .editor-scenario-panel[data-compact="true"] #scenarioTileFields { gap: 4px; }
.editor-preset-file-button .preset-short { display: none; }
@media (max-width: 360px) {
  body[data-view="editor"]:has(.editor-effect-panel[data-compact="true"]:not([hidden])) .editor-preset-file-button .preset-long { display: none; }
  body[data-view="editor"]:has(.editor-effect-panel[data-compact="true"]:not([hidden])) .editor-preset-file-button .preset-short { display: inline; }
}

/* Purpose controls and their consequence text fit together when there is room;
   measured groups remain reachable in shorter inspector pages. */
.scenario-criteria-heading, .scenario-criterion-row { display: flex; align-items: center; gap: 4px; min-width: 0; white-space: nowrap; }
.scenario-criteria-heading label, .scenario-criterion-row > span { flex: 0 0 auto; font-size: 12px; }
.scenario-criteria-heading select { flex: 1; width: 0; padding-inline: 3px; }
.scenario-criteria-heading button { flex: 0 0 auto; padding-inline: 5px; }
#scenarioEventPhaseHint { flex: 0 0 auto; font-size: 11px; }
.scenario-criterion-row select { flex: 1; width: 0; padding-inline: 2px; font-size: 12px; }
.scenario-criterion-row select:first-of-type { flex: 1.4; }
.scenario-criterion-row input { flex: 0 0 39px; width: 39px; min-width: 0; height: 38px; padding: 0 2px; color: #effcf8; background: #061425; border: 1px solid #3c8193; border-radius: 2px; font: inherit; font-size: 12px; box-sizing: border-box; }
.scenario-criterion-row button { flex: 0 0 24px; width: 24px; padding: 0; font-size: 18px; }
#scenarioDeploymentFields[data-event-exact-turn-only="true"] #scenarioEventCriteriaReset { flex: 0 0 auto; width: auto; padding-inline: 5px; font-size: 12px; }
.scenario-criterion-row input[hidden], .scenario-criterion-unit-row[hidden] { display: none; }
.scenario-criterion-unit-row { display: flex; align-items: center; gap: 4px; min-width: 0; }
.scenario-criterion-unit-row select { flex: 1; width: 0; min-width: 0; font-size: 12px; }
.scenario-criterion-unit-row button { flex: 0 0 24px; width: 24px; padding: 0; }
.scenario-criterion-region { display: grid; gap: 4px; min-width: 0; }
.scenario-criterion-region[hidden], .scenario-region-end[hidden] { display: none; }
.scenario-region-tools, .scenario-region-coordinates { display: flex; align-items: center; gap: 4px; min-width: 0; white-space: nowrap; }
.scenario-region-tools select { flex: 1; width: 0; min-width: 0; padding-inline: 2px; font-size: 12px; }
.scenario-region-tools .scenario-region-side { flex: 1.5; }
.scenario-region-tools button { flex: 0 0 auto; padding-inline: 5px; }
.scenario-region-tools .scenario-region-info { flex-basis: 24px; width: 24px; padding: 0; }
.scenario-region-coordinates { justify-content: space-between; }
.scenario-region-coordinates label { display: flex; align-items: center; gap: 2px; font-size: 11px; }
.scenario-region-coordinates input { width: 39px; min-width: 0; height: 38px; padding: 0 2px; color: #effcf8; background: #061425; border: 1px solid #3c8193; border-radius: 2px; font: inherit; box-sizing: border-box; }
.scenario-region-coordinates > span { font-size: 11px; }
.scenario-objective-copy{display:grid;grid-template-columns:auto minmax(0,1fr);gap:2px 8px;margin:0;font-size:12px;line-height:1.4}
.scenario-objective-copy dt{font-weight:700;color:var(--muted)}
.scenario-objective-copy dd{margin:0;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.scenario-objective-note{margin:0;font-size:11px;line-height:1.4;white-space:nowrap}
#scenarioDeadlineRule{min-width:0;font-size:12px;white-space:nowrap}

/* Acknowledgement is shared by ROM/save editors; it never changes their layout. */
.editor-notice {
  box-sizing: border-box; width: min(420px, calc(100vw - 32px)); margin: auto;
  max-height: calc(100dvh - 32px); padding: 22px; border: 1px solid #278a9d;
  background: #03131d; color: #e0e9e9; box-shadow: 0 12px 48px #0009;
  font: inherit; line-height: 1.6;
}
.editor-notice::backdrop { background: #000a; }
.editor-notice h2 { margin: 0 0 10px; color: #f1db74; font-size: 18px; }
.editor-notice p { margin: 0 0 18px; font-size: 14px; }
.editor-notice label { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.editor-notice input { width: 18px; height: 18px; accent-color: #42d1b0; }
.editor-notice-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }
.editor-notice button { min-width: 72px; min-height: 40px; border: 1px solid #278a9d; background: #061e2b; color: inherit; font: inherit; cursor: pointer; }
.editor-notice button.is-primary { border-color: #e5d471; background: #174135; color: #f1db74; }
.editor-notice :focus-visible { outline: 2px solid #f1db74; outline-offset: 3px; }

.editor-cost-dialog {
  box-sizing: border-box; width: min(480px, calc(100vw - 24px)); margin: auto;
  max-height: calc(100dvh - 24px); padding: 18px; border: 1px solid #278a9d;
  background: #03131d; color: #d9e6e7; font: inherit; line-height: 1.4;
}
.editor-cost-dialog::backdrop { background: #000a; }
.editor-cost-dialog h2 { margin: 0 0 12px; color: #f1db74; font-size: 18px; }
.editor-cost-dialog select { width: 100%; min-height: 36px; }
.editor-cost-dialog :is(select,input,button) { box-sizing: border-box; border: 1px solid #278a9d; background: #061e2b; color: inherit; font: inherit; }
.editor-cost-scope { margin: 7px 0 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; color: #f1db74; }
.editor-cost-scope:empty { display: none; }
.editor-cost-note { margin: 10px 0; font-size: 12px; color: #a5b7b5; }
.editor-cost-fields { display: grid; gap: 8px; min-height: calc(var(--cost-page-rows, 5) * 46px - 8px); align-content: start; }
.editor-cost-fields label { display: grid; grid-template-columns: minmax(0,1fr) minmax(95px,1fr) 48px; align-items: center; gap: 8px; font-size: 13px; }
.editor-cost-fields input { width: 100%; min-width: 0; height: 38px; padding: 5px 8px; }
.editor-cost-fields button { height: 38px; cursor: pointer; }
.editor-cost-fields input.is-modified { color: #f1db74; border-color: #d7ba53; }
.editor-cost-fields input[aria-invalid=true] { border-color: #ff8b7d; }
.editor-cost-status { min-height: 18px; margin: 8px 0; font-size: 12px; color: #f1b685; }
.editor-cost-actions { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.editor-cost-actions button { min-height: 36px; padding: 4px 10px; cursor: pointer; }
.editor-cost-dialog :focus-visible { outline: 2px solid #f1db74; outline-offset: 2px; }
@media (max-height: 560px) {
  .editor-cost-dialog { padding: 12px; }
  .editor-cost-dialog h2 { margin-bottom: 6px; }
  .editor-cost-fields { gap: 4px; min-height: calc(var(--cost-page-rows, 5) * 37px - 4px); }
  .editor-cost-fields :is(input,button) { height: 33px; }
  .editor-cost-scope { margin: 7px 0 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; color: #f1db74; }
.editor-cost-scope:empty { display: none; }
.editor-cost-note { margin: 7px 0; }
}

/* Loading feedback on the gray Saturn setup cards needs dark, explicit ink. */
body[data-view="setup"] :is(.editor-progress,.progress-panel){color:#29323c;background:#e7eae3;border-color:#9ca69e}
body[data-view="setup"] :is(.editor-progress-topline,.progress-copy) :is(strong,span){color:#29323c}
body[data-view="setup"] :is(.editor-progress-actions span,.progress-panel p){color:#505e58}
body[data-view="setup"] :is(#editorProgressPercent,#progressPercent){color:#3156ae}
body[data-view="setup"] :is(.editor-cancel-button,.progress-panel .cancel-button){color:#29323c;background:#d7ddd4;border-color:#9ca69e}
/* Error feedback inside the dark folder card sits on #fff1f0 and must not inherit dark-card light ink. */
body[data-view="setup"] #editorSourceRegion .message-panel.is-error{--ink:#29323c;--ink-soft:#59636d;color:#29323c;border-color:rgba(200,62,67,0.42)}
body[data-view="setup"] #editorSourceRegion .message-panel.is-error strong{color:#29323c}
body[data-view="setup"] #editorSourceRegion .message-panel.is-error p{color:#59636d}

/* User-entered names keep the numeric rows compact. */
.weapon-name-field { display:grid; grid-template-columns:max-content minmax(80px,1fr) max-content 24px; align-items:center; gap:4px; margin:2px 0; min-width:0; }
.weapon-name-field input { width:100%; min-width:0; height:26px; padding:2px 5px; }
.weapon-name-field small { font-size:10px; color:#a9c3c8; }
.unit-weapon-detail .weapon-name-field small { white-space: nowrap; }
.weapon-name-field button { min-height:24px; padding:0; }
.weapon-name-field.is-storage-blocked { grid-template-columns:max-content minmax(80px,1fr) max-content max-content; }
.weapon-name-field .weapon-name-base-reset { min-width:40px; padding:0 4px; }
.weapon-name-field .weapon-name-error { grid-column:2/-1; color:#ffb5a5; }
.unit-weapon-name-heading .weapon-name-field { grid-template-columns:minmax(0,1fr) max-content max-content; margin:0; gap:3px; }
.unit-weapon-name-heading .weapon-name-field > span,
.unit-weapon-name-heading .weapon-name-field > small:not(.weapon-name-error) { display:none; }
.unit-weapon-name-heading .weapon-name-field input { height:26px; color:#fff19b; font-weight:600; text-align:left; }
.unit-weapon-name-heading .weapon-name-field .weapon-name-error { grid-column:1/-1; white-space:normal; }
.unit-weapon-name-heading .weapon-name-error:empty { display:none; }
.weapon-name-error:empty { display:none; }
.save-name-panel { display:flex; flex-direction:column; gap:10px; align-self:start; }
.save-name-panel label { display:grid; grid-template-columns:92px minmax(70px,1fr) max-content; gap:6px; align-items:center; }
.save-name-panel input { min-width:0; width:100%;min-height:36px;padding:5px 8px;font-size:16px; }
.save-name-panel label>span { overflow-wrap:anywhere; }
.save-name-panel label[hidden] { display:none; }
.save-name-panel small { font-size:10px; }
.save-name-panel .save-field-message { grid-column:2/-1; color:#ffb5a5; }
@media (min-width:901px) {
 .save-name-panel { display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:14px 20px; }
 .save-name-panel .save-help { grid-column:1/-1; }
}
.weapon-timeline-panel { grid-area:timeline; min-height:0; min-width:0; padding:4px; overflow:hidden; }
.weapon-timeline-panel[hidden] { display:none!important; }
.editor-misc-panel { grid-area:panel; display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); align-content:start; align-items:stretch; gap:6px; flex:1; min-width:0; min-height:0; overflow:auto; padding:4px; }
body[data-view="editor"]:has(#miscEditorPanel:not([hidden])) { height:100dvh; min-height:0; overflow:hidden; }
.editor-workspace > .editor-misc-panel { flex:1 1 0; }
.editor-misc-panel > .srw4-source-panel { grid-column:1/-1; }
.editor-misc-panel > #fCampaignSourcePanel { grid-column:1/-1; grid-template-columns:minmax(0,1fr) auto; gap:3px 6px; }
#fCampaignSourcePanel > h3 { align-self:center; }
#fCampaignSourcePanel > p,#fCampaignSourcePanel > progress { grid-column:1/-1; }
@media (min-width:761px) {
 .editor-misc-panel > #fCampaignSourcePanel { grid-column:auto; }
 .editor-misc-panel:has(> #fCampaignSourcePanel:not([hidden])) > .srw4-source-panel { grid-column:span 2; }
}
.editor-misc-panel > .collection-unlock-panel { max-width:none; }
@media (max-width:760px) { .editor-misc-panel { grid-template-columns:minmax(0,1fr); } }
.editor-misc-panel[hidden] { display:none; }
.editor-tab[hidden],.collection-unlock-panel[hidden] { display:none!important; }
.collection-unlock-panel { display:grid; gap:5px; align-content:start; max-width:760px; margin:0; padding:8px; }
.collection-unlock-panel h3,.collection-unlock-panel p { margin:0; }
.collection-unlock-panel p { color:#aec3cb; line-height:1.35; font-size:11px; }
.collection-unlock-choice { display:flex; align-items:center; gap:8px; line-height:1.5; }
.collection-unlock-panel button { justify-self:start; }
.critical-fix-heading { display:flex; flex-wrap:wrap; align-items:center; gap:8px; }
.critical-fix-heading h3 { margin-right:auto; }
.critical-fix-heading output { border:1px solid #52707a; border-radius:4px; padding:2px 8px; color:#b9cbd0; font-size:12px; line-height:1.4; }
.critical-fix-heading output.is-enabled { border-color:#7cb09e; color:#b9efd3; }
.critical-fix-panel [hidden] { display:none; }

/* Both weapon editors show the game modifier beside the applied modifier.
   This compact selector owns its layout separately from long skill selects. */
.critical-applied-value { color:#a8d8cc; font-size:11px; line-height:1.2; white-space:nowrap; }
.critical-applied-value.is-different { color:#f2d777; }
.editor-data-panel #weaponStatsForm .weapon-detail-grid > .weapon-critical-field { display:flex; grid-column:1/-1; flex:0 0 auto; flex-wrap:nowrap; align-items:center; gap:5px; inline-size:auto; min-inline-size:0; min-height:28px; max-inline-size:100%; }
.editor-data-panel #weaponStatsForm .weapon-critical-field > .editor-field-name { flex:0 0 auto; order:1; white-space:nowrap; font-size:12px; line-height:1.2; }
.editor-data-panel #weaponStatsForm .weapon-critical-field > select[data-editor-field] { flex:0 0 76px; order:2; inline-size:76px; min-inline-size:76px; width:76px; min-height:28px; padding:2px 4px; }
.editor-data-panel #weaponStatsForm .weapon-critical-field > .critical-applied-value { flex:0 0 auto; order:3; }
.editor-data-panel #weaponStatsForm .weapon-critical-field > .editor-diff-reset { flex:0 0 18px; order:4; }
.editor-data-panel .unit-weapon-number-grid > .unit-weapon-critical-field { white-space: normal; }
.editor-data-panel .unit-weapon-number-grid > .unit-weapon-critical-field .unit-weapon-value select { inline-size:100%; min-inline-size:0; width:100%; padding-inline:4px; }
.editor-data-panel .unit-weapon-number-grid > .unit-weapon-critical-field .critical-applied-value { grid-column: 1 / -1; }
@media (max-width:760px) {
 .editor-data-panel #weaponStatsForm .weapon-critical-field > .editor-field-name { font-size:11px; }
}


.battle-timeline-heading,.battle-timeline-footer { display:flex; gap:6px; align-items:center; min-width:0; }
.battle-timeline-heading strong { font-size:12px; margin-right:auto; }
.battle-timeline-heading small { color:#f2d777; white-space:nowrap; font-size:10px; }
.battle-timeline-heading button,.battle-timeline-footer button,.battle-timeline-footer select { font-size:10px; padding:1px 5px; min-height:23px; }
.battle-timeline-note { font-size:10px; line-height:13px; color:#acc0c7; margin:3px 0; }
.battle-timeline-scroll { max-height:154px; overflow:auto; scrollbar-width:thin; border-block:1px solid #235665; }
.battle-timeline-chart { min-width:100%; }
.battle-timeline-lane { display:grid; grid-template-columns:90px minmax(0,1fr); height:23px; border-bottom:1px solid #16313b; }
.battle-timeline-label { position:sticky; left:0; z-index:5; display:flex; flex-direction:column; align-items:flex-start; justify-content:center; background:#071820; font-size:10px; line-height:1.3; padding:0 4px; border-right:1px solid #397081; white-space:nowrap; }
.battle-timeline-rail { position:relative; min-width:0; overflow:hidden; background-image:linear-gradient(90deg,#23404b 1px,transparent 1px); background-size:var(--timeline-grid-step,80px) 100%; }
.battle-timeline-rail > small { padding-left:5px; font-size:10px; color:#648087; }
.battle-timeline-event { position:absolute; top:50%; height:10px; transform:translateY(-50%); min-height:0!important; min-width:2px!important; border:0!important; padding:0!important; background:var(--track-color)!important; opacity:.85; border-radius:1px; transition:none; }
.battle-timeline-event.is-keyframe { height:8px; transform:translate(-50%,-50%) rotate(45deg); border:1px solid var(--track-color)!important; box-shadow:0 0 0 1px #071820; }
.battle-timeline-event.is-keyframe::after { content:""; position:absolute; inset:-4px; }
.battle-timeline-event.is-span { overflow:hidden; padding:0 4px!important; color:#e7efeb; background:color-mix(in srgb,var(--track-color) 30%,#05131b)!important; box-shadow:inset 2px 0 var(--track-color); border-bottom:1px solid var(--track-color)!important; font:9px/10px system-ui,sans-serif; white-space:nowrap; text-align:left; }
.battle-timeline-event.is-state[data-open="true"] { border-right:1px dashed var(--track-color)!important; }
.battle-timeline-lane[data-sides="true"] { --timeline-lane-min:34px; height:34px; }
.battle-timeline-lane[data-sides="true"] .battle-timeline-rail { background-image:linear-gradient(0deg,transparent calc(50% - .5px),#23404b calc(50% - .5px),#23404b calc(50% + .5px),transparent calc(50% + .5px)),linear-gradient(90deg,#23404b 1px,transparent 1px); background-size:100% 100%,var(--timeline-grid-step,80px) 100%; }
.battle-timeline-lane[data-sides="true"] .battle-timeline-event[data-side="0"] { top:27%; }
.battle-timeline-lane[data-sides="true"] .battle-timeline-event[data-side="1"] { top:73%; }
.battle-timeline-side-caption { font-size:9px; color:#7c9da6; line-height:12px; }
.battle-timeline-event:hover,.battle-timeline-event:focus-visible { opacity:1; outline:1px solid white; z-index:3; }
.battle-timeline-playhead { position:absolute; left:0; transform:translateX(var(--timeline-playhead,0px)); top:0; bottom:0; width:1px; background:#fff; z-index:4; pointer-events:none; }
.battle-timeline-footer input { flex:1; min-width:30px; height:21px; padding:0; }
.battle-timeline-footer output { width:55px; font-size:10px; white-space:nowrap; }
.battle-timeline-inspect { display:flex; align-items:center; gap:6px; min-width:0; margin-top:3px; }
.battle-timeline-inspect canvas { flex:0 0 64px; width:64px; height:45px; object-fit:contain; image-rendering:pixelated; }
.battle-timeline-inspect output { font-size:10px; line-height:13px; max-height:40px; overflow:auto; }
/* Desktop weapon workspace: one screen, with space reclaimed when preview is OFF.
   The measured packer remains responsible for phones and narrow windows. */
@media (min-width:900px) {
 body[data-view="editor"] .patch-section { padding-inline:12px; }
 body[data-view="editor"] .editor-workspace { position:relative; }
 body[data-view="editor"] .editor-footer { grid-template-columns:minmax(160px,1fr) auto minmax(150px,210px); grid-template-areas:"status presets export"; }
 body[data-view="editor"] .editor-footer > .editor-primary-button { min-height:44px; padding-block:6px; }
 body[data-view="editor"] #editorDownloadActions { grid-column:1/-1; grid-row:2; }
 #weaponEditorPanel[data-weapon-desktop] .editor-page-switch { display:none; }
 #weaponEditorPanel[data-weapon-desktop] .editor-panel-body { flex-direction:row; }
 #weaponEditorPanel[data-weapon-desktop] .record-pane.is-weapons { display:flex; --pane-width:clamp(216px,18vw,272px); }
 #weaponEditorPanel[data-weapon-desktop] .record-option { grid-template-columns:repeat(3,minmax(0,1fr));grid-template-areas:"name name name" "attack range hit" "meta meta meta";gap:3px 6px; }
 #weaponEditorPanel[data-weapon-desktop] .record-option-name { font-size:16px;line-height:1.25; }
 #weaponEditorPanel[data-weapon-desktop] .record-option-stat { font-size:13px;line-height:1.2; }
 #weaponEditorPanel[data-weapon-desktop] .record-option-meta { font-size:11px;line-height:1.3; }
 #weaponEditorPanel[data-weapon-desktop] .game-screen-shell { display:flex; }
 #weaponEditorPanel[data-weapon-desktop] #weaponStatsForm {
  grid-template-columns:minmax(280px,1.3fr) minmax(260px,.9fr);
  grid-template-rows:max-content minmax(0,1fr) max-content;
  grid-template-areas:"note note" "detail dialogue" "terrain owners";
  align-content:stretch; gap:8px; overflow:hidden; padding:8px;
 }
 /* The player is a landscape strip above a timeline spanning both columns. */
 #weaponEditorPanel[data-weapon-desktop] #weaponStatsForm:has(.weapon-animation-panel:not([hidden])) {
  grid-template-columns:minmax(280px,.78fr) minmax(0,1.55fr);
  grid-template-rows:max-content minmax(250px,1.1fr) minmax(48px,.18fr) minmax(180px,1fr);
  grid-template-areas:"note note" "detail preview" "terrain owners" "timeline timeline";
 }
 #weaponEditorPanel[data-weapon-desktop] #weaponStatsForm[data-desktop-size="wide"]:has(.weapon-animation-panel:not([hidden])) {
  grid-template-columns:minmax(360px,.78fr) minmax(0,1.55fr);
 }
 #weaponEditorPanel[data-weapon-desktop] #weaponStatsForm[data-map-preview="true"]:has(.weapon-animation-panel:not([hidden])) {
  grid-template-rows:max-content minmax(0,1fr) max-content;
  grid-template-areas:"note note" "detail preview" "terrain owners";
 }
 #weaponEditorPanel[data-weapon-desktop] #weaponStatsForm > [data-editor-section]:not([hidden]) { display:flex; min-width:0; min-height:0; }
 #weaponEditorPanel[data-weapon-desktop] #weaponStatsForm > .weapon-scope-note { margin:0; padding:2px 0; font-size:11px; }
 #weaponEditorPanel[data-weapon-desktop] #weaponStatsForm > .weapon-timeline-panel[data-editor-section] { display:grid; }
 #weaponEditorPanel[data-weapon-desktop] #weaponStatsForm > .weapon-detail-panel { padding:9px; gap:7px; overflow:auto; container-type:inline-size; container-name:weapon-fields; }
 #weaponEditorPanel[data-weapon-desktop] .weapon-dialogue-panel { grid-area:dialogue; min-height:0; padding:9px; overflow:auto; align-self:start; max-height:100%; }
 #weaponEditorPanel[data-weapon-desktop] .weapon-dialogue-panel .weapon-dialogue-lines { max-height:none; }
 #weaponEditorPanel[data-weapon-desktop] #weaponStatsForm > .weapon-terrain-panel[data-editor-section] { display:grid; grid-template-columns:max-content minmax(0,1fr); align-items:center; gap:8px; padding:8px; }
 #weaponEditorPanel[data-weapon-desktop] .weapon-terrain-panel h4 { margin:0; font-size:12px; white-space:nowrap; }
 #weaponEditorPanel[data-weapon-desktop] .weapon-terrain-panel .terrain-grid { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:5px; }
 #weaponEditorPanel[data-weapon-desktop] .weapon-terrain-panel .terrain-grid > label { display:flex; align-items:center; gap:4px; font-size:12px; }
 #weaponEditorPanel[data-weapon-desktop] .weapon-terrain-panel select { width:100%; min-width:0; min-height:28px; }
 #weaponEditorPanel[data-weapon-desktop] .weapon-detail-grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:8px; }
 #weaponEditorPanel[data-weapon-desktop] .weapon-detail-grid > label:not(.weapon-critical-field) { display:grid; grid-template-columns:minmax(0,1fr) auto; grid-template-rows:auto 32px; align-items:center; align-content:start; gap:3px; inline-size:auto; min-width:0; max-inline-size:none; }
 #weaponEditorPanel[data-weapon-desktop] .weapon-detail-grid > label:not(.weapon-critical-field) > .editor-field-name { grid-column:1/-1; grid-row:1; white-space:normal; line-height:16px; font-size:12px; }
 #weaponEditorPanel[data-weapon-desktop] .weapon-detail-grid > label:not(.weapon-critical-field) > input[data-editor-field] { grid-column:1; grid-row:2; inline-size:100%; min-inline-size:0; width:100%; height:32px; text-align:center; }
 #weaponEditorPanel[data-weapon-desktop] .weapon-detail-grid > label:not(.weapon-critical-field) > .editor-diff-reset { grid-column:2; grid-row:2; }
 #weaponEditorPanel[data-weapon-desktop] .weapon-detail-grid > label:not(.weapon-critical-field):has(select) { grid-column:1/-1; grid-template-columns:max-content minmax(0,1fr) auto; grid-template-rows:32px; gap:7px; inline-size:auto; }
 #weaponEditorPanel[data-weapon-desktop] .weapon-detail-grid > label:not(.weapon-critical-field):has(select) > .editor-field-name { grid-column:1; grid-row:1; }
 #weaponEditorPanel[data-weapon-desktop] .weapon-detail-grid > label:not(.weapon-critical-field) > select { grid-column:2; grid-row:1; inline-size:100%; min-width:0; width:100%; min-height:32px; }
 #weaponEditorPanel[data-weapon-desktop] .weapon-detail-grid > label:not(.weapon-critical-field):has(select) > .editor-diff-reset { grid-column:3; grid-row:1; }
 #weaponEditorPanel[data-weapon-desktop] #weaponStatsForm .weapon-detail-grid > .weapon-critical-field { display:grid; grid-column:auto; grid-template-columns:minmax(0,1fr) auto; grid-template-rows:auto 32px auto; align-content:start; align-items:center; gap:3px; min-width:0; max-width:none; }
 #weaponEditorPanel[data-weapon-desktop] #weaponStatsForm .weapon-critical-field > .editor-field-name { grid-column:1/-1; grid-row:1; }
 #weaponEditorPanel[data-weapon-desktop] #weaponStatsForm .weapon-critical-field > select[data-editor-field] { grid-column:1; grid-row:2; width:100%; min-width:0; inline-size:100%; height:32px; }
 #weaponEditorPanel[data-weapon-desktop] #weaponStatsForm .weapon-critical-field > .editor-diff-reset { grid-column:2; grid-row:2; }
 #weaponEditorPanel[data-weapon-desktop] #weaponStatsForm .weapon-critical-field > .critical-applied-value { grid-column:1/-1; grid-row:3; }
 #weaponEditorPanel[data-weapon-desktop] .weapon-name-field input { height:32px; }
 #weaponEditorPanel[data-weapon-desktop] .weapon-owner-panel { padding:8px; gap:7px; overflow:hidden; }
 #weaponEditorPanel[data-weapon-desktop] #weaponStatsForm:has(.weapon-dialogue-panel:not([hidden])) > .weapon-owner-panel {
  display:grid; grid-template-columns:max-content minmax(0,1fr); align-items:center; gap:7px; padding:4px 6px;
 }
 #weaponEditorPanel[data-weapon-desktop] #weaponStatsForm:has(.weapon-dialogue-panel:not([hidden])) .weapon-owner-panel h4 { display:flex; align-items:center; gap:5px; margin:0; white-space:nowrap; }
 #weaponEditorPanel[data-weapon-desktop] #weaponStatsForm:has(.weapon-dialogue-panel:not([hidden])) .weapon-owner-panel .panel-note { display:none; }
 #weaponEditorPanel[data-weapon-desktop] #weaponStatsForm:has(.weapon-dialogue-panel:not([hidden])) .owner-chip-list { flex-wrap:nowrap; align-items:center; height:100%; overflow:auto; }
 #weaponEditorPanel[data-weapon-desktop] #weaponStatsForm:has(.weapon-dialogue-panel:not([hidden])) .owner-chip { flex:none; min-height:34px; padding-block:1px; }
 #weaponEditorPanel[data-weapon-desktop] .owner-chip-list { gap:7px; }
 #weaponEditorPanel[data-weapon-desktop] #weaponStatsForm:has(.weapon-animation-panel:not([hidden])) > .weapon-owner-panel {
  display:grid; grid-template-columns:max-content minmax(0,1fr); align-items:center; padding:4px 8px; gap:8px;
 }
 #weaponEditorPanel[data-weapon-desktop] #weaponStatsForm:has(.weapon-animation-panel:not([hidden])) .weapon-owner-panel h4 { display:flex; align-items:center; gap:5px; margin:0; white-space:nowrap; }
 #weaponEditorPanel[data-weapon-desktop] #weaponStatsForm:has(.weapon-animation-panel:not([hidden])) .weapon-owner-panel:has(.owner-chip) .panel-note:not(.is-caution) { display:none; }
 #weaponEditorPanel[data-weapon-desktop] #weaponStatsForm:has(.weapon-animation-panel:not([hidden])) .weapon-owner-panel:not(:has(.owner-chip)) { grid-template-columns:minmax(0,1fr); }
 #weaponEditorPanel[data-weapon-desktop] #weaponStatsForm:has(.weapon-animation-panel:not([hidden])) .weapon-owner-panel:not(:has(.owner-chip)) .panel-note { white-space:normal; }
 #weaponEditorPanel[data-weapon-desktop] #weaponStatsForm:has(.weapon-animation-panel:not([hidden])) .weapon-owner-panel .panel-note.is-caution { max-width:180px; overflow:hidden; text-overflow:ellipsis; }
 #weaponEditorPanel[data-weapon-desktop] #weaponStatsForm:has(.weapon-animation-panel:not([hidden])) .owner-chip-list { flex-wrap:nowrap; align-items:center; height:100%; overflow:auto; }
 #weaponEditorPanel[data-weapon-desktop] #weaponStatsForm:has(.weapon-animation-panel:not([hidden])) .owner-chip { flex:none; min-height:34px; padding-block:1px; }
 #weaponEditorPanel[data-weapon-desktop] .weapon-timeline-panel { padding:8px; gap:5px; }
 #weaponEditorPanel[data-weapon-desktop] .battle-timeline-chart { display:flex; flex-direction:column; min-height:100%; }
 #weaponEditorPanel[data-weapon-desktop] .battle-timeline-ruler { flex:0 0 20px; }
 #weaponEditorPanel[data-weapon-desktop] .battle-timeline-lane { flex:1 0 var(--timeline-lane-min,24px); min-height:var(--timeline-lane-min,24px); height:auto; }
 #weaponEditorPanel[data-weapon-desktop] .battle-timeline-label { align-items:flex-start; line-height:1.3; font-size:11px; }
 #weaponEditorPanel[data-weapon-desktop] .battle-timeline-heading strong { font-size:13px; }
 @container weapon-fields (max-width:350px) {
  #weaponEditorPanel[data-weapon-desktop] .weapon-detail-grid { gap:6px; }
  #weaponEditorPanel[data-weapon-desktop] .weapon-detail-grid > label:not(.weapon-critical-field) { grid-template-rows:auto 30px; }
  #weaponEditorPanel[data-weapon-desktop] .weapon-detail-grid > label:not(.weapon-critical-field):has(select) { grid-template-rows:30px; }
  #weaponEditorPanel[data-weapon-desktop] .weapon-detail-grid > label:not(.weapon-critical-field) > input[data-editor-field],
  #weaponEditorPanel[data-weapon-desktop] .weapon-detail-grid > label:not(.weapon-critical-field) > select { min-height:30px;height:30px; }
 }
 /* The real page also contains the site header, settings and save controls.
    Keep the landscape player and full-width timeline on short desktops too. */
 #weaponEditorPanel[data-weapon-desktop] #weaponStatsForm[data-desktop-height="short"] {
  grid-template-rows:max-content minmax(0,1fr) 54px;
 }
 #weaponEditorPanel[data-weapon-desktop] #weaponStatsForm[data-desktop-height="short"]:has(.weapon-animation-panel:not([hidden])) {
  grid-template-rows:max-content minmax(190px,1.1fr) 48px minmax(140px,1fr);overflow-y:auto;
 }
 #weaponEditorPanel[data-weapon-desktop] #weaponStatsForm[data-desktop-height="short"] > .weapon-detail-panel {
  display:grid;grid-template-columns:minmax(0,1fr);grid-template-rows:max-content max-content auto;align-content:start;align-items:stretch;padding:7px;gap:7px;
 }
 #weaponEditorPanel[data-weapon-desktop] #weaponStatsForm[data-desktop-height="short"] .weapon-detail-panel h4 { margin:0;font-size:11px; }
 #weaponEditorPanel[data-weapon-desktop] #weaponStatsForm[data-desktop-height="short"] .weapon-detail-panel .record-tool { min-height:26px;padding:2px 3px;font-size:11px; }
 #weaponEditorPanel[data-weapon-desktop] #weaponStatsForm[data-desktop-height="short"] .weapon-detail-grid { grid-column:1/-1;grid-template-columns:repeat(2,minmax(0,1fr));gap:6px; }
 #weaponEditorPanel[data-weapon-desktop] #weaponStatsForm[data-desktop-height="short"] .weapon-detail-grid > label:not(.weapon-critical-field) { grid-template-rows:auto 28px;gap:2px; }
 #weaponEditorPanel[data-weapon-desktop] #weaponStatsForm[data-desktop-height="short"] .weapon-detail-grid > label:not(.weapon-critical-field) > .editor-field-name { font-size:11px;line-height:14px; }
 #weaponEditorPanel[data-weapon-desktop] #weaponStatsForm[data-desktop-height="short"] .weapon-detail-grid > label:not(.weapon-critical-field):has(select) { grid-column:1/-1;grid-template-columns:max-content minmax(0,1fr) auto;grid-template-rows:28px; }
 #weaponEditorPanel[data-weapon-desktop] #weaponStatsForm[data-desktop-height="short"] .weapon-detail-grid > label:not(.weapon-critical-field):has(select) > .editor-field-name { grid-column:1;grid-row:1; }
 #weaponEditorPanel[data-weapon-desktop] #weaponStatsForm[data-desktop-height="short"] .weapon-detail-grid > label:not(.weapon-critical-field) > input[data-editor-field],
 #weaponEditorPanel[data-weapon-desktop] #weaponStatsForm[data-desktop-height="short"] .weapon-detail-grid > label:not(.weapon-critical-field) > select { height:28px;min-height:28px; }
 #weaponEditorPanel[data-weapon-desktop] #weaponStatsForm[data-desktop-height="short"] .weapon-detail-grid > label:not(.weapon-critical-field) > select { grid-column:2;grid-row:1; }
 #weaponEditorPanel[data-weapon-desktop] #weaponStatsForm[data-desktop-height="short"] .weapon-detail-grid > label:not(.weapon-critical-field):has(select) > .editor-diff-reset { grid-column:3;grid-row:1; }
}
/* Desktop editors use the available page, while the measured/touch layouts
   below 1100px keep their existing controls and page structure. */
@media (min-width:1100px) {
 .editor-data-panel[data-editor-desktop] .editor-page-switch { display:none; }
 .editor-data-panel[data-editor-desktop] .editor-panel-body { flex-direction:row; }
 .editor-data-panel[data-editor-desktop] .record-pane { display:flex; --pane-width:clamp(240px,18vw,320px); }
 .editor-data-panel[data-editor-desktop] .game-screen-shell { display:flex; }
 .editor-data-panel[data-editor-desktop] .editor-game-screen { padding:10px;gap:10px;align-content:stretch; }
 .editor-data-panel[data-editor-desktop] .game-panel { padding:10px;gap:8px;min-height:0;overflow:auto; }
 .editor-data-panel[data-editor-desktop] .game-panel h4 { font-size:14px; }
 .editor-data-panel[data-editor-desktop] .game-panel .record-tool { min-height:30px;padding:3px 7px;font-size:12px; }
 .editor-data-panel[data-editor-desktop] .record-option-name { font-size:16px;line-height:1.4; }
 .editor-data-panel[data-editor-desktop] .record-option-meta { font-size:12px; }
 .editor-data-panel[data-editor-desktop] :is(.unit-core-grid,.pilot-combat-grid,.pilot-points-grid) { display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:8px;overflow:visible; }
 .editor-data-panel[data-editor-desktop] :is(.unit-core-grid,.pilot-combat-grid,.pilot-points-grid)>label { display:grid;grid-template-columns:minmax(0,1fr) auto;grid-template-rows:auto 36px;gap:4px;inline-size:auto;max-inline-size:none; }
 .editor-data-panel[data-editor-desktop] :is(.unit-core-grid,.pilot-combat-grid,.pilot-points-grid)>label>.editor-field-name { grid-column:1/-1;grid-row:1;font-size:14px;line-height:18px;white-space:normal; }
 .editor-data-panel[data-editor-desktop] :is(.unit-core-grid,.pilot-combat-grid,.pilot-points-grid)>label>input[data-editor-field] { grid-column:1;grid-row:2;width:100%;inline-size:100%;min-inline-size:0;min-height:36px;font-size:16px;text-align:center; }
 .editor-data-panel[data-editor-desktop] :is(.unit-core-grid,.pilot-combat-grid,.pilot-points-grid)>label>.editor-diff-reset { grid-column:2;grid-row:2; }
 #unitEditorPanel[data-editor-desktop] #unitStatsForm {
  grid-template-columns:160px minmax(0,1.1fr) minmax(0,1fr);
  grid-template-rows:174px max-content minmax(130px,1fr);
  grid-template-areas:"image vitals core" "abilities abilities terrain" "weapons weapons weapons";
 }
 #unitEditorPanel[data-editor-desktop] #unitStatsForm:has(#unitAnimationPanel:not([hidden])) { grid-template-areas:"image vitals core" "abilities abilities terrain" "weapons weapons preview"; }
 #unitEditorPanel[data-editor-desktop] .unit-image-panel { align-items:center;justify-content:center; }
 #unitEditorPanel[data-editor-desktop] #unitPreviewImage { width:128px;height:128px;max-height:160px;object-fit:contain;image-rendering:pixelated; }
 #unitEditorPanel[data-editor-desktop] .unit-vitals-grid { display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px; }
 #unitEditorPanel[data-editor-desktop] :is(.unit-vitals-grid,.unit-flag-grid)>label { display:grid;grid-template-columns:max-content minmax(0,1fr) auto;grid-template-rows:36px;align-items:center;gap:5px;inline-size:auto;min-width:0; }
 #unitEditorPanel[data-editor-desktop] :is(.unit-vitals-grid,.unit-flag-grid)>label>.editor-field-name { grid-column:1;grid-row:1;font-size:13px; }
 #unitEditorPanel[data-editor-desktop] :is(.unit-vitals-grid,.unit-flag-grid)>label>:is(input,select) { grid-column:2;grid-row:1;inline-size:100%;min-inline-size:0;min-height:36px;font-size:16px; }
 #unitEditorPanel[data-editor-desktop] :is(.unit-vitals-grid,.unit-flag-grid)>label>.editor-diff-reset { grid-column:3;grid-row:1; }
 #unitEditorPanel[data-editor-desktop] .unit-runtime-gauge { grid-column:1/-1;min-height:4px; }
 #unitEditorPanel[data-editor-desktop] .unit-flag-grid>label { grid-template-columns:minmax(0,1fr) auto;grid-template-rows:18px 36px; }
 #unitEditorPanel[data-editor-desktop] .unit-flag-grid>label>.editor-field-name { grid-column:1/-1;grid-row:1; }
 #unitEditorPanel[data-editor-desktop] .unit-flag-grid>label>select { grid-column:1;grid-row:2; }
 #unitEditorPanel[data-editor-desktop] .unit-flag-grid>label>.editor-diff-reset { grid-column:2;grid-row:2; }
 #unitEditorPanel[data-editor-desktop] .unit-flag-grid .editor-diff-reset.is-empty { display:none; }
 #unitEditorPanel[data-editor-desktop] .unit-special-list { grid-template-columns:repeat(4,minmax(0,1fr));gap:10px; }
 #unitEditorPanel[data-editor-desktop] .unit-special-row { gap:4px; }
 #unitEditorPanel[data-editor-desktop] .unit-special-name-field .editor-diff-reset.is-empty { display:none; }
 #unitEditorPanel[data-editor-desktop] .unit-info-panel { container:unit-skills / inline-size; }
 @container unit-skills (max-width:370px) { #unitEditorPanel[data-editor-desktop] .unit-special-list { grid-template-columns:repeat(2,minmax(0,1fr)); } }
 #unitEditorPanel[data-editor-desktop] .unit-special-name-field select { min-height:36px;font-size:14px; }
 #unitEditorPanel[data-editor-desktop] #unitStatsForm[data-desktop-size="medium"] { grid-template-rows:160px max-content minmax(150px,1fr); }
 #unitEditorPanel[data-editor-desktop] #unitStatsForm[data-desktop-size="medium"] .unit-core-panel { padding:8px;gap:4px; }
 #unitEditorPanel[data-editor-desktop] #unitStatsForm[data-desktop-size="medium"] .unit-core-panel .record-tool { min-height:26px; }
 #unitEditorPanel[data-editor-desktop] #unitStatsForm[data-desktop-size="medium"] .unit-core-grid>label { grid-template-rows:18px 32px;gap:2px; }
 #unitEditorPanel[data-editor-desktop] #unitStatsForm[data-desktop-size="medium"] .unit-core-grid>label>input { min-height:32px; }
 #unitEditorPanel[data-editor-desktop] #unitStatsForm[data-desktop-size="medium"] .unit-info-panel { padding:6px;gap:4px; }
 #unitEditorPanel[data-editor-desktop] #unitStatsForm[data-desktop-size="medium"] .unit-info-panel { display:grid;grid-template-columns:76px minmax(0,1fr);align-items:center; }
 #unitEditorPanel[data-editor-desktop] #unitStatsForm[data-desktop-size="medium"] .unit-info-panel h4 { display:flex;flex-direction:column;align-items:flex-start;gap:3px; }
 #unitEditorPanel[data-editor-desktop] #unitStatsForm[data-desktop-size="medium"] .unit-special-list { grid-template-columns:repeat(2,minmax(0,1fr));gap:2px 6px; }
 #unitEditorPanel[data-editor-desktop] #unitStatsForm[data-desktop-size="medium"] .unit-special-row { grid-template-columns:minmax(0,1fr) auto auto;gap:3px; }
 #unitEditorPanel[data-editor-desktop] #unitStatsForm[data-desktop-size="medium"] .unit-special-slot-name { display:none; }
 #unitEditorPanel[data-editor-desktop] #unitStatsForm[data-desktop-size="medium"] .unit-info-panel .record-tool { min-height:24px; }
 #unitEditorPanel[data-editor-desktop] #unitStatsForm[data-desktop-size="medium"] .unit-special-name-field select { min-height:28px;height:28px; }
 #unitEditorPanel[data-editor-desktop] #unitStatsForm[data-desktop-size="medium"] .unit-ability-remove { width:26px;height:28px; }
 #unitEditorPanel[data-editor-desktop] .unit-weapons-panel { overflow:hidden; }
 #unitEditorPanel[data-editor-desktop] .unit-weapon-list { grid-template-columns:repeat(auto-fit,minmax(220px,1fr));gap:8px; }
 #unitEditorPanel[data-editor-desktop] .unit-weapon-workarea[data-weapon-detail="open"] .unit-weapon-list { grid-template-columns:minmax(0,1fr); }
 #unitEditorPanel[data-editor-desktop] .unit-weapon-entry { min-height:0; }
 #unitEditorPanel[data-editor-desktop] .weapon-entry-name { font-size:14px; }
 #unitEditorPanel[data-editor-desktop] :is(.weapon-entry-slot,.weapon-entry-stats,.weapon-entry-flags) { font-size:12px;line-height:1.4; }
 #unitEditorPanel[data-editor-desktop] .unit-weapon-detail { padding:10px;gap:8px; }
 #unitEditorPanel[data-editor-desktop] .unit-weapon-detail :is(input,select) { min-height:32px;font-size:14px; }
 #unitEditorPanel[data-editor-desktop] .unit-weapon-detail h5 { font-size:15px; }
 #unitEditorPanel[data-editor-desktop] .unit-weapon-number-grid { gap:8px; }
 #pilotEditorPanel[data-editor-desktop] #pilotStatsForm {
  grid-template-columns:160px minmax(0,1.15fr) minmax(0,1fr);
  grid-template-rows:160px minmax(160px,1fr) 120px;
  grid-template-areas:"portrait combat points" "mental mental skills" "growth growth terrain";
 }
 #pilotEditorPanel[data-editor-desktop] #pilotPreview { align-items:center;justify-content:center; }
 #pilotEditorPanel[data-editor-desktop] #pilotPreviewImage { width:104px;height:104px;max-height:104px;image-rendering:pixelated; }
 #pilotEditorPanel[data-editor-desktop] .pilot-points-grid { grid-template-columns:repeat(2,minmax(0,1fr)); }
 #pilotEditorPanel[data-editor-desktop] :is(.pilot-mental-panel,.pilot-special-panel) { overflow:hidden; }
 #pilotEditorPanel[data-editor-desktop] .pilot-mental-grid { grid-template-columns:repeat(3,minmax(0,1fr));gap:10px;overflow:auto;align-content:start; }
 #pilotEditorPanel[data-editor-desktop] .pilot-mental-slot { padding:8px;min-height:62px;gap:5px; }
 #pilotEditorPanel[data-editor-desktop] .pilot-mental-name { font-size:16px; }
 #pilotEditorPanel[data-editor-desktop] .pilot-mental-level { font-size:14px; }
 #pilotEditorPanel[data-editor-desktop] .pilot-special-panel { container:pilot-skills / inline-size; }
 #pilotEditorPanel[data-editor-desktop] .pilot-runtime-skills { flex:1;grid-template-columns:minmax(0,1fr);gap:8px;overflow:auto;align-content:start; }
 #pilotEditorPanel[data-editor-desktop] .pilot-runtime-skill { min-height:36px;padding:7px;font-size:14px;border-bottom:1px solid #1c4654; }
 #pilotEditorPanel[data-editor-desktop] .pilot-growth-grid { display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:8px;overflow:visible; }
 #pilotEditorPanel[data-editor-desktop] .pilot-growth-grid>label { display:grid;grid-template-columns:max-content minmax(0,1fr) auto;grid-template-rows:32px;gap:5px;inline-size:auto; }
 #pilotEditorPanel[data-editor-desktop] .pilot-growth-grid>label>.editor-field-name { grid-column:1;grid-row:1;font-size:13px; }
 #pilotEditorPanel[data-editor-desktop] .pilot-growth-grid>label>input[data-editor-field] { grid-column:2;grid-row:1;inline-size:100%;min-inline-size:0;min-height:32px;font-size:16px; }
 #pilotEditorPanel[data-editor-desktop] .pilot-growth-grid>label>.editor-diff-reset { grid-column:3;grid-row:1; }
 .editor-data-panel[data-editor-desktop] :is(.unit-terrain-panel,.pilot-terrain-panel) { grid-template-columns:minmax(0,1fr);gap:8px;align-content:start; }
 .editor-data-panel[data-editor-desktop] :is(.unit-terrain-panel,.pilot-terrain-panel) .terrain-grid { display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:8px; }
 .editor-data-panel[data-editor-desktop] :is(.unit-terrain-panel,.pilot-terrain-panel) .terrain-grid>label { display:grid;grid-template-columns:1fr auto;gap:4px; }
 .editor-data-panel[data-editor-desktop] :is(.unit-terrain-panel,.pilot-terrain-panel) .terrain-grid>label>.editor-field-name { grid-column:1/-1;font-size:13px; }
 .editor-data-panel[data-editor-desktop] :is(.unit-terrain-panel,.pilot-terrain-panel) .terrain-grid select { width:100%;min-height:34px;font-size:16px; }
 @container pilot-skills (min-width:520px) { #pilotEditorPanel[data-editor-desktop] .pilot-runtime-skills { grid-template-columns:repeat(2,minmax(0,1fr)); } }
 #rewardEditorPanel,#terrainEditorPanel { grid-template-columns:clamp(260px,22vw,360px) minmax(0,1fr); }
 :is(#rewardEditorPanel,#terrainEditorPanel) :is(.reward-toolbar,.terrain-toolbar) { padding:10px 14px;gap:12px; }
 :is(#rewardEditorPanel,#terrainEditorPanel) .effect-record-rail { padding:12px;gap:10px; }
 :is(#rewardEditorPanel,#terrainEditorPanel) .effect-record-rail>input { height:40px;font-size:15px;padding:7px 10px; }
 :is(#rewardEditorPanel,#terrainEditorPanel) .effect-record { min-height:54px;padding:10px;font-size:14px;line-height:1.45; }
 #rewardEditorPanel .reward-card { display:grid;grid-template-columns:minmax(280px,.9fr) minmax(300px,1.2fr);gap:24px;padding:20px;overflow:hidden; }
 #rewardEditorPanel .reward-edit-column,#rewardEditorPanel .reward-use-column { display:flex;flex-direction:column;min-width:0;min-height:0;gap:12px; }
 #rewardEditorPanel #rewardFields { grid-template-columns:minmax(0,1fr);gap:20px; }
 #rewardEditorPanel .reward-pair { grid-template-columns:minmax(0,1fr) 110px;gap:12px; }
 #rewardEditorPanel .reward-pair label { gap:8px;font-size:14px; }
 #rewardEditorPanel .reward-pair :is(input,select) { height:44px;font-size:16px; }
 #rewardEditorPanel :is(#rewardSummary,#rewardScope) { margin:0;font-size:15px;line-height:1.6; }
 #rewardEditorPanel .reward-usage-row { margin:0;min-height:0; }
 #rewardEditorPanel #rewardUsageList { grid-auto-rows:minmax(56px,max-content);gap:8px;overflow:auto; }
 #rewardEditorPanel #rewardUsageList button { display:flex;align-items:center;gap:10px;min-height:56px;padding:8px 12px;font-size:14px;white-space:normal; }
 #terrainEditorPanel .terrain-card { display:grid;grid-template-columns:minmax(320px,1.3fr) minmax(240px,1fr);grid-template-rows:max-content max-content minmax(0,1fr);grid-template-areas:"fields examples" "note examples" "status examples";padding:20px;gap:20px; }
 #terrainEditorPanel #terrainFields { grid-area:fields;grid-template-columns:repeat(2,minmax(0,1fr));gap:16px; }
 #terrainEditorPanel #terrainFields>label { padding:14px;gap:10px;border:1px solid #315b6c;background:#061425;font-size:15px; }
 #terrainEditorPanel .terrain-value { min-height:48px;font-size:22px; }
 #terrainEditorPanel .terrain-value>span { font-size:16px; }
 #terrainEditorPanel .terrain-edit-note { grid-area:note;margin:0;font-size:14px;line-height:1.7; }
 #terrainEditorPanel #terrainStatus { grid-area:status;margin:0;align-self:start; }
 #terrainEditorPanel .terrain-tile-examples { grid-area:examples;--terrain-icon-size:64px;display:grid;grid-template-columns:repeat(auto-fit,minmax(110px,1fr));gap:12px;align-content:start;margin:0; }
 #terrainEditorPanel .terrain-tile-examples[hidden] { display:none; }
 #terrainEditorPanel .terrain-tile-examples button { flex-direction:column;min-height:104px;padding:10px;font-size:13px; }
 #scenarioEditorPanel .scenario-toolbar { padding:12px;gap:10px;grid-template-columns:minmax(300px,1fr) auto; }
 #scenarioEditorPanel .scenario-mode-row { width:min(760px,55vw);gap:8px; }
 #scenarioEditorPanel :is(.scenario-toolbar,.scenario-inspector) :is(input,select,button) { min-height:38px;font-size:14px; }
 #scenarioEditorPanel .scenario-context-row { gap:10px; }
 #scenarioEditorPanel .scenario-workarea { grid-template-columns:minmax(0,1fr) clamp(330px,27vw,460px); }
 #scenarioEditorPanel[data-mode="placement"] .scenario-workarea { grid-template-columns:clamp(220px,18vw,320px) minmax(0,1fr) clamp(330px,27vw,460px); }
 #scenarioEditorPanel .scenario-placement-rail { padding:12px;gap:12px; }
 #scenarioEditorPanel #scenarioDeploymentSelector[size] { font-size:14px; }
 #scenarioEditorPanel #scenarioDeploymentSelector[size] option { padding:10px;min-height:36px; }
 #scenarioEditorPanel .scenario-inspector { padding:14px;gap:12px;overflow-y:auto;overscroll-behavior:contain; }
 #scenarioEditorPanel .scenario-inspector>* { flex:0 0 auto; }
 #scenarioEditorPanel .scenario-inspector label { font-size:14px;gap:7px; }
 #scenarioEditorPanel .scenario-dialogue-panel { grid-template-columns:clamp(320px,27vw,460px) minmax(0,1fr); }
 #scenarioEditorPanel .scenario-dialogue-rail,#scenarioEditorPanel .scenario-dialogue-editor { padding:14px;gap:12px; }
 #scenarioEditorPanel .scenario-dialogue-list button { padding:12px;font-size:14px;line-height:1.6; }
 #scenarioEditorPanel #scenarioDialogueText { font-size:16px;line-height:1.7;padding:12px; }
 #scenarioEditorPanel #scenarioRosterList { display:grid;grid-template-columns:repeat(auto-fit,minmax(520px,1fr));gap:10px; }
 #scenarioEditorPanel .scenario-roster-row { padding:10px;font-size:14px; }
}

.weapon-name-field input,.save-name-panel input { background:#00161e; border:1px solid #147c91; color:#e7e8da; }
.weapon-timeline-panel { display:grid; grid-template-rows:24px 15px minmax(75px,1fr) 24px 32px; gap:2px; }
.battle-timeline-note { white-space:nowrap; overflow:hidden; text-overflow:ellipsis; margin:0; }
.battle-timeline-scroll { min-height:0; max-height:none; scrollbar-gutter:stable; }
.battle-timeline-inspect { overflow:hidden; margin:0; }
.weapon-timeline-panel { grid-template-rows:24px 15px minmax(0,1fr) 24px auto; }
.battle-timeline-ruler { display:grid; grid-template-columns:90px minmax(0,1fr); height:18px; }
.battle-timeline-ruler .battle-timeline-label { line-height:18px; }
.battle-timeline-ticks { position:relative; margin-right:2px; }
.battle-timeline-ticks span { position:absolute; top:2px; font-size:9px; color:#9cafb4; transform:translateX(-50%); white-space:nowrap; }
.battle-timeline-ticks span:first-child { transform:none; }
.battle-timeline-ticks span:last-child { transform:translateX(-100%); }
/* Event inspection retains all six summary lanes in a compact window. */
.battle-timeline-lane { height:18px; }
.battle-timeline-label { line-height:17px; }
.weapon-timeline-panel[data-follow="true"] .battle-timeline-playhead { transition:none; }
.battle-timeline-inspect { max-height:88px; min-height:0; align-items:flex-start; gap:4px; overflow:auto; overscroll-behavior:contain; }
.battle-timeline-inspect canvas { flex-basis:96px; width:96px; height:auto; max-height:67px; }
.battle-timeline-inspect output { min-width:0; max-height:52px; }
.battle-timeline-inspect[data-region="portrait"] canvas { flex-basis:48px; width:48px; max-height:44px; }
.battle-timeline-inspect button { flex:0 0 22px; width:22px; height:22px; min-height:22px; padding:0; font-size:13px; line-height:20px; }
.battle-timeline-inspect[data-region="dialogue"]:has(canvas:not([hidden])) { display:grid; grid-template-columns:minmax(0,1fr) 22px; grid-template-rows:auto minmax(0,1fr); }
.battle-timeline-inspect[data-region="dialogue"] canvas { grid-column:1/-1; width:min(100%,320px); max-height:56px; justify-self:start; }
.battle-timeline-inspect[data-region="dialogue"] output { max-height:26px; }

/* Existing roster joins: a compact directly editable list, no extra modal. */
.editor-scenario-panel[data-mode="roster"] .scenario-workarea,
.editor-scenario-panel[data-mode="roster"] .scenario-cell-context { display:none; }
.scenario-roster-panel { flex:1; min-height:0; overflow:auto; padding:6px; }
.scenario-roster-panel[hidden] { display:none; }
.scenario-roster-panel p { margin:0 0 6px; font-size:12px; }
.scenario-roster-row { display:flex; align-items:center; gap:6px; padding:5px 0; border-bottom:1px solid #28535f; }
.scenario-roster-row label { flex:1; min-width:0; display:flex; align-items:center; gap:8px; }
.scenario-roster-row label span { flex:1; min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.scenario-roster-row input { width:64px; min-width:0; }
.scenario-roster-row .is-modified { color:#ffe39e; }
.scenario-roster-row button { flex:0 0 auto; min-height:28px; padding:3px 6px; font-size:11px; }
.scenario-roster-row.is-expanded { background:#123c36; }
.scenario-roster-context-toggle::after { content:' ▸'; }
.scenario-roster-context-toggle[aria-expanded="true"]::after { content:' ▾'; }
.scenario-roster-context { max-height:min(36vh,280px); min-height:0; overflow:auto; overscroll-behavior:contain; border:1px solid #416975; border-top:0; padding:5px 7px; font-size:11px; line-height:1.45; }
.scenario-roster-context[hidden] { display:none; }
.scenario-roster-context h4 { margin:3px 0 1px; font-size:11px; color:#ebd773; }
.scenario-roster-context ul { margin:0 0 3px; padding-left:15px; }
.scenario-roster-context li { overflow-wrap:anywhere; }
.scenario-roster-context .scenario-roster-context-source,.scenario-roster-context .scenario-roster-context-note { margin:0 0 3px; font-size:10px; color:#a7bdc2; overflow-wrap:anywhere; }
.scenario-roster-dialogues { display:flex; flex-direction:column; gap:3px; }
.scenario-roster-dialogues button { display:flex; align-items:baseline; flex-wrap:wrap; gap:2px 6px; width:100%; min-width:0; min-height:26px; padding:3px 5px; text-align:left; }
.scenario-roster-dialogues button span { min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; flex:1 1 180px; font-size:11px; }
.scenario-roster-dialogues button small { font-size:10px; color:#a7bdc2; }
.scenario-roster-dialogues p { font-size:11px; margin:0 0 3px; }
.scenario-dialogue-pages { display:flex; align-items:center; gap:4px; flex:0 0 auto; min-width:0; }
.scenario-dialogue-pages span { font-size:11px; margin-right:auto; white-space:nowrap; }
.scenario-dialogue-pages button { min-height:26px; padding:3px 5px; font-size:11px; }
@media (max-width:600px) and (max-height:650px) {
  .scenario-dialogue-panel { grid-template-rows:58px minmax(0,1fr); }
  .scenario-dialogue-rail { gap:2px; }
  #scenarioDialogueCount { display:none; }
  #scenarioDialogueSearch { min-height:24px; height:24px; }
  .scenario-dialogue-list button { padding:2px 5px; min-height:23px; line-height:1.2; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
  .scenario-dialogue-editor { padding:3px; gap:1px; }
  .scenario-dialogue-heading button,.scenario-dialogue-pages button { min-height:22px; padding:2px 4px; }
  #scenarioDialogueSpeaker { height:24px; font-size:11px; }
  #scenarioDialogueSpeakerArt { flex-basis:22px; width:22px; height:22px; }
  #scenarioDialogueSpeakerArt :is(canvas,img) { width:22px; height:22px; }
  #scenarioDialogueSequence { height:22px; }
  .scenario-dialogue-sequence button { min-height:22px; }
  .scenario-dialogue-editor p,.scenario-dialogue-meta { font-size:10px; line-height:12px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; flex-shrink:0; }
  #scenarioDialogueText { min-height:32px; padding:4px; line-height:1.4; }
}

.editor-scenario-panel:is([data-mode="dialogue"],[data-mode="roster"]) .scenario-context-row { display:none; }
.scenario-roster-row .entity-art { flex:0 0 auto; display:inline-flex; align-items:center; gap:3px; }
.scenario-roster-row .entity-unit-icon,.scenario-roster-row .entity-pilot-portrait { width:24px; height:24px; object-fit:contain; image-rendering:pixelated; }
.scenario-roster-row .scenario-roster-art { flex:0 0 51px; min-width:51px; }

/* Deployment selection stays visible as a one-click, scrollable roster. */
#scenarioDeploymentSelector[size] { height:144px; min-height:144px; width:100%; min-width:0; background-image:none; padding:2px; }
#scenarioDeploymentSelector[size] option { padding:6px 8px; min-height:24px; white-space:nowrap; }
.scenario-entity-choice:has(#scenarioDeploymentSelector[size]) { display:flex; flex-direction:column; align-items:stretch; min-width:0; }

.scenario-placement-rail { display:none; min-width:0; min-height:0; padding:8px; gap:8px; border-right:1px solid #26778a; }
.editor-scenario-panel[data-mode="placement"] .scenario-placement-rail { display:flex; flex-direction:column; }
.editor-scenario-panel[data-mode="placement"] .scenario-workarea { grid-template-columns:minmax(190px,230px) minmax(0,1fr) 270px; }
.scenario-placement-rail > strong { font-size:12px; color:#b3d7de; }
.scenario-placement-rail > small { font-size:11px; color:#a1b9bb; }
.scenario-placement-list { display:none; }
.scenario-placement-rail #scenarioDeploymentSelector[size] { flex:1; height:0; min-height:120px; background:#061425; color:#effcf8; border:1px solid #3c8193; font-size:12px; }
#scenarioEntityArt .entity-art { display:flex; align-items:center; gap:10px; }
#scenarioEntityArt :is(canvas,img) { display:block; width:48px; height:48px; object-fit:contain; image-rendering:pixelated; }
@media(max-width:1000px) {
 .editor-scenario-panel[data-mode="placement"] .scenario-workarea { grid-template-columns:minmax(0,1fr) 260px; }
 .editor-scenario-panel[data-mode="placement"] .scenario-placement-rail { display:grid; grid-column:1/-1; grid-template-columns:106px minmax(0,1fr); grid-template-rows:auto 76px; gap:6px; height:112px; max-height:none; box-sizing:border-box; }
 .scenario-placement-rail > strong { grid-column:1/-1; }
 .scenario-placement-rail > small { display:none; }
 .scenario-placement-rail #scenarioEntityArt { grid-column:1; grid-row:2; }
 .scenario-placement-rail #scenarioDeploymentSelector[size] { grid-column:2; grid-row:2; height:76px; min-height:0; }
}
@media(max-width:759px) {
 .editor-scenario-panel[data-mode="placement"] .scenario-workarea { grid-template-columns:minmax(0,1fr); grid-template-rows:auto minmax(0,1fr) auto; }
 .editor-scenario-panel[data-mode="placement"] .scenario-placement-rail { display:grid; flex:0 0 120px; height:120px; grid-template-columns:minmax(0,1fr) auto; grid-template-rows:22px minmax(0,1fr); padding:4px; gap:4px; border-right:0; border-bottom:1px solid #26778a; }
 .scenario-placement-rail > strong { grid-column:1; grid-row:1; align-self:center; font-size:11px; }
 .scenario-placement-rail #scenarioEntityArt { grid-column:2; grid-row:1; }
 .scenario-placement-rail #scenarioEntityArt canvas { width:22px; height:22px; }
 .scenario-placement-rail #scenarioDeploymentSelector[size] { display:none; }
 .scenario-placement-list { position:relative; display:block; grid-column:1/-1; grid-row:2; min-width:0; min-height:0; overflow:auto; overscroll-behavior:contain; scrollbar-width:thin; }
 .scenario-placement-list button { display:grid; grid-template-columns:auto minmax(0,1fr) minmax(0,.9fr); align-items:center; gap:4px; width:100%; min-height:28px; padding:2px 4px; border:0; border-bottom:1px solid #245363; background:#061425; color:#d5ebe7; text-align:left; font:inherit; font-size:11px; line-height:1.35; cursor:pointer; }
 .scenario-placement-list button[aria-selected="true"] { background:#184b38; color:#efffd5; box-shadow:inset 2px 0 #a3e56b; }
 .scenario-placement-list button:focus-visible { outline:1px solid #ffe39e; outline-offset:-1px; }
 .scenario-placement-unit,.scenario-placement-pilot { min-width:0; overflow:hidden; white-space:nowrap; text-overflow:ellipsis; }
 .scenario-placement-unit { font-weight:600; }
 .scenario-placement-pilot { color:#b7d1d7; }
 .scenario-placement-art .entity-unit-icon { width:22px; height:22px; }
 .scenario-placement-art .entity-pilot-portrait { width:20px; height:22px; }
 .scenario-placement-art .entity-sortie-slot { width:22px; height:22px; font-size:9px; }
}

/* Version transfer is a compact file workflow, independent of editor tabs. */
.editor-migration-dialog{width:min(620px,calc(100vw - 24px));max-height:calc(100dvh - 32px);overflow:auto;padding:16px;box-sizing:border-box}
.editor-migration-dialog header{display:flex;justify-content:space-between;align-items:center;gap:12px}
.editor-migration-dialog h2{font-size:1.1rem;margin:0}
.editor-migration-dialog label{display:grid;gap:5px;margin:12px 0}
.editor-migration-dialog input{max-width:100%;min-width:0}
.editor-migration-dialog p,.editor-migration-dialog li{font-size:.85rem;line-height:1.5}

/* Capacity belongs to the save step; editor and player layouts are unchanged. */
.editor-storage-budget { margin:12px 0; padding:12px; border:1px solid #36505d; border-radius:8px; background:#071823; color:#dce7ed; }
.editor-budget-heading { display:flex; align-items:center; justify-content:space-between; gap:12px; }
.editor-budget-heading h4 { margin:0; font-size:15px; }
.editor-budget-heading button { flex:0 0 auto; min-height:36px; padding:5px 12px; cursor:pointer; }
.editor-storage-budget p { margin:8px 0 0; font-size:12px; line-height:1.5; }
.editor-budget-grid { display:grid; grid-template-columns:repeat(auto-fit,minmax(min(100%,310px),1fr)); gap:8px 16px; margin-top:10px; }
.editor-budget-grid:empty { display:none; }
.editor-budget-row { display:grid; gap:3px; min-width:0; padding:7px 0; }
.editor-budget-row strong { font-size:12px; font-weight:600; }
.editor-budget-row span { font-size:11px; color:#b4c9d4; overflow-wrap:anywhere; font-variant-numeric:tabular-nums; }
.editor-budget-row progress { width:100%; height:7px; accent-color:#8ed566; }
.editor-budget-row[data-state="error"] span,.editor-storage-budget[data-state="error"] > p[role="status"] { color:#ffb4a4; }
.editor-storage-budget[data-state="stale"] .editor-budget-grid { opacity:.55; }
/* Optional cartridge-source catalogue. It shares the existing Misc category. */
.srw4-source-panel { display:grid; grid-template-columns:minmax(0,1fr) auto; align-items:center; gap:4px 8px; min-inline-size:0; padding:7px; }
.srw4-source-panel h3 { margin:0; min-width:0; }
.srw4-source-tools { display:flex; flex-wrap:wrap; gap:6px; }
.srw4-source-panel p { margin:0; min-width:0; }
.srw4-source-progress { display:block; width:100%; height:9px; margin:4px 0 8px; accent-color:#74dc53; }
.srw4-source-progress[hidden] { display:none; }
.srw4-source-installed { grid-column:1/-1; color:var(--text,#ebf4f7); font-size:.86rem; font-weight:700; overflow-wrap:anywhere; }
.srw4-source-note { grid-column:1/-1; font-size:11px; line-height:1.3; color:var(--muted,#b6c7cf); }
.srw4-source-results { grid-column:1/-1; min-inline-size:0; }
.srw4-source-known { display:grid; grid-template-columns:repeat(8,minmax(0,1fr)); gap:4px; }
.srw4-source-asset { display:grid; align-content:center; justify-items:center; gap:2px; min-width:0; padding:2px; border:1px solid #385e6b; }
.srw4-source-asset span,.srw4-source-asset small { font-size:.75rem; }

.srw4-source-previews{display:flex;gap:8px;align-items:center}.srw4-source-previews figure{margin:0;text-align:center}.srw4-source-icon{width:32px;height:32px;image-rendering:pixelated;background:#151c2a}.srw4-source-previews figcaption{font-size:.68rem;white-space:nowrap}

/* Keep desktop map rows compact while showing unit and pilot separately. */
@media (min-width: 760px) {
 #scenarioEditorPanel[data-mode="placement"] .scenario-placement-rail #scenarioDeploymentSelector[size] { display:none; }
 #scenarioEditorPanel[data-mode="placement"] .scenario-placement-list { display:block; flex:1; min-width:0; min-height:0; overflow:auto; overscroll-behavior:contain; scrollbar-width:thin; border:1px solid #3c8193; }
 #scenarioEditorPanel[data-mode="placement"] .scenario-placement-list button { display:grid; grid-template-columns:36px minmax(0,1fr) minmax(0,1fr); align-items:center; gap:4px; box-sizing:border-box; width:100%; height:24px; min-height:24px; padding:1px 4px; border:0; border-bottom:1px solid #245363; background:#061425; color:#d5ebe7; text-align:left; font:inherit; font-size:11px; line-height:1.2; cursor:pointer; }
 #scenarioEditorPanel[data-mode="placement"] .scenario-placement-list button[aria-selected="true"] { background:#184b38; color:#efffd5; box-shadow:inset 2px 0 #a3e56b; }
 #scenarioEditorPanel[data-mode="placement"] .scenario-placement-list button:focus-visible { outline:1px solid #ffe39e; outline-offset:-1px; }
 #scenarioEditorPanel[data-mode="placement"] :is(.scenario-placement-unit,.scenario-placement-pilot) { min-width:0; overflow:hidden; white-space:nowrap; text-overflow:ellipsis; }
 #scenarioEditorPanel[data-mode="placement"] .scenario-placement-unit { font-weight:600; }
 #scenarioEditorPanel[data-mode="placement"] .scenario-placement-art { display:flex; width:36px; align-items:center; justify-content:center; overflow:hidden; }
 #scenarioEditorPanel[data-mode="placement"] .scenario-placement-art :is(canvas,img) { display:block; max-width:18px; max-height:20px; object-fit:contain; image-rendering:pixelated; }
}
@media (min-width: 1001px) {
 #scenarioEditorPanel[data-mode="placement"] .scenario-workarea { grid-template-columns:clamp(270px,22vw,340px) minmax(0,1fr) clamp(330px,27vw,460px); }
}
@media (min-width: 760px) and (max-width: 1000px) {
 #scenarioEditorPanel[data-mode="placement"] .scenario-placement-list { grid-column:2; grid-row:2; }
}

/* Shape-aware map layout keeps the whole map visible and leaves the sides usable. */
@media (min-width:760px) {
 #scenarioEditorPanel .scenario-toolbar { padding:5px 6px; gap:4px; }
 #scenarioEditorPanel .scenario-mode-row { gap:4px; }
 #scenarioEditorPanel .scenario-context-row { gap:4px; }
 #scenarioEditorPanel .scenario-toolbar :is(input,select,button,summary) { min-height:30px; height:30px; font-size:12px; }
 #scenarioEditorPanel[data-mode="placement"][data-map-shape="wide"] .scenario-workarea { grid-template-columns:clamp(240px,22vw,310px) minmax(0,1fr); grid-template-rows:minmax(110px,45%) minmax(0,1fr); }
 #scenarioEditorPanel[data-mode="placement"][data-map-shape="wide"] .scenario-placement-rail { display:flex; flex-direction:column; grid-column:1; grid-row:1; height:auto; min-height:0; max-height:none; padding:5px; gap:4px; border-right:1px solid #26778a; border-bottom:0; }
 #scenarioEditorPanel[data-mode="placement"][data-map-shape="wide"] .scenario-placement-list { flex:1; min-height:0; }
 #scenarioEditorPanel[data-mode="placement"][data-map-shape="wide"] .scenario-map-area { grid-column:2; grid-row:1 / 3; }
 #scenarioEditorPanel[data-mode="placement"][data-map-shape="wide"] .scenario-inspector { grid-column:1; grid-row:2; min-height:0; overflow:auto; padding:5px; gap:5px; border-left:0; border-top:1px solid #26778a; }
}
@media (max-width:759px) {
 #scenarioEditorPanel[data-mode="placement"] .scenario-placement-rail { flex-basis:92px; height:92px; }
}

/* Mobile placement: map first, compact icon strip, editable selection below. */
@media (max-width:759px) {
 #scenarioEditorPanel[data-mobile-split="true"][data-mode="placement"] .scenario-workarea { display:grid; grid-template-columns:minmax(0,1fr) 43px; grid-template-rows:minmax(0,1fr) auto; }
 #scenarioEditorPanel[data-mobile-split="true"][data-mode="placement"] .scenario-map-area { grid-column:1; grid-row:1; padding:3px; gap:2px; }
 #scenarioEditorPanel[data-mobile-split="true"][data-mode="placement"] .scenario-placement-rail { display:flex; grid-column:2; grid-row:1; width:43px; height:auto; min-height:0; padding:3px 1px; gap:0; border-left:1px solid #26778a; border-bottom:0; }
 #scenarioEditorPanel[data-mobile-split="true"][data-mode="placement"] .scenario-placement-rail > :is(strong,small,#scenarioEntityArt) { display:none; }
 #scenarioEditorPanel[data-mobile-split="true"][data-mode="placement"] .scenario-placement-list { display:flex; flex-direction:column; flex:1; width:100%; min-height:0; }
 #scenarioEditorPanel[data-mobile-split="true"][data-mode="placement"] .scenario-placement-list button { display:flex; flex:0 0 25px; align-items:center; justify-content:center; width:100%; height:25px; min-height:25px; padding:0; }
 #scenarioEditorPanel[data-mobile-split="true"][data-mode="placement"] :is(.scenario-placement-unit,.scenario-placement-pilot) { display:none; }
 #scenarioEditorPanel[data-mobile-split="true"][data-mode="placement"] .scenario-placement-art { display:flex; align-items:center; justify-content:center; }
 #scenarioEditorPanel[data-mobile-split="true"][data-mode="placement"] .scenario-inspector { grid-column:1 / -1; grid-row:2; min-height:0; max-height:165px; overflow:auto; padding:3px; gap:2px; border-left:0; border-top:1px solid #26778a; }
 #scenarioEditorPanel[data-mobile-split="true"][data-mode="placement"] #scenarioDeploymentFields { gap:2px; }
 #scenarioEditorPanel[data-mobile-split="true"][data-mode="placement"] #scenarioDeploymentFields > .scenario-edit-group:last-child { order:-1; }
 #scenarioEditorPanel[data-mobile-split="true"][data-mode="placement"] .scenario-inspector :is(input,select,button) { min-height:24px; height:24px; padding:1px 3px; font-size:11px; }
 #scenarioEditorPanel[data-mobile-split="true"][data-mode="placement"] :is(.scenario-position,.scenario-action-row,.scenario-reward-label) { gap:3px; }
 #scenarioEditorPanel[data-mobile-split="true"][data-mode="placement"] .scenario-position input { width:45px; }
 #scenarioEditorPanel[data-mobile-split="true"][data-mode="placement"] .scenario-combat-rewards { gap:2px; padding-top:2px; }
 #scenarioEditorPanel[data-mobile-split="true"][data-mode="placement"] .scenario-combat-reward-values { gap:3px; }
 #scenarioEditorPanel[data-mobile-split="true"][data-mode="placement"] .scenario-combat-reward-values label { grid-template-columns:auto minmax(0,1fr); align-items:center; gap:2px; font-size:9px; white-space:nowrap; }
 #scenarioEditorPanel[data-mobile-split="true"][data-mode="placement"] .scenario-combat-reward-note { font-size:9px; line-height:1.2; }
 #scenarioEditorPanel[data-mobile-split="true"][data-mode="placement"]:not([data-map-shape="tall"]) .scenario-workarea { grid-template-columns:minmax(0,1fr); grid-template-rows:minmax(0,1fr) 27px auto; }
 #scenarioEditorPanel[data-mobile-split="true"][data-mode="placement"]:not([data-map-shape="tall"]) .scenario-map-area { grid-column:1; grid-row:1; }
 #scenarioEditorPanel[data-mobile-split="true"][data-mode="placement"]:not([data-map-shape="tall"]) .scenario-placement-rail { grid-column:1; grid-row:2; width:auto; height:27px; padding:1px 3px; border-left:0; border-top:1px solid #26778a; }
 #scenarioEditorPanel[data-mobile-split="true"][data-mode="placement"]:not([data-map-shape="tall"]) .scenario-placement-list { flex-direction:row; overflow:auto; }
 #scenarioEditorPanel[data-mobile-split="true"][data-mode="placement"]:not([data-map-shape="tall"]) .scenario-placement-list button { flex:0 0 43px; width:43px; height:24px; }
 #scenarioEditorPanel[data-mobile-split="true"][data-mode="placement"]:not([data-map-shape="tall"]) .scenario-inspector { grid-column:1; grid-row:3; }
}

@media (min-width:760px) {
 #scenarioEditorPanel[data-mode="placement"][data-map-shape="wide"] .scenario-inspector :is(input,select,button) { min-height:26px; height:26px; font-size:11px; padding:2px 4px; }
 #scenarioEditorPanel[data-mode="placement"][data-map-shape="wide"] #scenarioDeploymentFields { gap:3px; }
 #scenarioEditorPanel[data-mode="placement"][data-map-shape="wide"] .scenario-combat-rewards { gap:2px; padding-top:2px; }
 #scenarioEditorPanel[data-mode="placement"][data-map-shape="wide"] .scenario-combat-reward-values label { gap:1px; font-size:10px; }
 #scenarioEditorPanel[data-mode="placement"][data-map-shape="wide"] .scenario-combat-reward-note { font-size:10px; line-height:1.2; }
}

.srw4-source-status { min-width:0; }
#srw4SourceStatus { grid-column:1 / -1; font-size:11px; line-height:1.3; }
.srw4-source-asset strong { max-width:100%; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; font-size:10px; }
.misc-help > summary { cursor:pointer; font-size:11px; color:#9cdce5; }
.misc-help p { margin:4px 0; }
@media (max-width:1000px) { .editor-misc-panel { grid-template-columns:repeat(2,minmax(0,1fr)); } }
@media (max-width:600px) { .srw4-source-known { grid-template-columns:repeat(4,minmax(0,1fr)); } .srw4-source-panel { grid-template-columns:minmax(0,1fr); } .srw4-source-tools { grid-column:1; } }
.misc-example-button { display:inline-flex; align-items:center; gap:3px; min-height:24px; padding:1px 3px; font-size:10px; white-space:nowrap; }
.misc-example-button[hidden] { display:none; }
.misc-example-button img { width:36px; height:22px; object-fit:cover; image-rendering:pixelated; }
.misc-example-dialog { max-width:min(96vw,1100px); max-height:92dvh; padding:8px; color:#d5ebe7; background:#061425; border:1px solid #70b0b4; }
.misc-example-dialog::backdrop { background:#000c; }
.misc-example-dialog-bar { display:flex; justify-content:space-between; align-items:center; gap:8px; margin-bottom:5px; }
.misc-example-dialog img { display:block; max-width:100%; max-height:78dvh; object-fit:contain; image-rendering:pixelated; }

@media (max-width:600px) {
 #miscEditorPanel { gap:4px; padding:3px; }
 #miscEditorPanel .collection-unlock-panel { gap:3px; padding:5px; }
 #miscEditorPanel .collection-unlock-panel h3 { font-size:10px; line-height:1.2; }
 #miscEditorPanel .collection-unlock-choice { gap:4px; font-size:11px; line-height:1.2; }
 #miscEditorPanel .collection-unlock-panel :is(button,summary) { min-height:25px; padding:2px 4px; font-size:10px; }
 #miscEditorPanel .collection-unlock-panel p { font-size:10px; line-height:1.25; }
 #miscEditorPanel .critical-fix-heading { flex-wrap:nowrap; gap:3px; }
 #miscEditorPanel .critical-fix-heading h3 { min-width:0; }
 #miscEditorPanel .critical-fix-heading output { padding:1px 3px; font-size:10px; }
 #miscEditorPanel .collection-unlock-panel .misc-example-button { gap:0; font-size:0; min-height:22px; padding:0; }
 #miscEditorPanel .misc-example-button img { width:36px; height:20px; }
 #miscEditorPanel .srw4-source-panel { gap:3px; padding:4px; }
 #miscEditorPanel .srw4-source-tools .record-tool { min-height:26px; padding:2px 4px; font-size:10px; }
 #miscEditorPanel .srw4-source-known { gap:3px; }
 #miscEditorPanel .srw4-source-asset { gap:1px; padding:1px; }
 #miscEditorPanel .srw4-source-asset strong { font-size:9px; line-height:1.15; }
 #miscEditorPanel .srw4-source-icon { width:26px; height:26px; }
}

/* Unit preview occupies the old portrait/vitals region; its values stay below. */
.unit-preview-map-icon { display:none; image-rendering:pixelated; width:32px; height:32px; }
@media (min-width: 0px) {
 #unitStatsForm:is([data-unit-preview="stacked"],[data-unit-preview="desktop"],[data-unit-preview="mobile-stack"]):has(#unitAnimationPanel:not([hidden])) .unit-image-panel { display:none !important; }
 #unitStatsForm:is([data-unit-preview="stacked"],[data-unit-preview="desktop"],[data-unit-preview="mobile-stack"]):has(#unitAnimationPanel:not([hidden])) .unit-vitals-panel { display:grid; grid-template-columns:32px repeat(3,minmax(0,1fr)); gap:3px; padding:4px; align-items:center; overflow:visible; }
 #unitStatsForm:is([data-unit-preview="stacked"],[data-unit-preview="desktop"],[data-unit-preview="mobile-stack"]):has(#unitAnimationPanel:not([hidden])) .unit-vitals-panel h4 { display:none; }
 #unitStatsForm:is([data-unit-preview="stacked"],[data-unit-preview="desktop"],[data-unit-preview="mobile-stack"]):has(#unitAnimationPanel:not([hidden])) .unit-preview-map-icon:not([hidden]) { display:block; }
 #unitStatsForm:is([data-unit-preview="stacked"],[data-unit-preview="desktop"],[data-unit-preview="mobile-stack"]):has(#unitAnimationPanel:not([hidden])) .unit-vitals-panel :is(.unit-vitals-grid,.unit-flag-grid,.unit-secondary-grid) { display:grid !important; grid-template-columns:minmax(0,1fr); gap:3px; }
 #unitStatsForm:is([data-unit-preview="stacked"],[data-unit-preview="desktop"],[data-unit-preview="mobile-stack"]):has(#unitAnimationPanel:not([hidden])) .unit-vitals-panel label { display:flex; gap:2px; align-items:center; min-width:0; white-space:nowrap; font-size:10px; }
 #unitStatsForm:is([data-unit-preview="stacked"],[data-unit-preview="desktop"],[data-unit-preview="mobile-stack"]):has(#unitAnimationPanel:not([hidden])) .unit-vitals-panel label > .editor-field-name { flex:0 0 auto; font-size:10px; }
 #unitStatsForm:is([data-unit-preview="stacked"],[data-unit-preview="desktop"],[data-unit-preview="mobile-stack"]):has(#unitAnimationPanel:not([hidden])) .unit-vitals-panel label > :is(input,select) { flex:1 1 5ch; inline-size:5ch; min-inline-size:5ch; min-height:26px; height:26px; padding:1px 2px; font-size:11px; }
 #unitStatsForm:is([data-unit-preview="stacked"],[data-unit-preview="desktop"],[data-unit-preview="mobile-stack"]):has(#unitAnimationPanel:not([hidden])) .unit-vitals-panel .editor-diff-reset.is-empty { display:none; }
 #unitStatsForm:is([data-unit-preview="stacked"],[data-unit-preview="desktop"],[data-unit-preview="mobile-stack"]) .unit-special-list.has-flags { grid-template-columns:repeat(2,minmax(0,1fr)); gap:3px; }
 #unitStatsForm:is([data-unit-preview="stacked"],[data-unit-preview="desktop"],[data-unit-preview="mobile-stack"]) .unit-special-row { grid-template-columns:minmax(0,1fr) auto auto; gap:2px; }
 #unitStatsForm:is([data-unit-preview="stacked"],[data-unit-preview="desktop"],[data-unit-preview="mobile-stack"]) .unit-special-slot-name { display:none; }
 #unitStatsForm:is([data-unit-preview="stacked"],[data-unit-preview="desktop"],[data-unit-preview="mobile-stack"]) .unit-special-row:has(> .unit-special-value-field:not([hidden])) > .unit-event-condition { display:none; }
 #unitStatsForm:is([data-unit-preview="stacked"],[data-unit-preview="desktop"],[data-unit-preview="mobile-stack"]) .unit-special-value-field { align-items:center; gap:3px; }
 #unitStatsForm:is([data-unit-preview="stacked"],[data-unit-preview="desktop"],[data-unit-preview="mobile-stack"]) .unit-special-value-field > .editor-field-name { flex:0 0 14px; width:14px; font-size:0; line-height:0; }
 #unitStatsForm:is([data-unit-preview="stacked"],[data-unit-preview="desktop"],[data-unit-preview="mobile-stack"]) .unit-special-value-field .editor-help-button { top:0; margin:0; }
 #unitStatsForm:is([data-unit-preview="stacked"],[data-unit-preview="desktop"],[data-unit-preview="mobile-stack"]) .unit-special-value-field input { width:3.5ch; min-width:3.5ch; min-height:26px; height:26px; padding:1px; text-align:center; }
 #unitStatsForm:is([data-unit-preview="stacked"],[data-unit-preview="desktop"],[data-unit-preview="mobile-stack"]) .unit-special-value-field .editor-diff-reset.is-empty { display:none; }
 #unitStatsForm:is([data-unit-preview="stacked"],[data-unit-preview="desktop"],[data-unit-preview="mobile-stack"]) .unit-special-value-field .editor-diff-reset { width:14px; min-width:14px; }
 #unitStatsForm:is([data-unit-preview="stacked"],[data-unit-preview="desktop"],[data-unit-preview="mobile-stack"]) .unit-special-value-field :is(.editor-diff-reset,.editor-help-button)::after { inset:0; }

}
@media (min-width:1100px) {
 #unitEditorPanel[data-editor-desktop] #unitStatsForm:has(#unitAnimationPanel:not([hidden])) { grid-template-columns:minmax(0,1.15fr) minmax(0,1fr) minmax(0,1fr); grid-template-rows:minmax(150px,1fr) auto auto auto auto; grid-template-areas:"preview weapons weapons" "vitals weapons weapons" "core weapons weapons" "abilities weapons weapons" "terrain weapons weapons"; }
}

@media (min-width:760px) {
 #unitStatsForm:is([data-unit-preview="stacked"],[data-unit-preview="desktop"],[data-unit-preview="mobile-stack"]) .unit-weapon-workarea[data-weapon-detail="open"] { grid-template-columns:minmax(0,1fr); grid-template-rows:minmax(80px,.8fr) minmax(120px,1fr); }
 #unitStatsForm:is([data-unit-preview="stacked"],[data-unit-preview="desktop"],[data-unit-preview="mobile-stack"]) .unit-weapon-workarea[data-weapon-detail="open"] > .unit-weapon-list { display:grid; grid-template-columns:repeat(auto-fit,minmax(220px,1fr)); }
 #unitStatsForm:is([data-unit-preview="stacked"],[data-unit-preview="desktop"],[data-unit-preview="mobile-stack"]) .unit-weapon-detail button.unit-weapon-detail-back { display:none; }
}

@media (max-width:759px) {
 #unitStatsForm[data-unit-preview="mobile-stack"] .unit-vitals-panel { min-height:0; height:auto; }
 #unitStatsForm[data-unit-preview="mobile-stack"] .unit-weapon-workarea[data-weapon-detail="open"] { grid-template-columns:minmax(0,1fr); grid-template-rows:minmax(60px,.7fr) minmax(120px,1fr); }
 #unitStatsForm[data-unit-preview="mobile-stack"] .unit-weapon-workarea[data-weapon-detail="open"] > .unit-weapon-list { display:grid; grid-template-columns:minmax(0,1fr); }
 #unitStatsForm[data-unit-preview="mobile-stack"] .unit-weapon-detail button.unit-weapon-detail-back { display:none; }
 #unitStatsForm[data-unit-preview="mobile-stack"] .unit-weapon-detail-scope { font-size:9px; line-height:1; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
 #unitStatsForm[data-unit-preview="mobile-stack"] .unit-weapon-detail { padding:3px; gap:2px; }
 #unitStatsForm[data-unit-preview="mobile-stack"] .unit-weapon-detail-heading button { min-height:22px; padding:1px 3px; }
}

/* Recover editor height from the navigation chrome, keeping touch targets compact. */
body[data-view="editor"] .patch-section { padding-block:4px; }
body[data-view="editor"] .patch-workspace { gap:3px; padding-block:3px; }
body[data-view="editor"] .mode-setup-toggle { min-height:30px; padding-block:0; }
body[data-view="editor"] .editor-workspace { gap:3px; }
body[data-view="editor"] .editor-tab-row > .editor-tab { min-height:32px; padding-block:2px; }
@media (max-width:760px) {
 body[data-view="editor"] .mode-setup-toggle { min-height:32px; }
 body[data-view="editor"] .editor-tab-row > .editor-tab { min-height:34px; }
}

/* Separate editorial notices: only the navigation link is shown here. */
.site-header .site-notices-link { display: inline-flex; align-items: center; gap: 3px; text-decoration: none; }
.site-header .site-notices-link:focus-visible { outline: 2px solid #9edfff; outline-offset: 2px; }

.patch-notes-timeline-link { display: inline-block; margin-top: 3px; color: inherit; font-size: var(--fs-label); text-underline-offset: .18em; }
.patch-notes-timeline-link[hidden] { display: none; }
