:root {
  --bg: #f5f6f8;
  --panel: #ffffff;
  --line: #e5e7ec;
  --line-soft: #eef0f4;
  --ink: #14171c;
  --ink-2: #4a5260;
  --ink-3: #8b93a1;
  --accent: #2563eb;
  --accent-soft: #eef3fe;
  --danger: #dc2626;
  --radius: 14px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow-md: 0 8px 24px -6px rgba(16, 24, 40, .12), 0 2px 6px rgba(16, 24, 40, .04);
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 13.5px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; }

/* ---------- 顶部 ---------- */
.topbar {
  flex: 0 0 auto;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

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

.logo {
  width: 34px; height: 34px;
  border-radius: 10px;
  background: linear-gradient(150deg, #2f6ff5, #1d4ed8);
  color: #fff;
  display: grid; place-items: center;
  box-shadow: 0 4px 10px -2px rgba(37, 99, 235, .45);
}

.brand h1 {
  margin: 0;
  font-size: 14.5px;
  font-weight: 600;
  letter-spacing: .2px;
}

.brand p {
  margin: 1px 0 0;
  font-size: 11.5px;
  color: var(--ink-3);
}

.badge-local {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 11.5px;
  color: #16794f;
  background: #ecfdf3;
  border: 1px solid #cdeedd;
  padding: 5px 11px;
  border-radius: 999px;
  white-space: nowrap;
}

.badge-local .dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: #16a34a;
  box-shadow: 0 0 0 3px rgba(22, 163, 74, .16);
}

.top-link {
  font-size: 12.5px;
  color: var(--ink-2);
  text-decoration: none;
  padding: 5px 11px;
  border-radius: 8px;
  white-space: nowrap;
  transition: background .12s, color .12s;
}
.top-link:hover { background: var(--accent-soft); color: var(--accent); }

.warn-banner {
  background: #fff7e6;
  border-bottom: 1px solid #f5d9a0;
  color: #8a5a00;
  font-size: 12.5px;
  padding: 9px 20px;
}

/* ---------- 布局 ---------- */
.layout {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: 292px minmax(0, 1fr);
}

.panel {
  background: var(--panel);
  border-right: 1px solid var(--line);
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.panel::-webkit-scrollbar { width: 8px; }
.panel::-webkit-scrollbar-thumb { background: #d9dde5; border-radius: 8px; }

.block { display: flex; flex-direction: column; gap: 10px; }
.block-grow { flex: 1 1 auto; min-height: 0; }
.block.export-block { gap: 8px; border-top: 1px solid var(--line-soft); padding-top: 14px; }

.block h2 {
  margin: 0;
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .7px;
  color: var(--ink-3);
  display: flex;
  align-items: center;
  gap: 7px;
}

.count {
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 999px;
  padding: 0 7px;
  font-size: 11px;
  letter-spacing: 0;
}

/* ---------- 拖放区 ---------- */
.drop {
  border: 1.5px dashed #cfd6e2;
  border-radius: var(--radius);
  background: #fafbfc;
  padding: 20px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  text-align: center;
  cursor: pointer;
  transition: .16s ease;
}

.drop:hover { border-color: #9db4e8; background: #f7f9fe; }
.drop.active { border-color: var(--accent); background: var(--accent-soft); }
.drop svg { color: #9aa4b4; }
.drop strong { font-size: 13px; font-weight: 600; }
.drop span { font-size: 11.5px; color: var(--ink-3); }
.drop.has-file svg { color: var(--accent); }
.drop.has-file strong { color: var(--ink); }
.drop.has-file span { color: var(--ink-2); word-break: break-all; }

/* ---------- 分段控件 ---------- */
.seg {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 3px;
  background: #f1f3f7;
  padding: 3px;
  border-radius: 10px;
}

.seg button {
  border: 0;
  background: transparent;
  padding: 7px 4px;
  border-radius: 8px;
  font-size: 12.5px;
  color: var(--ink-2);
  transition: .15s ease;
}

.seg button.on {
  background: #fff;
  color: var(--ink);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

.slider-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: var(--ink-2);
}

.slider-row output {
  font-variant-numeric: tabular-nums;
  color: var(--ink-3);
  min-width: 18px;
  text-align: right;
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  height: 3px;
  background: #dde2ea;
  border-radius: 3px;
  outline: none;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--accent);
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
  cursor: pointer;
}

/* ---------- 单选 ---------- */
.radios { display: flex; gap: 14px; }

.radio {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--ink-2);
  cursor: pointer;
}

.radio input {
  appearance: none;
  width: 14px; height: 14px;
  border: 1.5px solid #c3cad6;
  border-radius: 50%;
  margin: 0;
  position: relative;
  cursor: pointer;
}

.radio input:checked { border-color: var(--accent); }
.radio input:checked::after {
  content: "";
  position: absolute;
  inset: 2.5px;
  border-radius: 50%;
  background: var(--accent);
}

.text-input, .field select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 8px 10px;
  background: #fff;
  outline: none;
  transition: .15s ease;
}

.text-input:focus, .field select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37,99,235,.1); }
.text-input:disabled { background: #f7f8fa; color: var(--ink-3); cursor: not-allowed; }

.field { display: grid; grid-template-columns: 44px 1fr; align-items: center; gap: 10px; }
.field > label { font-size: 12.5px; color: var(--ink-2); }
.field select { padding: 7px 8px; font-size: 12.5px; }

.tip {
  margin: 0;
  font-size: 11.5px;
  line-height: 1.6;
  color: var(--ink-3);
}

.tip b { color: var(--ink-2); }
.tip.center { text-align: center; }

/* ---------- 区域列表 ---------- */
.rect-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 220px;
  overflow-y: auto;
}

