:root {
  --ink: #191a18;
  --muted: #73766e;
  --line: #dedfd8;
  --paper: #f6f5ef;
  --card: #fffefa;
  --accent: #d9ff57;
  --accent-strong: #bde92d;
  --shadow: 0 22px 60px rgba(30, 32, 24, .08);
}

* { box-sizing: border-box; }

/* 滚动条出现/消失时不再挤压居中内容（顶栏、底栏宽度也就不跟着抖） */
html { scrollbar-gutter: stable; }
html, body { min-height: 100%; }

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 15% 12%, rgba(217, 255, 87, .2), transparent 28rem),
    linear-gradient(180deg, #fbfaf5 0%, var(--paper) 100%);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

button, input, select { font: inherit; }

button { color: inherit; }

.app-shell {
  width: min(1500px, calc(100% - 48px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 42px 0 34px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 32px;
}

.eyebrow {
  margin: 0 0 9px;
  color: #778a35;
  font-size: 12px;
  font-weight: 850;
  letter-spacing: .18em;
}

h1 { margin: 0; max-width: 820px; font-size: clamp(30px, 4vw, 53px); line-height: 1.07; letter-spacing: -.045em; }
.subtitle { margin: 14px 0 0; max-width: 720px; color: var(--muted); font-size: 16px; line-height: 1.65; }

.button {
  min-height: 43px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: 11px;
  font-weight: 760;
  cursor: pointer;
  transition: transform .16s ease, background .16s ease, border-color .16s ease, opacity .16s ease;
}
.button:hover:not(:disabled) { transform: translateY(-1px); }
.button:disabled { cursor: not-allowed; opacity: .42; }
.button--dark { color: white; background: var(--ink); }
.button--light, .button--ghost { background: rgba(255,255,255,.62); border-color: var(--line); }
.button--ghost { margin-top: 7px; }
.button--accent { background: var(--accent); border-color: #c7ed42; }
.button--accent:hover:not(:disabled) { background: var(--accent-strong); }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 12px;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255,255,255,.7);
  box-shadow: 0 8px 26px rgba(30,32,24,.035);
}

.field { min-width: 120px; display: grid; gap: 7px; }
.field--wide { min-width: 230px; }
.field--palette { min-width: 190px; }
.field--range { min-width: 190px; flex: 1; }
.field--check { min-width: 145px; }
.field__label { color: #62665d; font-size: 12px; font-weight: 750; }
.field__label output { float: right; color: var(--ink); }

select, input[type="number"] {
  height: 41px;
  padding: 0 12px;
  border: 1px solid #d5d7cf;
  border-radius: 9px;
  outline: none;
  background: white;
}
select:focus, input:focus { border-color: #9ab43f; box-shadow: 0 0 0 3px rgba(190,226,64,.18); }
input[type="range"] { width: 100%; accent-color: #96b527; }
.check-control { height: 41px; padding: 0 11px; display: flex; align-items: center; gap: 8px; border: 1px solid #d5d7cf; border-radius: 9px; background: white; font-size: 13px; font-weight: 650; white-space: nowrap; }
.check-control input { width: 16px; height: 16px; accent-color: #96b527; }
.field--bg { min-width: 214px; }
.bg-control { display: flex; align-items: center; gap: 8px; }
.bg-control .check-control { flex: 1; }
input[type="color"].color-input { width: 43px; height: 41px; padding: 3px; border: 1px solid #d5d7cf; border-radius: 9px; background: white; cursor: pointer; }
input[type="color"].color-input::-webkit-color-swatch-wrapper { padding: 0; }
input[type="color"].color-input::-webkit-color-swatch { border: none; border-radius: 6px; }
.button--icon { width: 43px; min-height: 41px; padding: 0; display: grid; place-items: center; background: rgba(255,255,255,.62); border-color: var(--line); }
.button--icon svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.button--icon.is-active { background: var(--accent); border-color: #c7ed42; }

.segmented { display: flex; padding: 3px; border: 1px solid #d5d7cf; border-radius: 10px; background: #f1f1ec; }
.segmented__button { flex: 1; height: 33px; border: 0; border-radius: 7px; background: transparent; font-size: 13px; font-weight: 700; cursor: pointer; }
.segmented__button.is-active { background: white; box-shadow: 0 2px 7px rgba(0,0,0,.08); }

.workspace {
  min-height: 500px;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: stretch;
}

/* 卡片只负责裁切与撑高，不画边框/圆角/底色——中间的视觉边界是画布自己的黑框 */
.preview-card {
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.file-chip { max-width: 55%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 6px 10px; border-radius: 999px; background: #f1f1ec; color: var(--muted); font-size: 12px; }
.file-chip--accent { background: #f1f8d6; color: #657526; }

.result-controls { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px 20px; padding: 12px 18px; border-bottom: 1px solid var(--line); }
.result-controls .field { margin: 0; }
.result-controls .field--range { flex: 1 1 200px; }
.result-controls .segmented { flex-wrap: wrap; }
.custom-size-field input { width: 64px; }
.canvas-hint { margin: 0; width: 100%; color: var(--muted); font-size: 12px; line-height: 1.5; }
.result-controls .button { margin: 0; }

/* 底部停靠区：设置栏在上、色卡条在下，一起贴住视口底边。
   铺一层页面底色，画布滚到下面时不会从两条之间的缝里透出来 */
.bottom-dock { position: sticky; bottom: 0; z-index: 5; display: grid; gap: 8px; padding-top: 8px; background: #f7f8f5; }
/* 设置栏：缩放 + 背景/网格/画布/居中，画布相关设置都收在这一条里 */
.settings-bar { position: relative; min-height: 46px; padding: 8px 14px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; border: 1px solid var(--line); border-radius: 8px; background: rgba(255,255,255,.94); }
.settings-bar__divider { width: 1px; height: 24px; background: var(--line); }
.settings-bar__group { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; }
.settings-slot { position: relative; display: flex; }
.settings-button { min-height: 32px; padding: 0 10px; display: inline-flex; align-items: center; gap: 6px; border: 1px solid transparent; border-radius: 8px; background: transparent; font-size: 12px; font-weight: 700; cursor: pointer; white-space: nowrap; }
.settings-button svg { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
/* 悬停用中性灰、选中用绿：否则鼠标停在未选中的按钮上会和选中态长得一模一样 */
.settings-button:hover:not(:disabled) { background: #f1f1ec; border-color: #e3e3db; }
.settings-button.is-active,
.settings-button.is-active:hover:not(:disabled) { background: #dfeaba; border-color: #b0c772; }
.settings-button:disabled { opacity: .42; cursor: not-allowed; }
/* 色卡条：单排横向滚动，只展示色块与色号 */
.color-list { display: flex; align-items: center; gap: 12px; padding: 8px 14px; border: 1px solid var(--line); border-radius: 14px; background: rgba(255,255,255,.94); box-shadow: 0 -6px 22px rgba(30,32,24,.07); overflow-x: auto; overscroll-behavior-x: contain; -webkit-overflow-scrolling: touch; }
.color-list::-webkit-scrollbar { height: 6px; }
.color-list::-webkit-scrollbar-thumb { background: #d3d5cc; border-radius: 3px; }
.color-item { display: inline-flex; align-items: center; gap: 5px; flex: none; padding: 4px 6px; border: 1px solid transparent; border-radius: 7px; background: transparent; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px; color: var(--muted); cursor: pointer; }
.color-item:hover { background: #f1f1ec; }
.color-item.is-selected,
.color-item.is-selected:hover { border-color: #344624; background: transparent; box-shadow: 0 0 0 1px #344624; }
.color-swatch { width: 22px; height: 22px; border: 1px solid rgba(0,0,0,.2); border-radius: 50%; flex: none; }
.color-code { white-space: nowrap; }

.preview-stage {
  position: relative;
  flex: 1;
  min-height: 430px;
  padding: 22px;
  display: grid;
  place-items: center;
  overflow: auto;
  background-color: #f5f5ef;
  background-image: linear-gradient(45deg,#e9e9e2 25%,transparent 25%),linear-gradient(-45deg,#e9e9e2 25%,transparent 25%),linear-gradient(45deg,transparent 75%,#e9e9e2 75%),linear-gradient(-45deg,transparent 75%,#e9e9e2 75%);
  background-size: 20px 20px;
  background-position: 0 0,0 10px,10px -10px,-10px 0;
}
.preview-stage--drop { outline: none; }
/* 空态（还没有结果）时整块绘制区就是导入区，出结果后恢复普通光标 */
.preview-stage--drop.is-empty { cursor: pointer; }
.preview-stage--drop.is-dragging { box-shadow: inset 0 0 0 3px #b9dd36; }
.empty-state, .result-placeholder, .processing { text-align: center; }
.empty-state h3 { margin: 13px 0 5px; font-size: 18px; }
.empty-state p, .result-placeholder p { margin: 0 0 17px; color: var(--muted); font-size: 13px; }
.upload-mark { width: 58px; height: 58px; margin: auto; display: grid; place-items: center; border: 1px solid #d7d8d0; border-radius: 16px; background: rgba(255,255,255,.84); }
.upload-mark svg, .flow-arrow svg { width: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
#resultCanvas { image-rendering: pixelated; display: block; touch-action: none; }
#selectionCanvas { position: absolute; top: 0; left: 0; display: block; pointer-events: none; image-rendering: pixelated; }
.paint-loupe { position: fixed; z-index: 12; width: 112px; height: 112px; padding: 4px; border: 2px solid #fff; border-radius: 50%; background: #fff; box-shadow: 0 0 0 1px rgba(25,26,24,.5), 0 8px 24px rgba(0,0,0,.2); overflow: hidden; pointer-events: none; }
.paint-loupe canvas { display: block; width: 100px; height: 100px; border-radius: 50%; image-rendering: pixelated; }
.paint-loupe__code { position: absolute; left: 50%; bottom: 7px; transform: translateX(-50%); padding: 2px 5px; border-radius: 4px; background: rgba(255,255,255,.94); color: #1f241d; font: 700 10px ui-monospace, SFMono-Regular, Menlo, monospace; white-space: nowrap; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.result-unit { position: relative; display: inline-block; line-height: 0; box-shadow: 0 0 0 2px #000; }
/* 开栅格时黑框画在位图里（紧贴网格、把编号条留在框外），CSS 外框就撤掉 */
.result-unit.is-bitmap-framed { box-shadow: none; }
.coord-labels { position: absolute; left: 0; top: 0; pointer-events: none; z-index: 3;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; line-height: 1; white-space: nowrap; }
.coord-label { position: absolute; color: rgba(0,0,0,.65); }
.coord-label--y { transform: translateX(-100%); }
.canvas-handle {
  position: absolute;
  width: 14px; height: 14px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: rgba(255,255,255,.92);
  box-shadow: 0 1px 5px rgba(0,0,0,.45);
  cursor: grab;
  touch-action: none;
  z-index: 2;
  display: grid; place-items: center;
  transition: transform .12s ease, box-shadow .12s ease, background .12s ease;
}
.canvas-handle svg { width: 100%; height: 100%; display: block; }
.canvas-handle path { fill: #3a3d34; }
.canvas-handle:hover { transform: scale(1.25); background: #fff; box-shadow: 0 0 0 4px rgba(124,148,36,.22), 0 2px 8px rgba(0,0,0,.4); }
.canvas-handle.is-active { cursor: grabbing; transform: scale(1.45); background: #fff; box-shadow: 0 0 0 6px rgba(124,148,36,.28), 0 2px 10px rgba(0,0,0,.45); }
.flow-arrow { display: grid; place-items: center; color: #85897f; }
.flow-arrow svg { width: 25px; }

.pixel-glyph { width: 53px; margin: 0 auto 15px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 3px; transform: rotate(-4deg); }
.pixel-glyph i { aspect-ratio: 1; background: #d7d9cf; }
.pixel-glyph i:nth-child(2), .pixel-glyph i:nth-child(4), .pixel-glyph i:nth-child(5), .pixel-glyph i:nth-child(8) { background: #b7cd61; }
.processing { display: grid; justify-items: center; gap: 7px; color: #4c541d; }
.processing small { color: var(--muted); }
.spinner { width: 30px; height: 30px; margin-bottom: 5px; border: 3px solid #dde5bd; border-top-color: #7c9424; border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.actionbar { display: flex; justify-content: space-between; align-items: center; gap: 20px; padding-top: 2px; }
.status { margin: 0; color: var(--muted); font-size: 13px; }
.status.is-error { color: #aa3228; }
.is-hidden { display: none !important; }

@media (max-width: 900px) {
  .app-shell { width: min(100% - 28px, 720px); padding-top: 24px; }
  .toolbar { flex-wrap: wrap; }
  .field, .field--range { flex: 1 1 145px; }
  .field--wide { flex-basis: 220px; }
  .workspace { gap: 13px; }
  .flow-arrow { height: 30px; transform: rotate(90deg); }
  .preview-stage { min-height: 360px; }
}

@media (max-width: 560px) {
  .topbar { display: block; }
  .button--ghost { margin-top: 16px; }
  .preview-stage { min-height: 300px; padding: 14px; }
}

/* 简化后的工作台 */
body { background: #f7f8f5; }
/* 绘制区铺满窗口；间距只留在顶栏和底部操作区内部 */
.app-shell { width: 100%; max-width: none; padding: 0; gap: 0; }
.topbar { position: sticky; top: 0; z-index: 10; align-items: center; min-height: 52px; gap: 16px; padding: 18px 18px 10px; background: #f7f8f5; }
.brand { display: flex; align-items: center; gap: 9px; white-space: nowrap; font-size: 14px; font-weight: 800; letter-spacing: .08em; }
.brand__mark { width: 17px; height: 17px; display: block; background: linear-gradient(90deg, var(--ink) 50%, transparent 50%), linear-gradient(var(--ink) 50%, transparent 50%); background-size: 10px 10px; border: 1px solid var(--ink); }
.topbar__actions { display: flex; align-items: center; justify-content: flex-end; gap: 9px; flex-wrap: wrap; }
.topbar .button { min-height: 38px; padding: 0 13px; font-size: 13px; }
.button--ghost { margin-top: 0; }
/* flex:1 让绘制区吃掉剩余高度，底栏因此在内容不足一屏时也贴住视口底边 */
.workspace { flex: 1; min-height: min(680px, calc(100vh - 255px)); gap: 0; }
/* 结果标题与文件状态并入顶栏：卡片里只留绘制区 */
.topbar__result { display: flex; align-items: center; gap: 8px; margin-right: auto; min-width: 0; }
.topbar__result h2 { margin: 0; font-size: 13px; font-weight: 750; white-space: nowrap; }
.topbar__result .file-chip { max-width: min(40vw, 360px); padding: 4px 7px; border-radius: 5px; font-size: 11px; }
.text-button { border: 0; background: transparent; color: #576737; cursor: pointer; font-size: 12px; padding: 4px; white-space: nowrap; }
.text-button:hover { text-decoration: underline; }
.preview-stage { min-height: 0; padding: 14px; background: #f5f6f2; background-image: linear-gradient(45deg,#edeFE9 25%,transparent 25%),linear-gradient(-45deg,#edeFE9 25%,transparent 25%),linear-gradient(45deg,transparent 75%,#edeFE9 75%),linear-gradient(-45deg,transparent 75%,#edeFE9 75%); background-size: 24px 24px; background-position: 0 0,0 12px,12px -12px,-12px 0; }
.preview-stage--drop { min-height: 440px; }
.result-workspace { position: relative; display: flex; flex: 1; min-height: 0; --rail-w: 46px; --rail-x: 12px; --rail-y: 12px; --rail-shift: 0px; }
.result-workspace .preview-stage { min-width: 0; min-height: 440px; }
/* 工具列浮在绘制区上层（absolute + z-index，不占布局）：绘制区因此满宽，画布在整张卡片里居中；
   导入空态/处理中它还是隐藏的，点哪儿都是导入区 */
.tool-rail {
  position: absolute;
  z-index: 7;
  top: calc(var(--rail-y) + var(--rail-shift));
  left: var(--rail-x);
  width: var(--rail-w);
  max-height: calc(100% - var(--rail-y) - var(--rail-x));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 6px 4px 8px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, .96);
  box-shadow: 0 10px 26px rgba(20, 20, 15, .14);
  cursor: grab;
  touch-action: none;
}
/* 拖到右边时贴右边缘；纵向位置两边通用 */
.tool-rail--right { left: auto; right: var(--rail-x); }
.tool-rail.is-dragging { cursor: grabbing; opacity: .92; }
.tool-rail__grip { width: 18px; height: 12px; margin-bottom: 2px; flex: none; cursor: grab;
  background-image: radial-gradient(circle, #b0b4a6 1.2px, transparent 1.4px); background-size: 6px 6px; background-position: center; }
.tool-rail__grip:hover { background-image: radial-gradient(circle, #7c8266 1.2px, transparent 1.4px); }
.tool-rail .button--icon { width: 36px; min-height: 36px; border-color: transparent; background: transparent; border-radius: 7px; }
.tool-rail .button--icon:hover:not(:disabled):not(.is-active) { background: #f1f2ef; border-color: transparent; transform: none; }
.tool-rail .button--icon.is-active,
.tool-rail .button--icon.is-active:hover:not(:disabled) { background: #edf3dd; border-color: #d7e3bd; transform: none; }
.paint-tool { position: relative; }
.paint-tool__color { position: absolute; top: 2px; right: 2px; width: 13px; height: 13px; border: 1px solid #fff; border-radius: 3px; background: #000; box-shadow: 0 0 0 1px rgba(0,0,0,.55); pointer-events: none; }
.tool-rail__divider { width: 24px; height: 1px; background: var(--line); margin: 3px 0; }
.grid-tool { position: relative; cursor: pointer; }
.grid-tool input { position: absolute; opacity: 0; width: 100%; height: 100%; inset: 0; margin: 0; cursor: pointer; }
.grid-tool:has(input:checked) { background: #dfeaba !important; border-color: #b0c772 !important; }
.grid-tool:has(input:focus-visible) { outline: 2px solid #8da92e; outline-offset: 2px; }
/* 弹层：喷涂挂在工具列右侧，背景/画布尺寸从设置栏的按钮上方向上弹 */
.popover { display: grid; gap: 13px; padding: 16px; border: 1px solid var(--line); border-radius: 10px; background: #fff; font-size: 12px; }
/* 喷涂弹层跟着工具列走：同侧纵向对齐，横向挂在工具列外侧 */
.popover--rail { position: absolute; z-index: 8; top: calc(var(--rail-y) + var(--rail-shift)); left: calc(var(--rail-x) + var(--rail-w) + 8px); width: min(250px, calc(100% - 82px)); max-height: calc(100% - var(--rail-y) - var(--rail-shift) - 8px); overflow: auto; box-shadow: 0 12px 30px rgba(20,20,15,.12); }
.popover--rail.paint-popover { width: min(196px, calc(100% - 82px)); gap: 7px; padding: 10px 11px; }
.paint-popover__sample { width: 100%; min-height: 30px; padding: 5px 8px; border: 1px solid var(--line); border-radius: 6px; background: #f7f8f5; color: var(--ink); font-size: 11px; font-weight: 700; cursor: pointer; }
.paint-popover__sample:hover { border-color: #a5b689; background: #eef4e4; }
.paint-popover__sample:focus-visible { outline: 2px solid #8da92e; outline-offset: 2px; }
.paint-popover small { line-height: 1.4; }
.tool-rail--right ~ .popover--rail { left: auto; right: calc(var(--rail-x) + var(--rail-w) + 8px); }
.popover--dock { position: absolute; z-index: 9; left: 0; bottom: calc(100% + 10px); width: min(250px, calc(100vw - 40px)); box-shadow: 0 12px 30px rgba(20,20,15,.18); }
.popover strong { font-size: 13px; }
.popover small { color: var(--muted); line-height: 1.5; }
.popover .field { min-width: 0; }
.popover input[type="color"].color-input { width: 100%; }
.popover .check-control { font-size: 12px; white-space: normal; }
.canvas-popover { width: min(310px, calc(100vw - 40px)); }
.canvas-popover .segmented { flex-wrap: wrap; gap: 2px; }
.canvas-popover .segmented__button { min-width: 60px; }
.size-inputs { display: flex; align-items: center; gap: 6px; }
.size-inputs input { width: 70px; }
.zoom-control { display: flex; align-items: center; gap: 8px; font-size: 12px; white-space: nowrap; }
.zoom-control input { width: min(170px, 28vw); }
.help-details { position: relative; margin-left: auto; font-size: 12px; color: var(--muted); }
.help-details summary { cursor: pointer; white-space: nowrap; }
.help-details[open] .canvas-hint { position: absolute; z-index: 9; right: 0; bottom: 25px; width: min(300px, 75vw); padding: 11px; background: white; border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.09); }
.actionbar { min-height: 45px; }
.actionbar { padding: 8px 18px 0; }
.bottom-dock { padding-left: 18px; padding-right: 18px; }
.color-list { border-radius: 8px; box-shadow: none; }
.settings-dialog { width: min(560px, calc(100% - 24px)); max-height: min(780px, calc(100% - 32px)); padding: 0; border: 1px solid var(--line); border-radius: 14px; background: #fff; color: var(--ink); box-shadow: 0 26px 70px rgba(0,0,0,.2); }
.settings-dialog::backdrop { background: rgba(17,24,17,.35); }
.settings-dialog__header { display: flex; justify-content: space-between; align-items: center; padding: 18px 22px 10px; }
.settings-dialog__header h2 { margin: 0; font-size: 20px; }
.settings-dialog .eyebrow { margin-bottom: 4px; }
.settings-dialog__header .button--icon { font-size: 24px; font-weight: 400; }
.settings-dialog__note { margin: 0; padding: 0 22px 13px; color: var(--muted); font-size: 12px; }
.settings-group { padding: 15px 22px; border-top: 1px solid var(--line); }
.settings-group h3 { margin: 0 0 12px; font-size: 13px; }
.settings-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: end; gap: 14px; }
.settings-fields .field { min-width: 0; }
.settings-fields .field--wide { grid-column: 1 / -1; }
.settings-fields .field--range { align-self: stretch; }
.settings-fields .field--check { align-self: end; }
.settings-fields .field--buttons { display: flex; gap: 9px; }
.settings-fields .field--buttons .button { flex: 1; }
.settings-dialog__footer { display: flex; justify-content: flex-end; padding: 14px 22px; border-top: 1px solid var(--line); }
@media (max-width: 900px) {
  .app-shell { width: 100%; }
  .workspace { gap: 0; }
  .flow-arrow { display: none; }
  .preview-stage--drop, .result-workspace .preview-stage { min-height: 360px; }
}
@media (max-width: 620px) {
  .topbar { align-items: flex-start; flex-wrap: wrap; padding: 12px 12px 8px; }
  .actionbar { padding-left: 12px; padding-right: 12px; }
  .bottom-dock { padding-left: 12px; padding-right: 12px; }
  .topbar__actions { width: 100%; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .topbar__actions .button { width: 100%; }
  /* 窄屏也保持左上角竖排浮层工具列，只收窄一点，不横排到画布下方 */
  .result-workspace { --rail-w: 44px; --rail-x: 10px; }
  .result-workspace .preview-stage { min-height: 320px; }
  .tool-rail { padding: 5px 3px 7px; gap: 4px; }
  .tool-rail .button--icon { width: 34px; min-height: 34px; }
  .tool-rail__divider { width: 20px; }
  .popover--rail { width: min(228px, calc(100% - 74px)); }
  .popover--dock { width: min(228px, calc(100vw - 32px)); }
  .canvas-popover { width: min(280px, calc(100vw - 32px)); }
  .settings-bar { padding: 8px 10px; gap: 6px 10px; }
  .settings-button { padding: 0 8px; }
  .settings-fields { grid-template-columns: 1fr; }
  .settings-fields .field--wide { grid-column: auto; }
}
