:root {
  color-scheme: light;
  --panel-bg: rgba(247, 247, 247, 0.78);
  --panel-border: #d7d7d7;
  --text: #1f1f1f;
  --muted: #666;
  --accent: #2f7df6;
  --soft-yellow: #e8dc87;
  --soft-yellow-border: #c9bb5d;
  --soft-yellow-text: #4b4100;
  --canvas-bg: #ffffff;
}

* {
  box-sizing: border-box;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

*::-webkit-scrollbar {
  width: 0;
  height: 0;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
}

body {
  font-family: "VT323", "Courier New", "Lucida Console", monospace;
  color: var(--text);
  overflow: hidden;
  background: var(--canvas-bg);
}

button,
input {
  font-family: inherit;
}

#viewport {
  position: fixed;
  inset: 0;
  background: var(--canvas-bg);
  cursor: crosshair;
  touch-action: none;
  user-select: none;
}

#viewport.is-panning {
  cursor: grabbing;
}

#viewport.is-drawing {
  cursor: none;
}

#viewport.is-erasing {
  cursor: none;
}

#viewport.is-erasing.is-panning {
  cursor: grabbing;
}

#world {
  position: absolute;
  inset: 0;
  transform-origin: 0 0;
}

#eraseCursor {
  position: fixed;
  left: 0;
  top: 0;
  width: 18px;
  height: 18px;
  border: 1px solid rgba(0, 0, 0, 0.92);
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.08);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.24);
  pointer-events: none;
  z-index: 35;
  display: none;
  transform: translate3d(-9999px, -9999px, 0);
  will-change: transform, width, height;
}

#eraseCursor.is-visible {
  display: block;
}

#shortcutPreview {
  position: fixed;
  left: 0;
  top: 0;
  width: 0;
  height: 0;
  display: none;
  pointer-events: none;
  user-select: none;
  z-index: 36;
  opacity: 0;
}

#shortcutPreview.is-visible {
  display: block;
}

#shapePreview {
  position: fixed;
  left: 0;
  top: 0;
  display: none;
  pointer-events: none;
  z-index: 34;
  border: 1px dashed #111;
  background: rgba(47, 125, 246, 0.08);
  transform-origin: 0 50%;
}

#shapePreview.is-visible {
  display: block;
}

#shapePreview.is-line {
  height: 0;
  border: 0;
  border-top: 1px dashed #111;
  background: transparent;
}

#shapePreview.is-circle {
  border-radius: 50%;
}

#filterDefs {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
  pointer-events: none;
}

.stamp {
  position: absolute;
  display: block;
  pointer-events: none;
  user-select: none;
  contain: layout paint style;
}

.stamp.is-culled {
  visibility: hidden;
}

.trail-stamp {
  position: absolute;
  display: block;
  pointer-events: none;
  user-select: none;
  opacity: var(--trail-start-opacity, 1);
  animation: trail-fade 4s linear forwards;
}

@keyframes trail-fade {
  from {
    opacity: var(--trail-start-opacity, 1);
  }
  to {
    opacity: 0;
  }
}

#controls {
  position: fixed;
  top: 14px;
  right: 14px;
  z-index: 10;
  width: min(290px, calc(100vw - 28px));
  max-height: calc(100vh - 28px);
  overflow: auto;
  padding: 12px;
  padding-top: 30px;
  border: 1px solid var(--panel-border);
  border-radius: 0;
  background: var(--panel-bg);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  -webkit-user-select: none;
  user-select: none;
}

#controls * {
  -webkit-user-select: none;
  user-select: none;
}

#sidebarToggleButton {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 16px;
  height: 16px;
  border: 1px solid #d0d0d0;
  background: #f2f2f2;
  border-radius: 0;
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.78;
}

#sidebarOptionsButton {
  position: absolute;
  top: 6px;
  right: 26px;
  width: 16px;
  height: 16px;
  border: 1px solid #d0d0d0;
  background: #f2f2f2;
  border-radius: 0;
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.78;
}

#sidebarOptionsButton.is-active {
  background: #e6e6e6;
}

.options-icon {
  position: relative;
  display: block;
  width: 2px;
  height: 2px;
  background: #6f6f6f;
}

