﻿:root {
  color-scheme: light;
  font-family: "PixelFont", "Segoe UI", "Microsoft YaHei", system-ui, sans-serif;
  --accent: #3652f5;
  --border: #d8dbe5;
  --bg: #f5f6fb;
  --panel-bg: #ffffff;
  --text: #1f1f2d;
  --muted: #6f7285;
  --link: #fc72e9;
  --shadow: 0 0.6rem 1.6rem rgba(31, 31, 45, 0.12)
}

::before,
*::after {
  box-sizing: border-box
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: inherit
}

a {
  color: inherit;
  text-decoration: none
}

a:hover {
  text-decoration: underline
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit
}

button {
  padding: 0.45rem 0.9rem;
  border-radius: 0.6rem;
  border: 1px solid var(--border);
  background: var(--panel-bg);
  color: var(--text);
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 2px 8px rgba(31, 31, 45, 0.08)
}

button:hover:not(:disabled):not(.dropdown-item) {
  border-color: var(--accent);
  box-shadow: 0 4px 15px rgba(54, 82, 245, 0.2);
  transform: translateY(-1px)
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed
}

input[type="number"],
input[type="search"],
select,
textarea {
  width: 100%;
  padding: 0.45rem 0.6rem;
  border-radius: 0.55rem;
  border: 1px solid var(--border);
  background: var(--panel-bg)
}

input[type="search"] {
  padding-right: 2rem
}

input[type="range"] {
  width: 140px
}

.app-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh
}

.app-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1.2rem;
  padding: 1.4rem 2.2rem 1.2rem;
  background: var(--panel-bg);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 0.4rem 1rem rgba(31, 31, 45, 0.05)
}

.header-text {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  text-align: left;
  flex: 1
}

.app-header h1 {
  margin: 0 0 0.35rem;
  font-size: 1.65rem;
  letter-spacing: 0.04em;
  text-align: left
}

.app-header p {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
  text-align: left
}

.header-right {
  display: flex;
  align-items: center;
  gap: 0.8rem
}

.icon-btn {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.6rem 1rem;
  border-radius: 0.8rem;
  border: 1px solid var(--border);
  background: var(--panel-bg);
  color: var(--text);
  font-weight: 600;
  font-size: 0.9rem;
  transition: all 0.3s ease;
  box-shadow: 0 2px 8px rgba(31, 31, 45, 0.08)
}

.icon-btn:hover:not(:disabled) {
  border-color: var(--accent);
  box-shadow: 0 4px 15px rgba(54, 82, 245, 0.2);
  transform: translateY(-1px)
}

.btn-icon {
  width: 16px;
  height: 16px;
  stroke: currentColor
}

.app-main {
  flex: 1;
  display: flex;
  gap: 1.5rem;
  padding: 1.4rem 2.2rem 2rem;
  min-height: 0
}

.canvas-pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0
}

.canvas-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.9rem
}

.toolbar-section {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.6rem
}

.tool-toggle {
  display: inline-flex;
  border-radius: 0.6rem;
  border: 1px solid var(--border);
  overflow: hidden
}

.tool-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 0.8rem;
  border: none;
  border-right: 1px solid var(--border);
  background: var(--panel-bg);
  transition: background 0.2s ease, color 0.2s ease;
  color: var(--muted)
}

.tool-btn:hover:not(:disabled) {
  color: var(--accent);
  border-color: var(--border);
  box-shadow: none;
  transform: none
}

.tool-btn.active {
  background: rgba(54, 82, 245, 0.12);
  color: var(--accent);
  font-weight: 600
}

.tool-btn:last-child {
  border-right: none
}

.tool-icon {
  width: 18px;
  height: 18px;
  fill: currentColor;
  transition: fill 0.2s ease
}

#drawingCanvas.eyedropper-tool {
  cursor: copy
}

.tool-btn.active[data-tool="eyedropper"] {
  background: rgba(54, 82, 245, 0.12);
  color: var(--accent);
  font-weight: 600
}

.inline-control {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--muted);
  font-size: 0.92rem;
  user-select: none
}

.zoom-control {
  padding: 0.35rem 0.55rem;
  border-radius: 999px;
  background: #eef0fb;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem
}

.canvas-wrapper {
  position: relative;
  flex: 1;
  min-height: 0;
  border-radius: 0.9rem;
  border: 1px solid var(--border);
  background-image: linear-gradient(45deg, #f1f1f1 25%, transparent 25%), linear-gradient(-45deg, #f1f1f1 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #f1f1f1 75%), linear-gradient(-45deg, transparent 75%, #f1f1f1 75%);
  background-size: 20px 20px;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
  background-repeat: repeat;
  overflow: auto;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 0.9rem;
  box-shadow: var(--shadow)
}

.canvas-stage {
  position: relative;
  display: inline-block;
  transform-origin: 0 0
}

.canvas-stage canvas {
  position: absolute;
  top: 0;
  left: 0
}

#baseCanvas {
  display: none;
  pointer-events: none;
  image-rendering: pixelated;
  border-radius: 0.5rem
}

#drawingCanvas {
  image-rendering: pixelated;
  border-radius: 0.5rem;
  cursor: crosshair
}

#drawingCanvas.bucket-tool {
  cursor: cell
}

#drawingCanvas.base-edit-mode,
#drawingCanvas.is-base-dragging,
#drawingCanvas.is-panning {
  cursor: grabbing
}

.side-pane {
  width: 320px;
  display: flex;
  flex-direction: column;
  gap: 1rem
}

.panel {
  padding: 1.1rem 1.2rem;
  border-radius: 0.85rem;
  background: var(--panel-bg);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 0.9rem
}

.panel h2 {
  margin: 0;
  font-size: 1.05rem
}

.form-row {
  display: flex;
  flex-direction: column;
  gap: 0.35rem
}

.form-row label {
  font-size: 0.9rem;
  color: var(--muted)
}

.resolution-input-group {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.35rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 0.55rem;
  background: var(--panel-bg)
}