.rect-list .empty-item {
  font-size: 11.5px;
  color: var(--ink-3);
  padding: 10px 0;
  text-align: center;
  border: 1px dashed var(--line);
  border-radius: 9px;
}

.rect-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 9px;
  font-size: 12px;
  background: #fff;
  cursor: pointer;
  transition: .14s ease;
}

.rect-item:hover { border-color: #c6d3ee; background: #fafcff; }
.rect-item.on { border-color: var(--accent); background: var(--accent-soft); }

.rect-item .idx {
  width: 17px; height: 17px;
  border-radius: 5px;
  background: #eef1f6;
  color: var(--ink-2);
  font-size: 10.5px;
  display: grid; place-items: center;
  flex: 0 0 auto;
}

.rect-item.on .idx { background: var(--accent); color: #fff; }
.rect-item .meta { flex: 1; font-variant-numeric: tabular-nums; color: var(--ink-2); font-size: 11.5px; }

.rect-item .scope-tag {
  flex: 0 0 auto;
  font-size: 10px;
  color: var(--ink-3);
  background: #f1f3f7;
  border-radius: 5px;
  padding: 1px 6px;
  white-space: nowrap;
}
.rect-item.on .scope-tag { background: #dbe7fd; color: var(--accent); }

.rect-item .del {
  border: 0; background: transparent;
  color: var(--ink-3);
  width: 18px; height: 18px;
  border-radius: 5px;
  display: grid; place-items: center;
  font-size: 14px; line-height: 1;
}
.rect-item .del:hover { background: #fdecec; color: var(--danger); }

/* ---------- 按钮 ---------- */
.primary-btn {
  width: 100%;
  border: 0;
  border-radius: 11px;
  padding: 12px;
  background: linear-gradient(160deg, #2f6ff5, #1d4ed8);
  color: #fff;
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: .2px;
  box-shadow: 0 5px 14px -4px rgba(37, 99, 235, .55);
  transition: .16s ease;
}

.primary-btn:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 8px 20px -6px rgba(37,99,235,.6); }
.primary-btn:active:not(:disabled) { transform: translateY(0); }
.primary-btn:disabled { background: #dfe3ea; color: #9aa3b2; box-shadow: none; cursor: not-allowed; }

.ghost-btn {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 9px;
  padding: 8px;
  font-size: 12px;
  color: var(--ink-2);
  transition: .15s ease;
}

.ghost-btn:hover:not(:disabled) { border-color: #e2b6b6; color: var(--danger); background: #fffafa; }
.ghost-btn:disabled { color: #b8bfc9; cursor: not-allowed; }

/* ---------- 查看区 ---------- */
.viewer {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.toolbar {
  flex: 0 0 auto;
  height: 46px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  border-bottom: 1px solid var(--line);
  background: rgba(255,255,255,.7);
  backdrop-filter: blur(8px);
}

.tool-group { display: flex; align-items: center; gap: 6px; }
.tool-group.right { gap: 10px; }

.icon-btn {
  width: 28px; height: 28px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  display: grid; place-items: center;
  color: var(--ink-2);
  transition: .14s ease;
}

.icon-btn:hover:not(:disabled) { border-color: #c2cde2; color: var(--ink); }
.icon-btn:disabled { color: #cbd1da; cursor: not-allowed; }

.page-indicator {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--ink-3);
}

.page-indicator input {
  width: 40px;
  text-align: center;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 4px 0;
  outline: none;
  font-variant-numeric: tabular-nums;
}
.page-indicator input:focus { border-color: var(--accent); }

.switch { display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: 12px; color: var(--ink-2); }
.switch input { display: none; }

.switch.row-switch { justify-content: space-between; padding: 3px 0; }
.switch.row-switch .switch-label { font-size: 12.5px; color: var(--ink); font-weight: 500; }

.switch .track {
  width: 32px; height: 18px;
  border-radius: 999px;
  background: #d7dce5;
  position: relative;
  transition: .18s ease;
}

.switch .track::after {
  content: "";
  position: absolute;
  top: 2px; left: 2px;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,.25);
  transition: .18s ease;
}

.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track::after { transform: translateX(14px); }

.divider { width: 1px; height: 16px; background: var(--line); }

.text-btn {
  border: 0;
  background: transparent;
  color: var(--accent);
  font-size: 12px;
  padding: 5px 7px;
  border-radius: 7px;
}
.text-btn:hover:not(:disabled) { background: var(--accent-soft); }
.text-btn:disabled { color: #b8bfc9; cursor: not-allowed; }

.stage {
  flex: 1 1 auto;
  position: relative;
  overflow: auto;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 1px 1px, #dcdfe6 1px, transparent 0) 0 0 / 16px 16px,
    var(--bg);
}

.stage::-webkit-scrollbar { width: 10px; height: 10px; }
.stage::-webkit-scrollbar-thumb { background: #cfd5de; border-radius: 8px; border: 2px solid var(--bg); }

.page-box {
  position: relative;
  box-shadow: var(--shadow-md);
  background: #fff;
  border-radius: 3px;
  overflow: hidden;
  flex: 0 0 auto;
}

.page-box canvas { display: block; }
.page-box #baseCanvas { position: relative; }
.page-box #overlayCanvas {
  position: absolute;
  inset: 0;
  cursor: crosshair;
  touch-action: none;
}

/* ---------- 空状态 ---------- */
.stage-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 22px;
  pointer-events: none;
  text-align: center;
}

.stage-empty p {
  margin: 0;
  font-size: 12.5px;
  color: var(--ink-2);
  line-height: 1.9;
}
.stage-empty p span { color: var(--ink-3); font-size: 11.5px; }

.ghost-sheet {
  width: 168px;
  height: 216px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow: 0 10px 30px -12px rgba(16,24,40,.16);
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 9px;
  position: relative;
  overflow: hidden;
}

.ghost-line { height: 5px; border-radius: 3px; background: #e8ebf1; }
.w40 { width: 40%; } .w50 { width: 50%; } .w60 { width: 60%; }
.w70 { width: 70%; } .w80 { width: 80%; } .w88 { width: 88%; } .w90 { width: 90%; }

.ghost-mask {
  height: 20px;
  margin: 4px 0;
  border-radius: 3px;
  background: repeating-linear-gradient(45deg, #c9cfda 0 4px, #eef0f5 4px 8px);
  position: relative;
}
.ghost-mask::after {
  content: "";
  position: absolute;
  inset: 0;
  border: 1.5px dashed #a9b3c4;
  border-radius: 3px;
}

.drop-veil {
  position: absolute;
  inset: 12px;
  border: 2px dashed var(--accent);
  border-radius: var(--radius);
  background: rgba(238, 243, 254, .82);
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
  display: none;
  place-items: center;
  pointer-events: none;
  z-index: 20;
}
.drop-veil.on { display: grid; }

/* ---------- 隐私说明 ---------- */
.privacy-block {
  border-top: 1px solid var(--line-soft);
  padding-top: 14px;
  gap: 8px;
}

.privacy-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.privacy-list li {
  position: relative;
  padding-left: 14px;
  font-size: 11.5px;
  color: var(--ink-3);
  line-height: 1.55;
}

.privacy-list li::before {
  content: "";
  position: absolute;
  left: 2px;
  top: 7px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: #16a34a;
}

.privacy-list b { color: var(--ink-2); font-weight: 600; }

/* ---------- 进度 ---------- */
.progress-mask {
  position: fixed;
  inset: 0;
  background: rgba(20, 23, 28, .32);
  backdrop-filter: blur(3px);
  display: grid;
  place-items: center;
  z-index: 100;
}
.progress-mask[hidden] { display: none; }

.progress-card {
  width: 320px;
  background: #fff;
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: 0 24px 60px -18px rgba(16, 24, 40, .35);
  text-align: center;
}

.progress-card h3 { margin: 0 0 14px; font-size: 14px; font-weight: 600; }

.bar {
  height: 5px;
  background: #eef0f4;
  border-radius: 999px;
  overflow: hidden;
}

.bar i {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, #3b82f6, #2563eb);
  transition: width .2s ease;
}

.progress-card p { margin: 11px 0 0; font-size: 11.5px; color: var(--ink-3); }

/* ---------- toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 30px;
  transform: translate(-50%, 14px);
  background: #14171c;
  color: #fff;
  font-size: 12.5px;
  padding: 10px 16px;
  border-radius: 10px;
  box-shadow: 0 12px 30px -10px rgba(0,0,0,.5);
  opacity: 0;
  pointer-events: none;
  transition: .22s ease;
  z-index: 200;
  max-width: 80vw;
}
.toast.on { opacity: 1; transform: translate(-50%, 0); }
.toast.err { background: #b91c1c; }

@media (max-width: 900px) {
  .layout { grid-template-columns: 250px minmax(0, 1fr); }
  .badge-local { display: none; }
}

/* SEO 语义化文案：对用户隐藏，对搜索引擎可读（不使用 display:none 以免被判作弊） */
.seo-copy {
  position: absolute;
  left: -9999px;
  top: auto;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}
