/* ============================================================
   纸由我 PaperMe — 样式表
   设计基调：冷色调、清爽、留白充足；桌面双栏 / 移动单栏
   ============================================================ */

:root {
  --bg: #f4f7fb;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e3e9f2;
  --border-strong: #cbd6e4;
  --text: #1c2938;
  --text-2: #5b6b80;
  --text-3: #8b9aad;
  --primary: #3b6fe0;
  --primary-hover: #2f5ec7;
  --primary-soft: #eaf1fe;
  --accent: #0ea5b7;
  --shadow-sm: 0 1px 2px rgba(30, 58, 95, .04), 0 3px 10px rgba(30, 58, 95, .05);
  --shadow-md: 0 8px 30px rgba(30, 58, 95, .10);
  --radius: 12px;
  --radius-sm: 8px;
  --header-h: 62px;
  --font-sans: "Source Han Sans SC", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-serif: "Source Han Serif SC", "Noto Serif SC", "Songti SC", serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font-sans);
  color: var(--text);
  background: var(--bg);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }

/* ---------- Header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--header-h);
  background: rgba(255, 255, 255, .92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 clamp(16px, 4vw, 48px);
  gap: 24px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 19px;
  letter-spacing: .02em;
  color: var(--text);
  text-decoration: none;
  flex-shrink: 0;
}
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: linear-gradient(135deg, #4f86f7, #2f5ec7);
  color: #fff;
  display: grid;
  place-items: center;
  font-family: var(--font-serif);
  font-size: 19px;
  box-shadow: 0 4px 10px rgba(59, 111, 224, .28);
}
.brand-sub { font-size: 12px; color: var(--text-3); font-weight: 500; letter-spacing: .06em; }

.site-nav { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.site-nav a {
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-weight: 500;
  text-decoration: none;
  transition: background .15s, color .15s;
}
.site-nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.site-nav a.active { color: var(--primary); background: var(--primary-soft); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 9px 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s;
  white-space: nowrap;
}
.btn:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }
.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  box-shadow: 0 4px 12px rgba(59, 111, 224, .22);
}
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); color: #fff; }
.btn-lg { padding: 12px 22px; font-size: 15px; border-radius: 10px; }
.btn-sm { padding: 6px 11px; font-size: 12.5px; }
.btn svg { width: 16px; height: 16px; flex: none; }

/* ---------- Generator layout ---------- */
.generator {
  max-width: 1560px;
  margin: 0 auto;
  padding: 22px clamp(12px, 3vw, 32px) 40px;
  display: grid;
  grid-template-columns: 352px minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

/* ---------- Control panel ---------- */
.controls {
  max-height: calc(100vh - var(--header-h) - 42px);
  overflow-y: auto;
  position: sticky;
  top: calc(var(--header-h) + 20px);
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}
.controls::-webkit-scrollbar { width: 8px; }
.controls::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 8px; }

.controls-head {
  padding: 18px 18px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.controls-head h2 { margin: 0; font-size: 16px; font-weight: 700; }
.controls-head p { margin: 2px 0 0; font-size: 12px; color: var(--text-3); }

.ctrl-group { border-bottom: 1px solid var(--border); }
.ctrl-group:last-of-type { border-bottom: 0; }
.ctrl-group > summary {
  list-style: none;
  cursor: pointer;
  padding: 13px 18px;
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 650;
  font-size: 13.5px;
  user-select: none;
}
.ctrl-group > summary::-webkit-details-marker { display: none; }
.ctrl-group > summary:hover { background: var(--surface-2); }
.ctrl-group > summary .chev { margin-left: auto; color: var(--text-3); transition: transform .2s; }
.ctrl-group[open] > summary .chev { transform: rotate(180deg); }
.summary-icon {
  width: 22px; height: 22px; border-radius: 6px;
  background: var(--primary-soft); color: var(--primary);
  display: grid; place-items: center; font-size: 12px; flex: none;
}
.ctrl-body { padding: 2px 18px 16px; }

.field { margin-top: 12px; }
.field:first-child { margin-top: 2px; }
.field-label {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 12.5px; color: var(--text-2); margin-bottom: 7px; font-weight: 500;
}
.field-label .value { color: var(--primary); font-variant-numeric: tabular-nums; font-weight: 600; }

/* chip grid for paper types */
.chip-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; }
.chip {
  border: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  padding: 8px 4px;
  text-align: center;
  font-size: 12px;
  color: var(--text-2);
  cursor: pointer;
  transition: all .15s;
  user-select: none;
}
.chip:hover { border-color: var(--primary); color: var(--primary); }
.chip.active { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); font-weight: 650; }