.resolution-input-group input {
  flex: 1;
  min-width: 0;
  border: none;
  padding: 0;
  background: transparent;
  text-align: center
}

.resolution-input-group input:focus {
  outline: none
}

.resolution-input-group:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(54, 82, 245, 0.15)
}

.resolution-prefix,
.resolution-suffix {
  color: var(--muted);
  font-size: 0.9rem;
  white-space: nowrap
}

.base-scale-controls {
  display: flex;
  align-items: center;
  gap: 0.75rem
}

.base-scale-controls input[type="range"] {
  flex: 1
}

.base-scale-controls input[type="number"] {
  width: 90px;
  padding: 0.35rem 0.5rem;
  border-radius: 0.55rem;
  border: 1px solid var(--border);
  background: var(--panel-bg);
  text-align: center
}

.base-scale-controls input[type="number"]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(54, 82, 245, 0.15)
}

.palette-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.6rem;
  height: 300px;
  overflow-y: auto;
  padding: 0.5rem;
  scrollbar-width: thin;
  scrollbar-color: rgba(54, 82, 245, 0.5) transparent;
  background: linear-gradient(135deg, #f5f7ff 0%, #f0f4ff 100%);
  border-radius: 0.8rem;
  border: 1px solid rgba(54, 82, 245, 0.1)
}

.palette-grid::-webkit-scrollbar {
  width: 8px
}

.palette-grid::-webkit-scrollbar-track {
  background: rgba(54, 82, 245, 0.05);
  border-radius: 4px
}

.palette-grid::-webkit-scrollbar-thumb {
  background: rgba(54, 82, 245, 0.5);
  border-radius: 4px
}

.palette-grid::-webkit-scrollbar-thumb:hover {
  background: rgba(54, 82, 245, 0.7)
}

.palette-item {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0.8rem;
  border-radius: 0.8rem;
  background: white;
  border: 2px solid transparent;
  transition: all 0.3s ease;
  box-shadow: 0 2px 8px rgba(31, 31, 45, 0.08);
  position: relative;
  overflow: hidden;
  min-height: 60px
}

.palette-item::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), #667eea);
  opacity: 0;
  transition: opacity 0.3s ease
}

.palette-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 15px rgba(31, 31, 45, 0.12);
  border-color: rgba(54, 82, 245, 0.2)
}

.palette-item:hover::before {
  opacity: 1
}

.palette-item.active {
  border-color: var(--accent);
  background: rgba(54, 82, 245, 0.08);
  box-shadow: 0 4px 15px rgba(54, 82, 245, 0.15)
}

.palette-item.active::before {
  opacity: 1
}

.palette-swatch {
  width: 40px;
  height: 40px;
  border-radius: 0.6rem;
  border: 2px solid rgba(0, 0, 0, 0.1);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
  flex-shrink: 0
}

.palette-item:hover .palette-swatch {
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15)
}

.palette-swatch::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.2) 0%, transparent 50%);
  border-radius: inherit
}

.palette-meta {
  display: flex;
  flex-direction: column;
  font-size: 0.85rem;
  gap: 0.2rem;
  flex: 1;
  min-width: 0
}

.palette-meta strong {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis
}

.palette-meta span {
  color: var(--muted);
  font-size: 0.8rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis
}

.palette-empty,
.fullscreen-palette-empty {
  text-align: center;
  padding: 1rem 0;
  color: var(--muted);
  font-size: 0.9rem
}

.palette-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
  margin-bottom: 0.5rem
}

.palette-actions button {
  padding: 0.6rem 0.8rem;
  border-radius: 0.6rem;
  font-size: 0.85rem;
  text-align: center;
  transition: all 0.3s ease
}

#paletteFilter {
  padding: 0.7rem 1rem;
  border-radius: 0.8rem;
  border: 2px solid transparent;
  background: white;
  box-shadow: 0 2px 8px rgba(31, 31, 45, 0.08);
  transition: all 0.3s ease;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236f7285' stroke-width='2'%3E%3Cpath d='M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z'%3E%3C/path%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 12px center;
  background-size: 16px;
  padding-left: 2.5rem
}

#paletteFilter:focus {
  border-color: var(--accent);
  box-shadow: 0 4px 15px rgba(54, 82, 245, 0.2);
  outline: none
}

#paletteFilter::placeholder {
  color: var(--muted);
  opacity: 0.7
}

.current-color {
  padding: 0.8rem;
  border-radius: 0.8rem;
  background: var(--panel-bg);
  color: var(--text);
  font-weight: 600;
  text-align: center;
  box-shadow: 0 2px 8px rgba(31, 31, 45, 0.08);
  border: 1px solid var(--border)
}

.current-color .code {
  background: rgba(54, 82, 245, 0.1);
  padding: 0.2rem 0.6rem;
  border-radius: 0.4rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  color: var(--accent)
}

.status-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  font-size: 0.9rem;
  color: var(--muted)
}

.status-list span {
  color: var(--text);
  font-weight: 600
}

.fullscreen-palette {
  display: none;
  margin-top: 1rem;
  padding: 0.75rem;
  border-radius: 0.8rem;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 0.6rem 1.8rem rgba(31, 31, 45, 0.16);
  gap: 0.45rem
}

body.canvas-fullscreen .fullscreen-palette {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(32px, 1fr));
  gap: 0.4rem;
  max-height: 28vh;
  overflow-y: auto
}

.fullscreen-palette button {
  position: relative;
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 0.45rem;
  padding: 0;
  width: 100%;
  aspect-ratio: 1/1;
  background: transparent;
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.2s ease, box-shadow 0.2s ease
}

.fullscreen-palette button .fullscreen-swatch {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 0.35rem;
  border: 1px solid rgba(0, 0, 0, 0.12)
}

.fullscreen-palette button.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(54, 82, 245, 0.35);
  transform: scale(0.96)
}

.base-tool-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.75rem
}

