/* ── Export dialog (src/export.js) ── */
#export-backdrop, #sheet-backdrop { position: fixed; inset: 0; z-index: 2400; background: #000a; display: flex; align-items: center; justify-content: center; padding: 16px; }
#export-backdrop[hidden], #sheet-backdrop[hidden] { display: none; }
#export-dialog, #sheet-dialog {
  width: 920px; max-width: 100%; height: 600px; max-height: 100%;
  display: flex; flex-direction: column;
  background: #1a1a1a; border: 1px solid #3a3a3a; border-radius: 10px; box-shadow: 0 20px 60px #000c;
  color: #e0e0e0; font-size: 0.8rem; overflow: hidden;
}
.xd-head { display: flex; align-items: center; gap: 8px; padding: 10px 12px 10px 16px; border-bottom: 1px solid #2a2a2a; }
.xd-title-icon { color: #e0e0e0; opacity: 0.7; flex-shrink: 0; }
#export-dialog:focus, #sheet-dialog:focus { outline: none; }
.xd-head h2 { margin: 0; font-size: 0.95rem; font-weight: 600; }
.xd-main { flex: 1; min-height: 0; display: flex; }
/* preview */
.xd-preview { flex: 1; min-width: 0; display: flex; flex-direction: column; background: #111; }
.xd-view { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; overflow: hidden; padding: 20px; }
.xd-view.actual { overflow: auto; align-items: safe center; justify-content: safe center; }
#xd-canvas, #si-canvas { image-rendering: pixelated; box-shadow: 0 0 0 1px #333, 0 6px 24px #0008; flex-shrink: 0; }
.xd-checker { background: repeating-conic-gradient(#3a3a3a 0 25%, #2a2a2a 0 50%) 0 0 / 16px 16px; }
#xd-icons { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: center; gap: 18px; max-height: 100%; overflow: auto; }
#xd-icons[hidden] { display: none; }
#xd-icons figure { margin: 0; display: flex; flex-direction: column; align-items: center; gap: 6px; }
#xd-icons canvas { image-rendering: pixelated; box-shadow: 0 0 0 1px #333; }
#xd-icons figcaption { font-size: 0.7rem; color: #888; font-variant-numeric: tabular-nums; }
#xd-zoom-label { color: #777; font-size: 0.72rem; font-variant-numeric: tabular-nums; }
/* options */
.xd-side { width: 280px; flex-shrink: 0; padding: 14px 16px; display: flex; flex-direction: column; gap: 16px; overflow-y: auto; border-left: 1px solid #2a2a2a; }
.xd-label { margin-bottom: 6px; font-size: 0.66rem; color: #8a8a8a; text-transform: uppercase; letter-spacing: 0.06em; }
.xd-value { font-size: 0.95rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.xd-note { margin-top: 2px; color: #888; font-size: 0.72rem; }
.xd-seg .btn { border: none; border-radius: 0; height: 26px; padding: 0 9px; background: #222; color: #ccc; }
.xd-seg .btn + .btn { border-left: 1px solid #3a3a3a; }
.xd-seg .btn:hover { background: #2c2c2c; color: #fff; }
.xd-seg .btn.active, .xd-seg .btn.active:hover { background: #4a7fcb; color: #fff; }
.xd-wide { display: flex; }
.xd-wide .btn { flex: 1; }
.xd-custom { display: flex; align-items: center; gap: 6px; margin-top: 8px; color: #aaa; font-size: 0.75rem; }
.xd-custom input { width: 64px; }
.xd-bg-row { display: flex; align-items: center; gap: 10px; }
.xd-bg { width: 26px; height: 26px; padding: 0; border: 1px solid #555; border-radius: 4px; cursor: pointer; }
.xd-bg[hidden] { display: none; }
#export-dialog.ico .xd-png-only, #export-backdrop.ico .xd-png-only { display: none; }
.xd-foot { display: flex; align-items: center; gap: 8px; padding: 10px 16px; border-top: 1px solid #2a2a2a; }
#xd-zoom-label, #si-hint { margin-right: auto; } /* (pushes Cancel / Export to the right) */
.xd-foot > .btn { height: 30px; padding: 0 16px; line-height: 28px; }
.xd-foot .xd-seg .btn { height: 28px; }
/* scrollbars blended into the dark dialog, as elsewhere (scrollbar-color; older WebKit the pseudo-elements) */
.xd-view, #xd-icons, .xd-side { scrollbar-width: thin; scrollbar-color: #3a3a3a transparent; }
.xd-view::-webkit-scrollbar, #xd-icons::-webkit-scrollbar, .xd-side::-webkit-scrollbar { width: 8px; height: 8px; }
.xd-view::-webkit-scrollbar-track, #xd-icons::-webkit-scrollbar-track, .xd-side::-webkit-scrollbar-track { background: transparent; }
.xd-view::-webkit-scrollbar-thumb, #xd-icons::-webkit-scrollbar-thumb, .xd-side::-webkit-scrollbar-thumb { background: #3a3a3a; border-radius: 4px; border: 2px solid #1a1a1a; }
.xd-view::-webkit-scrollbar-corner { background: transparent; }
/* phones: options under the preview */
@media (max-width: 760px) {
  #export-dialog, #sheet-dialog { height: 100%; }
  .xd-main { flex-direction: column; }
  .xd-preview { flex: 1 1 50%; }
  .xd-side { width: auto; border-left: none; border-top: 1px solid #2a2a2a; flex: 0 1 auto; max-height: 50%; }
}

/* sprite sheet options */
#xd-layout-field { display: flex; flex-direction: column; gap: 8px; }
#xd-layout-field[hidden], .xd-grid-opts[hidden] { display: none; }
#xd-layout-field .xd-label { margin-bottom: -2px; }
.xd-grid-opts, .xd-pads { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.xd-num { display: flex; align-items: center; gap: 6px; color: #aaa; font-size: 0.75rem; }
.xd-num input { width: 52px; }
#xd-slice-note { line-height: 1.4; }
.xd-auto { height: 26px; padding: 0 10px; background: #222; color: #ccc; border: 1px solid #3a3a3a; border-radius: 4px; }
.xd-auto.active { background: #4a7fcb; border-color: #4a7fcb; color: #fff; }
.xd-tip { cursor: help; }
/* GIF options */
#xd-gif-field { display: flex; flex-direction: column; gap: 8px; }
#xd-gif-field[hidden], #xd-loop-n-field[hidden] { display: none; }
#xd-gif-field .xd-label { margin-bottom: -2px; }
#xd-gif-field .xd-label:not(:first-child) { margin-top: 6px; }
.xd-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.xd-label.xd-tip { align-self: flex-start; }
#xd-gif-fps { width: 40px; }
/* which frames: all, a tag, each tag */
#xd-tag-field[hidden], #xd-gif-dirloop[hidden], #xd-gif-tag-note[hidden] { display: none; }
#xd-tag { width: 100%; }
.xd-gif-dirloop { display: flex; flex-direction: column; gap: 8px; }
#xd-tag-menu, #xd-tileset-menu { z-index: 2700; } /* (above the Export window) */
#xd-tag-menu .tag-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; vertical-align: 0; }

/* ── Import sprite sheet (src/sheet-import.js): the Export window's parts ── */
#si-slice-field, #si-json-field { display: flex; flex-direction: column; gap: 8px; }
#si-slice-field[hidden], #si-size-opts[hidden], #si-count-opts[hidden], #si-json-remove[hidden], #si-scale-field[hidden], #si-fps-field[hidden] { display: none; }
#si-slice-field .xd-label, #si-json-field .xd-label { margin-bottom: -2px; }
#si-slice-field .xd-label:not(:first-child) { margin-top: 4px; }
#si-file { font-size: 0.85rem; overflow-wrap: anywhere; }
.xd-json-name { flex: 1; min-width: 0; color: #ccc; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#si-hint { color: #777; font-size: 0.72rem; }
#si-scale { width: 40px; }
/* the numbers in pairs, side by side (Width | Height, Spacing | Border): each label above its field */
.si-pair { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }
.si-pair .xd-num { flex-direction: column; align-items: stretch; gap: 4px; min-width: 0; }
.si-pair .num-field { width: 100%; box-sizing: border-box; }
.si-pair input, #si-fw, #si-fh, #si-cols, #si-rows { flex: 1; min-width: 0; width: 0; text-align: left; }
#si-border-note:empty, #si-auto-note:empty { display: none; }
#si-frame-field .xd-row:not(:has(.btn:not([hidden]))) { display: none; }
.si-frame-opts { display: flex; flex-direction: column; gap: 8px; }
.si-frame-opts[hidden] { display: none; }
.si-frame-btns { flex-wrap: wrap; gap: 6px; }
#si-cell-menu [hidden] { display: none; }
#si-cell-menu button:disabled { color: #666; }
.si-menu-sep { height: 1px; margin: 4px 2px; background: #333; }
.si-pair[hidden] { display: none; }
#si-grid-opts, #si-align-opts, #si-bg-field { display: flex; flex-direction: column; gap: 8px; }
#si-grid-opts[hidden], #si-align-opts[hidden], #si-bg-field[hidden] { display: none; }
#si-grid-opts .xd-label, #si-align-opts .xd-label { margin: 4px 0 -2px; }
.si-swatch { display: inline-block; width: 12px; height: 12px; margin: 0 2px -2px; border: 1px solid #555; border-radius: 3px; }
#si-cell-menu { z-index: 2700; min-width: 0; } /* (over the Import window) */
/* the result, playing: a small window over everything (bottom right of the sheet at first), dragged anywhere
   on the screen; the sheet stays centred under it */
#sheet-dialog .xd-preview { overflow: hidden; }
#si-view { position: relative; }
#si-canvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; }
/* zoom: − Fit + and the percent */
#si-zoom { flex-shrink: 0; }
#si-zoom .btn { display: flex; align-items: center; justify-content: center; min-width: 30px; padding: 0 8px; }
#si-zoom .btn:disabled { color: #555; background: #222; cursor: default; }
#si-zoom-label { min-width: 3.4em; color: #777; font-size: 0.72rem; font-variant-numeric: tabular-nums; }
.si-result { position: fixed; z-index: 2450; width: 184px; padding: 10px; display: flex; flex-direction: column; align-items: center; gap: 4px;
  background: #1a1a1ae8; border: 1px solid #333; border-radius: 8px; box-shadow: 0 6px 20px #0008; text-align: center; cursor: grab; touch-action: none; user-select: none; }
.si-result[hidden] { display: none; }
.si-result.dragging { cursor: grabbing; border-color: #4a7fcb; }
.si-result-hide { position: absolute; top: 4px; right: 4px; width: 20px; height: 20px; padding: 0; display: flex; align-items: center; justify-content: center;
  background: none; border: none; border-radius: 4px; color: #888; cursor: pointer; }
.si-result-hide:hover { background: #ffffff14; color: #e0e0e0; }
#si-preview-toggle { height: 30px; }
#si-anim { flex-shrink: 0; margin-bottom: 4px; image-rendering: pixelated; box-shadow: 0 0 0 1px #333; }
#si-count { font-size: 0.85rem; }
#si-note { line-height: 1.4; }
#si-note.xd-warn { color: #e5a050; }
/* each row its own animation */
#si-anims-field, #si-split-opts { display: flex; flex-direction: column; gap: 8px; }
#si-anims-field[hidden], #si-split-opts[hidden] { display: none; }
#si-anims-field .xd-label { margin-bottom: -2px; }
#si-split-opts .xd-label { margin-top: 2px; }
#si-anims-note { line-height: 1.4; }
#si-anims-note:empty { display: none; }
#si-lines { display: flex; flex-direction: column; gap: 2px; }
.si-line { display: flex; align-items: center; gap: 8px; padding: 3px 6px; border: 1px solid transparent; border-radius: 5px; cursor: pointer; }
.si-line:hover { background: #222; }
.si-line.sel { border-color: #4a7fcb; background: #4a7fcb1a; }
.si-line.off canvas, .si-line.off .si-line-name, .si-line.off .si-line-count { opacity: 0.4; }
.si-line input[type="checkbox"] { margin: 0; accent-color: #4a7fcb; cursor: pointer; }
.si-line canvas { width: 32px; height: 32px; flex-shrink: 0; image-rendering: pixelated; box-shadow: 0 0 0 1px #333; background-size: 8px 8px; }
.si-line-name { flex: 1; min-width: 0; height: 24px; padding: 0 7px; background: #222; color: #e0e0e0; border: 1px solid #3a3a3a; border-radius: 4px; font: inherit; }
.si-line-name:focus { outline: none; border-color: #4a7fcb; }
.si-line-name::placeholder { color: #777; }
.si-line-count { min-width: 18px; text-align: right; color: #888; font-size: 0.72rem; font-variant-numeric: tabular-nums; }
#si-import:disabled { opacity: 0.45; cursor: default; }
@media (max-width: 760px) {
  #si-hint { display: none; }
  #si-zoom-label { margin-right: auto; } /* (the hint hidden: the percent pushes Cancel / Import to the right) */
  #sheet-dialog .xd-foot { gap: 5px; padding: 10px; }
  #sheet-dialog .xd-foot > .btn { padding: 0 10px; }
  #si-zoom .btn { min-width: 26px; padding: 0 6px; }
  .si-result { width: 92px; padding: 6px; } /* (phones: smaller) */
  #si-count, #si-note { font-size: 0.66rem; }
}
