/* 上班鼓励器 · 心愿单 样式 —— 「记工簿」主题
 * 页面是一本摊开的账本：绿格账纸、朱砂抬头双线、楷体墨字。
 * 排在最底下的心愿盖上「正在攒」朱砂章，攒满盖「讫」章。 */

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

:root {
  /* 磨砂羊皮纸 */
  --paper: #EFE6D2;
  --paper-deep: #E4D8BE;
  --grid-line: rgba(139,120,89,.28);
  --margin-red: #C05A4A;
  /* 墨 */
  --ink: #3B372F;
  --ink-sub: #8C8577;
  --pen-blue: #39537A;
  --pen-blue-soft: rgba(57,83,122,.35);
  /* 印 */
  --seal-red: #B5402F;
  --seal-red-soft: rgba(181,64,47,.75);
  /* 楷体栈：手记账感 */
  --kai: 'Kaiti SC', 'STKaiti', 'KaiTi', 'BiauKai', '楷体', serif;
}

html { background: var(--paper); }

body {
  font-family: -apple-system, "PingFang SC", "Helvetica Neue", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  /* 磨砂羊皮纸：暖底 + 纤维斑驳 + 细颗粒，多层渐变叠加，无贴图 */
  background:
    /* 左侧朱红账本线 */
    linear-gradient(to right,
      transparent 0, transparent calc(44px - 1px),
      var(--margin-red) calc(44px - 1px), var(--margin-red) 44px,
      transparent 44px),
    /* 边缘陈旧的深色晕染 */
    radial-gradient(140% 100% at 50% 0%, rgba(255,252,242,.55) 0%, rgba(255,252,242,0) 55%),
    radial-gradient(120% 90% at 0% 100%, rgba(154,127,85,.16) 0%, rgba(154,127,85,0) 55%),
    radial-gradient(120% 90% at 100% 100%, rgba(154,127,85,.14) 0%, rgba(154,127,85,0) 55%),
    radial-gradient(90% 70% at 100% 0%, rgba(196,167,116,.14) 0%, rgba(196,167,116,0) 60%),
    /* 纤维斑块 */
    radial-gradient(22% 14% at 18% 28%, rgba(178,152,108,.10) 0%, rgba(178,152,108,0) 100%),
    radial-gradient(18% 12% at 74% 12%, rgba(168,140,96,.09) 0%, rgba(168,140,96,0) 100%),
    radial-gradient(25% 16% at 60% 62%, rgba(182,156,112,.08) 0%, rgba(182,156,112,0) 100%),
    radial-gradient(20% 13% at 32% 82%, rgba(172,146,102,.09) 0%, rgba(172,146,102,0) 100%),
    /* 细颗粒磨砂 */
    repeating-linear-gradient(115deg,
      rgba(255,253,244,.05) 0 1px, rgba(160,134,92,.045) 1px 2px,
      rgba(255,253,244,.04) 2px 3px, rgba(160,134,92,.035) 3px 4px),
    repeating-linear-gradient(25deg,
      rgba(255,253,244,.04) 0 1px, rgba(160,134,92,.04) 1px 2px),
    var(--paper);
  background-attachment: fixed;
  min-height: 100vh;
  touch-action: manipulation;
  -webkit-text-size-adjust: 100%;
}

.app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  padding-left: max(58px, calc(44px + 14px), env(safe-area-inset-left));
  padding-right: max(18px, env(safe-area-inset-right));
  padding-top: max(22px, env(safe-area-inset-top));
  padding-bottom: max(52px, env(safe-area-inset-bottom));
}

/* ── 抬头：账本封签 ── */
.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 10px;
  border-top: 3px double var(--seal-red);
  border-bottom: 3px double var(--seal-red);
  padding: 12px 2px 10px;
  margin-bottom: 26px;
}
.topbar-text h1 {
  font-family: var(--kai);
  font-size: 26px; font-weight: 700; letter-spacing: 6px;
  color: var(--ink);
}
.subtitle { font-size: 12px; color: var(--ink-sub); margin-top: 5px; }