.base-scale-row {
  display: flex;
  flex-direction: column;
  gap: 0.35rem
}

body.resize-modal-open {
  overflow: hidden
}

.resize-overlay {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  background: rgba(17, 22, 34, 0.45);
  backdrop-filter: blur(2px);
  z-index: 1200
}

.resize-overlay.is-visible {
  display: flex
}

.resize-dialog {
  width: clamp(360px, 68vw, 640px);
  border-radius: 1rem;
  background: var(--panel-bg);
  box-shadow: 0 1.2rem 2.6rem rgba(31, 31, 45, 0.28);
  display: flex;
  flex-direction: column;
  padding: 1.6rem;
  gap: 1.2rem;
  position: relative
}

.resize-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem
}

.resize-header h2 {
  margin: 0;
  font-size: 1.25rem;
  color: var(--text)
}

.resize-header button {
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 0.2rem 0.4rem;
  border-radius: 0.45rem;
  transition: background 0.2s ease, color 0.2s ease
}

.resize-header button:hover,
.resize-header button:focus-visible {
  background: rgba(54, 82, 245, 0.08);
  color: var(--accent);
  outline: none
}

.resize-body {
  display: flex;
  flex-direction: column;
  gap: 1.4rem
}

.resize-mode-row {
  display: flex;
  gap: 0.75rem;
  justify-content: center
}

.resize-mode-btn {
  flex: 1;
  padding: 0.65rem 0.8rem;
  border-radius: 0.75rem;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-weight: 600;
  transition: background 0.2s ease, color 0.2s ease, border 0.2s ease
}

.resize-mode-btn.active {
  background: var(--accent);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 0.6rem 1.2rem rgba(54, 82, 245, 0.25)
}

.resize-mode-btn:not(.active):hover,
.resize-mode-btn:not(.active):focus-visible {
  border-color: var(--accent);
  color: var(--accent);
  outline: none
}

.resize-grid {
  display: grid;
  grid-template-columns: auto minmax(320px, 1fr) auto;
  grid-template-rows: auto minmax(320px, 1fr) auto;
  gap: 1.1rem;
  justify-items: center;
  align-items: center
}

.resize-grid-row {
  display: contents
}

.resize-edit-btn[data-side="top"] {
  grid-row: 1;
  grid-column: 2
}

.resize-edit-btn[data-side="left"] {
  grid-row: 2;
  grid-column: 1
}

.resize-edit-btn[data-side="right"] {
  grid-row: 2;
  grid-column: 3
}

.resize-edit-btn[data-side="bottom"] {
  grid-row: 3;
  grid-column: 2
}

.resize-edit-btn {
  min-width: 120px;
  padding: 0.65rem 0.75rem;
  border-radius: 0.9rem;
  border: 1px dashed var(--border);
  background: rgba(54, 82, 245, 0.06);
  color: var(--accent);
  font-weight: 600;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  transition: border 0.2s ease, background 0.2s ease, transform 0.2s ease;
  justify-self: center;
  align-self: center
}

.resize-edit-btn:hover,
.resize-edit-btn:focus-visible {
  border-color: var(--accent);
  background: rgba(54, 82, 245, 0.12);
  transform: translateY(-1px);
  outline: none
}

.resize-edit-value {
  font-size: 0.8rem;
  color: var(--muted)
}

.resize-preview {
  grid-row: 2;
  grid-column: 2;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center
}

.resize-preview-stage {
  position: relative;
  width: clamp(360px, 55vw, 600px);
  max-width: 100%;
  aspect-ratio: 1/1;
  padding: 0.75rem;
  border-radius: 1rem;
  border: 1px solid var(--border);
  background: linear-gradient(45deg, rgba(17, 22, 34, 0.05) 25%, transparent 25%, transparent 75%, rgba(17, 22, 34, 0.05) 75%, rgba(17, 22, 34, 0.05)), linear-gradient(45deg, rgba(17, 22, 34, 0.05) 25%, transparent 25%, transparent 75%, rgba(17, 22, 34, 0.05) 75%, rgba(17, 22, 34, 0.05));
  background-position: 0 0, 12px 12px;
  background-size: 24px 24px;
  background-color: #f7f8ff;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden
}

.resize-preview-wrapper {
  position: relative;
  width: 0;
  height: 0;
  max-width: 100%;
  max-height: 100%;
  transform-origin: center
}

.resize-preview-wrapper::after {
  content: '';
  position: absolute;
  inset: 0;
  border: 1px solid rgba(17, 22, 34, 0.35);
  pointer-events: none
}

.resize-preview-wrapper canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  pointer-events: none
}

.resize-size-summary {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  font-size: 0.85rem;
  color: var(--muted);
  padding: 0 0.5rem
}

.resize-size-label {
  font-weight: 600;
  color: var(--text)
}

.resize-message {
  margin-top: 0.25rem;
  min-height: 1.2rem;
  font-size: 0.85rem;
  color: var(--muted);
  text-align: center
}

.resize-message.error {
  color: #ff4757
}

.resize-message.warning {
  color: #e58e26
}

.resize-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.8rem
}

#fullscreenBaseEditBtn {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 999;
  padding: 0.45rem 0.85rem;
  border-radius: 0.55rem;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.92);
  cursor: pointer;
  display: none;
  font-family: inherit;
  box-shadow: 0 0.3rem 0.9rem rgba(31, 31, 45, 0.18);
  transition: box-shadow 0.2s ease, transform 0.2s ease
}

#fullscreenBaseEditBtn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px
}

#fullscreenBaseEditBtn.active {
  box-shadow: 0 0.9rem 1.6rem rgba(54, 82, 245, 0.45);
  transform: translateY(-2px)
}

#fullscreenBaseEditBtn.is-editing {
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: 0 0 0 2px rgba(54, 82, 245, 0.25)
}

body.canvas-fullscreen {
  overflow: hidden
}

body.canvas-fullscreen .app-shell {
  height: 100vh
}

