/* canvas.css — 画布容器 / 工具条 / 图例 / 十字准星读数 */

.stage {
  position: relative;
  width: 100%;   /* 定宽：防止 aspect-ratio+min-height 在窄列反向顶宽（400px 侧栏里 16/7×260=594 撑破网格） */
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.stage-canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: crosshair;
}
.stage-canvas[data-grab="true"] { cursor: grab; }
.stage-canvas[data-dragging="true"] { cursor: grabbing; }

/* 尺寸变体 */
.stage-hero  { aspect-ratio: 16 / 10; min-height: 380px; }
.stage-main  { aspect-ratio: 4 / 3; min-height: 340px; }
.stage-square{ aspect-ratio: 1 / 1; min-height: 300px; }
.stage-wide  { aspect-ratio: 16 / 7; min-height: 260px; }

@media (max-width: 620px) {
  .stage-hero, .stage-main, .stage-square, .stage-wide {
    aspect-ratio: 1 / 1;
    min-height: 300px;
  }
}

/* ---------- 浮层工具条 ---------- */
.stage-bar {
  position: absolute;
  top: 10px; right: 10px;
  display: flex;
  gap: 5px;
  padding: 5px;
  background: var(--bg-overlay);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-sm);
  z-index: 3;
}
.stage-bar .btn-icon {
  background: transparent;
  border-color: transparent;
  color: var(--ink-soft);
}
.stage-bar .btn-icon:hover {
  background: var(--bg-sunken);
  border-color: var(--line);
  color: var(--ink);
}

/* 左下角坐标读数 */
.stage-readout {
  position: absolute;
  left: 10px; bottom: 10px;
  padding: 6px 11px;
  background: var(--bg-overlay);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  font-family: var(--mono);
  font-size: var(--fs-tiny);
  font-variant-numeric: tabular-nums;
  color: var(--ink-soft);
  white-space: nowrap;
  pointer-events: none;
  z-index: 3;
}
.stage-readout .sep { color: var(--ink-faint); margin: 0 5px; }

/* 左上角标题角标 */
.stage-badge {
  position: absolute;
  left: 10px; top: 10px;
  padding: 5px 10px;
  background: var(--bg-overlay);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-family: var(--mono);
  font-size: var(--fs-tiny);
  letter-spacing: 0.05em;
  color: var(--ink-mute);
  pointer-events: none;
  z-index: 3;
}

/* ---------- 图例 ---------- */
.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  margin-top: 12px;
  padding: 0;
  list-style: none;
  font-size: var(--fs-tiny);
  font-family: var(--mono);
  color: var(--ink-mute);
}
.legend li { display: flex; align-items: center; gap: 7px; }
.legend .swatch {
  width: 18px; height: 3px;
  border-radius: 2px;
  background: currentColor;
  flex: 0 0 auto;
}
.legend .swatch-dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  background: currentColor;
}
.legend .swatch-dash {
  width: 18px; height: 0;
  border-top: 2px dashed currentColor;
}
.legend .li-re  { color: var(--re); }
.legend .li-im  { color: var(--im); }
.legend .li-res { color: var(--res); }
.legend .li-warn{ color: var(--warn); }
.legend .li-mute{ color: var(--ink-faint); }
.legend .li-label { color: var(--ink-soft); }

/* ---------- 画布下方的控制排 ---------- */
.canvas-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  align-items: flex-end;
  margin-top: 14px;
  padding: 14px 16px;
  background: var(--bg-sunken);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
}
.canvas-controls .ctl {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 130px;
  flex: 0 1 auto;
}
.canvas-controls .ctl-grow { flex: 1 1 180px; }
.canvas-controls .ctl-value {
  font-family: var(--mono);
  font-size: var(--fs-tiny);
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}

/* ---------- 可拖拽手柄提示 ---------- */
.drag-hint {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  font-size: var(--fs-tiny);
  color: var(--ink-faint);
  font-family: var(--mono);
}
.drag-hint .dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--res);
  flex: 0 0 auto;
}

/* ---------- 首屏画布特化 ---------- */
.hero-stage {
  border-color: var(--line-strong);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-md);
}
@media (max-width: 620px) {
  .stage-bar { top: 8px; right: 8px; }
  .stage-readout { left: 8px; bottom: 8px; font-size: 10px; }
}