.options-icon::before,
.options-icon::after {
  content: "";
  position: absolute;
  top: 0;
  width: 2px;
  height: 2px;
  background: #6f6f6f;
}

.options-icon::before {
  left: -4px;
}

.options-icon::after {
  left: 4px;
}

.chevron-icon {
  display: block;
  width: 5px;
  height: 5px;
  border-right: 1px solid #6f6f6f;
  border-bottom: 1px solid #6f6f6f;
  transform-origin: 50% 50%;
  transform: translateY(0.5px) rotate(-135deg);
}

#controls.is-collapsed .chevron-icon {
  transform: translateY(0.5px) rotate(45deg);
}

#controls.is-collapsed {
  width: 28px;
  height: 28px;
  max-height: 28px;
  overflow: hidden;
  padding: 0;
}

#controls.is-collapsed > :not(#sidebarToggleButton) {
  display: none;
}

#controls.is-collapsed #sidebarToggleButton {
  border-color: transparent;
  background: transparent;
  opacity: 0.62;
}

#settingsPanel {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

#settingsPanel[hidden] {
  display: none;
}

#settingsTitle {
  margin: 0;
  font-size: 16px;
  text-transform: lowercase;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

#canvasBgColorInput {
  width: 30px;
  height: 18px;
  border: 1px solid #bcbcbc;
  border-radius: 0;
  background: #fff;
  padding: 0;
  cursor: pointer;
}

.control-group {
  margin-bottom: 10px;
}

.control-label {
  display: block;
  margin-bottom: 5px;
  font-size: 13px;
  text-transform: lowercase;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.inline-label {
  margin: 0;
}

.brush-data-toggle {
  width: fit-content;
  max-width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 4px;
  cursor: pointer;
  text-align: left;
}

.brush-data-toggle::after {
  content: "";
  display: block;
  width: 5px;
  height: 5px;
  border-right: 1px solid #6f6f6f;
  border-bottom: 1px solid #6f6f6f;
  transform: translateY(2px) rotate(-135deg);
  transform-origin: 50% 50%;
  margin-top: -1px;
}

.brush-data-toggle.is-collapsed::after {
  transform: translateY(-1px) rotate(45deg);
}

.brush-data-toggle:focus-visible {
  outline: 1px solid #000;
  outline-offset: 2px;
}

.slider-toggle-label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  width: fit-content;
  cursor: pointer;
}

.slider-toggle-label::after {
  content: "";
  display: block;
  width: 5px;
  height: 5px;
  border-right: 1px solid #6f6f6f;
  border-bottom: 1px solid #6f6f6f;
  transform: translateY(2px) rotate(-135deg);
  transform-origin: 50% 50%;
  margin-top: -1px;
}

.is-slider-collapsed .slider-toggle-label::after {
  transform: translateY(-1px) rotate(45deg);
}

.is-slider-collapsed > input[type="range"],
.is-slider-collapsed > .value-text {
  display: none;
}

#sizeScaleGroup.is-slider-collapsed + #consistentControlGroup {
  display: none;
}

.slider-toggle-label:focus-visible {
  outline: 1px solid #000;
  outline-offset: 2px;
}

#cursorTrailToggleRow {
  margin-top: 4px;
}

#consistentSizeGroup {
  margin-top: 8px;
}

#sizeScaleGroup.is-disabled .value-text {
  opacity: 0.45;
}

#cursorTrailCountGroup {
  margin-top: 6px;
}

#cursorTrailCountGroup.is-disabled .value-text {
  opacity: 0.45;
}

.settings-toggle-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

#drawModeGroup {
  margin-top: -2px;
}

#drawModeButtons {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 4px;
}

.draw-mode-button {
  min-width: 0;
  height: 24px;
  padding: 0;
  border: 1px solid #bcbcbc;
  border-radius: 0;
  background: #fff;
  cursor: pointer;
  display: grid;
  place-items: center;
}

.draw-mode-button.is-active {
  background: #e6e6e6;
  border-color: #8e8e8e;
}

.draw-mode-icon {
  display: block;
  width: 19px;
  height: 19px;
  overflow: visible;
}

.draw-mode-icon * {
  vector-effect: non-scaling-stroke;
}

.draw-mode-icon .icon-shadow {
  fill: rgba(0, 0, 0, 0.16);
  stroke: none;
}