body.canvas-fullscreen .app-header,
body.canvas-fullscreen .side-pane {
  display: none
}

body.canvas-fullscreen .app-main {
  padding: 1.2rem
}

body.canvas-fullscreen .canvas-pane {
  padding: 0.6rem
}

body.canvas-fullscreen .canvas-wrapper {
  flex: 1;
  width: 100%;
  height: calc(100vh - 3rem);
  margin: 0 auto
}

.reference-window {
  position: fixed;
  top: 24px;
  left: 24px;
  z-index: 1200;
  width: 320px;
  max-width: calc(100vw - 48px);
  max-height: calc(100vh - 48px);
  display: none;
  flex-direction: column;
  background: rgba(255, 255, 255, 0.98);
  border: 1px solid var(--border);
  border-radius: 1rem;
  box-shadow: 0 1rem 2.4rem rgba(31, 31, 45, 0.18);
  backdrop-filter: blur(4px);
  overflow: hidden
}

.reference-window.is-visible {
  display: flex
}

.reference-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  padding: 0.6rem 0.9rem;
  border-bottom: 1px solid var(--border);
  cursor: grab;
  user-select: none
}

.reference-window.is-dragging .reference-header {
  cursor: grabbing
}

.reference-title {
  font-weight: 600;
  color: var(--text)
}

.reference-actions {
  display: flex;
  align-items: center;
  gap: 0.35rem
}

.reference-actions button {
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  font-size: 1.2rem;
  line-height: 1;
  display: grid;
  place-items: center
}

.reference-body {
  padding: 0.8rem;
  overflow: auto;
  flex: 1;
  display: flex;
  flex-direction: column
}

.reference-resizer {
  position: absolute;
  width: 16px;
  height: 16px;
  right: 8px;
  bottom: 8px;
  border-radius: 3px;
  cursor: nwse-resize;
  background: linear-gradient(135deg, transparent 0 40%, rgba(54, 82, 245, 0.65) 40% 60%, transparent 60% 100%);
  opacity: 0.65
}

.reference-window.is-minimized {
  width: 88px !important;
  height: 88px !important;
  border-radius: 1.5rem;
  cursor: grab
}

.reference-window.is-minimized.is-dragging {
  cursor: grabbing
}

.reference-window.is-minimized .reference-body,
.reference-window.is-minimized .reference-resizer {
  display: none
}

.reference-window.is-minimized .reference-header {
  flex-direction: column;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.6rem
}

.reference-window.is-minimized .reference-title {
  display: none
}

.reference-window.is-minimized .reference-actions {
  width: 100%;
  justify-content: center
}

.reference-window.is-minimized .reference-actions button {
  width: 2.4rem;
  height: 2.4rem
}

.reference-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem
}

.reference-item {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  padding: 0.6rem;
  background: var(--panel-bg);
  box-shadow: 0 0.4rem 1rem rgba(31, 31, 45, 0.08)
}

.reference-item header {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  justify-content: space-between;
  font-size: 0.88rem;
  color: var(--muted)
}

.reference-item .name {
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap
}

.reference-item img {
  width: 100%;
  max-height: 220px;
  object-fit: contain;
  border-radius: 0.6rem;
  background: #fafbff
}

.reference-empty {
  text-align: center;
  color: var(--muted);
  font-size: 0.92rem;
  padding: 1rem 0.5rem
}

.reference-delete {
  align-self: flex-end
}

.reference-window .reference-footer {
  margin-top: 0.6rem
}

.reference-window.is-minimized .reference-actions button#referenceMinimizeBtn {
  font-weight: 600
}

.docs-window {
  position: fixed;
  top: 96px;
  right: 32px;
  width: min(420px, calc(100vw - 48px));
  max-height: calc(100vh - 128px);
  background: rgba(255, 255, 255, 0.98);
  border: 1px solid var(--border);
  border-radius: 1rem;
  box-shadow: 0 1rem 2.4rem rgba(31, 31, 45, 0.18);
  display: none;
  flex-direction: column;
  backdrop-filter: blur(4px);
  z-index: 1300
}

.docs-window.is-visible {
  display: flex
}

.docs-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  gap: 0.6rem
}

.docs-title {
  font-weight: 600;
  font-size: 1.05rem;
  color: var(--text)
}

.docs-header button {
  border: none;
  background: transparent;
  font-size: 1.25rem;
  cursor: pointer;
  line-height: 1;
  padding: 0.2rem;
  border-radius: 0.45rem;
  transition: background 0.2s ease, transform 0.2s ease
}

.docs-header button:hover {
  background: rgba(54, 82, 245, 0.12);
  transform: scale(1.05)
}

.docs-header button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px
}

.docs-body {
  padding: 1rem;
  overflow: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 0.95rem;
  color: var(--text)
}

.docs-body a {
  color: var(--link);
  text-decoration: underline
}

.docs-markdown {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word
}

.update-window {
  position: fixed;
  top: 96px;
  right: 32px;
  width: min(420px, calc(100vw - 48px));
  max-height: calc(100vh - 128px);
  background: rgba(255, 255, 255, 0.98);
  border: 1px solid var(--border);
  border-radius: 1rem;
  box-shadow: 0 1rem 2.4rem rgba(31, 31, 45, 0.18);
  display: none;
  flex-direction: column;
  backdrop-filter: blur(4px);
  z-index: 1300
}

.update-window.is-visible {
  display: flex
}

.update-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  gap: 0.6rem
}

.update-title {
  font-weight: 600;
  font-size: 1.05rem;
  color: var(--text)
}

.update-header button {
  border: none;
  background: transparent;
  font-size: 1.25rem;
  cursor: pointer;
  line-height: 1;
  padding: 0.2rem;
  border-radius: 0.45rem;
  transition: background 0.2s ease, transform 0.2s ease
}

.update-header button:hover {
  background: rgba(54, 82, 245, 0.12);
  transform: scale(1.05)
}

.update-header button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px
}

.update-body {
  padding: 1rem;
  overflow: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 0.95rem;
  color: var(--text)
}

