/*
 * ForgePix 界面样式
 * ----------------------------------------------------------------
 * 1. 桌面端采用“顶部栏 + 工具栏 + 画布 + 属性面板”网格布局。
 * 2. 860px 以下切换为单列画布和底部工具栏，属性面板改为可滑出的浮层。
 * 3. is-* 类表示运行时状态，browser-only 表示仅浏览器环境可见。
 * 4. z-index 从画布叠层、浮动控件、顶部栏到移动端面板逐级增加。
 */

/* ================================================================
   全局基础样式与设计令牌
   ================================================================ */
:root {
  color-scheme: dark;
  --ink: #17181c;
  --ink-soft: #22242a;
  --ink-muted: #30333b;
  --panel: #f4f2ed;
  --panel-strong: #ffffff;
  --text: #1e2025;
  --muted: #74767d;
  --line: #dedbd3;
  --accent: #ff5a36;
  --accent-dark: #d63d1c;
  --cream: #fffaf0;
  --shadow: 0 18px 46px rgba(0, 0, 0, 0.25);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--ink);
}

body {
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  touch-action: manipulation;
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 3px solid rgba(255, 90, 54, 0.36);
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

/* ================================================================
   应用骨架与顶部栏
   ================================================================ */
.app-shell {
  display: grid;
  grid-template-rows: 64px minmax(0, 1fr);
  width: 100%;
  height: 100dvh;
  min-height: 520px;
  background: var(--ink);
}

.topbar {
  position: relative;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 24px;
  min-width: 0;
  padding: 0 18px;
  color: #fff;
  background: #111216;
  border-bottom: 1px solid #2b2d33;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 220px;
}

.brand-mark {
  display: block;
  width: 29px;
  height: 29px;
  border-radius: 7px;
}

.brand-copy {
  display: flex;
  flex-direction: column;
  line-height: 1;
}

.brand-copy strong {
  font-size: 18px;
  letter-spacing: 0.03em;
}

.brand-copy small {
  margin-top: 5px;
  color: #8a8d95;
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.18em;
}

.file-summary {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  margin-right: auto;
  color: #aeb0b7;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
}

.file-summary span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
}

.status-dot {
  flex: 0 0 auto;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #555861;
}

.file-summary.has-file .status-dot {
  background: #63d092;
  box-shadow: 0 0 0 4px rgba(99, 208, 146, 0.1);
}

.top-actions,
.button-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-button,
.ghost-button,
.primary-button,
.secondary-button,
.accent-button,
.danger-button {
  min-height: 40px;
  border-radius: 10px;
  font-weight: 700;
  transition: transform 0.16s ease, background 0.16s ease, opacity 0.16s ease;
}

.icon-button:hover:not(:disabled),
.ghost-button:hover:not(:disabled),
.primary-button:hover:not(:disabled),
.secondary-button:hover:not(:disabled),
.accent-button:hover:not(:disabled),
.export-button:hover:not(:disabled) {
  transform: translateY(-1px);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.38;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 40px;
  padding: 0;
  color: #f7f7f7;
  background: #25272d;
  font-size: 21px;
}

.mobile-settings-button { display: none; }

.is-desktop-app .browser-only {
  display: none !important;
}

.ghost-button {
  padding: 0 14px;
  color: #c5c7cc;
  background: transparent;
}

.ghost-button:hover:not(:disabled) {
  background: #25272d;
}

/* 浏览器版下载入口刻意弱于“打开图片”主按钮，但保留清晰的版本信息。 */
.ghost-button.desktop-download-button {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 42px;
  padding: 0 12px 0 8px;
  overflow: hidden;
  color: #f5f6f8;
  white-space: nowrap;
  text-decoration: none;
  background: linear-gradient(135deg, #292b32, #202127);
  border: 1px solid #393b44;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05), 0 5px 14px rgba(0, 0, 0, 0.18);
  transition: transform 0.16s ease, color 0.16s ease, background 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
}

.ghost-button.desktop-download-button::before {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 18% 0%, rgba(255, 90, 54, 0.2), transparent 55%);
  content: "";
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.16s ease;
}

.ghost-button.desktop-download-button:hover {
  color: #fff;
  background: linear-gradient(135deg, #302822, #242329);
  border-color: rgba(255, 112, 79, 0.62);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.07), 0 8px 20px rgba(255, 90, 54, 0.14);
}

.ghost-button.desktop-download-button:hover::before {
  opacity: 1;
}

