/* WeChat screenshot editor — left preview / right panel */
:root {
  --bg: #0f1115;
  --panel: #171a21;
  --panel-2: #1e2330;
  --border: #2c3344;
  --text: #e8ecf4;
  --muted: #8b95a8;
  --accent: #07c160;
  --accent-2: #2b7cff;
  --danger: #e5484d;
  --hot: rgba(43, 124, 255, 0.35);
  --hot-active: rgba(7, 193, 96, 0.45);
  --radius: 10px;
  --font: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}

.app {
  display: grid;
  grid-template-columns: 1fr minmax(320px, 380px);
  height: 100vh;
}

/* LEFT stage */
.stage {
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: #0b0d11;
  border-right: 1px solid var(--border);
}
.stage-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
  flex-wrap: wrap;
}
.stage-title { display: flex; align-items: baseline; gap: 10px; }
.stage-title strong { font-size: 14px; }
.stage-title span { font-size: 12px; color: var(--muted); }
.stage-tools {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.stage-tools #zoomLabel {
  min-width: 42px;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
}
.chk {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
  margin-left: 8px;
  cursor: pointer;
  user-select: none;
}

.stage-scroll {
  flex: 1;
  overflow: auto;
  position: relative;
  padding: 20px;
  background:
    linear-gradient(45deg, #12151c 25%, transparent 25%),
    linear-gradient(-45deg, #12151c 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #12151c 75%),
    linear-gradient(-45deg, transparent 75%, #12151c 75%);
  background-size: 24px 24px;
  background-position: 0 0, 0 12px, 12px -12px, -12px 0;
  background-color: #0b0d11;
}

.empty-state {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 60%;
}
.empty-card {
  max-width: 420px;
  text-align: center;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 28px 24px;
}
.empty-card h2 { margin: 0 0 8px; font-size: 18px; }
.empty-card p { margin: 0 0 18px; color: var(--muted); font-size: 13px; line-height: 1.55; }
.empty-card .btn { margin: 4px; }

.canvas-wrap {
  position: relative;
  display: inline-block;
  line-height: 0;
  box-shadow: 0 12px 40px rgba(0,0,0,0.45);
  border-radius: 4px;
  overflow: hidden;
  background: #000;
}
.canvas-wrap.hidden, .hidden { display: none !important; }
#previewCanvas {
  display: block;
  max-width: none;
}
.hot-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.hotspot {
  position: absolute;
  border: 1.5px dashed rgba(43, 124, 255, 0.7);
  background: var(--hot);
  border-radius: 4px;
  pointer-events: auto;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}
.hotspot:hover { background: rgba(43, 124, 255, 0.5); }
.hotspot.active {
  border-color: #07c160;
  background: var(--hot-active);
  border-style: solid;
}
.hotspot .tag {
  position: absolute;
  left: 0;
  top: -18px;
  font-size: 10px;
  line-height: 14px;
  padding: 0 5px;
  border-radius: 3px;
  background: rgba(15,17,21,0.85);
  color: #cfe0ff;
  white-space: nowrap;
  pointer-events: none;
}
.hotspot.active .tag { color: #b6f5d0; background: rgba(7,193,96,0.25); }

.place-ghost {
  position: absolute;
  border: 2px dashed #07c160;
  background: rgba(7,193,96,0.18);
  border-radius: 6px;
  pointer-events: none;
  z-index: 5;
}
.canvas-wrap.placing { cursor: crosshair; }
.canvas-wrap.placing .hotspot { pointer-events: none; opacity: 0.35; }

.stage-hint {
  margin: 0;
  padding: 8px 14px;
  font-size: 12px;
  color: var(--muted);
  border-top: 1px solid var(--border);
  background: var(--panel);
}

/* RIGHT panel */
.panel {
  background: var(--panel);
  overflow: auto;
  padding: 14px 14px 36px;
}
.panel-header h1 {
  margin: 0 0 4px;
  font-size: 17px;
  font-weight: 650;
}
.panel-sub {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 12px;
}
.panel-section {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 12px;
}
.panel-section h2 {
  margin: 0 0 10px;
  font-size: 13px;
  font-weight: 600;
  color: #c5cddc;
}
.hint {
  margin: 0 0 8px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.45;
}
.empty-tip {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
  padding: 6px 0;
}

.form-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 8px;
}
.form-row label { font-size: 12px; color: var(--muted); }
.form-row.inline {
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}
.form-row.quad {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}
.form-row.quad label {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

input[type="text"],
input[type="number"],
textarea,
select {
  width: 100%;
  background: #12151c;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 9px;
  font: inherit;
  font-size: 13px;
}
textarea { resize: vertical; min-height: 64px; }
input[type="color"] {
  width: 36px;
  height: 28px;
  padding: 0;
  border: 1px solid var(--border);
  background: transparent;
  border-radius: 6px;
  cursor: pointer;
}
input[type="checkbox"] { accent-color: var(--accent); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid var(--border);
  background: #232836;
  color: var(--text);
  border-radius: 8px;
  padding: 7px 11px;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  user-select: none;
}
.btn:hover { filter: brightness(1.08); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.primary {
  background: var(--accent);
  border-color: #06a852;
  color: #04160c;
  font-weight: 600;
}
.btn.ghost { background: transparent; }
.btn.danger {
  background: rgba(229,72,77,0.15);
  border-color: rgba(229,72,77,0.45);
  color: #ffb4b6;
}
.btn.tiny { padding: 4px 8px; font-size: 12px; }
.btn.block { width: 100%; margin-top: 8px; }
.btn.tool.active {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
  color: #b6f5d0;
}
.file-btn { position: relative; overflow: hidden; }
.file-btn input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.tool-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}
.tool-grid .btn { width: 100%; font-size: 12px; padding: 8px 6px; }

.avatar-mini {
  width: 56px;
  height: 56px;
  border-radius: 10px;
  background: #12151c center/cover no-repeat;
  border: 1px solid var(--border);
  margin-bottom: 8px;
}

.region-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 240px;
  overflow: auto;
}
.region-item {
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #151922;
  cursor: pointer;
}
.region-item:hover { border-color: #3a455c; }
.region-item.active {
  border-color: var(--accent);
  background: rgba(7,193,96,0.08);
}
.region-item .name { font-size: 13px; font-weight: 560; }
.region-item .tag {
  display: inline-block;
  margin-top: 3px;
  font-size: 11px;
  color: #9eb0ff;
  background: rgba(43,124,255,0.15);
  padding: 1px 6px;
  border-radius: 999px;
}
.region-item .meta {
  margin-top: 4px;
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Popover */
.popover {
  position: fixed;
  z-index: 1000;
  min-width: 220px;
  max-width: 300px;
  background: #1a1f2b;
  border: 1px solid #3a455c;
  border-radius: 12px;
  box-shadow: 0 16px 48px rgba(0,0,0,0.55);
  padding: 10px 12px 12px;
}
.popover-arrow {
  position: absolute;
  width: 10px;
  height: 10px;
  background: #1a1f2b;
  border-left: 1px solid #3a455c;
  border-top: 1px solid #3a455c;
  transform: rotate(45deg);
  left: 24px;
  top: -6px;
}
.popover-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.popover-head strong { font-size: 13px; }
.icon-x {
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
}
.popover-body { display: flex; flex-direction: column; gap: 8px; }
.popover-body .pop-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.popover-body .pop-actions .btn { width: 100%; justify-content: flex-start; }
.popover-body input[type="text"],
.popover-body textarea {
  font-size: 14px;
}
.popover-body .row {
  display: flex;
  gap: 6px;
}
.popover-body .row .btn { flex: 1; }

@media (max-width: 900px) {
  .app {
    grid-template-columns: 1fr;
    grid-template-rows: 55vh 1fr;
  }
  .stage { border-right: none; border-bottom: 1px solid var(--border); }
}