.update-body a {
  color: var(--link);
  text-decoration: underline
}

.update-content {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word
}

.update-content h1 {
  margin-top: 0;
  font-size: 1.4rem;
  color: var(--accent)
}

.update-content p {
  line-height: 1.6;
  margin-bottom: 1rem
}

.export-window {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(1300px, calc(100vw - 48px));
  height: min(700px, calc(100vh - 48px));
  background: rgba(255, 255, 255, 0.98);
  border: 1px solid var(--border);
  border-radius: 1rem;
  box-shadow: 0 2rem 4rem rgba(31, 31, 45, 0.25);
  display: none;
  flex-direction: column;
  backdrop-filter: blur(8px);
  z-index: 1400;
}

.export-window.is-visible {
  display: flex
}

.export-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  gap: 0.6rem;
  flex-shrink: 0
}

.export-title {
  font-weight: 600;
  font-size: 1.2rem;
  color: var(--text)
}

.export-header button {
  border: none;
  background: transparent;
  font-size: 1.25rem;
  cursor: pointer;
  line-height: 1;
  padding: 0.2rem;
  border-radius: 0.45rem;
  transition: background 0.2s ease, transform 0.2s ease
}

.export-header button:hover {
  background: rgba(54, 82, 245, 0.12);
  transform: scale(1.05)
}

.export-body {
  display: flex;
  flex: 1;
  overflow: hidden;
  gap: 1.5rem;
  padding: 1.5rem;
}

.export-preview-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.export-preview-container h3 {
  margin: 0 0 1rem 0;
  font-size: 1.1rem;
  color: var(--text)
}

.export-preview {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  background: #f8f9fc;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 1rem;
  position: relative;
  cursor: grab;
  min-height: 400px;
}

.preview-controls-hint {
  font-weight: 400
}

.preview-zoom-controls {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  z-index: 10
}

.preview-zoom-controls button {
  width: 2rem;
  height: 2rem;
  border: none;
  background: rgba(255, 255, 255, 0.9);
  border-radius: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  font-weight: bold;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  transition: all 0.2s ease
}

.preview-zoom-controls button:hover {
  background: white;
  transform: scale(1.05)
}

.export-settings {
  width: 320px;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  overflow-y: auto;
  flex-shrink: 0;
}

.export-setting-group {
  display: flex;
  flex-direction: column;
  gap: 1rem
}

.export-setting-group h3 {
  margin: 0;
  font-size: 1.1rem;
  color: var(--text);
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border)
}

.radio-group {
  display: flex;
  flex-direction: column;
  gap: 0.75rem
}

.radio-label {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  background: white;
  cursor: pointer;
  transition: all 0.3s ease;
  user-select: none
}

.radio-label:hover {
  border-color: var(--accent);
  box-shadow: 0 2px 8px rgba(54, 82, 245, 0.1)
}

.radio-label input[type="radio"] {
  margin: 0;
  width: 1.2rem;
  height: 1.2rem
}

.radio-label input[type="radio"]:checked {
  accent-color: var(--accent)
}

.radio-label input[type="radio"]:checked+span {
  color: var(--accent);
  font-weight: 600
}

.color-picker-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem
}

.color-picker-group label {
  font-weight: 600;
  color: var(--text)
}

#exportBackgroundColor {
  width: 100%;
  height: 3rem;
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  cursor: pointer
}

.filename-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem
}

.filename-group label {
  font-weight: 600;
  color: var(--text)
}

#exportFilename {
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  font-size: 0.95rem
}

.filename-suffix {
  font-size: 0.85rem;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  margin-top: 0.25rem
}

.export-footer {
  display: flex;
  justify-content: flex-end;
  gap: 1rem;
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
  flex-shrink: 0
}

.export-footer button {
  padding: 0.75rem 1.5rem;
  border-radius: 0.75rem;
  font-weight: 600;
  min-width: 120px
}

.export-footer button.secondary {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted)
}

.export-footer button.secondary:hover {
  border-color: var(--accent);
  color: var(--accent)
}

.export-footer button.primary {
  background: var(--accent);
  border: 1px solid var(--accent);
  color: white
}

.export-footer button.primary:hover {
  background: #2a42d4;
  border-color: #2a42d4;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(54, 82, 245, 0.3)
}

.export-preview.loading::after {
  content: attr(data-loading-text);
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: var(--muted);
  font-size: 0.9rem
}

.export-progress {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(255, 255, 255, 0.95);
  padding: 1.5rem 2rem;
  border-radius: 1rem;
  box-shadow: 0 1rem 2.4rem rgba(31, 31, 45, 0.25);
  z-index: 2000;
  display: none;
  align-items: center;
  gap: 1rem;
  font-weight: 600;
}

.export-progress.visible {
  display: flex;
}

.export-spinner {
  width: 24px;
  height: 24px;
  border: 3px solid #f3f3f3;
  border-top: 3px solid var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }

  100% {
    transform: rotate(360deg);
  }
}

.export-highlight-panel {
  width: 320px;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  overflow-y: auto;
  border-left: 1px solid var(--border);
  padding-left: 1.5rem;
  flex-shrink: 0;
}

.highlight-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.highlight-controls button {
  padding: 0.4rem 0.8rem;
  font-size: 0.85rem;
  flex: 1;
  min-width: 0;
}

.highlight-search {
  margin-bottom: 1rem;
}

.highlight-search input {
  width: 100%;
  padding: 0.6rem 0.8rem;
  border-radius: 0.6rem;
  border: 1px solid var(--border);
  background: white;
}

.highlight-color-list {
  flex: 1;
  overflow-y: auto;
  max-height: 250px;
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  padding: 0.75rem;
  background: rgba(255, 255, 255, 0.5);
}

.highlight-color-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.8rem;
  border-radius: 0.6rem;
  background: white;
  border: 1px solid var(--border);
  margin-bottom: 0.5rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.highlight-color-item:hover {
  border-color: var(--accent);
  background: rgba(54, 82, 245, 0.05);
}