.download-button-icon,
.download-button-copy {
  position: relative;
  z-index: 1;
}

.download-button-icon {
  display: grid;
  flex: 0 0 28px;
  width: 28px;
  height: 28px;
  place-items: center;
  color: #ff8267;
  background: rgba(255, 90, 54, 0.12);
  border: 1px solid rgba(255, 116, 84, 0.18);
  border-radius: 8px;
}

.download-button-icon svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.7;
}

.download-button-copy {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1;
}

.download-button-copy strong {
  font-size: 12px;
  letter-spacing: 0.02em;
}

.download-button-copy small {
  margin-top: 4px;
  color: #8f929b;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.035em;
}

.desktop-download-button:hover .download-button-copy small {
  color: #c6c8ce;
}

.primary-button {
  padding: 0 17px;
  color: #fff;
  background: var(--accent);
  box-shadow: 0 8px 20px rgba(255, 90, 54, 0.22);
}

/* ================================================================
   主编辑布局与工具栏
   ================================================================ */
.editor-grid {
  position: relative;
  display: grid;
  grid-template-columns: 78px minmax(0, 1fr) 326px;
  min-height: 0;
}

.tool-rail {
  position: relative;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  padding: 16px 9px;
  overflow-y: auto;
  background: #18191e;
  border-right: 1px solid #2c2e35;
}

.tool-button {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-width: 58px;
  min-height: 62px;
  padding: 7px 3px;
  color: #898c94;
  background: transparent;
  border-radius: 11px;
  font-size: 11px;
  font-weight: 650;
}

.tool-button:hover {
  color: #e2e3e6;
  background: #24262c;
}

.tool-button.is-active {
  color: #fff;
  background: #2b2d34;
  box-shadow: inset 3px 0 0 var(--accent);
}

.tool-glyph {
  display: grid;
  place-items: center;
  width: 25px;
  height: 25px;
  color: currentColor;
  font-size: 24px;
  font-weight: 500;
  line-height: 1;
}

.text-glyph {
  font-family: Georgia, serif;
  font-size: 23px;
  font-weight: 800;
}

.number-glyph {
  width: 23px;
  height: 23px;
  color: #fff;
  background: var(--accent);
  border-radius: 50%;
  font-size: 13px;
  font-weight: 800;
}

/* 工具图标使用纯 CSS 绘制，避免字体图标和外部资源。 */
.crop-glyph::before,
.crop-glyph::after {
  content: "";
  position: absolute;
  width: 13px;
  height: 13px;
}

.crop-glyph {
  position: relative;
}

.crop-glyph::before {
  top: 3px;
  left: 3px;
  border-top: 2px solid;
  border-left: 2px solid;
}

.crop-glyph::after {
  right: 3px;
  bottom: 3px;
  border-right: 2px solid;
  border-bottom: 2px solid;
}

.mosaic-glyph {
  width: 22px;
  height: 22px;
  border: 1px solid currentColor;
  border-radius: 2px;
  background:
    linear-gradient(90deg, currentColor 50%, transparent 50%) 0 0 / 10px 10px,
    linear-gradient(currentColor 50%, transparent 50%) 5px 5px / 10px 10px;
  opacity: 0.86;
}

.arrow-glyph {
  position: relative;
  width: 24px;
  height: 24px;
}

.arrow-glyph::before {
  content: "";
  position: absolute;
  inset: 2px;
  background: currentColor;
  clip-path: polygon(2% 43%, 62% 43%, 62% 18%, 100% 50%, 62% 82%, 62% 57%, 2% 57%);
  transform: rotate(-38deg);
  filter: drop-shadow(0 1px 0 rgba(0, 0, 0, 0.18));
}

.arrow-glyph::after {
  content: none;
}

.highlight-glyph {
  position: relative;
  width: 23px;
  height: 18px;
  margin-top: 3px;
  background: rgba(255, 216, 77, 0.35);
  border: 2px solid currentColor;
  border-radius: 4px;
  box-shadow: inset 0 -5px 0 rgba(255, 216, 77, 0.72);
}

.rectangle-glyph,
.ellipse-glyph,
.shape-glyph {
  width: 23px;
  height: 17px;
  border: 2px solid currentColor;
}

.rectangle-glyph { border-radius: 2px; }
.ellipse-glyph { border-radius: 50%; }
.shape-glyph { border-radius: 2px 50% 50% 2px; }
.shape-glyph.is-ellipse { border-radius: 50%; }