.draw-mode-icon .icon-shadow-stroke {
  fill: none;
  stroke: rgba(0, 0, 0, 0.2);
  stroke-width: 2.6;
  stroke-linecap: round;
}

.draw-mode-icon .icon-dark {
  fill: none;
  stroke: #111;
  stroke-width: 1.25;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.draw-mode-icon .icon-dark-fill {
  fill: #111;
  stroke: none;
}

.draw-mode-icon .icon-metal {
  fill: #dce3ee;
  stroke: #111;
  stroke-width: 1.1;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.draw-mode-icon .icon-gold {
  fill: #e5bb59;
  stroke: none;
}

.draw-mode-icon .icon-blue {
  fill: #78b4ff;
  stroke: none;
}

.draw-mode-icon .icon-blue-soft {
  fill: rgba(120, 180, 255, 0.42);
  stroke: none;
}

.draw-mode-icon .icon-blue-stroke {
  fill: none;
  stroke: #2e7df7;
  stroke-width: 2.45;
  stroke-linecap: round;
}

.draw-mode-icon .icon-light,
.draw-mode-icon .icon-highlight {
  fill: none;
  stroke: rgba(255, 255, 255, 0.88);
  stroke-width: 1.05;
  stroke-linecap: round;
}

.draw-mode-icon .icon-tip {
  fill: #111;
  stroke: none;
}

.draw-mode-icon .icon-dot {
  fill: #2e7df7;
  stroke: #111;
  stroke-width: 0.75;
}

.draw-mode-icon .icon-handle {
  fill: #fff;
  stroke: #111;
  stroke-width: 1;
  stroke-linejoin: round;
}

#spraySpreadGroup {
  margin-top: 6px;
}

#spraySpreadGroup[hidden] {
  display: none;
}

#tintGroup {
  position: relative;
}

#tintPickerButton {
  width: 28px;
  height: 18px;
  padding: 0;
  border: 1px solid #bcbcbc;
  border-radius: 0;
  background: #fff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

#tintSwatch {
  width: 20px;
  height: 10px;
  border: 1px solid #bcbcbc;
  border-radius: 0;
  background: #fff;
}

#tintPopover {
  position: absolute;
  right: 0;
  top: calc(100% - 4px);
  width: min(180px, 100%);
  padding: 8px;
  border: 1px solid #bcbcbc;
  border-radius: 0;
  background: #fff;
  z-index: 26;
}

#tintPopover[hidden] {
  display: none;
}

#tintColorInput {
  width: 100%;
  height: 24px;
  border: 1px solid #bcbcbc;
  border-radius: 0;
  background: #fff;
  padding: 2px;
  cursor: pointer;
  margin-bottom: 6px;
}

#tintAmountSlider + .value-text {
  margin-top: -2px;
}

.ios-switch {
  position: relative;
  width: 34px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  cursor: pointer;
}

.ios-switch input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.ios-switch-slider {
  position: absolute;
  inset: 0;
  border-radius: 0;
  background: #d2d2d7;
  transition: background-color 0.18s ease;
}

.ios-switch-slider::before {
  content: "";
  position: absolute;
  width: 14px;
  height: 14px;
  top: 2px;
  left: 2px;
  border-radius: 0;
  background: #fff;
  transition: transform 0.18s ease;
}

.ios-switch input:checked + .ios-switch-slider {
  background: var(--soft-yellow);
}

.ios-switch input:checked + .ios-switch-slider::before {
  transform: translateX(16px);
}

.ios-switch input:focus-visible + .ios-switch-slider {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.ios-switch-neutral input:checked + .ios-switch-slider {
  background: #d2d2d7;
}

#rotationIndicator {
  position: relative;
  width: 24px;
  height: 24px;
  border: 1px solid #8f8f8f;
  border-radius: 50%;
  background: #fff;
  flex: 0 0 auto;
  transform: translateY(-3px);
  cursor: grab;
  touch-action: none;
}

#rotationIndicator.is-dragging {
  cursor: grabbing;
}

#rotationNeedle {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 1px;
  height: 10px;
  background: #303030;
  transform-origin: 50% 100%;
  transform: translate(-50%, -100%) rotate(0deg);
}

