/* ============================================================
   百日拼图 · 宝宝百天一百张照片纪念海报
   精美样式表
   ============================================================ */

:root {
  --primary: #f59e0b;
  --primary-deep: #d97706;
  --accent: #f472b6;
  --ink: #44403c;
  --ink-light: #a8a29e;
  --line: #eee7dd;
  --panel-bg: #ffffff;
  --shadow-sm: 0 1px 3px rgba(120, 90, 40, 0.08);
  --shadow-md: 0 8px 24px rgba(120, 90, 40, 0.12);
  --radius: 14px;
  --font: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", "Segoe UI", sans-serif;
  --font-serif: "Songti SC", "STSong", "SimSun", serif;
}

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

html, body { height: 100%; }

body {
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 85% -10%, rgba(245, 158, 11, 0.10), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, rgba(244, 114, 182, 0.10), transparent 60%),
    #faf7f2;
  -webkit-font-smoothing: antialiased;
}

button { font-family: inherit; cursor: pointer; }
input { font-family: inherit; }

/* ============ 顶栏 ============ */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(255, 253, 250, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.topbar-inner {
  max-width: 1500px;
  margin: 0 auto;
  padding: 12px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.brand { display: flex; align-items: center; gap: 14px; }

.brand-badge {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff;
  font-weight: 800;
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 16px rgba(245, 158, 11, 0.35);
  letter-spacing: 0.5px;
}

.brand-text h1 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 2px;
  background: linear-gradient(90deg, var(--primary-deep), var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-text p { font-size: 12.5px; color: var(--ink-light); margin-top: 2px; letter-spacing: 1px; }

.topbar-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ============ 按钮 ============ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  padding: 9px 16px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.18s ease;
  box-shadow: var(--card-sm);
  white-space: nowrap;
}

.btn:hover { border-color: #f0d9ae; background: #fffbf5; transform: translateY(-1px); box-shadow: var(--shadow-md); }
.btn:active { transform: translateY(0); }

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-deep));
  border: none;
  color: #fff;
  box-shadow: 0 4px 14px rgba(245, 158, 11, 0.35);
}
.btn-primary:hover { background: linear-gradient(135deg, var(--primary-deep), #b45309); }

.btn-export {
  width: 100%;
  justify-content: center;
  background: linear-gradient(135deg, #f97316, #ef4444);
  border: none;
  color: #fff;
  font-size: 15px;
  padding: 12px;
  box-shadow: 0 6px 18px rgba(249, 115, 22, 0.35);
}
.btn-export:hover { background: linear-gradient(135deg, #ea580c, #dc2626); }

.btn-ghost { width: 100%; justify-content: center; background: transparent; box-shadow: none; }
.btn-ghost:hover { background: #fdf6ec; }

.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; box-shadow: none; }

/* ============ 布局 ============ */
.layout {
  max-width: 1500px;
  margin: 0 auto;
  padding: 24px 28px 40px;
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 24px;
  align-items: start;
}

/* ============ 左侧面板 ============ */
.panel {
  position: sticky;
  top: 88px;
  background: var(--panel-bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--card-sm);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.panel-section { padding: 12px 0; border-bottom: 1px dashed var(--line); }
.panel-section:last-child { border-bottom: none; }

.panel-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sec-arrow {
  margin-left: 8px;
  font-size: 12px;
  color: var(--ink-light);
  transition: transform 0.2s ease;
  user-select: none;
}
.panel-section.collapsed .sec-arrow { transform: rotate(-90deg); }
.panel-section.collapsed > *:not(.panel-title) { display: none; }

.count-badge {
  font-size: 12px;
  font-weight: 600;
  color: var(--primary-deep);
  background: #fef3e2;
  border-radius: 20px;
  padding: 3px 10px;
}

.progress-track {
  height: 8px;
  background: #f4ede2;
  border-radius: 20px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  width: 0;
  border-radius: 20px;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  transition: width 0.4s ease;
}

.hint { font-size: 12.5px; color: var(--ink-light); margin-top: 10px; line-height: 1.6; }

/* 表单 */
.field { margin-bottom: 14px; }
.field:last-child { margin-bottom: 4px; }

.field label {
  display: block;
  font-size: 12.5px;
  color: var(--ink-light);
  margin-bottom: 6px;
}

.field input[type="text"] {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  font-size: 14px;
  background: #fffdf9;
  color: var(--ink);
  transition: border 0.15s ease, box-shadow 0.15s ease;
}
.field input[type="text"]:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.15);
}

.bg-options { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }

.bg-swatch {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 8px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  font-size: 12.5px;
  color: var(--ink);
  transition: all 0.15s ease;
}
.bg-swatch:hover { border-color: #e8cdb0; }
.bg-swatch.active { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.15); font-weight: 600; }

.bg-swatch .dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.08);
  flex-shrink: 0;
}
.dot-rainbow {
  background: conic-gradient(#f59e0b, #f472b6, #8b5cf6, #3b82f6, #22c55e, #f59e0b);
}

.range-row { display: flex; align-items: center; gap: 10px; }

.range-row input[type="range"] {
  flex: 1;
  accent-color: var(--primary);
}

.range-val {
  min-width: 48px;
  text-align: right;
  font-size: 12.5px;
  color: var(--ink-light);
  font-variant-numeric: tabular-nums;
}

.field-check label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  color: var(--ink);
  margin: 0;
  cursor: pointer;
}
.field-check input { accent-color: var(--primary); width: 16px; height: 16px; }

.panel-tips ul { list-style: none; }
.panel-tips li {
  position: relative;
  padding-left: 16px;
  font-size: 12.5px;
  color: var(--ink-light);
  line-height: 1.9;
}
.panel-tips li::before {
  content: "";
  position: absolute;
  left: 2px;
  top: 9px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--accent));
}

