/* MELD Studio — interface styles */

:root {
  --bg: #F4EFE6;
  --bg-top: #F7F3EB;
  --panel: #FDFBF7;
  --surface: #FFFDF9;
  --canvas-area: #EBE5D9;
  --text: #2C2C2C;
  --text-soft: #6F685E;
  --muted: #938A7C;
  --faint: #B2A898;
  --line: #E6DFD3;
  --line-soft: #EDE7DC;
  --active: #E8DFCF;
  --accent: #E5D9C5;
  --accent-hover: #DDD0BA;
  --radius-sm: 8px;
  --radius-md: 12px;
  --font: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
          "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

::selection {
  background: #E4D8C5;
  color: var(--text);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  white-space: nowrap;
  border: 0;
  clip: rect(0, 0, 0, 0);
  clip-path: inset(50%);
}

/* ---------- SVG icon assets ---------- */

.icon {
  display: block;
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  object-fit: contain;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
}

/* ---------- Scrollbars ---------- */

* {
  scrollbar-width: thin;
  scrollbar-color: #D7CDBE transparent;
}

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: #D7CDBE;
  border-radius: 999px;
}

::-webkit-scrollbar-thumb:hover {
  background: #C5B9A7;
}

::-webkit-scrollbar-corner {
  background: transparent;
}

/* ---------- Global layout ---------- */

.app {
  display: grid;
  grid-template-rows: 60px minmax(0, 1fr);
  width: 100%;
  height: 100vh;
  overflow: hidden;
}

.workspace {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr) 320px;
  min-width: 0;
  min-height: 0;
}

/* ---------- Header ---------- */

.app-header {
  position: relative;
  z-index: 30;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  height: 60px;
  padding: 0 20px;
  background: linear-gradient(180deg, #F8F4EC 0%, #F5F0E7 100%);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: inline-flex;
  align-items: center;
  justify-self: start;
  gap: 10px;
  min-width: 0;
  user-select: none;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  flex: 0 0 auto;
  color: #F6F1E7;
  background: #2C2C2C;
  border-radius: 9px;
  box-shadow: 0 2px 5px rgba(44, 44, 44, 0.14);
}

.brand-mark .icon {
  display: block;
  width: 17px;
  height: 17px;
}

.brand-word {
  font-size: 14px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: 0.18em;
}

.brand-sub {
  margin-left: -3px;
  padding-left: 9px;
  border-left: 1px solid #D9D0C1;
  color: var(--muted);
  font-size: 8px;
  font-weight: 600;
  line-height: 1;
  letter-spacing: 0.2em;
}

.project {
  display: flex;
  align-items: center;
  justify-self: center;
  gap: 10px;
  min-width: 0;
  padding: 7px 12px;
  border-radius: 9px;
  transition: background-color 0.2s ease;
}

.project-name {
  max-width: 260px;
  margin: 0;
  overflow: hidden;
  color: var(--text);
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: 0.015em;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: text;
  border-radius: 6px;
  transition: color 0.16s ease, background-color 0.16s ease,
              box-shadow 0.16s ease;
}

.project-name:hover {
  color: #1F1F1F;
}

.project-name[contenteditable="true"] {
  max-width: min(420px, 40vw);
  margin: -2px -8px;
  padding: 2px 8px;
  overflow: hidden;
  text-overflow: clip;
  background: var(--surface);
  outline: 1px solid #C9BDA9;
  box-shadow: 0 0 0 3px rgba(201, 189, 169, 0.16);
}

.project-name[contenteditable="true"]:empty::before {
  content: attr(data-placeholder);
  color: var(--faint);
  font-weight: 500;
}

.project-chevron {
  width: 12px;
  height: 12px;
  flex: 0 0 auto;
  color: #9B9182;
}

.project-save {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: #A39A8C;
  font-size: 9.5px;
  font-weight: 550;
  line-height: 1;
  letter-spacing: 0.04em;
  white-space: nowrap;
  transition: color 0.18s ease;
}

.project-save.is-saved {
  color: #5F7F4A;
}

.project-save.is-dirty {
  color: #A39A8C;
}

.save-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #B8AE9E;
  box-shadow: 0 0 0 3px rgba(184, 174, 158, 0.14);
  transition: background-color 0.18s ease, box-shadow 0.18s ease;
}

.project-save.is-saved .save-dot {
  background: #7F9A62;
  box-shadow: 0 0 0 3px rgba(127, 154, 98, 0.16);
}

.header-actions {
  display: flex;
  align-items: center;
  justify-self: end;
  gap: 8px;
}

/* 顶栏：语言切换 */
.language-switch {
  position: relative;
  display: inline-flex;
}

.language-trigger {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  padding: 0;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  transition: background-color 0.16s ease, border-color 0.16s ease;
}

.language-trigger:hover,
.language-trigger[aria-expanded="true"] {
  background: rgba(255, 253, 249, 0.7);
  border-color: rgba(214, 203, 185, 0.65);
}

.language-trigger:focus-visible {
  outline: 2px solid rgba(142, 122, 93, 0.45);
  outline-offset: 1px;
}

.language-icon {
  width: 16px;
  height: 16px;
  opacity: 0.7;
  transition: opacity 0.16s ease;
}

.language-trigger:hover .language-icon,
.language-trigger[aria-expanded="true"] .language-icon {
  opacity: 1;
}

.language-menu {
  position: absolute;
  top: calc(100% + 9px);
  right: 0;
  z-index: 90;
  width: 184px;
  padding: 5px;
  background: var(--surface);
  border: 1px solid #E4DCCF;
  border-radius: 10px;
  box-shadow: 0 18px 42px rgba(54, 43, 27, 0.16),
              0 4px 12px rgba(54, 43, 27, 0.07);
  transform-origin: top right;
  animation: export-menu-in 0.16s cubic-bezier(0.22, 1, 0.36, 1);
}

.language-menu[hidden] {
  display: none;
}

.language-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  height: 36px;
  padding: 0 9px;
  color: var(--text);
  font-family: inherit;
  font-size: 11.5px;
  font-weight: 550;
  line-height: 1.2;
  text-align: left;
  background: transparent;
  border: 0;
  border-radius: 7px;
  cursor: pointer;
  transition: background-color 0.14s ease;
}

.language-option:hover,
.language-option:focus-visible {
  background: #F2EBDD;
  outline: none;
}

.language-option:focus-visible {
  box-shadow: inset 0 0 0 1px #C7B79F;
}

.language-option.is-active {
  color: #3A352E;
  font-weight: 650;
}

.language-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.language-check {
  position: relative;
  width: 12px;
  height: 12px;
  flex: 0 0 auto;
  opacity: 0;
}

.language-option.is-active .language-check {
  opacity: 1;
}

.language-check::before {
  content: "";
  position: absolute;
  left: 2px;
  top: 0;
  width: 5px;
  height: 9px;
  border-right: 1.6px solid #7B6E5A;
  border-bottom: 1.6px solid #7B6E5A;
  transform: rotate(45deg);
}

/* 顶栏：像素化画布开关 */
.pixel-preview-control {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 36px;
  padding: 0 10px;
  color: var(--text-soft);
  border: 1px solid transparent;
  border-radius: 9px;
  transition: background-color 0.16s ease, border-color 0.16s ease;
}

.pixel-preview-control:hover {
  background: rgba(255, 253, 249, 0.58);
  border-color: rgba(214, 203, 185, 0.7);
}

.pixel-preview-label {
  font-size: 10.5px;
  font-weight: 600;
  line-height: 1;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

.pixel-help {
  display: grid;
  place-items: center;
  width: 15px;
  height: 15px;
  color: #8E8270;
  font-size: 9px;
  font-weight: 650;
  line-height: 1;
  border: 1px solid #C9BDA9;
  border-radius: 50%;
  cursor: help;
  user-select: none;
  transition: color 0.16s ease, background-color 0.16s ease,
              border-color 0.16s ease;
}

.pixel-help:hover,
.pixel-help:focus-visible {
  color: #4A453E;
  background: #F4EDE1;
  border-color: #A8987E;
}

.pixel-help:focus-visible {
  outline: 2px solid rgba(142, 122, 93, 0.45);
  outline-offset: 2px;
}

.pixel-switch {
  position: relative;
  width: 30px;
  height: 17px;
  padding: 0;
  background: #E4DCCD;
  border: 1px solid #D6CBBB;
  border-radius: 999px;
  cursor: pointer;
  transition: background-color 0.18s ease, border-color 0.18s ease,
              box-shadow 0.18s ease;
}

.pixel-switch-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 11px;
  height: 11px;
  background: #FFFDF9;
  border-radius: 50%;
  box-shadow: 0 1px 2px rgba(64, 52, 35, 0.22);
  transition: transform 0.18s cubic-bezier(0.22, 1, 0.36, 1);
}

