﻿/* Carton Mark · 全局样式：白底、深色字、技术感、高信息密度 */
:root {
  --ink: #0f172a;
  --ink-2: #334155;
  --muted: #64748b;
  --line: #e2e8f0;
  --line-2: #cbd5e1;
  --bg: #f5f7fa;
  --card: #ffffff;
  --accent: #1f6feb;
  --accent-soft: #eaf2ff;
  --danger: #c0392b;
  --warn: #b45309;
  --ok: #15803d;
  --radius: 10px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, p { margin: 0; }
button, input, select { font: inherit; color: inherit; }

/* ── 顶栏 ───────────────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 20px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-icon { width: 30px; height: 30px; display: block; flex: none; }
.brand-icon svg { display: block; width: 100%; height: 100%; }
.brand-text { min-width: 0; }
.brand-text h1 { font-size: 15px; font-weight: 650; letter-spacing: .01em; }
.brand-text p { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.topbar-actions { display: flex; align-items: center; gap: 10px; flex: none; }
.tag {
  font-size: 11px;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid #cfe0ff;
  border-radius: 999px;
  padding: 2px 9px;
  white-space: nowrap;
}

/* ── 按钮 ───────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 34px;
  padding: 0 14px;
  background: var(--card);
  border: 1px solid var(--line-2);
  border-radius: 7px;
  cursor: pointer;
  font-size: 13px;
  color: var(--ink-2);
  white-space: nowrap;
  transition: border-color .15s, background .15s, color .15s;
}
.btn:hover { border-color: #94a3b8; color: var(--ink); }
.btn:active { background: #f1f5f9; }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: #f1f5f9; }
.btn-icon { width: 30px; height: 30px; padding: 0; }
.btn:focus-visible, .segmented button:focus-visible, .select:focus-visible,
input:focus-visible, .panel:focus-visible rect { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ── 控制区 ─────────────────────────────────────── */
.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 14px 18px;
  padding: 14px 20px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}

.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.label { font-size: 12px; color: var(--muted); font-weight: 500; letter-spacing: .02em; }
.divider { width: 1px; align-self: stretch; background: var(--line); margin-bottom: 2px; }