/* 合计行：账本结转，压双红线 */
.total-line { margin-top: 10px; display: flex; align-items: baseline; gap: 8px; }
.total-line .total-label {
  font-family: var(--kai); font-size: 13px; color: var(--ink-sub); letter-spacing: 2px;
  white-space: nowrap;
}
.total-line .total-num {
  font-family: var(--kai);
  font-size: 22px; font-weight: 700;
  color: var(--seal-red);
  border-bottom: 3px double var(--seal-red);
  padding: 0 4px 1px;
  font-variant-numeric: tabular-nums;
}
/* 今日实时进账：略小一号，带呼吸动画强调「在跳」 */
.total-line .live-num {
  font-size: 17px;
  color: #C99A3F;
  animation: live-pulse 2s ease-in-out infinite;
}
@keyframes live-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .55; }
}
}

.topbar-actions { display: flex; align-items: center; gap: 8px; padding-bottom: 2px; flex-shrink: 0; }

.icon-btn {
  border: none; background: none; color: var(--ink-sub);
  width: 38px; height: 38px; font-size: 18px; cursor: pointer;
  text-decoration: underline dotted rgba(140,133,119,.5);
  text-underline-offset: 4px;
}
.add-btn {
  border: none; background: none;
  font-family: var(--kai);
  color: var(--seal-red); font-size: 15px; font-weight: 700; letter-spacing: 1px;
  cursor: pointer; padding: 8px 4px;
  border-bottom: 2px solid var(--seal-red);
}

/* ── 列表 ── */
.wish-list { display: flex; flex-direction: column; }
.empty-tip {
  font-family: var(--kai);
  text-align: center; color: var(--ink-sub); font-size: 15px; margin-top: 80px;
  letter-spacing: 1px;
}
.hidden { display: none !important; }

/* ── 心愿条目：账目行 ── */
.wish-card {
  position: relative;
  background: none;
  border: none;
  border-bottom: 1px solid var(--grid-line);
  padding: 15px 4px 13px 34px;
  transition: background-color .2s ease;
  will-change: transform;
}
.wish-card.queued { color: var(--ink); }
.wish-card.active { background: rgba(181,64,47,.045); padding-right: 66px; } /* 右侧留给印章 */
.wish-card.done { background: rgba(224,169,62,.07); }
.wish-card.dragging {
  z-index: 10;
  background: #FFFDF6;
  box-shadow: 0 8px 22px rgba(59,55,47,.18);
  transition: none;
  cursor: grabbing;
}

/* 拖拽把手：把手区域画在账本线右侧 */
.drag-handle {
  position: absolute; left: -34px; top: 0; bottom: 0; width: 36px;
  display: flex; align-items: center; justify-content: center;
  cursor: grab; color: rgba(140,133,119,.55); font-size: 13px;
  touch-action: none; user-select: none;
}
.wish-card.active .drag-handle { visibility: hidden; }

/* 汉字序号：排队顺序 */
.row-no {
  position: absolute; left: 2px; top: 16px;
  font-family: var(--kai);
  font-size: 15px; color: var(--ink-sub);
}

/* 卡片头部 */
.card-head { display: flex; align-items: baseline; gap: 8px; }
.card-title {
  font-family: var(--kai);
  font-size: 19px; font-weight: 700; letter-spacing: 1px;
  flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: var(--ink);
}
.card-target {
  font-family: var(--kai);
  font-size: 17px; font-weight: 700; flex-shrink: 0;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}