.highlight-color-item.selected {
  border-color: var(--accent);
  background: rgba(54, 82, 245, 0.1);
}

.highlight-color-checkbox {
  width: 1.2rem;
  height: 1.2rem;
  border: 2px solid var(--border);
  border-radius: 0.35rem;
  background: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.highlight-color-checkbox.checked {
  background: var(--accent);
  border-color: var(--accent);
}

.highlight-color-checkbox.checked::after {
  content: '✓';
  color: white;
  font-size: 0.8rem;
  font-weight: bold;
}

.highlight-color-swatch {
  width: 2rem;
  height: 2rem;
  border-radius: 0.5rem;
  border: 1px solid rgba(0, 0, 0, 0.2);
  flex-shrink: 0;
}

.highlight-color-info {
  flex: 1;
  min-width: 0;
}

.highlight-color-code {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.highlight-color-count {
  font-size: 0.8rem;
  color: var(--muted);
}

.highlight-color-empty {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.highlight-actions {
  margin-top: 1rem;
}

.highlight-actions button {
  width: 100%;
  padding: 0.75rem 1rem;
  border-radius: 0.75rem;
  font-weight: 600;
}

.highlight-message {
  margin-top: 0.75rem;
  padding: 0.6rem 0.8rem;
  border-radius: 0.6rem;
  font-size: 0.85rem;
  text-align: center;
  min-height: 1.2rem;
}

.highlight-message.error {
  background: rgba(255, 71, 87, 0.1);
  color: #ff4757;
  border: 1px solid rgba(255, 71, 87, 0.2);
}

.highlight-message.info {
  background: rgba(54, 82, 245, 0.1);
  color: var(--accent);
  border: 1px solid rgba(54, 82, 245, 0.2);
}

#baseEditModeFeedback {
  font-family: "PixelFont", "Segoe UI", "Microsoft YaHei", system-ui, sans-serif;
  backdrop-filter: blur(4px);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3)
}

.reference-item button {
  padding: 0.4rem 0.8rem;
  border-radius: 0.5rem;
  border: 1px solid var(--border);
  background: var(--panel-bg);
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.2s ease
}

.reference-item button:hover {
  border-color: var(--accent);
  background: rgba(54, 82, 245, 0.1)
}

.image-operations-dropdown {
  position: relative;
  display: inline-block
}

.dropdown-toggle {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 0.9rem;
  border-radius: 0.6rem;
  border: 1px solid var(--border);
  background: var(--panel-bg);
  color: var(--text);
  cursor: pointer;
  transition: all 0.3s ease;
  font-size: 0.9rem;
  font-weight: 500;
  box-shadow: 0 2px 8px rgba(31, 31, 45, 0.08)
}

.dropdown-toggle:hover {
  border-color: var(--accent);
  box-shadow: 0 4px 15px rgba(54, 82, 245, 0.15);
  transform: translateY(-1px)
}

.dropdown-toggle[aria-expanded="true"] {
  border-color: var(--accent);
  background: rgba(54, 82, 245, 0.08);
  color: var(--accent)
}

.dropdown-icon {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  transition: transform 0.3s ease
}

.dropdown-toggle[aria-expanded="true"] .dropdown-icon {
  transform: rotate(180deg)
}

.dropdown-menu {
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 0.4rem;
  min-width: 160px;
  padding: 0.5rem;
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  box-shadow: var(--shadow);
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
  gap: 0.75rem
}

.dropdown-menu[aria-hidden="false"] {
  opacity: 1;
  visibility: visible
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  width: 100%;
  padding: 0.6rem 0.8rem;
  border: none;
  border-radius: 0.5rem;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 0.9rem;
  text-align: left
}

.dropdown-item:hover {
  background: rgba(54, 82, 245, 0.1);
  color: var(--accent)
}

.menu-icon {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  flex-shrink: 0
}

body.canvas-fullscreen .image-operations-dropdown {
  z-index: 100
}

body.canvas-fullscreen .dropdown-menu {
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(54, 82, 245, 0.2);
  box-shadow: 0 0.8rem 2.4rem rgba(31, 31, 45, 0.2)
}

body.canvas-fullscreen .canvas-toolbar {
  z-index: 99;
  position: relative
}

#baseCanvas {
  z-index: 0
}

#drawingCanvas {
  z-index: 1
}

#selectionMaskCanvas,
#selectionContentCanvas,
#selectionOutlineCanvas {
  pointer-events: none;
  image-rendering: pixelated;
  border-radius: 0.5rem
}

#selectionMaskCanvas {
  z-index: 2;
  opacity: 0.45;
  background: transparent
}

#selectionContentCanvas {
  z-index: 3
}

#selectionOutlineCanvas {
  z-index: 4
}

/* 优化后的颜色管理窗口样式 */
.color-manage-window {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(680px, calc(100vw - 48px));
  /* 稍微加宽以容纳网格布局 */
  height: min(560px, calc(100vh - 48px));
  /* 稍微调低高度 */
  background: rgba(255, 255, 255, 0.98);
  border: 1px solid var(--border);
  border-radius: 1rem;
  box-shadow: 0 2rem 4rem rgba(31, 31, 45, 0.25);
  display: none;
  flex-direction: column;
  backdrop-filter: blur(8px);
  z-index: 1400;
}

.color-manage-window.is-visible {
  display: flex;
}

.color-manage-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  gap: 0.6rem;
  flex-shrink: 0;
}

.color-manage-title {
  font-weight: 600;
  font-size: 1.2rem;
  color: var(--text);
}

.color-manage-header button {
  border: none;
  background: transparent;
  font-size: 1.25rem;
  cursor: pointer;
  line-height: 1;
  padding: 0.2rem;
  border-radius: 0.45rem;
  transition: background 0.2s ease, transform 0.2s ease;
}

.color-manage-header button:hover {
  background: rgba(54, 82, 245, 0.12);
  transform: scale(1.05);
}