.pixel-switch[aria-checked="true"] {
  background: #8E7A5D;
  border-color: #8E7A5D;
}

.pixel-switch[aria-checked="true"] .pixel-switch-thumb {
  transform: translateX(13px);
}

.pixel-switch:focus-visible {
  outline: 2px solid rgba(142, 122, 93, 0.5);
  outline-offset: 2px;
}

.pixel-tooltip {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 80;
  width: 300px;
  padding: 10px 12px;
  color: #6F685E;
  font-size: 10.5px;
  font-weight: 400;
  line-height: 1.7;
  letter-spacing: 0.01em;
  text-align: left;
  background: #FDFBF7;
  border: 1px solid #E6DFD3;
  border-radius: 10px;
  box-shadow: 0 10px 26px rgba(44, 44, 44, 0.11),
              0 2px 6px rgba(44, 44, 44, 0.05);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px);
  transition: opacity 0.16s ease, transform 0.16s ease,
              visibility 0.16s ease;
  pointer-events: none;
}

.pixel-help:hover + .pixel-tooltip,
.pixel-help:focus-visible + .pixel-tooltip {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.export-menu-wrap {
  position: relative;
  display: inline-flex;
}

.export-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 36px;
  padding: 0 16px;
  color: #3A352E;
  font-family: inherit;
  font-size: 11.5px;
  font-weight: 650;
  letter-spacing: 0.03em;
  background: var(--accent);
  border: 1px solid rgba(181, 158, 122, 0.28);
  border-radius: 10px;
  box-shadow: 0 2px 7px rgba(91, 73, 45, 0.1),
              inset 0 1px 0 rgba(255, 255, 255, 0.35);
  cursor: pointer;
  transition: all 0.2s ease;
}

.export-button .icon {
  width: 15px;
  height: 15px;
  flex: 0 0 auto;
}

.export-button:hover {
  background: var(--accent-hover);
  box-shadow: 0 4px 12px rgba(91, 73, 45, 0.13),
              inset 0 1px 0 rgba(255, 255, 255, 0.35);
  transform: translateY(-1px);
}

.export-button:active {
  box-shadow: 0 1px 3px rgba(91, 73, 45, 0.1);
  transform: translateY(0);
}

.export-button:disabled {
  opacity: 0.72;
  cursor: progress;
  transform: none;
}

.export-button:disabled:hover {
  background: var(--accent);
  box-shadow: 0 2px 7px rgba(91, 73, 45, 0.1),
              inset 0 1px 0 rgba(255, 255, 255, 0.35);
  transform: none;
}

.export-caret {
  width: 10px;
  height: 10px;
  flex: 0 0 auto;
  margin-left: 1px;
  opacity: 0.62;
  transition: transform 0.18s ease, opacity 0.18s ease;
}

.export-button[aria-expanded="true"] {
  background: var(--accent-hover);
  box-shadow: 0 3px 9px rgba(91, 73, 45, 0.12),
              inset 0 1px 0 rgba(255, 255, 255, 0.35);
}

.export-button[aria-expanded="true"] .export-caret {
  opacity: 0.9;
  transform: rotate(180deg);
}

/* 顶栏：导出格式浮窗 */
.export-menu {
  position: absolute;
  top: calc(100% + 9px);
  right: 0;
  z-index: 90;
  width: min(246px, calc(100vw - 28px));
  padding: 6px;
  background: var(--surface);
  border: 1px solid #E4DCCF;
  border-radius: 12px;
  box-shadow: 0 18px 42px rgba(54, 43, 27, 0.16),
              0 4px 12px rgba(54, 43, 27, 0.07);
  transform-origin: top right;
  animation: export-menu-in 0.16s cubic-bezier(0.22, 1, 0.36, 1);
}

.export-menu[hidden] {
  display: none;
}

