:root {
  --bg: #11151c;
  --panel: #181e28;
  --panel-2: #1f2733;
  --border: #2b3545;
  --text: #e6edf6;
  --muted: #8c9bb0;
  --accent: #4da3ff;
  --accent-soft: rgba(77, 163, 255, .14);
  --danger: #ff6b6b;
  --paper: #ffffff;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif;
  font-size: 13px;
}

.topbar {
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 8px;
  background: linear-gradient(135deg, #4da3ff, #845ef7);
  display: grid; place-items: center; font-weight: 700; font-size: 17px;
}
.brand-title { font-size: 15px; font-weight: 600; letter-spacing: .3px; }
.version { font-size: 10px; font-weight: 500; color: var(--muted); margin-left: 6px; }
.rotate-range { width: 100%; margin: 8px 0 10px; accent-color: var(--primary, #b3261e); }
.brand-sub { color: var(--muted); font-size: 11px; margin-top: 2px; }
.top-actions { display: flex; gap: 8px; align-items: center; }

.btn {
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  padding: 8px 13px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  line-height: 1.2;
  transition: background .15s, border-color .15s;
  white-space: nowrap;
}
.btn:hover { background: #273346; border-color: #3d4d64; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #08111c; font-weight: 600; }
.btn.primary:hover { background: #6cb4ff; }
.btn.small { padding: 6px 10px; font-size: 11px; }
.btn.danger { color: var(--danger); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.file-btn { position: relative; overflow: hidden; display: inline-block; }
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }

.app {
  display: grid;
  grid-template-columns: 168px minmax(0, 1fr) 318px;
  height: calc(100% - 64px);
}

.left, .right {
  background: var(--panel);
  overflow-y: auto;
  min-height: 0;
}
.left { border-right: 1px solid var(--border); }
.right { border-left: 1px solid var(--border); padding: 14px; }

.panel-title {
  padding: 14px 14px 10px;
  font-weight: 600;
  font-size: 12px;
  letter-spacing: .5px;
  color: var(--muted);
  text-transform: uppercase;
}
.muted { color: var(--muted); font-weight: 400; }
.small { font-size: 11px; }

.thumbs { padding: 0 10px 14px; }
.thumb-item {
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 6px;
  margin-bottom: 8px;
  cursor: pointer;
  text-align: center;
  background: var(--panel-2);
}
.thumb-item:hover { border-color: #3d4d64; }
.thumb-item.active { border-color: var(--accent); background: var(--accent-soft); }
.thumb-item canvas { display: block; margin: 0 auto 4px; max-width: 100%; background: var(--paper); }
.thumb-num { font-size: 11px; color: var(--muted); }
.thumb-item.active .thumb-num { color: var(--accent); }

.stage { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.stage-toolbar {
  height: 42px;
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  border-bottom: 1px solid var(--border);
  background: #151b24;
}
.icon-btn {
  width: 26px; height: 26px;
  border-radius: 5px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
}
.icon-btn:hover { background: #273346; }
.text-btn {
  border: none; background: none; color: var(--accent);
  cursor: pointer; font-size: 11px; padding: 4px;
}
.page-indicator, .zoom-label {
  font-variant-numeric: tabular-nums;
  color: var(--text);
  min-width: 54px;
  text-align: center;
  font-size: 12px;
}
.divider { width: 1px; height: 18px; background: var(--border); margin: 0 3px; }
.status-text { color: var(--muted); font-size: 11px; margin-left: auto; }

.stage-scroll {
  flex: 1;
  overflow: auto;
  padding: 24px;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  min-height: 0;
}
.page-wrap {
  position: relative;
  flex: none;
  background: var(--paper);
  box-shadow: 0 10px 34px rgba(0, 0, 0, .45);
}
.page-wrap canvas { display: block; }
.overlay { position: absolute; inset: 0; pointer-events: none; }

.seal-el {
  position: absolute;
  overflow: visible;
  pointer-events: auto;
  cursor: grab;
  outline: 1px solid transparent;
  touch-action: none;
}
.seal-clip {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}
.seal-el:active { cursor: grabbing; }
.seal-el.selected { outline: 1px dashed var(--accent); }
.seal-el.selected::after {
  content: attr(data-label);
  position: absolute;
  left: 0; top: 0;
  transform: translateY(-100%);
  background: var(--accent);
  color: #08111c;
  font-size: 10px;
  padding: 1px 4px;
  white-space: nowrap;
  pointer-events: none;
}
.seal-el img { position: absolute; max-width: none; user-select: none; -webkit-user-drag: none; }
.resize-handle {
  position: absolute;
  right: -6px;
  bottom: -6px;
  width: 11px;
  height: 11px;
  background: var(--accent);
  border: 1px solid #08111c;
  border-radius: 2px;
  cursor: nwse-resize;
  pointer-events: auto;
  touch-action: none;
  z-index: 3;
}
.resize-handle:hover { background: #8cc8ff; }

.empty-hint {
  margin: auto;
  text-align: center;
  color: var(--muted);
  line-height: 1.9;
}
.empty-icon { font-size: 46px; color: #35435a; margin-bottom: 8px; }
.empty-sub { font-size: 11px; color: #64748b; }
.hidden { display: none !important; }

.card {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 12px;
}
.card-title { font-weight: 600; font-size: 12px; margin-bottom: 10px; }
.seal-preview-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.seal-thumb {
  width: 52px; height: 52px;
  object-fit: contain;
  border: 1px dashed var(--border);
  border-radius: 6px;
  background: #0f141c;
}
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field.wide { grid-column: 1 / -1; }
.field span { color: var(--muted); font-size: 11px; }
.field input, .field select {
  width: 100%;
  background: #121925;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 6px 7px;
  font-size: 12px;
  outline: none;
}
.field input:focus, .field select:focus { border-color: var(--accent); }
.field input[type="range"] { padding: 0; accent-color: var(--accent); }
.btn-row { display: flex; gap: 8px; margin-top: 10px; }
.btn-row .btn { flex: 1; }
.hint { color: #e8b86d; font-size: 11px; line-height: 1.6; margin-top: 9px; }

.element-list { max-height: 188px; overflow-y: auto; margin-bottom: 9px; }
.el-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 6px 8px; border-radius: 5px; cursor: pointer;
  background: #151b24; margin-bottom: 5px; border: 1px solid transparent;
}
.el-item:hover { border-color: #3d4d64; }
.el-item.active { border-color: var(--accent); background: var(--accent-soft); }
.el-name { font-size: 11px; }
.el-coord { font-size: 10px; color: var(--muted); font-variant-numeric: tabular-nums; }
.help ul { margin: 0; padding-left: 16px; color: var(--muted); font-size: 11px; line-height: 1.75; }
.help b { color: var(--text); }

.toast {
  position: fixed;
  left: 50%; bottom: 26px;
  transform: translateX(-50%) translateY(20px);
  background: #243044;
  border: 1px solid #3d4d64;
  color: var(--text);
  padding: 9px 16px;
  border-radius: 6px;
  font-size: 12px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 50;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { border-color: var(--danger); color: #ffd5d5; }

/* v1.0.3：印章未授权拦截层 */
.auth-block {
  position: fixed; inset: 0; z-index: 60;
  background: var(--bg); display: grid; place-items: center; padding: 24px;
}
.auth-block-card {
  max-width: 460px; background: var(--panel-2); border: 1px solid var(--border);
  border-radius: 12px; padding: 30px; text-align: center;
}
.auth-block-icon { font-size: 16px; font-weight: 700; color: var(--danger); margin-bottom: 10px; }
.auth-block-card p { color: var(--muted); line-height: 1.8; margin: 0 0 20px; }

/* v1.0.3：印章大图预览弹层 */
.seal-modal { position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; }
.seal-modal-mask { position: absolute; inset: 0; background: rgba(4, 8, 14, .72); }
.seal-modal-card {
  position: relative; background: var(--panel-2); border: 1px solid var(--border);
  border-radius: 12px; padding: 18px; max-width: min(560px, 92vw); text-align: center;
  box-shadow: 0 18px 50px rgba(0, 0, 0, .5);
}
.seal-modal-card img { max-width: 480px; max-height: 60vh; object-fit: contain; background: #fff; border-radius: 8px; }
.seal-modal-name { margin-top: 12px; font-size: 13px; }
.seal-modal-close {
  position: absolute; right: 8px; top: 6px; width: 26px; height: 26px;
  border: 1px solid var(--border); background: var(--panel); color: var(--text);
  border-radius: 6px; cursor: pointer; font-size: 16px; line-height: 1;
}
.seal-thumb { cursor: zoom-in; }
.seal-preview-img { cursor: zoom-in; border: 1px dashed var(--border); border-radius: 6px; background: #0f141c; }

/* v1.0.3：拖放上传提示 */
.stage-scroll.drag-over { outline: 3px dashed var(--accent); outline-offset: -10px; background: var(--accent-soft); }
.drop-hint {
  position: absolute; inset: 0; z-index: 6; display: grid; place-items: center;
  background: rgba(17, 21, 28, .78); color: var(--text); font-size: 16px; font-weight: 600;
  border: 3px dashed var(--accent); border-radius: 8px; pointer-events: none;
}

@media (max-width: 1100px) {
  .app { grid-template-columns: 132px minmax(0, 1fr) 280px; }
}
