* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --panel-w: 320px;
  --border: #e2e6ec;
  --text: #1d2733;
  --muted: #7a8794;
  --accent: #2b6cb0;
  --accent-dark: #235a92;
  --danger: #d64545;
}

html, body { height: 100%; font-family: "PingFang SC", "Microsoft YaHei", system-ui, sans-serif; color: var(--text); }

#app { display: flex; height: 100vh; overflow: hidden; }

/* ---------- 左侧面板 ---------- */
#panel {
  width: var(--panel-w);
  flex: 0 0 var(--panel-w);
  background: #fff;
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 20px 18px 40px;
}

.panel-header h1 { font-size: 20px; letter-spacing: 1px; }
.panel-header .sub { font-size: 12px; color: var(--muted); margin-top: 4px; }

.group { margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--border); }
.group h2 { font-size: 13px; color: var(--muted); font-weight: 600; margin-bottom: 12px; letter-spacing: 1px; }

.hint { font-size: 11px; color: var(--muted); line-height: 1.6; margin-top: 8px; }

/* 上传 */
.upload-row { display: flex; gap: 10px; }
.upload-box {
  flex: 1;
  aspect-ratio: 3 / 4;
  border: 1.5px dashed #c3ccd6;
  border-radius: 8px;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 6px;
  cursor: pointer;
  overflow: hidden;
  position: relative;
  transition: border-color .2s;
  background: #f8fafc;
}
.upload-box:hover { border-color: var(--accent); }
.upload-box[hidden] { display: none; }
.upload-box span { font-size: 12px; color: var(--muted); z-index: 1; }
.upload-box img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: none; }
.upload-box.has-img img { display: block; }
.upload-box.has-img span { position: absolute; bottom: 6px; background: rgba(0,0,0,.55); color: #fff; padding: 2px 8px; border-radius: 4px; }

/* 装订按钮 */
.binding-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; }
.binding-btn {
  padding: 8px 6px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  font-size: 12px;
  cursor: pointer;
  text-align: center;
  transition: all .15s;
}
.binding-btn:hover { border-color: var(--accent); background: #f8fbff; }
.binding-btn.active { border-color: var(--accent); background: #ebf3fb; color: var(--accent-dark); font-weight: 600; }

/* 表单 */
.field { margin-bottom: 14px; }
.field label { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 6px; }
.field select, .field input[type="range"] { width: 100%; }
.field select {
  padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px;
  font-size: 13px; background: #fff; outline: none;
}
.field input[type="color"] {
  width: 100%; height: 34px; border: 1px solid var(--border);
  border-radius: 6px; background: #fff; cursor: pointer; padding: 2px;
}
.field.inline { display: flex; justify-content: space-between; align-items: center; }
.field.inline label { margin: 0; }
.field input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--accent); }
output { color: var(--accent-dark); font-weight: 600; }

/* 导出按钮 */
.export-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.btn {
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: #fff;
  font-size: 13px;
  cursor: pointer;
  transition: all .15s;
}
.btn:hover { border-color: var(--accent); color: var(--accent-dark); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-dark); }
.btn.danger { background: #fff; border-color: var(--danger); color: var(--danger); }
.btn.danger.recording { background: var(--danger); color: #fff; }

/* ---------- 3D 视口 ---------- */
#viewport { flex: 1; position: relative; }
#scene { width: 100%; height: 100%; display: block; }
#viewport-tip {
  position: absolute; bottom: 14px; left: 50%; transform: translateX(-50%);
  font-size: 12px; color: var(--muted);
  background: rgba(255,255,255,.8); padding: 5px 14px; border-radius: 20px;
  pointer-events: none; backdrop-filter: blur(4px);
}
#rec-badge {
  position: absolute; top: 16px; right: 18px;
  background: var(--danger); color: #fff;
  font-size: 13px; font-weight: 600;
  padding: 6px 14px; border-radius: 20px;
  animation: blink 1.2s infinite;
}
@keyframes blink { 50% { opacity: .55; } }

/* ---------- 弹窗 ---------- */
.modal {
  position: fixed; inset: 0;
  background: rgba(15, 23, 32, .45);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
}
.modal[hidden] { display: none; }
.modal-card {
  width: 560px; max-width: 92vw;
  background: #fff; border-radius: 12px;
  padding: 24px;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
.modal-card h2 { font-size: 17px; margin-bottom: 10px; }
.modal-card code { background: #f0f3f7; padding: 1px 5px; border-radius: 4px; font-size: 11px; }
.modal-card textarea {
  width: 100%; margin-top: 12px;
  border: 1px solid var(--border); border-radius: 8px;
  padding: 10px; font-size: 12px; font-family: Consolas, monospace;
  resize: vertical; outline: none;
}
.modal-actions { display: flex; gap: 8px; margin-top: 14px; justify-content: flex-end; }
.embed-opt {
  display: flex; align-items: center; gap: 8px;
  margin-top: 14px; font-size: 13px; color: var(--text);
  cursor: pointer; user-select: none;
}
.embed-opt input { width: 16px; height: 16px; accent-color: var(--accent); }

/* 色板 */
.swatch-row { display: flex; gap: 7px; flex-wrap: wrap; margin-top: 8px; }
.swatch {
  width: 24px; height: 24px; border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px #c3ccd6;
  cursor: pointer; padding: 0;
  transition: transform .12s;
}
.swatch:hover { transform: scale(1.15); }
.swatch.active { box-shadow: 0 0 0 2px var(--accent); }

/* Toast */
#toast {
  position: fixed; bottom: 30px; left: 50%; transform: translateX(-50%);
  background: #1d2733; color: #fff;
  padding: 10px 22px; border-radius: 8px;
  font-size: 13px; z-index: 200;
  box-shadow: 0 8px 24px rgba(0,0,0,.3);
}

/* 窄屏适配 */
@media (max-width: 760px) {
  #app { flex-direction: column; }
  #panel { width: 100%; flex: 0 0 auto; max-height: 45vh; border-right: none; border-bottom: 1px solid var(--border); }
}