#dropZone {
  width: 100%;
  min-height: 72px;
  padding: 9px;
  border: 1px dashed #9f9f9f;
  border-radius: 0;
  background: #fff;
  color: #333;
  font-size: 13px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-align: center;
  line-height: 1.3;
}

#dropZone.is-over {
  border-color: var(--accent);
  background: #edf5ff;
}

#dropZone.has-gallery {
  height: clamp(170px, calc(39vh - 50px), 250px);
  border-style: solid;
  align-items: stretch;
  justify-content: flex-start;
}

#stockBrushButtons {
  margin-top: 6px;
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 4px;
}

#stockBrushButtons[hidden] {
  display: none;
}

.stock-brush-button {
  min-width: 0;
  aspect-ratio: 1 / 1;
  padding: 2px;
  border: 1px solid #d9d9d9;
  border-radius: 0;
  background: #fff;
  cursor: pointer;
}

.stock-brush-button.is-active {
  border-color: #2f7df6;
  background: #edf5ff;
}

.stock-brush-button.is-loading {
  opacity: 0.62;
  cursor: progress;
}

.stock-brush-button:disabled {
  opacity: 0.52;
  cursor: progress;
}

.stock-brush-icon {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  image-rendering: auto;
  pointer-events: none;
}

#dropZoneHeader {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 24px;
  gap: 4px;
  align-items: stretch;
}

#dropZoneHeader.no-unload {
  grid-template-columns: minmax(0, 1fr);
}

#dropZonePrompt {
  width: auto;
  border-radius: 0;
  padding: 8px 10px;
  cursor: pointer;
  user-select: none;
}

#unloadBrushDataButton {
  width: 24px;
  min-width: 24px;
  min-height: 24px;
  padding: 0;
  border: 1px solid #d9d9d9;
  border-radius: 0;
  background: #fff;
  color: #333;
  cursor: pointer;
  line-height: 1;
  font-size: 12px;
}

#unloadBrushDataButton:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

#dropZonePrompt:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

#dropZone.has-gallery #dropZonePrompt {
  border: 1px solid #d9d9d9;
  background: #f8f8f8;
  font-size: 11px;
  padding: 6px 8px;
}

#dropZone.has-gallery #unloadBrushDataButton {
  background: #f8f8f8;
  font-size: 11px;
}

#brushGallery {
  width: 100%;
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  overflow-y: auto;
  padding-right: 1px;
  scrollbar-width: none;
}

#brushGallery[hidden] {
  display: none;
}

#brushGallery::-webkit-scrollbar {
  width: 0;
  height: 0;
  display: none;
}

#brushGallery::-webkit-scrollbar-thumb {
  background: #9eb2d1;
  border-radius: 0;
}

.brush-item {
  border: 1px solid #d9d9d9;
  border-radius: 0;
  background: #fff;
  padding: 4px;
}

.brush-item.is-disabled {
  opacity: 0.76;
}

.brush-item.is-solo {
  border-color: #2f7df6;
}

.brush-item.is-solo-muted {
  opacity: 0.45;
}

.brush-thumb {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: contain;
  display: block;
  border: 1px solid #ececec;
  border-radius: 0;
  background: #f7f7f7;
  cursor: pointer;
}

.brush-name {
  margin: 4px 0 0;
  font-size: 9px;
  line-height: 1.25;
  color: #4f4f4f;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brush-actions {
  margin-top: 3px;
  display: flex;
  gap: 3px;
}

.brush-action-button {
  flex: 1;
  border: 1px solid #bac3d3;
  border-radius: 0;
  background: #edf1f8;
  color: #324359;
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  padding: 4px 0;
  min-height: 23px;
  box-shadow: none;
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease, opacity 0.12s ease;
}

.brush-action-button[data-action="toggle-enabled"] {
  font-size: 13px;
  position: relative;
}

.brush-action-button[data-action="weight-low"],
.brush-action-button[data-action="weight-high"] {
  font-weight: 700;
}

.brush-action-button[data-action="crop"] {
  font-size: 11px;
  font-weight: 700;
}

.brush-action-button:not(.is-active) {
  opacity: 0.78;
}

.brush-action-button:hover {
  background: #e1e8f2;
}

.brush-action-button:active {
  background: #d7e0ec;
}