/* ============ 右侧工作区 ============ */
.stage {
  position: relative;
  min-width: 0;
  background: rgba(255, 255, 255, 0.75);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--card-sm);
  padding: 28px;
  min-height: 70vh;
}

.stage-scroll { overflow: visible; }

/* ---------- 海报缩放容器 ---------- */
.poster-scale {
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  position: relative;
}

/* 窄屏时海报等比缩小，阴影视觉占位大，去掉更干净 */
@media (max-width: 960px) {
  .poster { box-shadow: none; }
}

/* ---------- 海报本体 ---------- */
.poster {
  width: 960px;
  margin: 0 auto;
  padding: 46px 44px 34px;
  border-radius: 18px;
  box-shadow: 0 16px 48px rgba(120, 90, 40, 0.16);
  transition: background 0.25s ease;
  position: relative;
  font-family: var(--font-serif);
  transform-origin: top left;
}

/* 背景风格 */
.bg-cream  { background: linear-gradient(170deg, #fffdf7, #fdf1e0); }
.bg-mint   { background: linear-gradient(170deg, #f4fcf7, #e0f3e8); }
.bg-sky    { background: linear-gradient(170deg, #f4fafd, #ddeff8); }
.bg-peach  { background: linear-gradient(170deg, #fff8f5, #fde5df); }
.bg-lilac  { background: linear-gradient(170deg, #fbf9fe, #e9e1f8); }

/* 海报头部 */
.poster-head { text-align: center; margin-bottom: 30px; }

.poster-title {
  font-size: 40px;
  font-weight: 700;
  letter-spacing: 8px;
  color: #6b4b2a;
  line-height: 1.2;
}

.poster-subtitle {
  margin-top: 12px;
  font-size: 14px;
  letter-spacing: 3px;
  color: #b08d63;
}

/* 照片网格 */
.grid {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 8px;
  transition: gap 0.2s ease;
}

.cell {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: 10px;
  overflow: hidden;
  background: #f3ead9;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  cursor: pointer;
}

.cell:hover { transform: scale(1.05); z-index: 2; box-shadow: 0 8px 20px rgba(120, 90, 40, 0.22); }

.cell img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  user-select: none;
  -webkit-user-drag: none;
  pointer-events: none;
}

.cell .day-num {
  position: absolute;
  left: 4px;
  top: 4px;
  background: rgba(0, 0, 0, 0.42);
  color: #fff;
  font-size: 11px;
  font-family: var(--font);
  line-height: 1;
  padding: 4px 6px;
  border-radius: 6px;
  letter-spacing: 0.5px;
  pointer-events: none;
}

/* 空格子 */
.cell.placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #d9c6a8;
  font-size: 26px;
  background: repeating-linear-gradient(45deg, #faf3e6, #faf3e6 8px, #f5ecdb 8px, #f5ecdb 16px);
  border: 1px dashed #e6d5b8;
  cursor: pointer;
}
.cell.placeholder:hover { border-color: var(--primary); color: var(--primary); }

.cell.dragging { opacity: 0.35; transform: scale(0.96); }
.cell.drop-target { outline: 3px solid var(--primary); outline-offset: -1px; }

/* 触屏拖拽时的跟随幽灵图 */
.touch-ghost {
  position: fixed;
  z-index: 500;
  display: none;
  pointer-events: none;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 16px 40px rgba(120, 90, 40, 0.35);
  transform: scale(1.08);
}
.touch-ghost img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* 海报底部 */
.poster-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 26px;
  font-size: 13px;
  color: #b08d63;
  letter-spacing: 2px;
}
.poster-foot::before,
.poster-foot::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, transparent, #dcc7a8);
  margin: 0 14px;
}
.poster-foot::before { order: 1; margin-left: 0; }
.poster-foot::after { order: 4; margin-right: 0; }
.foot-left { order: 2; white-space: nowrap; }
.foot-right { order: 3; white-space: nowrap; font-variant-numeric: tabular-nums; }

/* 空状态提示 */
.empty-tip {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.55);
  text-align: center;
  z-index: 5;
}
.empty-tip.show { display: flex; }
.empty-icon { font-size: 56px; filter: grayscale(0.2); }
.empty-tip p { font-size: 17px; color: #8a735a; margin-top: 10px; font-weight: 600; }
.empty-tip .empty-sub { font-size: 13.5px; color: #b3a48f; font-weight: 400; line-height: 1.9; }

/* ============ 提示气泡 ============ */
.toast {
  position: fixed;
  left: 50%;
  bottom: 40px;
  transform: translateX(-50%) translateY(20px);
  background: rgba(40, 32, 24, 0.92);
  color: #fff;
  padding: 12px 22px;
  border-radius: 12px;
  font-size: 14px;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s ease;
  backdrop-filter: blur(4px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
  white-space: nowrap;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ============ 右键菜单 ============ */
.ctxmenu {
  position: fixed;
  z-index: 200;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.15);
  padding: 6px;
  min-width: 140px;
  animation: pop 0.12s ease;
}
.ctxmenu button {
  display: block;
  width: 100%;
  text-align: left;
  border: none;
  background: none;
  padding: 9px 12px;
  border-radius: 7px;
  font-size: 13.5px;
  color: var(--ink);
}
.ctxmenu button:hover { background: #fdf3e2; color: var(--primary-deep); }
.ctxmenu button.danger:hover { background: #fdecec; color: #dc2626; }

@keyframes pop {
  from { transform: scale(0.92); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}

/* ============ 全屏预览 ============ */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: rgba(20, 18, 12, 0.9);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  animation: fade 0.2s ease;
}
.lightbox[hidden], .ctxmenu[hidden] { display: none !important; }
.lightbox img {
  max-width: 88vw;
  max-height: 82vh;
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}
.lightbox-close {
  position: absolute;
  top: 22px;
  right: 26px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  font-size: 26px;
  line-height: 1;
  transition: background 0.15s ease;
}
.lightbox-close:hover { background: rgba(255, 255, 255, 0.3); }
.lightbox-cap { color: #e8ddcf; font-size: 14px; letter-spacing: 1px; }

@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* ============ 导出进度遮罩 ============ */
.export-mask {
  position: fixed;
  inset: 0;
  z-index: 400;
  background: rgba(40, 32, 24, 0.55);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  backdrop-filter: blur(3px);
}
.export-spinner {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 5px solid rgba(255, 255, 255, 0.3);
  border-top-color: var(--primary);
  animation: spin 0.8s linear infinite;
}
.export-mask p { color: #fff; font-size: 15px; letter-spacing: 1px; }

@keyframes spin { to { transform: rotate(360deg); } }

/* ============ 导出结果弹层 ============ */
.export-result {
  position: fixed;
  inset: 0;
  z-index: 350;
  background: rgba(40, 32, 24, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(3px);
}
.export-result[hidden] { display: none !important; }
.export-result-card {
  background: #fff;
  border-radius: 18px;
  padding: 22px;
  max-width: 520px;
  width: 100%;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.28);
  animation: pop 0.18s ease;
  text-align: center;
  max-height: 90vh;
  overflow-y: auto;
}
.export-result-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 14px;
  letter-spacing: 1px;
}
.export-result-imgwrap {
  border-radius: 12px;
  overflow: hidden;
  background: #f6f1e8;
  border: 1px solid var(--line);
  max-height: 56vh;
  display: flex;
  align-items: center;
  justify-content: center;
}
.export-result-imgwrap img {
  width: 100%;
  height: auto;
  display: block;
  -webkit-user-drag: none;
  user-select: none;
}
.export-result-tip {
  font-size: 13px;
  color: var(--ink-light);
  line-height: 1.7;
  margin: 14px 0 16px;
}
.export-result-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
}
.export-result-actions .btn { flex: 1; justify-content: center; }

/* ============ 响应式 ============ */
/* 两列布局需要：300(面板)+24(间距)+960(海报)+56(留白) ≈ 1340 */
@media (max-width: 1340px) {
  .layout { grid-template-columns: 1fr; }
  .panel { position: static; max-height: none; }
}

/* 触屏设备：去掉悬停放大等桌面交互效果 */
@media (hover: none) {
  .cell:hover { transform: none; box-shadow: none; }
  .btn:hover { transform: none; box-shadow: var(--shadow-sm); }
}

/* 手机端 */
@media (max-width: 640px) {
  .topbar-inner { padding: 10px 14px; }
  .brand-badge { width: 42px; height: 42px; border-radius: 12px; font-size: 17px; }
  .brand-text h1 { font-size: 18px; letter-spacing: 1.5px; }
  .brand-text p { display: none; }
  .topbar-actions { gap: 8px; }
  .topbar-actions .btn { padding: 8px 10px; }
  .topbar-actions .btn .btn-label { display: none; }
  .layout { padding: 12px 12px 24px; gap: 12px; }
  .stage { padding: 12px; min-height: 0; }
  .ctxmenu { min-width: 168px; }
  .ctxmenu button { padding: 13px 16px; font-size: 15px; }
  .empty-icon { font-size: 44px; }
  .toast { max-width: 90vw; white-space: normal; text-align: center; }
  .field input[type="text"] { font-size: 16px; }
  .export-result-card { padding: 16px; }
  .export-result-actions .btn { padding: 12px 10px; }
}

@media print {
  body { background: #fff; }
  .topbar, .panel, .empty-tip, .toast, .ctxmenu, .lightbox { display: none !important; }
  .layout { display: block; padding: 0; max-width: none; }
  .stage { border: none; box-shadow: none; padding: 0; min-height: 0; }
  .stage-scroll { overflow: visible; }
  .poster-scale { height: auto !important; overflow: visible !important; }
  .poster {
    width: 100% !important;
    transform: none !important;
    margin: 0;
    border-radius: 0;
    box-shadow: none;
    page-break-inside: avoid;
  }
  .cell:hover { transform: none; box-shadow: none; }
}