.chip-row { display: flex; gap: 7px; flex-wrap: wrap; }
.chip-row .chip { flex: 1 1 auto; min-width: 72px; }

/* form controls */
select, input[type="text"], input[type="number"] {
  width: 100%;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  background: var(--surface);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
select:focus, input[type="text"]:focus, input[type="number"]:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59, 111, 224, .12);
}
input[type="color"] {
  width: 38px; height: 32px; padding: 2px;
  border: 1px solid var(--border-strong);
  border-radius: 7px; background: var(--surface); cursor: pointer;
}
input[type="range"] { width: 100%; accent-color: var(--primary); cursor: pointer; }
.color-row { display: flex; align-items: center; gap: 10px; }
.color-row input[type="text"] { flex: 1; font-family: ui-monospace, monospace; font-size: 12px; }

.four-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.four-grid label { font-size: 11.5px; color: var(--text-3); display: block; margin-bottom: 4px; }

.switch-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 7px 0; font-size: 13px; color: var(--text-2);
}
.switch {
  position: relative; width: 38px; height: 21px; flex: none;
}
.switch input { opacity: 0; width: 0; height: 0; }
.switch .track {
  position: absolute; inset: 0; background: #d5dde8; border-radius: 20px;
  cursor: pointer; transition: background .2s;
}
.switch .track::after {
  content: ""; position: absolute; width: 15px; height: 15px; left: 3px; top: 3px;
  background: #fff; border-radius: 50%; transition: transform .2s;
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.switch input:checked + .track { background: var(--primary); }
.switch input:checked + .track::after { transform: translateX(17px); }

.hint { font-size: 11.5px; color: var(--text-3); line-height: 1.5; margin-top: 7px; }
.hint strong { color: var(--accent); font-weight: 600; }

.controls-actions {
  position: sticky; bottom: 0;
  background: linear-gradient(to top, var(--surface) 82%, rgba(255,255,255,0));
  padding: 14px 18px 16px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  border-top: 1px solid var(--border);
}
.controls-actions .btn-primary { grid-column: 1 / -1; }

/* ---------- Preview area ---------- */
.preview-panel { min-width: 0; display: flex; flex-direction: column; }
.preview-toolbar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 12px 16px; border-bottom: 1px solid var(--border);
}
.preview-title { font-weight: 700; font-size: 15px; }
.preview-meta { font-size: 12px; color: var(--text-3); }
.preview-tools { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.zoom-group {
  display: flex; align-items: center; border: 1px solid var(--border);
  border-radius: var(--radius-sm); overflow: hidden;
}
.zoom-group button {
  border: 0; background: var(--surface); padding: 6px 10px; cursor: pointer;
  color: var(--text-2); font-size: 13px;
}
.zoom-group button:hover { background: var(--primary-soft); color: var(--primary); }
.zoom-group span { padding: 0 8px; font-size: 12px; color: var(--text-2); min-width: 44px; text-align: center; }

.preview-stage {
  background:
    radial-gradient(circle at 1px 1px, #d9e1ec 1px, transparent 0) 0 0 / 22px 22px,
    #eef2f7;
  padding: 28px 20px 48px;
  overflow: auto;
  flex: 1;
  min-height: 480px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 26px;
}
.paper-wrap {
  background: #fff;
  box-shadow: 0 10px 34px rgba(30, 58, 95, .16), 0 1px 3px rgba(30,58,95,.12);
  border-radius: 2px;
  line-height: 0;
  transition: width .18s ease;
}
.paper-wrap canvas { display: block; width: 100%; height: auto; border-radius: 2px; }
.page-caption {
  text-align: center; font-size: 11.5px; color: var(--text-3);
  margin-top: -16px; line-height: 1;
}

.empty-preview { color: var(--text-3); padding: 80px 20px; text-align: center; }

/* ---------- Modal / template library ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(18, 32, 52, .48);
  backdrop-filter: blur(3px); z-index: 100;
  display: none; align-items: center; justify-content: center; padding: 20px;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: var(--surface); border-radius: 16px; box-shadow: var(--shadow-md);
  width: min(900px, 100%); max-height: 86vh; overflow: hidden;
  display: flex; flex-direction: column;
}
.modal-head {
  padding: 20px 24px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px;
}
.modal-head h2 { margin: 0; font-size: 18px; }
.modal-head p { margin: 3px 0 0; font-size: 12.5px; color: var(--text-3); }
.modal-close {
  margin-left: auto; border: 0; background: var(--surface-2); width: 32px; height: 32px;
  border-radius: 8px; cursor: pointer; color: var(--text-2); font-size: 18px; line-height: 1;
}
.modal-close:hover { background: #e8edf5; }
.modal-body { padding: 20px 24px 26px; overflow-y: auto; }
.template-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 14px;
}
.template-card {
  border: 1px solid var(--border); border-radius: 10px; background: var(--surface);
  padding: 12px; cursor: pointer; transition: all .16s; text-align: center;
}
.template-card:hover { border-color: var(--primary); transform: translateY(-2px); box-shadow: var(--shadow-sm); }
.template-card canvas {
  width: 100%; max-width: 108px; height: auto; border: 1px solid var(--border);
  border-radius: 3px; background: #fff; margin-bottom: 9px;
}
.template-card .t-name { font-weight: 650; font-size: 13px; }
.template-card .t-desc { font-size: 11.5px; color: var(--text-3); margin-top: 2px; line-height: 1.4; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%) translateY(20px);
  background: #1c2938; color: #fff; padding: 10px 18px; border-radius: 9px;
  font-size: 13px; box-shadow: var(--shadow-md); opacity: 0; pointer-events: none;
  transition: all .25s; z-index: 200;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- Guide page ---------- */
.guide-wrap { max-width: 940px; margin: 0 auto; padding: 34px clamp(16px, 4vw, 40px) 70px; }
.guide-hero { margin-bottom: 30px; }
.guide-hero .eyebrow {
  display: inline-block; font-size: 12px; font-weight: 700; letter-spacing: .12em;
  color: var(--primary); background: var(--primary-soft); padding: 5px 11px; border-radius: 20px;
}
.guide-hero h1 { font-family: var(--font-serif); font-size: clamp(28px, 5vw, 40px); margin: 14px 0 8px; line-height: 1.25; }
.guide-hero p { color: var(--text-2); font-size: 15px; margin: 0; max-width: 620px; }

.guide-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); padding: 26px clamp(18px, 3vw, 30px); margin-bottom: 18px;
}
.guide-card h2 {
  font-size: 20px; margin: 0 0 14px; padding-bottom: 12px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
}
.sec-num {
  width: 27px; height: 27px; border-radius: 8px; background: var(--primary-soft);
  color: var(--primary); display: inline-grid; place-items: center; font-size: 13px; flex: none;
}
.guide-card h3 { font-size: 15.5px; margin: 20px 0 8px; }
.guide-card p { color: var(--text-2); margin: 8px 0; }
.guide-card ul, .guide-card ol { color: var(--text-2); padding-left: 22px; }
.guide-card li { margin: 6px 0; }
.guide-card strong { color: var(--text); }