.brush-action-button.is-active {
  opacity: 1;
  color: #fff;
  border-color: #3b7de4;
  background: #2f7df6;
  box-shadow: none;
}

.brush-action-button.is-active[data-action="toggle-enabled"] {
  background: #2f7df6;
  border-color: #3278e8;
}

.brush-action-button[data-action="toggle-enabled"]:not(.is-active) {
  border-color: #c2b8bc;
  background: #ece7e8;
  color: #7e6a73;
}

.brush-action-button[data-action="toggle-enabled"].is-solo {
  border-color: #1f4ea0;
  background: #1f4ea0;
  color: #fff;
}

.brush-action-button[data-action="toggle-enabled"]:not(.is-active)::after {
  content: "";
  position: absolute;
  width: 13px;
  height: 2px;
  top: 50%;
  left: 50%;
  margin-left: -6.5px;
  margin-top: -1px;
  border-radius: 0;
  background: #8f7480;
  transform: rotate(-30deg);
}

.brush-action-button.is-active[data-action="weight-low"] {
  color: var(--soft-yellow-text);
  background: var(--soft-yellow);
  border-color: var(--soft-yellow-border);
  box-shadow: none;
}

.brush-action-button.is-active[data-action="weight-high"] {
  color: var(--soft-yellow-text);
  background: var(--soft-yellow);
  border-color: var(--soft-yellow-border);
  box-shadow: none;
}

#brushInput {
  display: none;
}

#brushStatus {
  display: none;
}

input[type="range"] {
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
  height: 16px;
  cursor: grab;
}

input[type="range"]:active {
  cursor: grabbing;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 2px;
  background: #000;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 10px;
  height: 10px;
  margin-top: -4px;
  border: 0;
  border-radius: 0;
  background: #000;
  cursor: grab;
}

input[type="range"]:active::-webkit-slider-thumb {
  cursor: grabbing;
}

input[type="range"]::-moz-range-track {
  height: 2px;
  border: 0;
  background: #000;
}

input[type="range"]::-moz-range-progress {
  height: 2px;
  background: #000;
}

input[type="range"]::-moz-range-thumb {
  width: 10px;
  height: 10px;
  border: 0;
  border-radius: 0;
  background: #000;
  cursor: grab;
}

input[type="range"]:active::-moz-range-thumb {
  cursor: grabbing;
}

input[type="range"]:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

input[type="range"]:disabled::-webkit-slider-thumb,
input[type="range"]:disabled::-moz-range-thumb {
  cursor: not-allowed;
}

.value-text {
  margin: 3px 0 0;
  font-size: 12px;
  color: var(--muted);
}

input[type="range"] + .value-text {
  margin-top: -2px;
}

#eraseModeButton,
#undoButton,
#redoButton,
#clearButton,
#exportButton,
#exportCancelButton,
#gifPauseButton {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #bcbcbc;
  border-radius: 0;
  background: #fff;
  color: #111;
  font-size: 14px;
  cursor: pointer;
}

#eraseModeButton {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 6px;
}

#eraseModeButton .button-icon {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  display: block;
}

#eraseModeButton .erase-icon-image {
  image-rendering: auto;
  transform: translateY(-1px);
}

#eraseModeButton.is-active {
  background: #e6e6e6;
}

#exportButton.is-active {
  background: #e6e6e6;
}

#gifPauseButton {
  margin-top: 6px;
  height: 34px;
  display: grid;
  place-items: center;
}

#gifPauseButton.is-paused {
  background: #e6e6e6;
}

.gif-pause-symbol {
  position: relative;
  display: block;
  width: 14px;
  height: 16px;
}

.gif-pause-symbol::before,
.gif-pause-symbol::after {
  content: "";
  position: absolute;
  top: 2px;
  width: 4px;
  height: 12px;
  background: #111;
}

.gif-pause-symbol::before {
  left: 2px;
}

.gif-pause-symbol::after {
  right: 2px;
}

#gifPauseButton.is-paused .gif-pause-symbol::before {
  left: 3px;
  top: 1px;
  width: 0;
  height: 0;
  border-top: 7px solid transparent;
  border-bottom: 7px solid transparent;
  border-left: 10px solid #111;
  background: transparent;
}