.watermark-glyph {
  display: grid;
  place-items: center;
  width: 24px;
  height: 20px;
  color: currentColor;
  border: 2px dashed currentColor;
  border-radius: 5px;
  transform: rotate(-12deg);
  font-family: Georgia, serif;
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
  opacity: 0.82;
}

/* ================================================================
   图片工作区、空状态与画布叠层
   ================================================================ */
.workspace {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background-color: #23252b;
  background-image: radial-gradient(#3b3e46 0.75px, transparent 0.75px);
  background-size: 19px 19px;
}

.empty-state {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 30px;
  color: #fff;
  text-align: center;
}

.empty-state h1 {
  margin: 24px 0 9px;
  font-family: Georgia, "Songti SC", serif;
  font-size: clamp(28px, 3.2vw, 45px);
  font-weight: 600;
  letter-spacing: -0.02em;
}

.empty-state p {
  margin: 0;
  color: #9b9ea6;
  font-size: 14px;
  line-height: 1.8;
}

.empty-art {
  position: relative;
  width: 190px;
  height: 132px;
  overflow: hidden;
  background: #30323a;
  border: 1px solid #4b4e58;
  border-radius: 9px;
  box-shadow: 0 24px 55px rgba(0, 0, 0, 0.27);
  transform: rotate(-2deg);
}

.empty-art::after {
  content: "";
  position: absolute;
  inset: 6px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 5px;
}

.empty-sun {
  position: absolute;
  top: 27px;
  right: 35px;
  width: 25px;
  height: 25px;
  background: var(--accent);
  border-radius: 50%;
}

.empty-mountain {
  position: absolute;
  bottom: -36px;
  width: 126px;
  height: 126px;
  background: #6d727d;
  transform: rotate(45deg);
  border-radius: 12px 3px;
}

.mountain-one { left: 3px; }
.mountain-two { right: -45px; bottom: -56px; background: #525660; }

.empty-spark {
  position: absolute;
  z-index: 3;
  color: #c9cbd0;
  font-size: 20px;
}

.spark-one { top: 16px; left: 23px; }
.spark-two { top: 48px; left: 51px; font-size: 12px; }

.drop-button {
  min-width: 145px;
  min-height: 46px;
  margin-top: 23px;
  color: #fff;
  background: var(--accent);
  border-radius: 12px;
  font-weight: 750;
  box-shadow: 0 12px 30px rgba(255, 90, 54, 0.24);
}

.privacy-note {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 16px;
  color: #777b84;
  font-size: 11px;
}

.privacy-note i {
  display: grid;
  place-items: center;
  width: 15px;
  height: 15px;
  color: #25272d;
  background: #6dd29c;
  border-radius: 50%;
  font-size: 10px;
  font-style: normal;
  font-weight: 900;
}

.canvas-viewport {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 40px 46px 74px;
  overflow: hidden;
  touch-action: none;
}

.canvas-wrap {
  position: relative;
  flex: 0 0 auto;
  line-height: 0;
  transform-origin: center center;
  will-change: transform;
  box-shadow: var(--shadow);
}

/* 就地输入框会根据落点切换方向，避免超出图片边缘。 */
.text-composer {
  position: absolute;
  z-index: 20;
  width: min(260px, 70%);
  padding: 8px;
  line-height: 1.3;
  color: #24262c;
  background: rgba(255, 255, 255, 0.98);
  border: 2px solid var(--accent);
  border-radius: 12px;
  box-shadow: 0 16px 38px rgba(0, 0, 0, 0.35);
  transform: translate(8px, 8px);
}

.text-composer.align-right {
  transform: translate(calc(-100% - 8px), 8px);
}

.text-composer.align-above {
  transform: translate(8px, calc(-100% - 8px));
}

.text-composer.align-right.align-above {
  transform: translate(calc(-100% - 8px), calc(-100% - 8px));
}

.text-composer textarea {
  display: block;
  width: 100%;
  min-height: 72px;
  padding: 10px;
  color: #202126;
  background: #f6f4ef;
  border: 1px solid #d9d5cc;
  border-radius: 8px;
  outline: none;
  resize: vertical;
}

.text-composer textarea:focus {
  border-color: var(--accent);
}

.text-composer-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 7px;
}

.text-composer-footer > span {
  color: #8a8c92;
  font-size: 9px;
}

.text-composer-footer div {
  display: flex;
  gap: 6px;
}

.text-composer-footer button {
  min-height: 30px;
  padding: 0 10px;
  color: #65676d;
  background: #ebe8e1;
  border-radius: 7px;
  font-size: 10px;
  font-weight: 800;
}

#confirmCanvasText {
  color: #fff;
  background: var(--accent);
}