.tip {
  background: #eef5ff; border-left: 3px solid var(--primary); border-radius: 0 8px 8px 0;
  padding: 12px 15px; margin: 14px 0; font-size: 13px; color: #2c5282;
}
.tip strong { color: #1c4587; }

.steps { display: grid; gap: 12px; margin: 16px 0; }
.step {
  display: flex; gap: 14px; align-items: flex-start;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px;
}
.step-num {
  width: 26px; height: 26px; border-radius: 50%; background: var(--primary); color: #fff;
  display: grid; place-items: center; font-size: 13px; font-weight: 700; flex: none;
}
.step-body b { display: block; margin-bottom: 2px; }
.step-body span { font-size: 13px; color: var(--text-2); }

.faq-item { border-bottom: 1px solid var(--border); padding: 14px 0; }
.faq-item:last-child { border-bottom: 0; }
.faq-q { font-weight: 650; display: flex; gap: 9px; align-items: baseline; }
.faq-q::before { content: "Q"; color: var(--primary); font-weight: 800; }
.faq-a { color: var(--text-2); margin: 6px 0 0 20px; font-size: 13.5px; }
.faq-a::before { content: "A"; color: var(--accent); font-weight: 800; margin-right: 7px; }

pre.code {
  background: #16243a; color: #d7e3f4; border-radius: 10px; padding: 16px 18px;
  overflow-x: auto; font-size: 12px; line-height: 1.65; margin: 12px 0;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
}
pre.code .k { color: #8ab4f8; }
pre.code .c { color: #7089a8; }

.feature-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin: 16px 0; }
.feature {
  border: 1px solid var(--border); border-radius: 10px; padding: 15px;
  background: var(--surface-2);
}
.feature .fi { font-size: 20px; }
.feature b { display: block; margin: 6px 0 3px; }
.feature span { font-size: 12.5px; color: var(--text-2); }

.guide-cta { text-align: center; padding: 28px 0 10px; }

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid var(--border); background: var(--surface);
  padding: 22px clamp(16px, 4vw, 48px); text-align: center;
  color: var(--text-3); font-size: 12.5px;
}
.site-footer a { color: var(--text-2); }

/* ---------- Responsive ---------- */
@media (max-width: 960px) {
  .generator { grid-template-columns: 1fr; }
  .controls { position: static; max-height: none; }
  .preview-stage { min-height: 380px; }
}
/* ---------- Print ---------- */
@media print {
  @page { margin: 0; }
  body { background: #fff; }
  .site-header, .controls, .preview-toolbar, .site-footer,
  .modal-backdrop, .toast, .page-caption { display: none !important; }
  .generator { display: block; max-width: none; margin: 0; padding: 0; }
  .preview-panel { border: 0; box-shadow: none; display: block; }
  .preview-stage {
    background: none; padding: 0; margin: 0; display: block;
    overflow: visible; min-height: 0; gap: 0;
  }
  .paper-wrap {
    box-shadow: none; margin: 0 auto; page-break-after: always;
    break-after: page; width: auto !important;
  }
  .paper-wrap:last-of-type { page-break-after: auto; break-after: auto; }
  .paper-wrap canvas { width: auto !important; height: auto !important; }
}

@media (max-width: 620px) {
  .site-header { padding: 0 14px; gap: 10px; }
  .brand-sub { display: none; }
  .site-nav a { padding: 7px 10px; font-size: 13px; }
  .generator { padding: 14px 12px 30px; gap: 14px; }
  .ctrl-group > summary { padding: 12px 14px; }
  .ctrl-body { padding: 2px 14px 14px; }
  .chip-grid { grid-template-columns: repeat(3, 1fr); }
  .preview-toolbar { padding: 10px 12px; }
  .preview-tools { margin-left: 0; width: 100%; justify-content: space-between; }
  .preview-stage { padding: 18px 10px 32px; }
  .guide-card { padding: 20px 16px; }
  .template-grid { grid-template-columns: repeat(2, 1fr); }
}