#gifPauseButton.is-paused .gif-pause-symbol::after {
  display: none;
}

#historyActions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
}

#historyActions > button {
  min-width: 0;
  padding: 6px 4px;
  font-size: 12px;
  line-height: 1;
}

#undoButton {
  grid-column: 1;
}

#redoButton {
  grid-column: 2;
}

#clearButton {
  grid-column: 3;
  margin-top: 0;
}

#undoButton:disabled,
#redoButton:disabled,
#clearButton:disabled,
#exportButton:disabled,
#exportCancelButton:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

#exportButton {
  margin-top: 0;
}

#exportButton.is-loading {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

#exportButton.is-loading::before {
  content: "";
  width: 9px;
  height: 9px;
  border: 1px solid #111;
  border-right-color: transparent;
  border-radius: 50%;
  animation: export-button-spin 0.72s linear infinite;
}

#exportActions {
  margin-top: 6px;
}

#exportActions.is-active {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 28px;
  gap: 6px;
}

#exportActions.is-active #exportButton {
  margin-top: 0;
}

#exportCancelButton {
  width: 28px;
  min-width: 28px;
  padding: 0;
  line-height: 1;
  font-size: 14px;
}

#exportCancelButton[hidden] {
  display: none;
}

@keyframes export-button-spin {
  to {
    transform: rotate(360deg);
  }
}

#clearConfirmModal {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(0, 0, 0, 0.28);
}

#clearConfirmModal.is-open {
  display: flex;
}

#clearConfirmDialog {
  width: min(360px, 100%);
  border-radius: 12px;
  border: 1px solid #d4d4d4;
  background: #fff;
  padding: 14px;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.16);
}

#clearConfirmMessage {
  margin: 0;
  font-size: 15px;
  line-height: 1.35;
}

.confirm-actions {
  margin-top: 12px;
  display: flex;
  gap: 8px;
}

#confirmYesButton,
#confirmNoButton {
  flex: 1;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid #bcbcbc;
  background: #fff;
  color: #111;
  font-size: 14px;
  cursor: pointer;
}

#confirmYesButton {
  border-color: #5ca170;
}

#confirmNoButton {
  border-color: #bb7a7a;
}

#brushCropModal {
  position: fixed;
  inset: 0;
  z-index: 31;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 14px;
  background: rgba(0, 0, 0, 0.2);
}

#brushCropModal.is-open {
  display: flex;
}

#brushCropDialog {
  width: min(620px, calc(100vw - 24px));
  max-height: calc(100vh - 28px);
  border: 1px solid #d4d4d4;
  border-radius: 0;
  background: #fff;
  padding: 10px;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 8px;
}

#brushCropStageWrap {
  min-height: 230px;
  border: 1px solid #d8d8d8;
  background: #fff;
  display: grid;
  place-items: center;
  overflow: auto;
}

#brushCropStage {
  position: relative;
  display: inline-block;
  line-height: 0;
}

#brushCropImage {
  display: block;
  max-width: min(580px, calc(100vw - 62px));
  max-height: min(62vh, 700px);
  width: auto;
  height: auto;
  user-select: none;
  -webkit-user-drag: none;
  pointer-events: none;
  image-rendering: auto;
}

.brush-crop-shade {
  position: absolute;
  background: rgba(255, 255, 255, 0.42);
  pointer-events: none;
}

#brushCropSelection {
  position: absolute;
  border: 1px dashed #111;
  background: transparent;
  cursor: move;
}

.brush-crop-edge {
  position: absolute;
  background: transparent;
  z-index: 1;
}

.brush-crop-edge[data-edge="top"] {
  top: -7px;
  left: 0;
  width: 100%;
  height: 14px;
  cursor: ns-resize;
}

.brush-crop-edge[data-edge="bottom"] {
  bottom: -7px;
  left: 0;
  width: 100%;
  height: 14px;
  cursor: ns-resize;
}

.brush-crop-edge[data-edge="left"] {
  left: -7px;
  top: 0;
  width: 14px;
  height: 100%;
  cursor: ew-resize;
}

.brush-crop-edge[data-edge="right"] {
  right: -7px;
  top: 0;
  width: 14px;
  height: 100%;
  cursor: ew-resize;
}

