/* ===== 定制贺卡 · 编辑端样式 ===== */
:root {
  --blue-1: #3a5cf5;
  --blue-2: #5b7cfa;
  --blue-3: #7c97ff;
  --blue-soft: #eef2ff;
  --blue-soft2: #e3eaff;
  --ink: #1f2740;
  --ink-2: #5b6480;
  --ink-3: #98a0b8;
  --line: #e6eaf3;
  --white: #ffffff;
  --danger: #ef4a5a;
  --ok: #1fb27a;
  --shadow: 0 10px 40px rgba(58, 92, 245, .10);
  --shadow-lg: 0 20px 60px rgba(31, 39, 64, .14);
  --radius: 18px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background: linear-gradient(160deg, #f5f7ff 0%, #eef2ff 45%, #e8edff 100%);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
button, input, textarea { font-family: inherit; }
button { cursor: pointer; }
a { color: inherit; }

/* ---------- 顶部栏 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between;
  height: 64px; padding: 0 clamp(16px, 4vw, 40px);
  background: rgba(255,255,255,.82); backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 17px; letter-spacing: .2px; }
.brand .logo {
  width: 34px; height: 34px; border-radius: 10px;
  background: linear-gradient(135deg, var(--blue-1), var(--blue-3));
  display: grid; place-items: center; color: #fff; font-size: 18px;
  box-shadow: 0 6px 16px rgba(58,92,245,.35);
}
.topbar .right { display: flex; align-items: center; gap: 12px; }

/* ---------- 通用按钮 ---------- */
.btn {
  border: none; border-radius: 11px; padding: 10px 18px;
  font-size: 14px; font-weight: 700; color: #fff;
  background: linear-gradient(135deg, var(--blue-1), var(--blue-2));
  box-shadow: 0 6px 16px rgba(58,92,245,.28);
  transition: transform .15s, box-shadow .15s, opacity .15s;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 10px 22px rgba(58,92,245,.36); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn.ghost { background: #fff; color: var(--blue-1); border: 1px solid var(--blue-soft2); box-shadow: none; }
.btn.soft { background: var(--blue-soft); color: var(--blue-1); box-shadow: none; }
.btn.danger { background: linear-gradient(135deg, #ef4a5a, #f4727e); box-shadow: 0 6px 16px rgba(239,74,90,.28); }
.btn.sm { padding: 7px 13px; font-size: 13px; border-radius: 9px; }
.btn.block { width: 100%; }

/* ---------- 视图容器 ---------- */
.view { display: none; max-width: 1080px; margin: 0 auto; padding: 28px clamp(16px, 4vw, 40px) 80px; }
.view.active { display: block; animation: fadeUp .35s ease; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

/* ---------- 登录 ---------- */
#loginView { display: none; }
#loginView.active { display: grid; place-items: center; min-height: 100vh; }
.login-card {
  width: min(420px, 92vw); background: #fff; border-radius: 24px;
  padding: 44px 38px; box-shadow: var(--shadow-lg); text-align: center;
}
.login-card .emoji {
  width: 74px; height: 74px; margin: 0 auto 18px; border-radius: 22px;
  background: linear-gradient(135deg, var(--blue-1), var(--blue-3));
  display: grid; place-items: center; font-size: 40px;
  box-shadow: 0 14px 30px rgba(58,92,245,.35);
}
.login-card h1 { margin: 0 0 8px; font-size: 24px; }
.login-card p { margin: 0 0 28px; color: var(--ink-2); font-size: 14px; }
.pw-wrap { position: relative; }
.pw-wrap input { text-align: center; letter-spacing: 6px; font-size: 18px; }
.pw-err { color: var(--danger); font-size: 13px; min-height: 20px; margin-top: 8px; }

/* ---------- 输入框 ---------- */
.input, .textarea {
  width: 100%; border: 1.5px solid var(--line); border-radius: 12px;
  padding: 12px 14px; font-size: 15px; color: var(--ink); background: #fff;
  transition: border-color .15s, box-shadow .15s; outline: none;
}
.input:focus, .textarea:focus { border-color: var(--blue-2); box-shadow: 0 0 0 4px var(--blue-soft); }
.textarea { resize: vertical; min-height: 120px; line-height: 1.7; }

/* ---------- 贺卡列表 ---------- */
.section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
.section-head h2 { margin: 0 0 4px; font-size: 26px; }
.section-head .sub { color: var(--ink-2); font-size: 14px; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 18px; }
.card-item {
  background: #fff; border-radius: var(--radius); overflow: hidden;
  box-shadow: var(--shadow); border: 1px solid rgba(230,234,243,.8);
  transition: transform .18s, box-shadow .18s;
}
.card-item:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); }
.card-cover {
  height: 140px; background: linear-gradient(135deg, var(--blue-1), var(--blue-3));
  position: relative; display: grid; place-items: center; overflow: hidden;
}
.card-cover img { width: 100%; height: 100%; object-fit: cover; }
.card-cover .ph { color: rgba(255,255,255,.9); font-size: 34px; }
.card-body { padding: 16px; }
.card-body h3 { margin: 0 0 4px; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-body .meta { color: var(--ink-3); font-size: 12px; margin-bottom: 14px; }
.card-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.empty {
  grid-column: 1/-1; text-align: center; padding: 70px 20px; color: var(--ink-2);
  background: #fff; border-radius: var(--radius); box-shadow: var(--shadow);
}
.empty .big { font-size: 54px; margin-bottom: 10px; }

/* ---------- 编辑器 ---------- */
.editor-head { display: flex; align-items: center; gap: 14px; margin-bottom: 24px; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 11px; border: 1px solid var(--line);
  background: #fff; display: grid; place-items: center; font-size: 18px; color: var(--ink-2);
}
.icon-btn:hover { border-color: var(--blue-2); color: var(--blue-1); }
.editor-head h2 { margin: 0; font-size: 22px; flex: 1; }
.editor-grid { display: grid; grid-template-columns: 1.05fr .95fr; gap: 22px; align-items: start; }
@media (max-width: 860px) { .editor-grid { grid-template-columns: 1fr; } }

.panel {
  background: #fff; border-radius: var(--radius); padding: 22px;
  box-shadow: var(--shadow); border: 1px solid rgba(230,234,243,.8); margin-bottom: 20px;
}
.panel h3 { margin: 0 0 4px; font-size: 16px; display: flex; align-items: center; gap: 8px; }
.panel h3 .n {
  width: 22px; height: 22px; border-radius: 7px; background: var(--blue-soft);
  color: var(--blue-1); display: grid; place-items: center; font-size: 12px;
}
.panel .hint { color: var(--ink-3); font-size: 12px; margin: 0 0 16px; }
.field { margin-top: 14px; }
.field label { display: block; font-size: 13px; font-weight: 700; margin-bottom: 7px; color: var(--ink-2); }

/* 图片上传区 */
.upload-zone {
  border: 2px dashed var(--blue-soft2); border-radius: 14px; padding: 26px 16px;
  text-align: center; color: var(--ink-2); background: var(--blue-soft);
  transition: .2s; cursor: pointer;
}
.upload-zone:hover, .upload-zone.drag { border-color: var(--blue-2); background: #e8edff; }
.upload-zone .ic { font-size: 32px; display: block; margin-bottom: 8px; }
.upload-zone b { color: var(--blue-1); }
.img-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 14px; }
.img-cell {
  position: relative; aspect-ratio: 1; border-radius: 12px; overflow: hidden;
  border: 2px solid transparent; background: var(--blue-soft); cursor: grab;
}
.img-cell.cover { border-color: var(--blue-1); }
.img-cell img { width: 100%; height: 100%; object-fit: cover; display: block; }
.img-cell.dragging { opacity: .35; }
.img-cell .tools { position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: space-between; }
.img-cell .row { display: flex; justify-content: space-between; padding: 5px; }
.chip {
  width: 26px; height: 26px; border-radius: 8px; border: none;
  background: rgba(31,39,64,.55); color: #fff; font-size: 12px; display: grid; place-items: center;
  backdrop-filter: blur(4px);
}
.chip.cover-chip { background: rgba(58,92,245,.92); }
.chip.del { background: rgba(239,74,90,.92); }
.cover-tag {
  position: absolute; bottom: 5px; left: 50%; transform: translateX(-50%);
  background: var(--blue-1); color: #fff; font-size: 10px; padding: 2px 8px; border-radius: 20px; white-space: nowrap;
}
.order-hint { font-size: 11px; color: var(--ink-3); margin-top: 10px; text-align: center; }

/* 录音区 */
.recorder {
  display: flex; align-items: center; gap: 16px; padding: 16px;
  background: var(--blue-soft); border-radius: 14px;
}
.rec-btn {
  width: 58px; height: 58px; border-radius: 50%; border: none; flex: none;
  background: linear-gradient(135deg, var(--blue-1), var(--blue-2)); color: #fff;
  font-size: 22px; box-shadow: 0 8px 20px rgba(58,92,245,.35);
  display: grid; place-items: center; transition: .15s;
}
.rec-btn.recording { background: linear-gradient(135deg, #ef4a5a, #f4727e); animation: pulse 1.2s infinite; }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(239,74,90,.45); } 50% { box-shadow: 0 0 0 14px rgba(239,74,90,0); } }
.rec-info { flex: 1; min-width: 0; }
.rec-time { font-size: 24px; font-weight: 800; font-variant-numeric: tabular-nums; }
.rec-status { font-size: 12px; color: var(--ink-2); margin-top: 2px; }
.rec-actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
audio { width: 100%; height: 40px; margin-top: 12px; }

/* 底部保存栏 */
.save-bar {
  position: sticky; bottom: 0; z-index: 20; margin-top: 8px;
  background: rgba(255,255,255,.9); backdrop-filter: blur(12px);
  border: 1px solid var(--line); border-radius: 14px; padding: 14px 18px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  box-shadow: 0 -6px 24px rgba(31,39,64,.06);
}
.save-state { font-size: 13px; color: var(--ink-3); display: flex; align-items: center; gap: 6px; }
.save-state.ok { color: var(--ok); }
.save-state.err { color: var(--danger); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }

/* 分享区 */
.share-box { margin-top: 6px; }
.share-row { display: flex; gap: 10px; align-items: center; }
.share-row .input { flex: 1; font-size: 13px; }
.qr-wrap { display: flex; gap: 18px; align-items: center; margin-top: 16px; }
.qr-box {
  width: 150px; height: 150px; border-radius: 14px; background: #fff;
  border: 1px solid var(--line); display: grid; place-items: center; flex: none; padding: 8px;
}
.qr-box img { width: 100%; height: 100%; }
.qr-tip { font-size: 13px; color: var(--ink-2); line-height: 1.7; }
.qr-tip b { color: var(--blue-1); }

/* ---------- 弹窗 ---------- */
.modal-mask {
  position: fixed; inset: 0; z-index: 100; background: rgba(20,26,48,.5);
  display: none; align-items: center; justify-content: center; padding: 20px; backdrop-filter: blur(3px);
}
.modal-mask.show { display: flex; animation: fadeIn .2s; }
@keyframes fadeIn { from { opacity: 0; } }
.modal {
  background: #fff; border-radius: 20px; padding: 26px; width: min(360px, 92vw);
  box-shadow: var(--shadow-lg); text-align: center;
}
.modal h3 { margin: 0 0 8px; font-size: 18px; }
.modal p { color: var(--ink-2); font-size: 14px; margin: 0 0 20px; }
.modal .btns { display: flex; gap: 10px; }
.modal .btns .btn { flex: 1; }

/* ---------- Toast ---------- */
#toast {
  position: fixed; left: 50%; bottom: 34px; transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: #fff; padding: 12px 22px; border-radius: 12px;
  font-size: 14px; z-index: 200; opacity: 0; pointer-events: none; transition: .25s;
  box-shadow: var(--shadow-lg); max-width: 90vw; text-align: center;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