/* 底层画布显示结果，上层画布只承载临时笔迹与选择框。 */
#editorCanvas,
#interactionCanvas {
  display: block;
  max-width: none;
  background-image: linear-gradient(45deg, #d9d9d9 25%, transparent 25%), linear-gradient(-45deg, #d9d9d9 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #d9d9d9 75%), linear-gradient(-45deg, transparent 75%, #d9d9d9 75%);
  background-position: 0 0, 0 7px, 7px -7px, -7px 0;
  background-size: 14px 14px;
  background-color: #f4f4f4;
}

#interactionCanvas {
  position: absolute;
  inset: 0;
  background: transparent;
  touch-action: none;
  cursor: grab;
}

#interactionCanvas[data-cursor="crosshair"] { cursor: crosshair; }
#interactionCanvas[data-cursor="text"] { cursor: text; }
#interactionCanvas[data-cursor="grabbing"] { cursor: grabbing; }

.zoom-controls {
  position: absolute;
  z-index: 12;
  left: 50%;
  bottom: 18px;
  display: flex;
  align-items: center;
  overflow: hidden;
  transform: translateX(-50%);
  background: rgba(17, 18, 22, 0.9);
  border: 1px solid #3a3d45;
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  backdrop-filter: blur(10px);
}

.zoom-controls button {
  min-width: 42px;
  min-height: 38px;
  padding: 0 12px;
  color: #c6c8cd;
  background: transparent;
  font-weight: 750;
}