/* 进度：圆珠笔线 */
.progress {
  margin: 10px 0 8px; height: 5px; border-radius: 0;
  background: rgba(57,83,122,.12);
  overflow: hidden;
}
.progress-fill {
  height: 100%; width: 0;
  background: var(--pen-blue);
  box-shadow: 0 1px 0 rgba(57,83,122,.25);
  transition: width .6s cubic-bezier(.22,.8,.36,1);
}
.wish-card.active .progress-fill { background: var(--seal-red); }
.wish-card.done .progress-fill { background: #C99A3F; }

/* 底部金额行 */
.card-foot { display: flex; justify-content: space-between; align-items: baseline; font-size: 12px; }
.money {
  font-family: var(--kai);
  font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums;
}
.muted { color: var(--ink-sub); }
.foot-right { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.est-time {
  font-size: 11px; color: var(--ink-sub); letter-spacing: .5px;
}
.est-time.done {
  color: #C99A3F; font-weight: 700;
  font-family: var(--kai); font-size: 13px; letter-spacing: 1px;
}

/* 操作区：账目备注行 */
.card-actions { display: flex; gap: 16px; margin-top: 9px; }
.card-actions button {
  border: none; background: none; font-size: 12px; color: var(--ink-sub);
  cursor: pointer; padding: 0;
  text-decoration: underline dotted rgba(140,133,119,.45);
  text-underline-offset: 3px;
}
.card-actions button:active { color: var(--ink); }
.card-actions .op-danger { color: var(--seal-red); }

/* 存钱按钮：按手印式的红字按钮 */
.save-btn {
  border: none; background: none;
  font-family: var(--kai);
  color: var(--seal-red); font-size: 14px; font-weight: 700; letter-spacing: 1px;
  cursor: pointer; padding: 4px 2px;
  border-bottom: 2px solid var(--seal-red-soft);
}
.save-btn:active { transform: scale(.96); }

/* ── 朱砂印章：全页唯一的胆量 ── */
.stamp {
  position: absolute; top: 14px; right: 4px; z-index: 2;
  display: flex; align-items: center; justify-content: center;
  width: 58px; height: 58px; border-radius: 50%;
  border: 2.5px solid var(--seal-red-soft);
  color: var(--seal-red-soft);
  font-family: var(--kai);
  font-size: 15px; font-weight: 700; letter-spacing: 2px; line-height: 1.25;
  text-align: center;
  transform: rotate(-14deg);
  pointer-events: none;
  -webkit-text-size-adjust: 100%;
}
/* 印泥的斑驳感：内圈细线 */
.stamp::before {
  content: '';
  position: absolute; inset: 3px;
  border: 1px solid rgba(181,64,47,.4);
  border-radius: 50%;
}
.stamp.stamp-on { padding-left: 2px; }
.stamp.stamp-done {
  font-size: 24px; letter-spacing: 0;
}

/* ── 弹窗：凭单 ── */
.modal-mask {
  position: fixed; inset: 0; background: rgba(59,55,47,.45);
  display: flex; align-items: center; justify-content: center; z-index: 100;
}
.modal {
  width: 88%; max-width: 360px;
  background:
    radial-gradient(120% 90% at 0% 100%, rgba(154,127,85,.14) 0%, rgba(154,127,85,0) 55%),
    radial-gradient(90% 70% at 100% 0%, rgba(196,167,116,.13) 0%, rgba(196,167,116,0) 60%),
    repeating-linear-gradient(115deg,
      rgba(255,253,244,.05) 0 1px, rgba(160,134,92,.045) 1px 2px,
      rgba(255,253,244,.04) 2px 3px, rgba(160,134,92,.035) 3px 4px),
    #F4ECDA;
  color: var(--ink);
  border: 1px solid var(--grid-line);
  outline: 3px double var(--seal-red);
  outline-offset: -8px;
  border-radius: 0;
  padding: 20px 22px; animation: pop .18s ease;
  box-shadow: 0 12px 36px rgba(59,55,47,.35);
}
@keyframes pop { from { transform: scale(.94); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal h2 {
  font-family: var(--kai);
  font-size: 18px; margin-bottom: 14px; letter-spacing: 4px;
}
.field { display: block; margin-bottom: 12px; }
.field span { display: block; font-size: 12px; color: var(--ink-sub); margin-bottom: 6px; letter-spacing: 1px; }
.field input, .field select {
  width: 100%; border: none; border-bottom: 1px solid rgba(140,133,119,.5);
  border-radius: 0; padding: 8px 2px; font-size: 15px; outline: none;
  background: transparent; color: var(--ink);
  font-family: var(--kai); font-size: 16px;
}
.field input:focus, .field select:focus { border-bottom-color: var(--seal-red); }
.field select { font-family: -apple-system, "PingFang SC", sans-serif; font-size: 14px; }
.field-hint { font-size: 11px; color: var(--ink-sub); margin: -4px 0 10px; }
.error { color: var(--seal-red); font-size: 12px; margin-bottom: 8px; }
.modal-btns { display: flex; gap: 10px; margin-top: 14px; }
.btn {
  flex: 1; border: none; background: none; border-radius: 0;
  padding: 10px 0; font-family: var(--kai);
  font-size: 15px; font-weight: 700; letter-spacing: 2px; cursor: pointer;
}
.btn.primary { color: var(--seal-red); border-bottom: 2px solid var(--seal-red); }
.btn.ghost { color: var(--ink-sub); border-bottom: 2px solid rgba(140,133,119,.4); }
.btn.danger { color: var(--seal-red); border-bottom: 2px dotted var(--seal-red); }

.settings-row { display: flex; gap: 10px; margin: 8px 0; }
.settings-row .btn { flex: 1; font-size: 13px; font-weight: 400; }
.about { font-size: 11px; color: #B0A895; text-align: center; margin-top: 12px; }

/* ── 编排动效：仅页面加载一次，墨迹干掉的感觉 ── */
@media (prefers-reduced-motion: no-preference) {
  .wish-card { animation: ink-in .45s ease backwards; }
  .wish-card:nth-child(1) { animation-delay: .05s; }
  .wish-card:nth-child(2) { animation-delay: .11s; }
  .wish-card:nth-child(3) { animation-delay: .17s; }
  .wish-card:nth-child(4) { animation-delay: .23s; }
  .wish-card:nth-child(n+5) { animation-delay: .29s; }
  .topbar { animation: ink-in .4s ease backwards; }
  .stamp { animation: stamp-in .35s cubic-bezier(.3,1.4,.5,1) backwards .5s; }
  .progress-fill { animation: grow .8s cubic-bezier(.22,.8,.36,1) backwards .3s; }
}
@keyframes ink-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes stamp-in {
  from { opacity: 0; transform: rotate(-14deg) scale(1.7); }
  to { opacity: 1; transform: rotate(-14deg) scale(1); }
}
@keyframes grow { from { width: 0; } }

/* ── 跨端适配 ── */

/* 触控目标不小于 40px（手机/平板） */
@media (pointer: coarse) {
  .icon-btn { width: 40px; height: 40px; }
  .card-actions button { padding: 8px 0; }
  .card-actions button:first-child { margin-left: -8px; padding-left: 8px; }
  .save-btn { padding: 9px 4px; }
  .modal .btn { padding: 13px 0; }
  .field input, .field select { font-size: 16px; } /* ≥16px 防止 iOS 聚焦时自动放大页面 */
}

/* 拖拽时禁止页面选中文本 / iOS 长按呼出菜单 */
.wish-card.dragging, .drag-handle {
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

/* 键盘+鼠标设备：hover 反馈 */
@media (hover: hover) and (pointer: fine) {
  .wish-card.queued:hover { background: rgba(148,166,138,.1); }
  .wish-card.active:hover { background: rgba(181,64,47,.08); }
  .card-actions button:hover { color: var(--ink); }
  .card-actions .op-danger:hover { color: var(--seal-red); }
  .add-btn:hover, .btn.primary:hover, .save-btn:hover { border-bottom-style: double; }
  .btn.ghost:hover, .btn.danger:hover, .icon-btn:hover { color: var(--ink); }
}

/* PC 宽屏：账页更宽，行距更舒展 */
@media (min-width: 768px) {
  .app { max-width: 600px; }
  .topbar-text h1 { font-size: 30px; }
  .card-title { font-size: 21px; }
  .card-target { font-size: 19px; }
  .total-line .total-num { font-size: 26px; }
  .wish-card { padding: 17px 6px 15px 38px; }
  .row-no { top: 18px; }
}

/* 横屏矮视口（如平板横持）：压缩顶部留白 */
@media (max-height: 480px) {
  .app { padding-top: 8px; }
  .topbar { margin-bottom: 14px; padding: 8px 2px 7px; }
}

/* 窄屏：抬头字距收紧 */
@media (max-width: 360px) {
  .topbar-text h1 { font-size: 22px; letter-spacing: 4px; }
  .total-line .total-num { font-size: 19px; }
  .stamp { width: 52px; height: 52px; font-size: 13px; }
}