.color-manage-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 1.5rem;
  gap: 1rem;
  overflow: hidden;
}

.color-manage-controls {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1rem;
  background: rgba(54, 82, 245, 0.05);
  border-radius: 0.75rem;
  border: 1px solid rgba(54, 82, 245, 0.1);
  flex-shrink: 0;
  /* 防止控制区域被压缩 */
}

.color-manage-controls button {
  padding: 0.5rem 1rem;
  border-radius: 0.6rem;
  border: 1px solid var(--border);
  background: var(--panel-bg);
  font-size: 0.9rem;
  transition: all 0.3s ease;
}

.color-manage-controls button:hover {
  border-color: var(--accent);
  background: rgba(54, 82, 245, 0.1);
}

.color-count {
  margin-left: auto;
  font-size: 0.9rem;
  color: var(--muted);
  font-weight: 600;
}

.color-manage-list {
  flex: 1;
  overflow-y: auto;
  display: grid;
  /* 改为网格布局 */
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  /* 自适应列数，每列最小140px */
  gap: 0.75rem;
  /* 网格间距 */
  padding: 0.5rem;
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  background: rgba(255, 255, 255, 0.5);
  align-content: start;
  /* 内容从顶部开始排列 */
}

.color-manage-item {
  display: flex;
  flex-direction: column;
  /* 改为垂直布局 */
  align-items: center;
  gap: 0.6rem;
  padding: 0.9rem 0.75rem;
  /* 调整内边距 */
  border-radius: 0.75rem;
  background: white;
  border: 1px solid var(--border);
  transition: all 0.3s ease;
  position: relative;
  cursor: pointer;
  /* 整个项可点击 */
  min-height: 120px;
  /* 固定高度保持一致性 */
}

.color-manage-item:hover {
  border-color: var(--accent);
  box-shadow: 0 2px 8px rgba(54, 82, 245, 0.1);
  transform: translateY(-1px);
}

.color-manage-item.disabled {
  opacity: 0.6;
  background: rgba(0, 0, 0, 0.03);
}

.color-manage-checkbox {
  position: absolute;
  /* 绝对定位在右上角 */
  top: 0.5rem;
  right: 0.5rem;
  width: 1.2rem;
  height: 1.2rem;
  border: 2px solid var(--border);
  border-radius: 0.35rem;
  background: white;
  cursor: pointer;
  transition: all 0.2s ease;
  z-index: 2;
  /* 确保在最上层 */
}

.color-manage-checkbox.checked {
  background: var(--accent);
  border-color: var(--accent);
}

.color-manage-checkbox.checked::after {
  content: '✓';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: white;
  font-size: 0.8rem;
  font-weight: bold;
}

.color-manage-swatch {
  width: 3.5rem;
  /* 稍微加大颜色块 */
  height: 3.5rem;
  border-radius: 0.6rem;
  border: 2px solid rgba(0, 0, 0, 0.1);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
  position: relative;
  overflow: hidden;
  margin-top: 0.5rem;
  /* 为复选框留出空间 */
}

.color-manage-swatch::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.2) 0%, transparent 50%);
  border-radius: inherit;
}

.color-manage-info {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  align-items: center;
  /* 居中对齐 */
  text-align: center;
  flex: 1;
  width: 100%;
}

.color-manage-code {
  font-weight: 700;
  font-size: 0.9rem;
  /* 稍微调小字体 */
  color: var(--text);
  letter-spacing: 0.02em;
  white-space: nowrap;
  /* 防止换行 */
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.color-manage-color {
  color: var(--muted);
  font-size: 0.75rem;
  /* 调小颜色值字体 */
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  white-space: nowrap;
  /* 防止换行 */
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.color-manage-empty {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--muted);
  font-size: 0.95rem;
  grid-column: 1 / -1;
  /* 空状态占满整行 */
}

.color-manage-message {
  padding: 0.75rem 1rem;
  border-radius: 0.75rem;
  font-size: 0.9rem;
  text-align: center;
  min-height: auto;
  /* 移除固定最小高度 */
  margin-top: 0;
  /* 移除上边距 */
  flex-shrink: 0;
  /* 防止被压缩 */
}

/* 当没有消息时完全隐藏消息区域 */
.color-manage-message:empty {
  display: none;
}

.color-manage-message.error {
  background: rgba(255, 71, 87, 0.1);
  color: #ff4757;
  border: 1px solid rgba(255, 71, 87, 0.2);
}

.color-manage-message.warning {
  background: rgba(229, 142, 38, 0.1);
  color: #e58e26;
  border: 1px solid rgba(229, 142, 38, 0.2);
}

.color-manage-message.info {
  background: rgba(54, 82, 245, 0.1);
  color: var(--accent);
  border: 1px solid rgba(54, 82, 245, 0.2);
}

.color-manage-footer {
  display: flex;
  justify-content: flex-end;
  gap: 1rem;
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.color-manage-footer button {
  padding: 0.75rem 1.5rem;
  border-radius: 0.75rem;
  font-weight: 600;
  min-width: 100px;
}

.color-manage-footer button.secondary {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
}

.color-manage-footer button.secondary:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.color-manage-footer button.primary {
  background: var(--accent);
  border: 1px solid var(--accent);
  color: white;
}

.color-manage-footer button.primary:hover {
  background: #2a42d4;
  border-color: #2a42d4;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(54, 82, 245, 0.3);
}

/* 响应式调整 */
@media (max-width: 768px) {
  .color-manage-list {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    /* 在小屏幕上使用更小的列 */
    gap: 0.5rem;
  }

  .color-manage-item {
    padding: 0.7rem 0.5rem;
    min-height: 110px;
  }

  .color-manage-swatch {
    width: 3rem;
    height: 3rem;
  }
}

.palette-item.disabled {
  opacity: 0.4;
  pointer-events: none;
  position: relative;
}

.palette-item.disabled::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, transparent 0%, rgba(255, 255, 255, 0.7) 50%, transparent 100%);
  border-radius: inherit;
}