@keyframes export-menu-in {
  from {
    opacity: 0;
    transform: translateY(-5px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.export-menu-heading {
  padding: 5px 10px 7px;
  color: #9B9182;
  font-size: 9px;
  font-weight: 650;
  line-height: 1;
  letter-spacing: 0.12em;
}

.export-option {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 44px;
  padding: 6px 9px;
  color: var(--text);
  font-family: inherit;
  text-align: left;
  background: transparent;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  transition: background-color 0.14s ease;
}

.export-option:hover,
.export-option:focus-visible {
  background: #F2EBDD;
  outline: none;
}

.export-option:focus-visible {
  box-shadow: inset 0 0 0 1px #C7B79F;
}

.export-option:active {
  background: #EBE2D1;
}

.export-format {
  display: grid;
  place-items: center;
  width: 38px;
  height: 30px;
  flex: 0 0 auto;
  color: #7B6E5A;
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0.02em;
  background: #F3ECDF;
  border: 1px solid #E5DAC8;
  border-radius: 7px;
}

.export-format-meld {
  color: #F6F1E7;
  font-family: var(--font);
  font-size: 7.5px;
  letter-spacing: 0.06em;
  background: #2C2C2C;
  border-color: #2C2C2C;
}

.export-option-label {
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.export-option-note {
  margin-left: auto;
  color: #9B9182;
  font-size: 9px;
  line-height: 1;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

/* ---------- Left tool rail ---------- */

.tool-rail {
  position: relative;
  z-index: 12;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 0;
  padding: 18px 0 16px;
  background: transparent;
}

.tool-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.tool-slot {
  position: relative;
  width: 40px;
  height: 40px;
}

.tool-input,
.edge-input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
  clip-path: inset(50%);
  pointer-events: none;
}

.tool-button {
  position: relative;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  color: #666;
  background: transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
}

.tool-button .icon {
  display: block;
  width: 19px;
  height: 19px;
  flex: 0 0 auto;
  transition: transform 0.2s ease;
}

.tool-button:hover {
  color: #3D3933;
  background: rgba(255, 253, 249, 0.64);
  box-shadow: inset 0 0 0 1px rgba(230, 223, 211, 0.7);
}

.tool-button:hover .icon {
  transform: scale(1.04);
}

.tool-input:checked + .tool-button {
  color: #2C2C2C;
  background: var(--active);
  box-shadow: inset 0 0 0 1px rgba(177, 158, 127, 0.18),
              0 1px 2px rgba(64, 52, 35, 0.04);
}

.tool-input:focus-visible + .tool-button {
  outline: 2px solid rgba(142, 122, 93, 0.55);
  outline-offset: 2px;
}

.tool-button::after {
  position: absolute;
  top: 50%;
  left: calc(100% + 10px);
  z-index: 100;
  padding: 5px 8px;
  color: #F8F4EC;
  font-size: 10px;
  font-weight: 500;
  line-height: 1.3;
  letter-spacing: 0.02em;
  white-space: nowrap;
  background: rgba(44, 44, 44, 0.94);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(44, 44, 44, 0.14);
  content: attr(data-tooltip);
  opacity: 0;
  visibility: hidden;
  transform: translate(-4px, -50%);
  transition: opacity 0.18s ease, transform 0.18s ease, visibility 0.18s ease;
  pointer-events: none;
}

.tool-button:hover::after,
.tool-button:focus-visible::after {
  opacity: 1;
  visibility: visible;
  transform: translate(0, -50%);
}

/* ---------- Workspace color swatches ---------- */

.workspace-swatches {
  position: absolute;
  top: 16px;
  right: 18px;
  z-index: 24;
  width: 48px;
  height: 48px;
  user-select: none;
  /* 容器不拦截画布手势，只有两个色块本身可点击。 */
  pointer-events: none;
}

.swatch-color-input {
  position: absolute;
  top: 0;
  left: 0;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.workspace-swatches .swatch {
  position: absolute;
  display: block;
  width: 28px;
  height: 28px;
  padding: 2px;
  background: #FFFDF9;
  border: 1px solid #D7CDBD;
  border-radius: 7px;
  box-shadow: 0 1px 2px rgba(64, 52, 35, 0.06);
  cursor: pointer;
  pointer-events: auto;
  transition: transform 0.16s ease, box-shadow 0.16s ease,
              border-color 0.16s ease;
}

.workspace-swatches .swatch:hover {
  transform: translateY(-1px);
}

.workspace-swatches .swatch:focus-visible {
  outline: 2px solid rgba(142, 122, 93, 0.6);
  outline-offset: 2px;
}

.workspace-swatches .swatch.is-active {
  z-index: 3;
  border-color: #8E7A5D;
  box-shadow: 0 0 0 2px #FDFBF7,
              0 0 0 3px #8E7A5D,
              0 3px 8px rgba(64, 52, 35, 0.16);
}

.workspace-swatches .swatch-back {
  right: 0;
  bottom: 0;
  z-index: 1;
}

.workspace-swatches .swatch-front {
  top: 0;
  left: 0;
  z-index: 2;
  border-color: rgba(255, 255, 255, 0.28);
}

.swatch-fill {
  display: block;
  width: 100%;
  height: 100%;
  background: #2C2C2C;
  border-radius: 4px;
}

.swatch-back .swatch-fill {
  background: #FFFDF9;
}

/* ---------- Canvas area ---------- */

.canvas-viewport {
  position: relative;
  z-index: 1;
  display: flex;
  min-width: 0;
  min-height: 0;
  /* 工作区使用滚轮缩放 + 空格/中键平移，不需要原生滚动条。 */
  overflow: hidden;
  padding: 30px 28px 50px;
  background-color: var(--canvas-area);
  background-image: radial-gradient(rgba(104, 89, 64, 0.055) 0.7px, transparent 0.8px);
  background-size: 18px 18px;
  overscroll-behavior: contain;
}

.canvas-stage {
  position: relative;
  width: 800px;
  height: 600px;
  flex: 0 0 auto;
  margin: auto;
}

/* 拖拽图片 / 工程文件或导入过程中的画板提示。 */
.canvas-stage.is-drop-target::after {
  content: attr(data-drop-label);
  position: absolute;
  inset: 12px;
  z-index: 8;
  display: grid;
  place-items: center;
  padding: 24px;
  color: #6F5A35;
  font-size: 11px;
  font-weight: 550;
  line-height: 1.7;
  letter-spacing: 0.12em;
  text-align: center;
  background: rgba(253, 251, 247, 0.8);
  border: 1px dashed rgba(176, 140, 47, 0.7);
  border-radius: 4px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.55);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  pointer-events: none;
}

.artboard-meta {
  position: absolute;
  top: -23px;
  left: 1px;
  z-index: 6;
  display: flex;
  align-items: center;
  color: #8B8172;
  font-size: 9.5px;
  font-weight: 550;
  line-height: 1;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  white-space: nowrap;
  pointer-events: none;
}

.artboard-meta .meta-size {
  color: #A19888;
  font-family: var(--mono);
  font-size: 8.5px;
  font-weight: 400;
  letter-spacing: 0.04em;
  text-transform: none;
}

.canvas {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  pointer-events: none;
  user-select: none;
  transform-origin: 50% 50%;
  will-change: transform;
  background-color: #FFFFFF;
  background-image:
    linear-gradient(45deg, #F0EBE2 25%, transparent 25%, transparent 75%, #F0EBE2 75%),
    linear-gradient(45deg, #F0EBE2 25%, transparent 25%, transparent 75%, #F0EBE2 75%);
  background-position: 0 0, 11px 11px;
  background-size: 22px 22px;
  border-radius: 3px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.05),
              0 0 0 1px rgba(107, 92, 69, 0.08);
}

/* 像素化预览：位于画板内容之上、原生控制点之下，只显示、不改数据。 */
.pixel-preview {
  position: absolute;
  z-index: 1;
  overflow: hidden;
  border-radius: 3px;
  background-color: #FFFFFF;
  background-image:
    linear-gradient(45deg, #F0EBE2 25%, transparent 25%, transparent 75%, #F0EBE2 75%),
    linear-gradient(45deg, #F0EBE2 25%, transparent 25%, transparent 75%, #F0EBE2 75%);
  background-position: 0 0, 11px 11px;
  background-size: 22px 22px;
  pointer-events: none;
  user-select: none;
}

.pixel-preview[hidden] {
  display: none;
}

.pixel-preview-canvas {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: auto;
}

/* Expanded by drawing.js to match the workspace viewport.
   Content is clipped by the viewport edge, not by the 800 × 600 artboard. */
.layer-canvas-stack {
  position: absolute;
  inset: 0;
  z-index: 2;
}

/* 用带孔的遮罩隐藏画板内的原始清晰下层画布；
   上层画布（Fabric 控制点、文字光标）不受影响。 */
.layer-canvas-stack.is-pixel-preview .lower-canvas {
  -webkit-mask-image: linear-gradient(#000, #000), linear-gradient(#000, #000);
  -webkit-mask-size: 100% 100%, var(--pixel-mask-w, 0px) var(--pixel-mask-h, 0px);
  -webkit-mask-position: 0 0, var(--pixel-mask-x, 0px) var(--pixel-mask-y, 0px);
  -webkit-mask-repeat: no-repeat;
  -webkit-mask-composite: xor;
  mask-image: linear-gradient(#000, #000), linear-gradient(#000, #000);
  mask-size: 100% 100%, var(--pixel-mask-w, 0px) var(--pixel-mask-h, 0px);
  mask-position: 0 0, var(--pixel-mask-x, 0px) var(--pixel-mask-y, 0px);
  mask-repeat: no-repeat;
  mask-composite: exclude;
}

.fabric-layer {
  position: absolute !important;
  inset: 0 !important;
  top: 0 !important;
  left: 0 !important;
  width: 100% !important;
  height: 100% !important;
  background: transparent !important;
  pointer-events: none !important;
  transition: opacity 0.15s ease;
}

.fabric-layer.is-active {
  pointer-events: auto !important;
}

.fabric-layer canvas {
  display: block;
  touch-action: none;
}


.canvas-stage.is-drawable .fabric-layer.is-active canvas {
  cursor: none !important;
}

.canvas-stage.is-text-tool .fabric-layer.is-active canvas {
  cursor: text;
}

.canvas-stage.is-shape-tool .fabric-layer.is-active canvas {
  cursor: crosshair;
}

.canvas-stage.is-canvas-tool .fabric-layer.is-active canvas {
  cursor: default;
}

.canvas-stage.is-draw-blocked .fabric-layer.is-active canvas {
  cursor: not-allowed !important;
}

.canvas-stage.is-draw-blocked .brush-cursor {
  opacity: 0 !important;
}

.brush-cursor {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 5;
  width: 24px;
  height: 24px;
  border: 1px solid rgba(44, 44, 44, 0.6);
  border-radius: 50%;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.65),
              inset 0 0 0 1px rgba(255, 255, 255, 0.3);
  opacity: 0;
  transform: translate(-50%, -50%);
  transition: opacity 0.1s ease, width 0.12s ease, height 0.12s ease;
  pointer-events: none;
}

.brush-cursor::after {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 2px;
  height: 2px;
  background: rgba(44, 44, 44, 0.5);
  border-radius: 50%;
  content: "";
  transform: translate(-50%, -50%);
}

.brush-cursor.is-visible {
  opacity: 1;
}

.brush-cursor.is-eraser {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(74, 65, 52, 0.7);
  border-style: dashed;
}

.canvas-viewport.is-pan-ready,
.canvas-viewport.is-pan-ready .canvas-stage,
.canvas-viewport.is-pan-ready .fabric-layer.is-active canvas {
  cursor: grab !important;
}

.canvas-viewport.is-panning,
.canvas-viewport.is-panning .canvas-stage,
.canvas-viewport.is-panning .fabric-layer.is-active canvas {
  cursor: grabbing !important;
}

.canvas-viewport.is-pan-ready .brush-cursor,
.canvas-viewport.is-panning .brush-cursor {
  opacity: 0 !important;
}

/* ---------- Selection and transform overlay ---------- */

.canvas-stage.is-select-tool .fabric-layer.is-active {
  pointer-events: none !important;
}

.selection-overlay {
  position: absolute;
  inset: 0;
  z-index: 18;
  overflow: hidden;
  pointer-events: none;
  touch-action: none;
}

.selection-overlay.is-active {
  pointer-events: auto;
}

.selection-overlay.is-marqueeing {
  cursor: crosshair;
}

.selection-overlay[hidden],
.selection-frame[hidden],
.selection-marquee[hidden] {
  display: none;
}

.selection-frame {
  position: absolute;
  box-sizing: border-box;
  border: 1px dashed #C7A33E;
  transform-origin: center center;
  pointer-events: auto;
  cursor: move;
  will-change: left, top, width, height, transform;
}

.selection-handle {
  position: absolute;
  width: 9px;
  height: 9px;
  background: #FFFDF9;
  border: 1.5px solid #B08C2F;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(64, 52, 35, 0.16);
  pointer-events: auto;
}

.selection-handle[data-handle="nw"] {
  top: 0;
  left: 0;
  transform: translate(-50%, -50%);
  cursor: nwse-resize;
}

.selection-handle[data-handle="ne"] {
  top: 0;
  left: 100%;
  transform: translate(-50%, -50%);
  cursor: nesw-resize;
}

.selection-handle[data-handle="sw"] {
  top: 100%;
  left: 0;
  transform: translate(-50%, -50%);
  cursor: nesw-resize;
}

.selection-handle[data-handle="se"] {
  top: 100%;
  left: 100%;
  transform: translate(-50%, -50%);
  cursor: nwse-resize;
}

.selection-rotate {
  position: absolute;
  top: -24px;
  left: 50%;
  width: 10px;
  height: 10px;
  background: #FFFDF9;
  border: 1.5px solid #B08C2F;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(64, 52, 35, 0.16);
  transform: translate(-50%, -50%);
  cursor: grab;
  pointer-events: auto;
}

.selection-rotate::before {
  position: absolute;
  top: 100%;
  left: 50%;
  width: 1px;
  height: 15px;
  background: #C7A33E;
  content: "";
  transform: translateX(-50%);
}

.selection-marquee {
  position: absolute;
  box-sizing: border-box;
  background: rgba(199, 163, 62, 0.08);
  border: 1px dashed #C7A33E;
  pointer-events: none;
}

.selection-overlay.is-transforming,
.selection-overlay.is-transforming * {
  cursor: grabbing !important;
}

/* ---------- Canvas resize tool ---------- */

.canvas-resize-overlay {
  position: absolute;
  inset: 0;
  z-index: 21;
  overflow: hidden;
  pointer-events: none;
}

.canvas-resize-overlay[hidden],
.canvas-resize-frame[hidden] {
  display: none;
}

.canvas-resize-frame {
  position: absolute;
  box-sizing: border-box;
  border: 1px dashed #C7A33E;
  pointer-events: none;
  will-change: left, top, width, height;
}

.canvas-resize-handle {
  position: absolute;
  width: 10px;
  height: 10px;
  background: #FFFDF9;
  border: 1.5px solid #B08C2F;
  border-radius: 3px;
  box-shadow: 0 1px 3px rgba(64, 52, 35, 0.16);
  pointer-events: auto;
}

.canvas-resize-frame.is-bottom-right [data-canvas-handle="nw"],
.canvas-resize-frame.is-bottom-right [data-canvas-handle="n"],
.canvas-resize-frame.is-bottom-right [data-canvas-handle="ne"],
.canvas-resize-frame.is-bottom-right [data-canvas-handle="w"],
.canvas-resize-frame.is-bottom-right [data-canvas-handle="sw"] {
  display: none;
}

.canvas-resize-handle[data-canvas-handle="nw"] {
  top: 0;
  left: 0;
  transform: translate(-50%, -50%);
  cursor: nwse-resize;
}

.canvas-resize-handle[data-canvas-handle="n"] {
  top: 0;
  left: 50%;
  transform: translate(-50%, -50%);
  cursor: ns-resize;
}

.canvas-resize-handle[data-canvas-handle="ne"] {
  top: 0;
  left: 100%;
  transform: translate(-50%, -50%);
  cursor: nesw-resize;
}

.canvas-resize-handle[data-canvas-handle="e"] {
  top: 50%;
  left: 100%;
  transform: translate(-50%, -50%);
  cursor: ew-resize;
}

.canvas-resize-handle[data-canvas-handle="se"] {
  top: 100%;
  left: 100%;
  transform: translate(-50%, -50%);
  cursor: nwse-resize;
}

.canvas-resize-handle[data-canvas-handle="s"] {
  top: 100%;
  left: 50%;
  transform: translate(-50%, -50%);
  cursor: ns-resize;
}

.canvas-resize-handle[data-canvas-handle="sw"] {
  top: 100%;
  left: 0;
  transform: translate(-50%, -50%);
  cursor: nesw-resize;
}

.canvas-resize-handle[data-canvas-handle="w"] {
  top: 50%;
  left: 0;
  transform: translate(-50%, -50%);
  cursor: ew-resize;
}

.canvas-size-grid {
  margin-top: 10px;
}

.canvas-anchor-block {
  margin-top: 12px;
}

.canvas-size-panel .shape-create-hint {
  margin-top: 12px;
}

.zoom-dock {
  position: absolute;
  bottom: 24px;
  left: 50%;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 2px;
  height: 44px;
  padding: 0 7px;
  background: rgba(255, 253, 249, 0.97);
  border: 1px solid var(--line);
  border-radius: 30px;
  box-shadow: 0 8px 22px rgba(72, 58, 38, 0.1),
              0 1px 2px rgba(64, 52, 35, 0.05),
              inset 0 1px 0 rgba(255, 255, 255, 0.8);
  transform: translateX(-50%);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.dock-button {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  padding: 0;
  color: #756D61;
  background: transparent;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.2s ease;
}

.dock-button .icon {
  width: 14px;
  height: 14px;
}

.dock-button:hover {
  color: #2C2C2C;
  background: #F2ECE2;
}

.dock-button:active {
  background: #EAE2D5;
}

.dock-button:focus-visible {
  outline: 2px solid rgba(142, 122, 93, 0.42);
  outline-offset: 1px;
}

.dock-button:disabled {
  color: #B8AF9F;
  background: transparent;
  cursor: default;
  opacity: 0.45;
}

.zoom-value {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 46px;
  padding: 0 3px;
  color: #4A453E;
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 500;
  line-height: 1;
  letter-spacing: 0.01em;
  font-variant-numeric: tabular-nums;
  user-select: none;
}

.dock-divider {
  width: 1px;
  height: 17px;
  margin: 0 5px;
  background: #EAE3D8;
}

/* ---------- Right inspector ---------- */

.inspector {
  position: relative;
  z-index: 10;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--panel);
  border-left: 1px solid var(--line);
}

.inspector-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.inspector-section {
  padding: 24px 20px;
}

.inspector-section + .inspector-section {
  border-top: 1px dashed #E4DCCE;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
}

.section-title {
  margin: 0;
  color: #7C7468;
  font-size: 12px;
  font-weight: 650;
  line-height: 1.2;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.section-context {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #8C8273;
  font-size: 10px;
  line-height: 1;
  letter-spacing: 0.03em;
}

.context-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #B4A88F;
  box-shadow: 0 0 0 3px rgba(180, 168, 143, 0.11);
}

/* Color picker */

.color-control {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr);
  align-items: center;
  gap: 13px;
  margin-bottom: 22px;
}

.color-wheel-wrap {
  position: relative;
  width: 46px;
  height: 46px;
}

.color-wheel {
  position: relative;
  display: block;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  cursor: pointer;
  transition: transform 0.2s ease, filter 0.2s ease;
}

.color-wheel-img {
  display: block;
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 2px 3px rgba(64, 52, 35, 0.12));
}

.color-wheel-center {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 45%;
  height: 45%;
  background: #2C2C2C;
  border: 2px solid #FFFDF9;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.16);
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.color-wheel:hover {
  transform: scale(1.045);
  filter: saturate(1.06);
}

.color-wheel:active {
  transform: scale(0.985);
}

.color-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  clip-path: inset(50%);
  pointer-events: none;
}

.color-wheel:has(+ .color-input:focus-visible) {
  outline: 2px solid rgba(142, 122, 93, 0.55);
  outline-offset: 3px;
}

.color-fields {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.color-field {
  display: grid;
  grid-template-columns: 35px minmax(0, 1fr);
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.color-field-label {
  color: #A09788;
  font-family: var(--mono);
  font-size: 8.5px;
  font-weight: 500;
  letter-spacing: 0.07em;
}

.color-field input {
  width: 100%;
  min-width: 0;
  height: 28px;
  padding: 0 8px;
  color: #413C35;
  font-family: var(--mono);
  font-size: 10.5px;
  font-variant-numeric: tabular-nums;
  background: #FAF7F1;
  border: 1px solid #E6DFD3;
  border-radius: 7px;
  transition: all 0.2s ease;
}

.color-field input:hover {
  background: #FFFDF9;
  border-color: #D8CEBE;
}

.color-field input:focus {
  background: #FFFFFF;
  border-color: #B5A181;
  outline: none;
  box-shadow: 0 0 0 3px rgba(181, 161, 129, 0.14);
}

/* Form controls */

.control-block {
  margin-top: 22px;
}

.control-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 9px;
  line-height: 1.2;
}

.control-label {
  color: #6B6459;
  font-size: 10.5px;
  font-weight: 550;
  letter-spacing: 0.035em;
}

.edge-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3px;
  min-width: 0;
  margin: 0;
  padding: 3px;
  background: #F1EAE0;
  border: 1px solid #ECE4D8;
  border-radius: 999px;
}

.edge-option {
  position: relative;
  display: block;
  min-width: 0;
}

.edge-label {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 30px;
  padding: 0 8px;
  color: #8A8174;
  font-size: 10.5px;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.edge-label .icon {
  width: 14px;
  height: 14px;
  flex: 0 0 auto;
}

.edge-label:hover {
  color: #4B453D;
}

.edge-input:checked + .edge-label {
  color: #2C2C2C;
  background: var(--surface);
  box-shadow: 0 1px 4px rgba(64, 52, 35, 0.1),
              inset 0 0 0 1px rgba(230, 223, 211, 0.65);
}

.edge-input:focus-visible + .edge-label {
  outline: 2px solid rgba(142, 122, 93, 0.5);
  outline-offset: 1px;
}

.value-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 48px;
  height: 21px;
  padding: 0 8px;
  color: #72695C;
  font-family: var(--mono);
  font-size: 9.5px;
  line-height: 1;
  background: #F6F1E8;
  border: 1px solid #EDE6DB;
  border-radius: 999px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.range-wrap {
  padding: 4px 0 0;
}

.brush-range {
  display: block;
  width: 100%;
  height: 18px;
  margin: 0;
  background-image: linear-gradient(to right, #9B886D 0 var(--fill), #DED6C8 var(--fill) 100%);
  background-repeat: no-repeat;
  background-position: center;
  background-size: 100% 3px;
  border: 0;
  border-radius: 999px;
  outline: none;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
}

.brush-range::-webkit-slider-runnable-track {
  height: 3px;
  background: transparent;
  border-radius: 999px;
}

.brush-range::-webkit-slider-thumb {
  width: 16px;
  height: 16px;
  margin-top: -6.5px;
  background: #FFFDF9;
  border: 1.5px solid #8D795D;
  border-radius: 50%;
  box-shadow: 0 1px 4px rgba(70, 57, 40, 0.18);
  cursor: grab;
  appearance: none;
  -webkit-appearance: none;
  transition: transform 0.16s ease, box-shadow 0.16s ease;
}

.brush-range::-webkit-slider-thumb:hover {
  transform: scale(1.08);
  box-shadow: 0 2px 6px rgba(70, 57, 40, 0.22);
}

.brush-range::-webkit-slider-thumb:active {
  cursor: grabbing;
  transform: scale(1.04);
}

.brush-range::-moz-range-track {
  height: 3px;
  background: transparent;
  border-radius: 999px;
}

.brush-range::-moz-range-thumb {
  width: 13px;
  height: 13px;
  background: #FFFDF9;
  border: 1.5px solid #8D795D;
  border-radius: 50%;
  box-shadow: 0 1px 4px rgba(70, 57, 40, 0.18);
  cursor: grab;
}

.brush-range:focus-visible::-webkit-slider-thumb {
  box-shadow: 0 0 0 4px rgba(141, 122, 94, 0.18),
              0 1px 4px rgba(70, 57, 40, 0.18);
}

.brush-range:focus-visible::-moz-range-thumb {
  box-shadow: 0 0 0 4px rgba(141, 122, 94, 0.18),
              0 1px 4px rgba(70, 57, 40, 0.18);
}

.range-scale {
  display: flex;
  justify-content: space-between;
  margin-top: 4px;
  color: #B1A797;
  font-family: var(--mono);
  font-size: 8px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.select-panel {
  padding: 14px;
  background: #F8F5EE;
  border: 1px solid #E9E1D5;
  border-radius: 10px;
}

.select-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.select-hint {
  margin: 0;
  color: #9B9285;
  font-size: 9px;
  line-height: 1.65;
  letter-spacing: 0.015em;
}

.select-hint + .select-hint {
  margin-top: 2px;
}

.tool-params[hidden],
.tool-empty[hidden] {
  display: none;
}

#eraser-params .control-block:first-child {
  margin-top: 0;
}

.hardness-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  margin: 0;
  padding: 4px;
  background: #F1EAE0;
  border: 1px solid #EAE2D5;
  border-radius: 12px;
}

.hardness-label {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 34px;
  color: #8A8174;
  font-size: 10.5px;
  font-weight: 500;
  line-height: 1;
  border-radius: 9px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.hardness-label:hover {
  color: #4B453D;
}

.edge-input:checked + .hardness-label {
  color: #3A342C;
  background: #D8C6A9;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

.edge-input:focus-visible + .hardness-label {
  outline: 2px solid rgba(142, 122, 93, 0.5);
  outline-offset: 1px;
}

.text-param-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 92px;
  gap: 10px;
  margin-bottom: 22px;
}

.text-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.text-select-wrap {
  position: relative;
  display: block;
}

.text-select {
  width: 100%;
  height: 34px;
  padding: 0 25px 0 9px;
  color: #4A453E;
  font-family: inherit;
  font-size: 10px;
  background: #FAF7F1;
  border: 1px solid #E6DFD3;
  border-radius: 8px;
  outline: none;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  transition: all 0.2s ease;
}

.text-select:hover {
  background: #FFFDF9;
  border-color: #D8CEBE;
}

.text-select:focus-visible {
  background: #FFFFFF;
  border-color: #B5A181;
  box-shadow: 0 0 0 3px rgba(181, 161, 129, 0.14);
}

.text-select-chevron {
  position: absolute;
  top: 50%;
  right: 8px;
  width: 11px;
  height: 11px;
  color: #A09788;
  transform: translateY(-50%);
  pointer-events: none;
}

.text-size-control {
  display: flex;
  align-items: center;
  height: 34px;
  overflow: hidden;
  background: #FAF7F1;
  border: 1px solid #E6DFD3;
  border-radius: 8px;
  transition: all 0.2s ease;
}

.text-size-control:hover {
  background: #FFFDF9;
  border-color: #D8CEBE;
}

.text-size-control:focus-within {
  background: #FFFFFF;
  border-color: #B5A181;
  box-shadow: 0 0 0 3px rgba(181, 161, 129, 0.14);
}

.text-size-control input {
  width: 100%;
  min-width: 0;
  height: 100%;
  padding: 0 2px 0 9px;
  color: #413C35;
  font-family: var(--mono);
  font-size: 10.5px;
  font-variant-numeric: tabular-nums;
  background: transparent;
  border: 0;
  outline: 0;
  appearance: textfield;
  -moz-appearance: textfield;
}

.text-size-control input::-webkit-outer-spin-button,
.text-size-control input::-webkit-inner-spin-button {
  margin: 0;
  appearance: none;
  -webkit-appearance: none;
}

.text-size-control span {
  padding-right: 9px;
  color: #A09788;
  font-family: var(--mono);
  font-size: 8.5px;
  line-height: 1;
  pointer-events: none;
}

.text-color-row {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  align-items: center;
  gap: 9px;
}

.text-color-chip {
  position: relative;
  display: block;
  width: 32px;
  height: 32px;
  padding: 2px;
  background: conic-gradient(from 210deg, #E9C46A, #E76F51, #D98BA8, #B18CD9, #78A9D1, #8FB996, #E9C46A);
  border: 1px solid #E3DACD;
  border-radius: 8px;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(64, 52, 35, 0.06);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.text-color-chip:hover {
  transform: scale(1.04);
  box-shadow: 0 2px 6px rgba(64, 52, 35, 0.1);
}

.text-color-chip-inner {
  display: block;
  width: 100%;
  height: 100%;
  background: #2C2C2C;
  border: 2px solid #FFFDF9;
  border-radius: 6px;
}

.text-color-hex {
  width: 100%;
  min-width: 0;
  height: 32px;
  padding: 0 9px;
  color: #413C35;
  font-family: var(--mono);
  font-size: 10.5px;
  font-variant-numeric: tabular-nums;
  background: #FAF7F1;
  border: 1px solid #E6DFD3;
  border-radius: 8px;
  outline: none;
  transition: all 0.2s ease;
}

.text-color-hex:hover {
  background: #FFFDF9;
  border-color: #D8CEBE;
}

.text-color-hex:focus {
  background: #FFFFFF;
  border-color: #B5A181;
  box-shadow: 0 0 0 3px rgba(181, 161, 129, 0.14);
}

.align-toggle {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 3px;
  margin: 0;
  padding: 3px;
  background: #F1EAE0;
  border: 1px solid #EAE2D5;
  border-radius: 9px;
}

.align-label {
  display: grid;
  place-items: center;
  height: 30px;
  color: #8A8174;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.align-label .icon {
  width: 16px;
  height: 16px;
}

.align-label:hover {
  color: #4B453D;
}

.edge-input:checked + .align-label {
  color: #2C2C2C;
  background: #FFFDF9;
  box-shadow: 0 1px 4px rgba(64, 52, 35, 0.1),
              inset 0 0 0 1px rgba(230, 223, 211, 0.65);
}

.edge-input:focus-visible + .align-label {
  outline: 2px solid rgba(142, 122, 93, 0.5);
  outline-offset: 1px;
}

.text-move-hint {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  row-gap: 4px;
  margin-top: 14px;
  color: #B0A695;
  font-size: 8px;
  line-height: 1.5;
  letter-spacing: 0.015em;
}

.text-move-hint .icon {
  width: 8px;
  height: 12px;
  flex: 0 0 auto;
  color: #C4B8A6;
}

.shape-type-toggle {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 3px;
  margin: 0;
  padding: 3px;
  background: #F1EAE0;
  border: 1px solid #EAE2D5;
  border-radius: 9px;
}

.shape-type-option {
  position: relative;
  display: block;
  min-width: 0;
}

.shape-type-input,
.shape-dash-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  clip-path: inset(50%);
  pointer-events: none;
}

.shape-type-label {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  height: 32px;
  color: #8A8174;
  font-size: 9.5px;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  border-radius: 7px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.shape-type-label .icon {
  width: 14px;
  height: 14px;
  flex: 0 0 auto;
}

.shape-type-label:hover {
  color: #4B453D;
}

.shape-type-input:checked + .shape-type-label {
  color: #2C2C2C;
  background: #FFFDF9;
  box-shadow: 0 1px 4px rgba(64, 52, 35, 0.1),
              inset 0 0 0 1px rgba(230, 223, 211, 0.65);
}

.shape-type-input:focus-visible + .shape-type-label {
  outline: 2px solid rgba(142, 122, 93, 0.5);
  outline-offset: 1px;
}

#shape-params > .control-block:first-of-type {
  margin-top: 20px;
}

.shape-color-row {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) 36px;
  align-items: center;
  gap: 8px;
}

.shape-color-chip {
  position: relative;
  display: block;
  width: 32px;
  height: 32px;
  padding: 2px;
  background: conic-gradient(from 210deg, #E9C46A, #E76F51, #D98BA8, #B18CD9, #78A9D1, #8FB996, #E9C46A);
  border: 1px solid #E3DACD;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(64, 52, 35, 0.06);
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.shape-color-chip:hover {
  transform: scale(1.04);
  box-shadow: 0 2px 6px rgba(64, 52, 35, 0.1);
}

.shape-color-chip:has(+ .color-input:focus-visible) {
  outline: 2px solid rgba(142, 122, 93, 0.55);
  outline-offset: 3px;
}

.shape-color-chip-inner {
  display: block;
  width: 100%;
  height: 100%;
  background: #D9C9AE;
  border: 2px solid #FFFDF9;
  border-radius: 6px;
  transition: background 0.18s ease, border-color 0.18s ease;
}

.shape-color-chip-inner.is-none {
  background:
    linear-gradient(135deg, transparent 43%, #C3B6A2 44%, #C3B6A2 56%, transparent 57%),
    #FFFDF9;
  border-color: #EFE8DC;
}

.shape-color-value {
  min-width: 0;
  color: #8E8476;
  font-family: var(--mono);
  font-size: 9.5px;
  line-height: 1;
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.shape-color-value.is-none {
  color: #B0A695;
}

.shape-none-button {
  height: 26px;
  padding: 0 10px;
  color: #8A8174;
  font-family: inherit;
  font-size: 9px;
  font-weight: 550;
  line-height: 1;
  background: #FAF7F1;
  border: 1px solid #E6DFD3;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.18s ease;
}

.shape-none-button:hover {
  color: #4B453D;
  background: #FFFDF9;
  border-color: #D8CEBE;
}

.shape-none-button[aria-pressed="true"] {
  color: #5B5347;
  background: #E9DFCF;
  border-color: #D9CBB5;
}

.shape-none-button:focus-visible {
  outline: 2px solid rgba(142, 122, 93, 0.5);
  outline-offset: 1px;
}

.shape-stroke-row {
  display: grid;
  grid-template-columns: 68px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  margin-top: 9px;
  transition: opacity 0.18s ease;
}

.shape-stroke-row.is-disabled {
  opacity: 0.42;
}

.shape-width-field {
  display: flex;
  align-items: center;
  height: 30px;
  overflow: hidden;
  background: #FAF7F1;
  border: 1px solid #E6DFD3;
  border-radius: 8px;
  transition: all 0.2s ease;
}

.shape-width-field:focus-within {
  background: #FFFFFF;
  border-color: #B5A181;
  box-shadow: 0 0 0 3px rgba(181, 161, 129, 0.14);
}

.shape-width-field input {
  width: 100%;
  min-width: 0;
  height: 100%;
  padding: 0 2px 0 8px;
  color: #413C35;
  font-family: var(--mono);
  font-size: 9.5px;
  font-variant-numeric: tabular-nums;
  background: transparent;
  border: 0;
  outline: 0;
  appearance: textfield;
  -moz-appearance: textfield;
}

.shape-width-field input::-webkit-outer-spin-button,
.shape-width-field input::-webkit-inner-spin-button,
.shape-metric-control input::-webkit-outer-spin-button,
.shape-metric-control input::-webkit-inner-spin-button {
  margin: 0;
  appearance: none;
  -webkit-appearance: none;
}

.shape-width-field span {
  padding-right: 7px;
  color: #A09788;
  font-family: var(--mono);
  font-size: 8px;
  line-height: 1;
  pointer-events: none;
}

.shape-dash-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3px;
  min-width: 0;
  margin: 0;
  padding: 3px;
  background: #F1EAE0;
  border: 1px solid #EAE2D5;
  border-radius: 999px;
}

.shape-dash-option {
  position: relative;
  display: block;
  min-width: 0;
}

.shape-dash-label {
  display: grid;
  place-items: center;
  height: 22px;
  color: #8A8174;
  font-size: 9px;
  font-weight: 500;
  line-height: 1;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.18s ease;
}

.shape-dash-label:hover {
  color: #4B453D;
}

.shape-dash-input:checked + .shape-dash-label {
  color: #2C2C2C;
  background: #FFFDF9;
  box-shadow: 0 1px 3px rgba(64, 52, 35, 0.09),
              inset 0 0 0 1px rgba(230, 223, 211, 0.65);
}

.shape-dash-input:focus-visible + .shape-dash-label {
  outline: 2px solid rgba(142, 122, 93, 0.5);
  outline-offset: 1px;
}

#shape-corner-block[hidden],
#shape-fill-block[hidden] {
  display: none;
}

.shape-metric-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 8px;
}

.shape-metric {
  display: grid;
  grid-template-columns: 16px minmax(0, 1fr);
  align-items: center;
  gap: 5px;
  min-width: 0;
}

.shape-metric-label {
  color: #A09788;
  font-family: var(--mono);
  font-size: 8.5px;
  line-height: 1;
  text-align: center;
}

.shape-metric-control {
  display: flex;
  align-items: center;
  height: 30px;
  overflow: hidden;
  background: #FAF7F1;
  border: 1px solid #E6DFD3;
  border-radius: 7px;
  transition: all 0.2s ease;
}

.shape-metric-control:focus-within {
  background: #FFFFFF;
  border-color: #B5A181;
  box-shadow: 0 0 0 3px rgba(181, 161, 129, 0.14);
}

.shape-metric-control:has(input:disabled) {
  background: #F7F3EB;
  border-color: #EEE8DD;
}

.shape-metric-control input {
  width: 100%;
  min-width: 0;
  height: 100%;
  padding: 0 2px 0 8px;
  color: #413C35;
  font-family: var(--mono);
  font-size: 9.5px;
  font-variant-numeric: tabular-nums;
  background: transparent;
  border: 0;
  outline: 0;
  appearance: textfield;
  -moz-appearance: textfield;
}

.shape-metric-control input:disabled {
  color: #B7AD9D;
  cursor: default;
}

.shape-metric-control span {
  padding-right: 7px;
  color: #A09788;
  font-family: var(--mono);
  font-size: 8px;
  line-height: 1;
  pointer-events: none;
}

.shape-create-hint {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  row-gap: 4px;
  margin-top: 12px;
  color: #B0A695;
  font-size: 8px;
  line-height: 1.5;
  letter-spacing: 0.015em;
}

.shape-create-hint + .shape-create-hint {
  margin-top: 5px;
}

.shape-create-hint .hint-dot {
  width: 2px;
  height: 2px;
  flex: 0 0 auto;
  background: #CEC3B2;
  border-radius: 50%;
}

.tool-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 142px;
  padding: 22px 16px;
  text-align: center;
  background: #F8F5EE;
  border: 1px dashed #DCD5C8;
  border-radius: var(--radius-md);
}

.tool-empty-icon {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  margin-bottom: 10px;
  color: #AA9F8D;
  background: #FFFDF9;
  border: 1px solid #E8E0D4;
  border-radius: 9px;
}

.tool-empty-icon .icon {
  width: 16px;
  height: 16px;
}

.tool-empty-title {
  margin: 0 0 5px;
  color: #978D7E;
  font-size: 10.5px;
  font-weight: 500;
  line-height: 1.4;
}

.tool-empty-hint {
  margin: 0;
  color: #B4AA9A;
  font-size: 9px;
  line-height: 1.5;
}

/* Layers */

.add-layer-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  height: 27px;
  padding: 0 9px;
  color: #72695C;
  font-family: inherit;
  font-size: 9.5px;
  font-weight: 550;
  line-height: 1;
  letter-spacing: 0.01em;
  white-space: nowrap;
  background: #F7F2E9;
  border: 1px solid #E9E1D5;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.add-layer-button .icon {
  width: 11px;
  height: 11px;
}

.add-layer-button:hover {
  color: #3D3831;
  background: #F0E9DD;
  border-color: #DCD2C2;
  box-shadow: 0 1px 3px rgba(64, 52, 35, 0.05);
}

.add-layer-button:active {
  background: #E9E1D4;
}

.layers-section .section-heading {
  margin-bottom: 12px;
}

.layers-heading-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.layer-count {
  display: inline-grid;
  place-items: center;
  min-width: 19px;
  height: 17px;
  padding: 0 5px;
  color: #918778;
  font-family: var(--mono);
  font-size: 8px;
  line-height: 1;
  background: #F6F1E8;
  border: 1px solid #ECE4D8;
  border-radius: 999px;
  font-variant-numeric: tabular-nums;
}

.layer-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  height: clamp(236px, 31vh, 304px);
  margin: -4px;
  padding: 4px;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  border-radius: 10px;
}

.layer-card {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) 42px 12px;
  grid-template-areas: "controls info thumb drag";
  align-items: center;
  column-gap: 7px;
  flex: 0 0 auto;
  min-width: 0;
  padding: 8px;
  background: #FFFDF9;
  border: 1px solid #E9E1D5;
  border-radius: 10px;
  box-shadow: 0 1px 2px rgba(64, 52, 35, 0.025);
  cursor: grab;
  outline: none;
  user-select: none;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  transition: background-color 0.18s ease, border-color 0.18s ease,
              box-shadow 0.18s ease, opacity 0.18s ease, filter 0.18s ease;
}

.layer-list.is-sorting .layer-card {
  will-change: transform;
}

.layer-card:hover {
  border-color: #D8CDBC;
  background: #FFFEFB;
}

.layer-card:focus-visible {
  outline: 2px solid rgba(142, 122, 93, 0.5);
  outline-offset: 1px;
}

.layer-list.has-selection .layer-card:not(.is-selected) {
  background: #FAF6EF;
  border-color: #EAE2D6;
}

.layer-list.has-selection .layer-card:not(.is-selected):hover {
  background: #F7F2EA;
  border-color: #DED4C4;
}

.layer-card.is-selected {
  background: #FFFEFB;
  border-color: #B7A381;
  box-shadow: 0 0 0 2px rgba(183, 163, 129, 0.14),
              0 2px 8px rgba(64, 52, 35, 0.05);
}

.layer-card.is-object-selected:not(.is-selected) {
  background: #FBF6EC;
  border-color: #CDBB9D;
  box-shadow: inset 0 0 0 1px rgba(183, 163, 129, 0.16);
}

.layer-card.is-selected .layer-drag {
  color: #9C8B72;
}

.layer-drag {
  grid-area: drag;
  display: grid;
  place-items: center;
  justify-self: end;
  width: 12px;
  height: 32px;
  color: #C8BDAC;
  cursor: grab;
  transition: color 0.18s ease;
}

.layer-drag .icon {
  display: block;
  width: 8px;
  height: 15px;
}

.layer-card:active .layer-drag {
  cursor: grabbing;
}

.layer-thumb {
  grid-area: thumb;
  width: 42px;
  height: 42px;
  overflow: hidden;
  opacity: var(--layer-opacity, 1);
  background-color: #FFFFFF;
  background-image:
    linear-gradient(45deg, #EEE9DF 25%, transparent 25%, transparent 75%, #EEE9DF 75%),
    linear-gradient(45deg, #EEE9DF 25%, transparent 25%, transparent 75%, #EEE9DF 75%);
  background-position: 0 0, 4px 4px;
  background-size: 8px 8px;
  border: 1px solid #E5DCCF;
  border-radius: 7px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.35);
  transition: opacity 0.16s ease, filter 0.18s ease;
}

.layer-thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.layer-info {
  grid-area: info;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.layer-name {
  min-width: 0;
  overflow: hidden;
  color: #4B453D;
  font-size: 10.5px;
  font-weight: 550;
  line-height: 1.25;
  letter-spacing: 0.015em;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: text;
}

.layer-name[contenteditable="true"] {
  overflow: visible;
  margin: -1px -3px;
  padding: 1px 3px;
  background: #FFFFFF;
  border-radius: 3px;
  box-shadow: 0 0 0 1px #C6B596;
  outline: none;
  text-overflow: clip;
  white-space: normal;
  user-select: text;
}

.layer-meta {
  overflow: hidden;
  color: #A99F90;
  font-size: 8px;
  line-height: 1.2;
  letter-spacing: 0.04em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.layer-leading {
  grid-area: controls;
  display: flex;
  align-items: center;
  gap: 3px;
  min-width: 0;
}

.visibility-toggle,
.opacity-trigger {
  display: grid;
  place-items: center;
  padding: 0;
  color: #9B9183;
  font-family: inherit;
  background: transparent;
  border: 0;
  cursor: pointer;
  transition: all 0.2s ease;
}

.visibility-toggle {
  width: 24px;
  height: 24px;
  border-radius: 6px;
}

.visibility-toggle .icon {
  width: 15px;
  height: 15px;
}

.visibility-toggle:hover {
  color: #4D473F;
  background: #F2ECE2;
}

.visibility-toggle .eye-closed {
  display: none;
}

.layer-card.is-hidden .visibility-toggle .eye-open {
  display: none;
}

.layer-card.is-hidden .visibility-toggle .eye-closed {
  display: block;
}

.opacity-trigger {
  justify-content: center;
  min-width: 31px;
  height: 20px;
  padding: 0 4px;
  color: #9B9183;
  font-family: var(--mono);
  font-size: 7.5px;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  background: #F8F3EA;
  border: 1px solid #EDE6DB;
  border-radius: 5px;
}

.opacity-trigger:hover,
.opacity-trigger[aria-expanded="true"] {
  color: #62594C;
  background: #F1EADF;
  border-color: #E2D7C6;
}

.layer-card.is-hidden,
.layer-list.has-selection .layer-card.is-hidden:not(.is-selected) {
  background-color: #EAE5DB;
  background-image: repeating-linear-gradient(
    -45deg,
    rgba(116, 104, 86, 0.045) 0,
    rgba(116, 104, 86, 0.045) 1px,
    transparent 1px,
    transparent 7px
  );
  border-color: #CFC5B6;
  border-style: dashed;
}

.layer-card.is-hidden .layer-thumb {
  opacity: 0.22;
  filter: grayscale(1) contrast(0.9);
}

.layer-card.is-hidden .layer-info {
  opacity: 0.48;
}

.layer-card.is-hidden .layer-name {
  color: #847B6D;
}

.layer-card.is-hidden .visibility-toggle {
  color: #746A5C;
  background: #E2DACE;
}

.layer-card.is-hidden .layer-meta {
  color: #8B7F6F;
}

.layer-card.is-hidden .opacity-trigger {
  color: #9B9182;
  background: #E8E1D6;
  border-color: #DAD0C2;
  opacity: 0.6;
}

.layer-card.is-hidden.is-selected {
  background-color: #F1ECE2;
  background-image: none;
  border-color: #B7A381;
  border-style: solid;
}

.layer-opacity-panel {
  grid-column: 1 / -1;
  margin-top: 9px;
  padding: 8px 7px 7px;
  background: #F7F2E9;
  border: 1px solid #EDE6DA;
  border-radius: 7px;
  cursor: default;
  animation: layer-panel-in 0.16s ease both;
}

.layer-opacity-panel[hidden] {
  display: none;
}

@keyframes layer-panel-in {
  from {
    opacity: 0;
    transform: translateY(-3px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.opacity-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 7px;
  color: #8E8476;
  font-size: 8.5px;
  line-height: 1;
  letter-spacing: 0.04em;
}

.opacity-value {
  color: #6D6457;
  font-family: var(--mono);
  font-size: 8.5px;
  font-variant-numeric: tabular-nums;
}

.opacity-range {
  display: block;
  width: 100%;
  height: 14px;
  margin: 0;
  padding: 0;
  background-image: linear-gradient(to right, #9B886D 0 var(--fill), #DED6C8 var(--fill) 100%);
  background-repeat: no-repeat;
  background-position: center;
  background-size: 100% 2px;
  border: 0;
  border-radius: 999px;
  outline: none;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
}

.opacity-range::-webkit-slider-runnable-track {
  height: 2px;
  background: transparent;
  border-radius: 999px;
}

.opacity-range::-webkit-slider-thumb {
  width: 12px;
  height: 12px;
  margin-top: -5px;
  background: #FFFDF9;
  border: 1.5px solid #8D795D;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(70, 57, 40, 0.16);
  cursor: grab;
  appearance: none;
  -webkit-appearance: none;
}

.opacity-range::-moz-range-track {
  height: 2px;
  background: transparent;
  border-radius: 999px;
}

.opacity-range::-moz-range-thumb {
  width: 9px;
  height: 9px;
  background: #FFFDF9;
  border: 1.5px solid #8D795D;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(70, 57, 40, 0.16);
  cursor: grab;
}

.opacity-range:focus-visible::-webkit-slider-thumb {
  box-shadow: 0 0 0 4px rgba(141, 122, 94, 0.16),
              0 1px 3px rgba(70, 57, 40, 0.16);
}

.opacity-range:focus-visible::-moz-range-thumb {
  box-shadow: 0 0 0 4px rgba(141, 122, 94, 0.16),
              0 1px 3px rgba(70, 57, 40, 0.16);
}

.layer-ghost {
  background: #F1EAE0 !important;
  border: 1px dashed #CBBEAA !important;
  box-shadow: none !important;
  opacity: 0.28 !important;
}

.layer-ghost > * {
  visibility: hidden;
}

.layer-chosen {
  cursor: grabbing;
  box-shadow: 0 8px 20px rgba(64, 52, 35, 0.12),
              0 0 0 1px rgba(183, 163, 129, 0.32) !important;
}

.layer-dragging {
  opacity: 0.96 !important;
}

.layer-drag-fallback {
  z-index: 100000 !important;
  opacity: 0.98 !important;
  scale: 1.012;
  border-color: #B7A381 !important;
  box-shadow: 0 16px 34px rgba(64, 52, 35, 0.17),
              0 3px 8px rgba(64, 52, 35, 0.08),
              0 0 0 1px rgba(183, 163, 129, 0.22) !important;
  cursor: grabbing !important;
  transition: none !important;
  pointer-events: none !important;
  will-change: transform;
  animation: layer-drag-lift 0.14s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes layer-drag-lift {
  from {
    scale: 0.985;
  }
  to {
    scale: 1.012;
  }
}

.layer-drag-fallback .layer-opacity-panel {
  display: none !important;
}

body.is-sorting-layers,
body.is-sorting-layers * {
  cursor: grabbing !important;
}

.layer-hint {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  row-gap: 4px;
  margin-top: 11px;
  color: #B0A695;
  font-size: 8px;
  line-height: 1.5;
  letter-spacing: 0.015em;
}

.layer-hint .icon {
  width: 8px;
  height: 12px;
  flex: 0 0 auto;
  color: #C4B8A6;
}

.layer-hint .hint-dot {
  width: 2px;
  height: 2px;
  border-radius: 50%;
  background: #CEC3B2;
}

.layer-hint-import {
  margin-top: 6px;
}

.layer-context-menu {
  position: fixed;
  z-index: 2000;
  min-width: 132px;
  padding: 5px;
  background: #FDFBF7;
  border: 1px solid #E6DFD3;
  border-radius: 10px;
  box-shadow: 0 10px 26px rgba(44, 44, 44, 0.11),
              0 2px 6px rgba(44, 44, 44, 0.05);
  animation: context-menu-in 0.13s ease both;
}

.layer-context-menu[hidden] {
  display: none;
}

@keyframes context-menu-in {
  from {
    opacity: 0;
    transform: translateY(-3px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.layer-context-delete {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  height: 32px;
  padding: 0 9px;
  color: #B4473C;
  font-family: inherit;
  font-size: 10.5px;
  font-weight: 550;
  line-height: 1;
  text-align: left;
  background: transparent;
  border: 0;
  border-radius: 7px;
  cursor: pointer;
  transition: background-color 0.16s ease, color 0.16s ease;
}

.layer-context-delete .icon {
  width: 14px;
  height: 14px;
  flex: 0 0 auto;
}

.layer-context-delete:hover,
.layer-context-delete:focus-visible {
  color: #96352C;
  background: #F8E9E6;
  outline: none;
}

/* Footer */

.panel-footer {
  flex: 0 0 auto;
  padding: 14px 20px 16px;
  background: #FCF9F3;
  border-top: 1px solid var(--line);
}

.shortcut-row {
  display: flex;
  align-items: center;
  gap: 11px;
  margin-bottom: 11px;
  white-space: nowrap;
}

.shortcut {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: #9B9285;
  font-size: 8.5px;
  line-height: 1;
}

kbd {
  display: inline-grid;
  place-items: center;
  min-width: 18px;
  height: 17px;
  padding: 0 4px;
  color: #887E70;
  font-family: var(--font);
  font-size: 8px;
  font-weight: 500;
  line-height: 1;
  background: #FFFDF9;
  border: 1px solid #E3DACD;
  border-bottom-color: #D4C8B6;
  border-radius: 4px;
  box-shadow: 0 1px 0 rgba(64, 52, 35, 0.04);
}

.footer-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: #AFA596;
  font-size: 8px;
  line-height: 1;
  letter-spacing: 0.05em;
}


/* ---------- Project replacement confirmation ---------- */

.confirm-backdrop {
  position: fixed;
  inset: 0;
  z-index: 4000;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(44, 38, 29, 0.22);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  animation: confirm-backdrop-in 0.16s ease both;
}

.confirm-backdrop[hidden] {
  display: none;
}

.confirm-dialog {
  width: min(420px, calc(100vw - 32px));
  padding: 24px;
  background: var(--surface);
  border: 1px solid #E1D8C9;
  border-radius: 14px;
  box-shadow: 0 24px 60px rgba(44, 38, 29, 0.2),
              0 6px 18px rgba(44, 38, 29, 0.08);
  animation: confirm-dialog-in 0.18s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.confirm-dialog-title {
  margin: 0;
  color: var(--text);
  font-size: 14px;
  font-weight: 650;
  line-height: 1.3;
  letter-spacing: 0.01em;
}

.confirm-dialog-message {
  margin: 10px 0 0;
  color: var(--text-soft);
  font-size: 11.5px;
  line-height: 1.7;
  word-break: break-word;
}

.confirm-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 24px;
}

.confirm-button {
  min-width: 64px;
  height: 34px;
  padding: 0 18px;
  color: #5E5548;
  font-family: inherit;
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
  letter-spacing: 0.03em;
  background: #F8F3EA;
  border: 1px solid #E2D8C8;
  border-radius: 8px;
  cursor: pointer;
  transition: background-color 0.16s ease, border-color 0.16s ease,
              box-shadow 0.16s ease, transform 0.16s ease;
}

.confirm-button:hover {
  background: #F1E9DC;
  border-color: #D6C8B3;
}

.confirm-button:active {
  transform: translateY(1px);
}

.confirm-button-primary {
  color: #3A352E;
  background: var(--accent);
  border-color: rgba(181, 158, 122, 0.42);
  box-shadow: 0 2px 7px rgba(91, 73, 45, 0.1),
              inset 0 1px 0 rgba(255, 255, 255, 0.35);
}

.confirm-button-primary:hover {
  background: var(--accent-hover);
  border-color: rgba(181, 158, 122, 0.6);
}

.confirm-button:focus-visible {
  outline: 2px solid rgba(142, 122, 93, 0.55);
  outline-offset: 2px;
}

@keyframes confirm-backdrop-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes confirm-dialog-in {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* ---------- Focus & motion ---------- */

button:focus-visible {
  outline: 2px solid rgba(142, 122, 93, 0.55);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}

@media (max-width: 1120px) {
  .project-save {
    display: none;
  }

  .brand-sub {
    display: none;
  }
}

@media (max-width: 900px) {
  .workspace {
    grid-template-columns: 64px minmax(0, 1fr);
  }

  .inspector {
    display: none;
  }
}

@media (max-width: 620px) {
  .app-header {
    grid-template-columns: auto 1fr auto;
    padding: 0 14px;
  }

  .project {
    justify-self: center;
  }

  .project-name {
    max-width: 150px;
  }

  .export-button {
    width: 36px;
    padding: 0;
  }

  .export-button span {
    display: none;
  }

  .export-caret {
    display: none;
  }

  .pixel-preview-label {
    display: none;
  }

  .pixel-preview-control {
    gap: 5px;
    padding: 0 6px;
  }

  .language-trigger {
    width: 28px;
    height: 28px;
  }

  .language-menu {
    width: 172px;
  }
}
