/* 字帖库 — 样式（浅色主题，响应式：PC 左右分栏 / 手机上下布局） */
:root {
  --red: #c0392b;
  --red-dark: #a93226;
  --ink: #2c3e50;
  --muted: #7f8c8d;
  --line: #e5e0d8;
  --bg: #f6f3ee;
  --card: #ffffff;
  --accent-bg: #fdf6f0;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(44, 62, 80, .08), 0 4px 14px rgba(44, 62, 80, .06);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 10px 18px;
  background: rgba(255,255,255,.92); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-icon { width: 34px; height: 34px; flex: none; }
.brand-text { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.brand-text strong { font-size: 17px; letter-spacing: .5px; }
.brand-text span { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-actions { display: flex; gap: 8px; flex: none; }

/* ---------- 按钮 ---------- */
.btn {
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  border-radius: 8px; padding: 8px 14px; font-size: 14px; cursor: pointer;
  transition: all .15s; white-space: nowrap;
}
.btn:hover { border-color: var(--red); color: var(--red); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--red); border-color: var(--red); color: #fff; font-weight: 600; }
.btn-primary:hover { background: var(--red-dark); color: #fff; }
.btn-ghost { background: transparent; }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

/* ---------- 布局 ---------- */
.layout {
  display: grid; grid-template-columns: 400px 1fr; gap: 16px;
  max-width: 1500px; margin: 0 auto; padding: 16px 18px 30px;
  align-items: start;
}
.panel { display: flex; flex-direction: column; gap: 14px; position: sticky; top: 66px; max-height: calc(100vh - 82px); overflow-y: auto; padding-bottom: 10px; }
.panel::-webkit-scrollbar { width: 6px; }
.panel::-webkit-scrollbar-thumb { background: #d8d2c8; border-radius: 3px; }

.card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 14px 16px;
}
.card h2 { font-size: 14px; margin: 0 0 10px; color: var(--red); letter-spacing: 1px; }

/* ---------- 表单 ---------- */
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; font-size: 13px; }
.field > span { color: var(--muted); }
.field input[type="text"], .field input[type="number"], .field select, textarea, .preset-row select {
  width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px;
  font-size: 14px; font-family: inherit; background: #fff; color: var(--ink);
  transition: border-color .15s;
}
.field input:focus, .field select:focus, textarea:focus, .preset-row select:focus {
  outline: none; border-color: var(--red);
}
textarea { resize: vertical; min-height: 96px; line-height: 1.7; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.row { display: flex; align-items: center; gap: 8px; }
.between { justify-content: space-between; }
.hint { font-size: 12px; color: var(--muted); }
.tip {
  font-size: 12px; color: var(--muted); background: var(--accent-bg);
  border-left: 3px solid var(--red); border-radius: 4px; padding: 8px 10px; margin: 8px 0 0; line-height: 1.6;
}
.checks { display: flex; flex-wrap: wrap; gap: 10px 16px; font-size: 13px; margin: 4px 0 2px; }
.checks label { display: flex; align-items: center; gap: 5px; cursor: pointer; }
.checks input { accent-color: var(--red); }
input[type="color"] { height: 34px; padding: 2px; border: 1px solid var(--line); border-radius: 8px; background: #fff; cursor: pointer; }
input[type="range"] { accent-color: var(--red); }
.radio-row { display: flex; gap: 16px; font-size: 13px; }
.radio-row label { display: flex; align-items: center; gap: 5px; cursor: pointer; }
.radio-row input { accent-color: var(--red); }
.qr-preview { display: block; max-width: 120px; max-height: 120px; margin-top: 8px; border: 1px solid var(--line); border-radius: 6px; background: #fff; padding: 4px; }
.tpl-actions { display: flex; gap: 10px; flex-wrap: wrap; margin: 6px 0 2px; }
.tpl-actions .btn { cursor: pointer; }

.preset-row { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; margin-top: 8px; }
.history { margin-top: 8px; font-size: 12px; }
.history-chip {
  display: inline-block; background: var(--accent-bg); border: 1px solid var(--line);
  border-radius: 20px; padding: 2px 10px; margin: 2px 3px 2px 0; cursor: pointer; color: var(--ink);
  max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: middle;
}
.history-chip:hover { border-color: var(--red); color: var(--red); }
.panel-foot { display: flex; justify-content: center; padding-bottom: 10px; }

/* ---------- 预览区 ---------- */
.preview { min-height: 60vh; }
.preview-bar {
  position: sticky; top: 66px; z-index: 40;
  display: flex; align-items: center; justify-content: space-between;
  background: rgba(246,243,238,.92); backdrop-filter: blur(8px);
  padding: 8px 4px; margin-bottom: 10px; border-bottom: 1px solid var(--line);
}
.status { font-size: 13px; color: var(--muted); flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-right: 8px; }
.status b { color: var(--red); }
.zoom { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); flex: none; }

.pages { display: flex; flex-direction: column; gap: 18px; align-items: center; }
.page {
  background: #fff; border-radius: 4px; box-shadow: var(--shadow);
  width: 100%; max-width: 780px; overflow: hidden;
}
.page canvas { display: block; width: 100%; height: auto; }
.page-label { font-size: 12px; color: var(--muted); text-align: center; padding: 6px 0 0; }

.empty { text-align: center; color: var(--muted); padding: 80px 20px; }
.empty-icon { font-size: 44px; margin-bottom: 10px; }
.empty p { margin: 6px 0; }

.foot { text-align: center; font-size: 12px; color: var(--muted); padding: 24px 16px 40px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 32px; transform: translateX(-50%);
  background: var(--ink); color: #fff; font-size: 14px;
  padding: 10px 18px; border-radius: 24px; box-shadow: 0 6px 20px rgba(0,0,0,.25);
  z-index: 100; max-width: 86vw;
}

/* ---------- 打印 ---------- */
.print-area { display: none; }
@media print {
  body { background: #fff; }
  .topbar, .panel, .preview-bar, .foot, .toast, .empty { display: none !important; }
  .layout { display: block; padding: 0; margin: 0; max-width: none; }
  .preview { min-height: 0; }
  .pages { display: none !important; }
  .print-area { display: block; }
  .print-area img { display: block; width: 100%; height: auto; page-break-after: always; }
  .print-area img:last-child { page-break-after: auto; }
  @page { margin: 0; }
}

/* ---------- 手机端 ---------- */
@media (max-width: 920px) {
  .layout { grid-template-columns: 1fr; padding: 12px 12px 24px; gap: 12px; }
  .panel { position: static; max-height: none; overflow: visible; order: 2; }
  /* 手机上不用 vh 定高：浏览器工具栏显隐会改变 vh，导致预览区高度乱跳 */
  .preview { order: 1; min-height: 0; }
  .preview-bar { position: static; }
  .topbar { padding: 8px 12px; }
  .brand-text span { display: none; }
  .topbar-actions .btn { padding: 8px 10px; font-size: 13px; }
  .page { max-width: 100%; }
  .grid-2 { gap: 8px; }
}