.zoom-controls button:hover { color: #fff; background: #2b2d34; }
.zoom-controls button:nth-child(2) { min-width: 68px; border-right: 1px solid #383a42; border-left: 1px solid #383a42; font-size: 12px; }

.drop-overlay {
  position: absolute;
  z-index: 60;
  inset: 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #fff;
  background: rgba(24, 25, 30, 0.92);
  border: 2px dashed var(--accent);
  border-radius: 20px;
  backdrop-filter: blur(9px);
}

.drop-overlay strong { font-size: 24px; }
.drop-overlay span { margin-top: 8px; color: #a6a9b1; }

/* ================================================================
   工具属性面板
   ================================================================ */
.side-panel {
  position: relative;
  z-index: 24;
  min-width: 0;
  min-height: 0;
  color: var(--text);
  background: var(--panel);
  border-left: 1px solid #d1cec6;
}

.panel-scroll {
  height: 100%;
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: #c4c1b9 transparent;
}

.panel-section {
  padding: 24px 22px;
  border-bottom: 1px solid var(--line);
}

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

.section-heading.compact { margin-bottom: 16px; }

.section-heading h2 {
  margin: 4px 0 0;
  font-family: Georgia, "Songti SC", serif;
  font-size: 22px;
  line-height: 1.12;
}

.eyebrow {
  color: var(--accent);
  font-size: 9px;
  font-weight: 850;
  letter-spacing: 0.16em;
}

.panel-close {
  display: none;
  width: 36px;
  height: 36px;
  color: #55575e;
  background: #e8e5de;
  border-radius: 9px;
  font-size: 23px;
}

.tool-panel { display: none; }
.tool-panel.is-visible { display: block; }

.helper-copy {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.65;
}

.selected-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
  padding: 12px 13px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.selected-card div { display: flex; flex-direction: column; gap: 3px; }
.selected-card span { color: var(--muted); font-size: 10px; }
.selected-card strong { font-size: 13px; }
.danger-button { min-height: 34px; padding: 0 12px; color: #bb351a; background: #fff0eb; font-size: 12px; }

.field-label,
.text-field > span,
.select-field > span,
.range-field b {
  color: #55575d;
  font-size: 11px;
  font-weight: 750;
}

.field-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin: 14px 0;
}

.color-input {
  width: 39px;
  height: 32px;
  padding: 3px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 9px;
  cursor: pointer;
}

/* 比例选择器及其他分段按钮。 */
.segmented {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  margin-top: 8px;
  padding: 4px;
  background: #e7e4dd;
  border-radius: 10px;
}

.segmented button {
  min-height: 34px;
  color: #6b6d73;
  background: transparent;
  border-radius: 7px;
  font-size: 11px;
  font-weight: 750;
}

.segmented button.is-active {
  color: var(--text);
  background: #fff;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.08);
}

/* 自定义裁剪宽高，中间一列用于乘号。 */
.crop-custom-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 14px minmax(0, 1fr);
  align-items: end;
  gap: 6px;
  margin-top: 8px;
}

.crop-custom-grid .text-field { margin: 8px 0 0; }
.crop-custom-grid > span { padding-bottom: 12px; color: #8b8d93; text-align: center; }
.crop-custom-hint { margin-top: 7px; }

.shape-type-picker {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 8px 0 17px;
}

.shape-type-picker button {
  display: grid;
  grid-template-columns: 48px 1fr;
  align-items: center;
  min-height: 62px;
  padding: 8px 13px;
  color: #62646b;
  background: #e9e6df;
  border: 2px solid transparent;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 800;
  text-align: left;
}

.shape-type-picker button.is-active {
  color: var(--accent-dark);
  background: #fff4ef;
  border-color: var(--accent);
  box-shadow: 0 5px 14px rgba(255, 90, 54, 0.12);
}

.shape-choice-icon {
  display: block;
  width: 34px;
  height: 25px;
  border: 3px solid currentColor;
}

.shape-choice-icon.is-rectangle { border-radius: 3px; }
.shape-choice-icon.is-ellipse { border-radius: 50%; }

.crop-size-readout,
.export-dimensions {
  display: flex;
  justify-content: space-between;
  margin: 16px 0;
  padding: 11px 12px;
  background: #e9e6df;
  border-radius: 9px;
  color: #71737a;
  font-size: 11px;
}

.crop-size-readout strong { color: #303238; }
.button-row > * { flex: 1; }
.secondary-button { padding: 0 14px; color: #56585e; background: #e4e1da; }
.accent-button { padding: 0 14px; color: #fff; background: var(--accent); }

/* ================================================================
   通用表单控件
   ================================================================ */
.range-field,
.text-field,
.select-field {
  display: block;
  margin: 15px 0;
}

.range-field > span,
.select-field > span {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.range-field output {
  color: var(--accent-dark);
  font-size: 11px;
  font-weight: 800;
}

input[type="range"] {
  width: 100%;
  height: 4px;
  margin: 7px 0;
  accent-color: var(--accent);
}

.text-field textarea,
.text-field input,
.select-field select {
  width: 100%;
  margin-top: 7px;
  padding: 11px 12px;
  color: #292b31;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: none;
}

.text-field textarea { resize: vertical; min-height: 72px; line-height: 1.5; }
.text-field input:focus,
.text-field textarea:focus,
.select-field select:focus { border-color: var(--accent); }

.toggle-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin: 14px 0;
}

.toggle-row label {
  position: relative;
}

.toggle-row input {
  position: absolute;
  opacity: 0;
}

.toggle-row span {
  display: grid;
  place-items: center;
  min-height: 38px;
  color: #73757b;
  background: #e6e3dc;
  border: 1px solid transparent;
  border-radius: 9px;
  font-size: 11px;
  font-weight: 750;
  cursor: pointer;
}

.toggle-row input:checked + span {
  color: var(--accent-dark);
  background: #fff2ed;
  border-color: rgba(255, 90, 54, 0.25);
}

/* 序号列表与画布中的 annotation 命令保持同步。 */
.annotation-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 226px;
  margin-top: 14px;
  overflow: auto;
}

.empty-list {
  padding: 18px 8px;
  color: #96989d;
  background: #e9e6df;
  border-radius: 10px;
  font-size: 11px;
  text-align: center;
}

.annotation-item {
  display: grid;
  grid-template-columns: 29px minmax(0, 1fr) 30px;
  align-items: center;
  gap: 8px;
  padding: 8px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
}

.annotation-item.is-selected { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(255, 90, 54, 0.1); }
.annotation-index { display: grid; place-items: center; width: 27px; height: 27px; color: #fff; background: var(--accent); border: 2px solid currentColor; border-radius: 50%; font-size: 12px; font-weight: 850; }
.annotation-item input { min-width: 0; height: 31px; padding: 0 7px; color: #3b3d43; background: #f6f4ef; border: 1px solid transparent; border-radius: 7px; font-size: 11px; }
.annotation-item input:focus { border-color: var(--accent); outline: none; }
.annotation-delete { width: 29px; height: 29px; color: #a1a2a7; background: transparent; border-radius: 7px; font-size: 17px; }
.annotation-delete:hover { color: #bb351a; background: #fff0eb; }

/* ================================================================
   导出、状态提示与确认对话框
   ================================================================ */
.export-section { background: #eeece6; }

.stats-strip {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 10px;
  padding: 12px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.stats-strip div { display: flex; flex-direction: column; gap: 3px; }
.stats-strip span { color: #8a8c92; font-size: 9px; }
.stats-strip strong { font-size: 12px; }
.stats-strip div:last-child { text-align: right; }
.stats-strip .stats-arrow { color: var(--accent); font-size: 17px; }

.export-dimensions { justify-content: center; margin: 10px 0 12px; font-weight: 750; letter-spacing: 0.03em; }

.export-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: 50px;
  padding: 0 16px 0 18px;
  color: #fff;
  background: var(--accent);
  border-radius: 12px;
  box-shadow: 0 12px 26px rgba(255, 90, 54, 0.2);
  font-weight: 800;
}

.export-button b { display: grid; place-items: center; width: 28px; height: 28px; color: var(--accent); background: #fff; border-radius: 50%; font-size: 18px; }
.local-note { margin: 10px 0 0; color: #9a9b9f; font-size: 9px; text-align: center; }
.local-note span { color: #63be88; }

/* ================================================================
   裁剪遮罩、控制点与三分网格
   ================================================================ */
.crop-layer {
  position: absolute;
  z-index: 8;
  inset: 0;
  pointer-events: none;
}

.crop-shade {
  position: absolute;
  background: rgba(6, 7, 9, 0.62);
}

.crop-box {
  position: absolute;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.5);
  pointer-events: auto;
  touch-action: none;
  cursor: move;
}

.crop-grid { position: absolute; background: rgba(255, 255, 255, 0.4); pointer-events: none; }
.grid-v { top: 0; bottom: 0; width: 1px; }
.grid-v.one { left: 33.333%; }
.grid-v.two { left: 66.666%; }
.grid-h { left: 0; right: 0; height: 1px; }
.grid-h.one { top: 33.333%; }
.grid-h.two { top: 66.666%; }

.crop-handle {
  position: absolute;
  width: 18px;
  height: 18px;
  padding: 0;
  background: transparent;
  pointer-events: auto;
}

.crop-handle::after {
  content: "";
  position: absolute;
  inset: 5px;
  background: #fff;
  border: 1px solid #25272d;
  border-radius: 1px;
}

.crop-handle.nw { left: -9px; top: -9px; cursor: nwse-resize; }
.crop-handle.n { left: calc(50% - 9px); top: -9px; cursor: ns-resize; }
.crop-handle.ne { right: -9px; top: -9px; cursor: nesw-resize; }
.crop-handle.e { right: -9px; top: calc(50% - 9px); cursor: ew-resize; }
.crop-handle.se { right: -9px; bottom: -9px; cursor: nwse-resize; }
.crop-handle.s { left: calc(50% - 9px); bottom: -9px; cursor: ns-resize; }
.crop-handle.sw { left: -9px; bottom: -9px; cursor: nesw-resize; }
.crop-handle.w { left: -9px; top: calc(50% - 9px); cursor: ew-resize; }

.toast {
  position: fixed;
  z-index: 100;
  left: 50%;
  bottom: 24px;
  max-width: calc(100vw - 32px);
  padding: 11px 16px;
  color: #fff;
  background: rgba(17, 18, 22, 0.94);
  border: 1px solid #3d4048;
  border-radius: 10px;
  box-shadow: var(--shadow);
  font-size: 12px;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 10px);
  transition: 0.2s ease;
}

.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }
.toast.is-error { background: #611f14; border-color: #8c2d1c; }

.confirm-dialog {
  width: min(390px, calc(100vw - 32px));
  padding: 0;
  color: var(--text);
  background: var(--panel);
  border: 0;
  border-radius: 18px;
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.5);
}

.confirm-dialog::backdrop { background: rgba(5, 6, 8, 0.72); backdrop-filter: blur(3px); }
.confirm-dialog form { padding: 28px; text-align: center; }
.dialog-icon { display: grid; place-items: center; width: 48px; height: 48px; margin: 0 auto 14px; color: var(--accent); background: #ffe7df; border-radius: 50%; font-size: 25px; }
.confirm-dialog h2 { margin: 0; font-family: Georgia, "Songti SC", serif; font-size: 22px; }
.confirm-dialog p { margin: 10px 0 22px; color: var(--muted); font-size: 12px; line-height: 1.65; }

.panel-handle { display: none; }

/* ================================================================
   响应式布局：
   - 1100px：压缩桌面侧栏和品牌信息；
   - 860px：进入触控优先的单列编辑布局；
   - 480px：下载入口折叠为图标，给关键操作保留空间。
   ================================================================ */
@media (max-width: 1100px) {
  .editor-grid { grid-template-columns: 72px minmax(0, 1fr) 300px; }
  .panel-section { padding: 20px 17px; }
  .brand { min-width: 185px; }
  .brand-copy small { display: none; }
}

@media (max-width: 860px) {
  .app-shell { grid-template-rows: 58px minmax(0, 1fr); min-height: 460px; }
  .topbar { gap: 10px; padding: 0 10px; }
  .brand { min-width: auto; margin-right: auto; }
  .brand-copy strong { font-size: 16px; }
  .file-summary { display: none; }
  .hide-mobile { display: none; }
  .primary-button { min-width: 42px; padding: 0 12px; font-size: 0; }
  .primary-button span { font-size: 20px; }
  .mobile-settings-button { display: grid; }
  .mobile-settings-button[aria-expanded="true"] { color: #fff; background: var(--accent); }
  .editor-grid { grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr) calc(70px + var(--safe-bottom)); }
  .workspace { grid-row: 1; }
  .tool-rail {
    grid-row: 2;
    flex-direction: row;
    align-items: stretch;
    justify-content: flex-start;
    gap: 1px;
    padding: 6px 6px calc(6px + var(--safe-bottom));
    border-top: 1px solid #30323a;
    border-right: 0;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
  }
  .tool-rail::-webkit-scrollbar { display: none; }
  .tool-button { flex: 0 0 54px; min-width: 54px; min-height: 56px; padding: 4px 1px; border-radius: 9px; font-size: 10px; }
  .tool-button.is-active { box-shadow: inset 0 3px 0 var(--accent); }
  .tool-glyph { width: 22px; height: 22px; font-size: 21px; }
  .number-glyph { width: 21px; height: 21px; font-size: 11px; }
  .side-panel {
    position: absolute;
    z-index: 50;
    right: 8px;
    bottom: calc(76px + var(--safe-bottom));
    left: 8px;
    height: min(48vh, 420px);
    overflow: hidden;
    border: 1px solid #d2cfc7;
    border-radius: 18px;
    box-shadow: 0 25px 70px rgba(0, 0, 0, 0.48);
    opacity: 0;
    pointer-events: none;
    transform: translateY(calc(100% + 100px));
    transition: transform 0.22s ease, opacity 0.18s ease;
  }
  .side-panel.is-open { opacity: 1; pointer-events: auto; transform: translateY(0); }
  .panel-close { display: grid; place-items: center; }
  .panel-handle { display: block; width: 42px; height: 4px; margin: 8px auto -5px; background: #ccc8bf; border-radius: 99px; }
  .panel-scroll { overscroll-behavior: contain; }
  .panel-section { padding: 15px 18px 18px; }
  .canvas-viewport { padding: 24px 18px 66px; }
  .empty-state { padding: 20px; }
  .empty-art { width: 145px; height: 101px; }
  .empty-state h1 { margin-top: 17px; }
  .empty-state p { font-size: 12px; }
  .drop-button { margin-top: 16px; min-height: 44px; }
  .zoom-controls { bottom: 12px; }
  .toast { bottom: calc(82px + var(--safe-bottom)); }
  .text-composer { width: min(250px, 82%); }
  .text-composer-footer > span { display: none; }
}

@media (max-width: 480px) {
  .brand-copy { display: none; }
  .top-actions { gap: 5px; }
  .icon-button { width: 37px; min-height: 37px; }
  .ghost-button.desktop-download-button { width: 37px; min-height: 37px; padding: 0; border-radius: 10px; }
  .download-button-icon { width: 100%; height: 100%; flex-basis: 100%; background: transparent; border: 0; }
  .download-button-copy { display: none; }
  .empty-state h1 { font-size: 27px; }
  .empty-art { width: 126px; height: 88px; }
  .privacy-note { margin-top: 11px; }
  .tool-button span:last-child { font-size: 9px; }
  .side-panel { height: min(52vh, 430px); }
}

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