.brush-crop-edge[data-edge="top-left"] {
  left: -7px;
  top: -7px;
  width: 14px;
  height: 14px;
  cursor: nwse-resize;
  z-index: 2;
}

.brush-crop-edge[data-edge="top-right"] {
  right: -7px;
  top: -7px;
  width: 14px;
  height: 14px;
  cursor: nesw-resize;
  z-index: 2;
}

.brush-crop-edge[data-edge="bottom-right"] {
  right: -7px;
  bottom: -7px;
  width: 14px;
  height: 14px;
  cursor: nwse-resize;
  z-index: 2;
}

.brush-crop-edge[data-edge="bottom-left"] {
  left: -7px;
  bottom: -7px;
  width: 14px;
  height: 14px;
  cursor: nesw-resize;
  z-index: 2;
}

.brush-crop-actions {
  margin-top: 0;
}

#exportOverlay {
  position: fixed;
  inset: 0;
  z-index: 8;
  pointer-events: auto;
}

#exportOverlay[hidden] {
  display: none;
}

.export-shade {
  position: fixed;
  background: rgba(0, 0, 0, 0.22);
  pointer-events: auto;
}

#exportSelection {
  position: fixed;
  border: 1px dashed #111;
  background: transparent;
  pointer-events: auto;
  cursor: move;
}

.export-edge-handle {
  position: absolute;
  background: transparent;
  z-index: 1;
}

.export-edge-handle[data-edge="top"] {
  top: -7px;
  left: 0;
  width: 100%;
  height: 14px;
  cursor: ns-resize;
}

.export-edge-handle[data-edge="bottom"] {
  bottom: -7px;
  left: 0;
  width: 100%;
  height: 14px;
  cursor: ns-resize;
}

.export-edge-handle[data-edge="left"] {
  left: -7px;
  top: 0;
  width: 14px;
  height: 100%;
  cursor: ew-resize;
}

.export-edge-handle[data-edge="right"] {
  right: -7px;
  top: 0;
  width: 14px;
  height: 100%;
  cursor: ew-resize;
}

.export-edge-handle[data-edge="top-left"] {
  left: -7px;
  top: -7px;
  width: 14px;
  height: 14px;
  cursor: nwse-resize;
  z-index: 2;
}

.export-edge-handle[data-edge="top-right"] {
  right: -7px;
  top: -7px;
  width: 14px;
  height: 14px;
  cursor: nesw-resize;
  z-index: 2;
}

.export-edge-handle[data-edge="bottom-right"] {
  right: -7px;
  bottom: -7px;
  width: 14px;
  height: 14px;
  cursor: nwse-resize;
  z-index: 2;
}

.export-edge-handle[data-edge="bottom-left"] {
  left: -7px;
  bottom: -7px;
  width: 14px;
  height: 14px;
  cursor: nesw-resize;
  z-index: 2;
}

#exportMeta {
  position: fixed;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  pointer-events: auto;
}

#exportResolutionControls {
  display: flex;
  align-items: center;
  gap: 4px;
  color: #111;
  font-size: 13px;
  line-height: 1;
}

#exportWidthInput,
#exportHeightInput {
  width: 62px;
  padding: 3px 5px;
  border: 1px solid #111;
  border-radius: 0;
  background: rgba(255, 255, 255, 0.92);
  color: #111;
  font-size: 13px;
  line-height: 1;
  text-align: center;
  appearance: textfield;
  -moz-appearance: textfield;
}

#exportWidthInput::-webkit-outer-spin-button,
#exportWidthInput::-webkit-inner-spin-button,
#exportHeightInput::-webkit-outer-spin-button,
#exportHeightInput::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

#exportWidthInput:focus,
#exportHeightInput:focus {
  outline: 2px solid #111;
  outline-offset: 1px;
}

#exportResolutionSeparator {
  padding: 0 1px;
  color: #111;
}

#exportScaleButtons {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 4px;
}

.export-scale-button {
  min-width: 44px;
  padding: 4px 6px;
  border: 1px solid #111;
  border-radius: 0;
  background: rgba(255, 255, 255, 0.92);
  color: #111;
  font-size: 12px;
  cursor: pointer;
}

.export-scale-button.is-active {
  background: #111;
  color: #fff;
}