.fullscreen-palette button.disabled {
  opacity: 0.3;
  pointer-events: none;
}

.fullscreen-palette button.disabled .fullscreen-swatch {
  filter: grayscale(100%);
}

.canvas-highlight-window {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(520px, calc(100vw - 48px));
  height: min(560px, calc(100vh - 48px));
  background: rgba(255, 255, 255, 0.98);
  border: 1px solid var(--border);
  border-radius: 1rem;
  box-shadow: 0 2rem 4rem rgba(31, 31, 45, 0.25);
  display: none;
  flex-direction: column;
  backdrop-filter: blur(8px);
  z-index: 1400;
}

.canvas-highlight-window.is-visible {
  display: flex;
}

.canvas-highlight-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  gap: 0.6rem;
  flex-shrink: 0;
}

.canvas-highlight-title {
  font-weight: 600;
  font-size: 1.2rem;
  color: var(--text);
}

.canvas-highlight-header button {
  border: none;
  background: transparent;
  font-size: 1.25rem;
  cursor: pointer;
  line-height: 1;
  padding: 0.2rem;
  border-radius: 0.45rem;
  transition: background 0.2s ease, transform 0.2s ease;
}

.canvas-highlight-header button:hover {
  background: rgba(54, 82, 245, 0.12);
  transform: scale(1.05);
}

.canvas-highlight-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 1.5rem;
  gap: 1rem;
  overflow: hidden;
}

.canvas-highlight-controls {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1rem;
  background: rgba(54, 82, 245, 0.05);
  border-radius: 0.75rem;
  border: 1px solid rgba(54, 82, 245, 0.1);
  flex-shrink: 0;
}

.canvas-highlight-controls button {
  padding: 0.5rem 1rem;
  border-radius: 0.6rem;
  border: 1px solid var(--border);
  background: var(--panel-bg);
  font-size: 0.9rem;
  transition: all 0.3s ease;
}

.canvas-highlight-controls button:hover {
  border-color: var(--accent);
  background: rgba(54, 82, 245, 0.1);
}

.canvas-highlight-body .highlight-search {
  flex-shrink: 0;
}

.canvas-highlight-body .highlight-color-list {
  flex: 1;
  overflow-y: auto;
}

.canvas-highlight-replace {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 1rem;
  border-radius: 0.9rem;
  border: 1px solid rgba(54, 82, 245, 0.08);
  background: rgba(54, 82, 245, 0.04);
  flex-shrink: 0;
}

.canvas-highlight-replace label {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text);
}

.canvas-highlight-replace-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.canvas-highlight-replace-row select {
  flex: 1;
  padding: 0.5rem 0.75rem;
  border-radius: 0.6rem;
  border: 1px solid var(--border);
  background: var(--panel-bg);
  font-size: 0.95rem;
  color: var(--text);
  transition: border 0.2s ease, box-shadow 0.2s ease;
}

.canvas-highlight-replace-row select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(54, 82, 245, 0.15);
}

.canvas-highlight-replace-row .primary {
  flex-shrink: 0;
}

#canvasHighlightMessage {
  min-height: 1.25rem;
}

.canvas-size-warning {
  min-height: 1.2rem;
  margin: 0.4rem 0 0.2rem;
  font-size: 0.85rem;
  color: var(--muted);
  transition: color 0.2s ease;
}

.canvas-size-warning.is-warning {
  color: #d9822b;
}

.canvas-size-warning.is-danger {
  color: #e2554f;
  font-weight: 600;
}

.palette-switch-overlay {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  background: rgba(17, 22, 34, 0.45);
  backdrop-filter: blur(2px);
  z-index: 1450;
}

.palette-switch-overlay.is-visible {
  display: flex;
}

.palette-switch-dialog {
  width: clamp(340px, 60vw, 520px);
  border-radius: 1rem;
  background: var(--panel-bg);
  box-shadow: 0 1.6rem 3rem rgba(31, 31, 45, 0.28);
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  padding: 1.5rem;
}

.palette-switch-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.palette-switch-title {
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--text);
}

.palette-switch-header button {
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 0.2rem 0.45rem;
  border-radius: 0.5rem;
  transition: background 0.2s ease, color 0.2s ease;
}

.palette-switch-header button:hover,
.palette-switch-header button:focus-visible {
  background: rgba(54, 82, 245, 0.12);
  color: var(--accent);
}

.palette-switch-body {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  color: var(--muted);
  line-height: 1.6;
}

.palette-switch-target {
  font-weight: 600;
  color: var(--text);
}

.palette-switch-target span {
  color: var(--accent);
}

.palette-switch-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
}

.palette-switch-actions button {
  min-width: 120px;
  padding: 0.55rem 1rem;
  border-radius: 0.7rem;
  border: 1px solid transparent;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.palette-switch-actions button.secondary {
  background: var(--panel-bg);
  border-color: var(--border);
  color: var(--text);
}

.palette-switch-actions button.secondary:hover,
.palette-switch-actions button.secondary:focus-visible {
  border-color: var(--accent);
  color: var(--accent);
}

.palette-switch-actions button.primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.palette-switch-actions button.primary:hover,
.palette-switch-actions button.primary:focus-visible {
  box-shadow: 0 0.6rem 1.4rem rgba(54, 82, 245, 0.3);
}

.palette-switch-actions button.danger {
  background: #e2554f;
  border-color: #e2554f;
  color: #fff;
}

.palette-switch-actions button.danger:hover,
.palette-switch-actions button.danger:focus-visible {
  box-shadow: 0 0.6rem 1.4rem rgba(226, 85, 79, 0.32);
}

.palette-switch-actions button:disabled,
.palette-switch-actions button:disabled:hover {
  cursor: not-allowed;
  opacity: 0.55;
  box-shadow: none;
  border-color: var(--border);
  background: rgba(120, 123, 140, 0.1);
  color: var(--muted);
}