.select {
  height: 34px;
  min-width: 230px;
  padding: 0 10px;
  background: var(--card);
  border: 1px solid var(--line-2);
  border-radius: 7px;
  cursor: pointer;
}
.select option:disabled { color: #9aa6b6; }

.segmented {
  display: inline-flex;
  padding: 2px;
  background: #f1f5f9;
  border: 1px solid var(--line);
  border-radius: 7px;
  height: 34px;
}
.segmented button {
  border: 0;
  background: transparent;
  border-radius: 5px;
  padding: 0 11px;
  font-size: 12.5px;
  color: var(--muted);
  cursor: pointer;
}
.segmented button.is-active {
  background: var(--card);
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(15, 23, 42, .12);
  font-weight: 600;
}

.field--dim { min-width: 132px; }
.input-wrap { position: relative; display: flex; align-items: center; }
.input-wrap input {
  width: 118px;
  height: 34px;
  padding: 0 34px 0 10px;
  background: var(--card);
  border: 1px solid var(--line-2);
  border-radius: 7px;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
}
.input-wrap input:hover { border-color: #94a3b8; }
.input-wrap input.is-error { border-color: var(--danger); box-shadow: 0 0 0 2px rgba(192, 57, 43, .12); }
.input-wrap .suffix {
  position: absolute;
  right: 10px;
  font-size: 11.5px;
  color: var(--muted);
  pointer-events: none;
}
.field-error { min-height: 15px; font-size: 11.5px; color: var(--danger); line-height: 15px; }
.field--actions { margin-left: auto; align-self: center; flex-direction: row; align-items: center; gap: 12px; }

.check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--ink-2);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
.check input { width: 14px; height: 14px; accent-color: var(--accent); cursor: pointer; }

/* ── 提示条 ─────────────────────────────────────── */
.notice {
  margin: 10px 20px 0;
  padding: 8px 12px;
  font-size: 12.5px;
  border-radius: 8px;
  border: 1px solid #fde68a;
  background: #fffbeb;
  color: #92400e;
}
.notice.is-error { border-color: #fecaca; background: #fef2f2; color: var(--danger); }

/* ── 工作区 ─────────────────────────────────────── */
.workspace {
  display: grid;
  grid-template-columns: minmax(280px, 0.85fr) minmax(420px, 1.5fr);
  gap: 14px;
  padding: 14px 20px 0;
  align-items: start;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 14px;
  border-bottom: 1px solid var(--line);
  background: #fbfcfe;
  min-width: 0;
}
.card-head h2 { font-size: 13px; font-weight: 650; letter-spacing: .02em; white-space: nowrap; }
.card-meta {
  font-size: 11.5px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.canvas { position: relative; padding: 6px 8px 2px; min-width: 0; }
.canvas svg { display: block; width: 100%; max-width: 100%; height: auto; }

.statusbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 8px 14px;
  border-top: 1px solid var(--line);
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  min-width: 0;
}
.statusbar span { min-width: 0; overflow-wrap: anywhere; }
.statusbar .dot { width: 3px; height: 3px; border-radius: 50%; background: var(--line-2); }
#selInfo.is-active { color: var(--accent); font-weight: 600; }

.footnote {
  padding: 10px 20px 24px;
  font-size: 11.5px;
  color: var(--muted);
  line-height: 1.6;
}

/* ── SVG 图纸样式 ───────────────────────────────── */
.net-outline { fill: #fbfcfe; stroke: #1f2937; stroke-width: 1.6; stroke-linejoin: round; }
.net-fold { stroke: #9aa6b6; stroke-width: 1.1; stroke-dasharray: 6 5; fill: none; }

.panel { cursor: pointer; }
.panel .panel-bg { fill: transparent; stroke: none; }
.panel .panel-hover { fill: rgba(31, 111, 235, 0); stroke: none; transition: fill .12s; }
.panel:hover .panel-hover { fill: rgba(31, 111, 235, .055); }
.panel .panel-edge { fill: none; stroke: #dbe3ee; stroke-width: 1; }
.panel .panel-label { fill: #0f172a; font-size: 12px; font-weight: 600; pointer-events: none; }
.panel .panel-size { fill: #7c8899; font-size: 11px; pointer-events: none; font-variant-numeric: tabular-nums; }
.panel.is-selected .panel-hover { fill: rgba(31, 111, 235, .10); }
.panel.is-selected .panel-edge { stroke: var(--accent); stroke-width: 2; }
.panel.is-selected .panel-label { fill: var(--accent); }

/* 防尘摇盖：只画轮廓，不可交互 */
.panel.is-locked { cursor: default; }
.panel.is-locked:hover .panel-hover { fill: transparent; }
.panel.is-locked .panel-edge { stroke: #e3e9f1; stroke-dasharray: 4 3; }
.panel.is-locked .panel-label { fill: #93a0b1; font-weight: 500; }
.panel.is-locked .panel-size { fill: #aab4c2; }

.iso-fill { stroke: none; }
.iso-edge { stroke: #22303f; stroke-width: 1.4; stroke-linecap: round; fill: none; }
.iso-edge.is-hidden { stroke: #b6c0cd; stroke-width: 1; stroke-dasharray: 4 4; }
.iso-vertex { fill: #22303f; }

.dim-line { stroke: #8a94a6; stroke-width: 1; fill: none; }
.dim-ext { stroke: #b6c0cd; stroke-width: .9; fill: none; stroke-dasharray: 2 3; }
.dim-text {
  fill: #5b6779;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  paint-order: stroke;
  stroke: #fff;
  stroke-width: 3.2px;
  stroke-linejoin: round;
}
.dim-text.is-strong { fill: #334155; font-weight: 600; }

/* ── 使用说明弹层 ───────────────────────────────── */
.help-dialog {
  width: min(560px, calc(100vw - 32px));
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 24px 60px rgba(15, 23, 42, .24);
  color: var(--ink);
}
.help-dialog::backdrop { background: rgba(15, 23, 42, .38); }
.help-inner { margin: 0; }
.help-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}
.help-head h2 { font-size: 15px; font-weight: 650; }
.help-body { padding: 14px 18px 18px; font-size: 13px; color: var(--ink-2); }
.help-body ol { margin: 0 0 12px; padding-left: 20px; }
.help-body li { margin-bottom: 6px; }
.help-note {
  margin-top: 10px;
  padding: 9px 11px;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 12.5px;
  color: var(--muted);
}

/* ── 轻提示 ─────────────────────────────────────── */
.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  background: #0f172a;
  color: #f8fafc;
  font-size: 12.5px;
  padding: 8px 14px;
  border-radius: 8px;
  box-shadow: 0 8px 22px rgba(15, 23, 42, .28);
  z-index: 50;
  max-width: calc(100vw - 32px);
}

/* ── 编辑器 ─────────────────────────────────────── */
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: #1a5fd0; border-color: #1a5fd0; color: #fff; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-icon:disabled { opacity: .35; }

.editor {
  margin: 14px 20px 0;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.editor-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  background: #fbfcfe;
  flex-wrap: wrap;
}
.editor-title { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.editor-title h2 { font-size: 14px; font-weight: 650; white-space: nowrap; }
.editor-sub { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.editor-tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.editor-tools .divider { height: 22px; }
.select--sm { height: 34px; min-width: 132px; padding: 0 8px; font-size: 12.5px; }

.editor-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  min-height: 320px;
}

.editor-stage { padding: 14px; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.editor-canvas {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  min-height: 260px;
  padding: 14px;
  background:
    linear-gradient(#f1f4f9 1px, transparent 1px) 0 0 / 20px 20px,
    linear-gradient(90deg, #f1f4f9 1px, transparent 1px) 0 0 / 20px 20px,
    #f8fafc;
  border-radius: 8px;
  min-width: 0;
}

.ed-canvas {
  position: relative;
  background: #fff;
  box-shadow: 0 2px 8px rgba(15, 23, 42, .10);
  outline: 1px solid #d8e0ea;
  cursor: crosshair;
  flex: none;
}

.ed-el {
  position: absolute;
  box-sizing: border-box;
  cursor: move;
  touch-action: none;
}
.ed-el.is-selected { outline: 1.5px dashed var(--accent); outline-offset: 1px; }
.ed-el.is-dragging { cursor: grabbing; }

.ed-text {
  width: 100%;
  height: 100%;
  overflow: hidden;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.22;
  color: #0f172a;
  pointer-events: none;
}
.ed-img { width: 100%; height: 100%; object-fit: fill; display: block; pointer-events: none; }

.ed-handle {
  position: absolute;
  width: 10px;
  height: 10px;
  background: #fff;
  border: 1.5px solid var(--accent);
  border-radius: 2px;
  z-index: 3;
  touch-action: none;
}
.ed-handle[data-corner="nw"] { left: -5px; top: -5px; cursor: nwse-resize; }
.ed-handle[data-corner="ne"] { right: -5px; top: -5px; cursor: nesw-resize; }
.ed-handle[data-corner="sw"] { left: -5px; bottom: -5px; cursor: nesw-resize; }
.ed-handle[data-corner="se"] { right: -5px; bottom: -5px; cursor: nwse-resize; }

.ed-guide { position: absolute; background: #ef4444; pointer-events: none; display: none; z-index: 4; }
.ed-guide--v { width: 1px; top: 0; bottom: 0; }
.ed-guide--h { height: 1px; left: 0; right: 0; }

.editor-hint { font-size: 11.5px; color: var(--muted); margin: 0; }

/* 属性面板 */
.props {
  border-left: 1px solid var(--line);
  background: #fbfcfe;
  padding: 12px 14px;
  overflow: auto;
  max-height: 640px;
  min-width: 0;
}
.props-empty { font-size: 12.5px; color: var(--muted); line-height: 1.7; }
.prop-section { margin-bottom: 14px; }
.prop-section > h3 {
  font-size: 11.5px;
  font-weight: 650;
  color: var(--muted);
  letter-spacing: .04em;
  margin: 0 0 8px;
  text-transform: uppercase;
}
.prop-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.prop-row label { font-size: 12px; color: var(--ink-2); width: 42px; flex: none; }
.prop-row input[type="number"], .prop-row input[type="text"] {
  width: 100%;
  height: 30px;
  padding: 0 8px;
  border: 1px solid var(--line-2);
  border-radius: 6px;
  font-variant-numeric: tabular-nums;
  background: #fff;
  min-width: 0;
}
.prop-row textarea {
  width: 100%;
  min-height: 64px;
  padding: 6px 8px;
  border: 1px solid var(--line-2);
  border-radius: 6px;
  resize: vertical;
  background: #fff;
  min-width: 0;
}
.prop-row select {
  width: 100%;
  height: 30px;
  border: 1px solid var(--line-2);
  border-radius: 6px;
  background: #fff;
  min-width: 0;
}
.prop-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.prop-grid .field { gap: 4px; }
.prop-grid .label { font-size: 11px; }
.prop-grid input { width: 100%; height: 30px; padding: 0 8px; border: 1px solid var(--line-2); border-radius: 6px; background: #fff; font-variant-numeric: tabular-nums; }
.prop-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.prop-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.prop-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
  font-size: 12px;
  text-align: left;
  width: 100%;
}
.prop-item:hover { border-color: #b9c6d6; }
.prop-item.is-active { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.prop-item .kind { color: var(--muted); font-size: 11px; flex: none; }
.prop-item .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0; }

/* 新建元素弹层 */
.element-dialog {
  width: min(520px, calc(100vw - 32px));
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 24px 60px rgba(15, 23, 42, .24);
  color: var(--ink);
}
.element-dialog::backdrop { background: rgba(15, 23, 42, .38); }
.element-body { padding: 14px 18px 6px; }
.tabs { display: inline-flex; gap: 4px; padding: 3px; background: #f1f5f9; border: 1px solid var(--line); border-radius: 8px; margin-bottom: 12px; }
.tabs button {
  border: 0;
  background: transparent;
  padding: 4px 14px;
  border-radius: 6px;
  font-size: 12.5px;
  color: var(--muted);
  cursor: pointer;
}
.tabs button.is-active { background: #fff; color: var(--ink); font-weight: 600; box-shadow: 0 1px 2px rgba(15, 23, 42, .12); }
.row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.row3 .field { min-width: 0; }
.row3 input, .row3 select { width: 100%; height: 32px; padding: 0 8px; border: 1px solid var(--line-2); border-radius: 6px; background: #fff; }
.row3 input[type="number"] { padding-right: 4px; }
#textPane textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--line-2);
  border-radius: 7px;
  resize: vertical;
  font-family: inherit;
}
#imagePane input[type="file"] { font-size: 12.5px; }
.image-preview { margin-top: 10px; min-height: 0; }
.image-preview img { max-width: 100%; max-height: 160px; border: 1px solid var(--line); border-radius: 6px; }
.image-preview .meta { font-size: 11.5px; color: var(--muted); margin-top: 4px; }
.hint { font-size: 11.5px; color: var(--muted); margin: 6px 0 0; line-height: 1.6; }
.element-error { min-height: 18px; font-size: 12px; color: var(--danger); margin: 6px 0 0; }
.help-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 10px 18px 14px;
}

/* 导出 PDF 弹层 */
.export-summary {
  font-size: 12.5px;
  color: var(--ink-2);
  line-height: 1.9;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
}
.export-summary b { color: var(--ink); font-variant-numeric: tabular-nums; }
.export-filename {
  width: 100%;
  height: 32px;
  padding: 0 8px;
  border: 1px solid var(--line-2);
  border-radius: 6px;
  font-family: inherit;
}
.export-warnings { margin-top: 10px; display: flex; flex-direction: column; gap: 6px; }
.export-warnings:empty { display: none; }
.export-warnings div {
  font-size: 12px;
  line-height: 1.6;
  color: #92400e;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 6px;
  padding: 6px 8px;
}
.export-warnings div.is-error { color: var(--danger); background: #fef2f2; border-color: #fecaca; }

/* ── 打印说明 / 移动端提示 ─────────────────────── */
.mobile-hint {
  margin: 10px 20px 0;
  padding: 9px 12px;
  font-size: 12.5px;
  line-height: 1.6;
  border-radius: 8px;
  border: 1px solid #bfdbfe;
  background: #eff6ff;
  color: #1e40af;
}

.print-note {
  margin: 14px 20px 0;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 16px;
}
.print-note h2 { font-size: 13px; margin: 0 0 6px; }
.print-note ul { margin: 0; padding-left: 18px; font-size: 12.5px; color: var(--ink-2); line-height: 1.8; }
.print-note b { color: var(--ink); }

/* ── 响应式 ─────────────────────────────────────── */
@media (max-width: 1080px) {
  .workspace { grid-template-columns: 1fr; }
  .select { min-width: 180px; }
  .editor-body { grid-template-columns: 1fr; }
  .props { border-left: 0; border-top: 1px solid var(--line); max-height: none; }
  .editor-tools .select--sm { min-width: 110px; }
}

@media (max-width: 640px) {
  .topbar { padding: 10px 14px; flex-wrap: nowrap; }
  .brand { flex: 1 1 auto; }
  .brand-text h1 { font-size: 14px; white-space: nowrap; }
  .topbar-actions { flex: none; }
  .topbar-actions .tag { display: none; }
  .brand-text p { display: none; }
  .controls { padding: 12px 14px; gap: 10px 10px; }
  .divider { display: none; }
  .segmented button { padding: 0 9px; }
  .field--dim { flex: 1 1 30%; min-width: 0; }
  .field--dim .input-wrap input { width: 100%; min-width: 0; padding-right: 26px; }
  .field--dim .suffix { right: 7px; font-size: 11px; }
  .field--actions { margin-left: 0; }
  .workspace { padding: 12px 14px 0; }
  .footnote { padding: 10px 14px 20px; }
  .notice { margin: 10px 14px 0; }
  .mobile-hint { margin: 10px 14px 0; }
  .print-note { margin: 12px 14px 0; padding: 10px 12px; }
  .card-meta { display: none; }
  .editor { margin: 12px 14px 0; }
  .editor-head { padding: 10px 12px; }
  .editor-tools { gap: 6px; }
  .editor-tools .label { display: none; }
  .editor-stage { padding: 10px; }
  .props { padding: 10px 12px; }
  .row3 { grid-template-columns: 1fr; }
}
