/* ==========================================================
   我的小站 · 可爱手账风
   奶油底色 + 圆角卡片 + 和纸胶带 + 楷体标题
   ========================================================== */

:root {
  --bg: #FFF6EC;
  --card: #FFFDF8;
  --ink: #5A4A42;
  --ink-light: #9B8878;
  --line: #F3E2D2;

  --pink: #FF9EB5;
  --pink-soft: #FFE3EB;
  --peach: #FFB88C;
  --peach-soft: #FFEBDD;
  --mint: #8FD5B5;
  --mint-soft: #E2F5EB;
  --lav: #C3B1E1;
  --lav-soft: #F0EAF9;
  --yellow: #FFD97D;
  --yellow-soft: #FFF6DC;

  --radius: 22px;
  --shadow: 0 6px 18px rgba(190, 150, 120, .13);
  --font-hand: "Kaiti SC", "STKaiti", "KaiTi", "楷体", "PingFang SC", "Microsoft YaHei", sans-serif;
}

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

/* hidden 属性必须始终生效（防止 display:flex 等规则覆盖） */
[hidden] { display: none !important; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-hand);
  color: var(--ink);
  background-color: var(--bg);
  /* 波点桌布 */
  background-image: radial-gradient(rgba(255, 158, 181, .16) 1.6px, transparent 1.6px),
                    radial-gradient(rgba(143, 213, 181, .13) 1.6px, transparent 1.6px);
  background-size: 28px 28px, 28px 28px;
  background-position: 0 0, 14px 14px;
  min-height: 100vh;
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
  font-size: 16px;
  line-height: 1.6;
}

/* ---------- 通用 ---------- */
button { font-family: inherit; color: inherit; border: none; background: none; cursor: pointer; }
input, textarea { font-family: inherit; color: var(--ink); }

.app {
  max-width: 520px;
  margin: 0 auto;
  padding: 16px 16px 24px;
}

.view { animation: fadeUp .3s ease; }
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: none; }
}

/* ---------- 顶部 Hero ---------- */
.hero {
  position: relative;
  background: linear-gradient(135deg, var(--pink-soft), var(--peach-soft) 55%, var(--yellow-soft));
  border: 2px solid #FFD9E2;
  border-radius: var(--radius);
  padding: 22px 18px 18px;
  box-shadow: var(--shadow);
  overflow: hidden;
  margin-bottom: 14px;
}

/* 和纸胶带 */
.hero-tape, .modal-tape {
  position: absolute;
  top: -10px;
  left: 50%;
  width: 96px;
  height: 22px;
  transform: translateX(-50%) rotate(-3deg);
  border-radius: 3px;
  opacity: .85;
}
.tape-pink { background: repeating-linear-gradient(45deg, var(--pink), var(--pink) 8px, #ffb3c6 8px, #ffb3c6 16px); }
.tape-mint { background: repeating-linear-gradient(45deg, var(--mint), var(--mint) 8px, #a9e2c9 8px, #a9e2c9 16px); }
.tape-lav  { background: repeating-linear-gradient(45deg, var(--lav), var(--lav) 8px, #d3c6ec 8px, #d3c6ec 16px); }

.hero-row { display: flex; justify-content: space-between; align-items: flex-start; }
.hero-date { font-size: 13px; color: var(--ink-light); letter-spacing: 1px; }
.hero-greeting { font-size: 26px; margin-top: 2px; }
.hero-avatar {
  width: 54px; height: 54px;
  background: #fff;
  border: 2px dashed var(--pink);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 26px;
  box-shadow: var(--shadow);
}
.hero-motto { margin-top: 10px; font-size: 14px; color: var(--ink-light); }
.hero-hitokoto {
  margin-top: 6px; font-size: 13px; color: var(--ink-light);
  border-top: 1px dashed rgba(155, 136, 120, .35);
  padding-top: 8px; min-height: 14px;
}

/* ---------- 统计小卡 ---------- */
.widget-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 14px; }
.mini-card {
  border-radius: 18px;
  padding: 12px 8px 10px;
  text-align: center;
  border: 2px solid #fff;
  box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 2px;
}
.card-peach { background: var(--peach-soft); }
.card-mint  { background: var(--mint-soft); }
.card-lav   { background: var(--lav-soft); }
.mini-num { font-size: 22px; font-weight: bold; }
.mini-label { font-size: 12px; color: var(--ink-light); }

/* ---------- 卡片 ---------- */
.card {
  position: relative;
  background: var(--card);
  border: 2px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  margin-bottom: 14px;
}
.card-title-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.card-title { font-size: 17px; }
.card-note { font-size: 12px; color: var(--ink-light); margin-bottom: 10px; }

.link-btn { font-size: 13px; color: var(--pink); }
.link-btn:active { opacity: .6; }

/* ---------- 倒数日 ---------- */
.countdown-list { display: flex; flex-wrap: wrap; gap: 8px; }
.countdown-pill {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--yellow-soft);
  border: 1.5px dashed #E8C56A;
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 13px;
}
.countdown-pill b { color: #D89A1E; }
.countdown-manage { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.countdown-manage-item {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 14px; background: var(--yellow-soft);
  border-radius: 10px; padding: 6px 10px;
}
.countdown-manage-item button { color: #E38C8C; font-size: 13px; }
.countdown-form { display: flex; gap: 6px; }
.countdown-form input {
  flex: 1; min-width: 0;
  border: 2px solid var(--line); border-radius: 10px;
  padding: 7px 10px; font-size: 13px; background: #fff;
}
.countdown-form input[type="date"] { flex: .9; }

/* ---------- 首页迷你待办 ---------- */
.todo-mini-list { list-style: none; }
.todo-mini-list li {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 2px; font-size: 14px;
  border-bottom: 1px dashed var(--line);
}
.todo-mini-list li:last-child { border-bottom: none; }
.todo-mini-list .done-text { text-decoration: line-through; color: var(--ink-light); }
.todo-mini-empty { font-size: 13px; color: var(--ink-light); padding: 6px 0; }

.home-footer { text-align: center; font-size: 12px; color: var(--ink-light); padding: 8px 0 4px; }

/* ---------- 页头 ---------- */
.page-head {
  display: flex; justify-content: space-between; align-items: center;
  margin: 4px 2px 14px;
}
.page-title { font-size: 22px; }
.page-head-actions { display: flex; gap: 8px; }
.icon-btn {
  width: 38px; height: 38px;
  border-radius: 14px;
  background: var(--card);
  border: 2px solid var(--line);
  box-shadow: var(--shadow);
  font-size: 15px;
  display: flex; align-items: center; justify-content: center;
}
.icon-btn:active { transform: scale(.94); }
.add-btn { background: var(--pink-soft); border-color: #FFD0DC; font-size: 20px; color: #E0698A; }

/* ---------- 待办 ---------- */
.todo-form { display: flex; gap: 8px; margin-bottom: 12px; }
.todo-input {
  flex: 1;
  border: 2px solid var(--line);
  background: var(--card);
  border-radius: 16px;
  padding: 12px 16px;
  font-size: 15px;
  outline: none;
}
.todo-input:focus { border-color: var(--pink); }
.todo-add {
  width: 48px; height: 48px;
  border-radius: 16px;
  background: var(--pink);
  color: #fff;
  font-size: 24px;
  box-shadow: 0 4px 10px rgba(255, 158, 181, .45);
}
.todo-add:active { transform: scale(.92); }

.todo-filters { display: flex; gap: 8px; margin-bottom: 12px; }
.chip {
  font-size: 13px;
  padding: 5px 14px;
  border-radius: 999px;
  background: var(--card);
  border: 1.5px solid var(--line);
  color: var(--ink-light);
}
.chip.active { background: var(--pink); border-color: var(--pink); color: #fff; }

.todo-list { list-style: none; }
.todo-item {
  display: flex; align-items: center; gap: 10px;
  background: var(--card);
  border: 2px solid var(--line);
  border-radius: 16px;
  padding: 11px 14px;
  margin-bottom: 9px;
  box-shadow: var(--shadow);
  animation: fadeUp .25s ease;
}
.todo-check {
  width: 24px; height: 24px; flex: none;
  border: 2px solid var(--pink);
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; color: transparent;
  transition: all .15s;
}
.todo-item.done .todo-check { background: var(--mint); border-color: var(--mint); color: #fff; }
.todo-text { flex: 1; font-size: 15px; word-break: break-all; }
.todo-item.done .todo-text { text-decoration: line-through; color: var(--ink-light); }
.todo-date-tag { font-size: 11px; color: var(--ink-light); background: var(--yellow-soft); border-radius: 8px; padding: 1px 7px; flex: none; }
.todo-del { color: #E38C8C; font-size: 13px; flex: none; padding: 4px; }
.empty-hint { text-align: center; font-size: 14px; color: var(--ink-light); padding: 26px 10px; }

/* ---------- 日记时间轴 ---------- */
.diary-timeline { position: relative; padding-left: 20px; }
.diary-timeline::before {
  content: "";
  position: absolute; left: 5px; top: 6px; bottom: 6px;
  border-left: 2px dashed #E9C8CF;
}
.diary-entry { position: relative; margin-bottom: 14px; }
.diary-entry::before {
  content: "🌸";
  position: absolute; left: -22px; top: 14px;
  font-size: 11px;
  background: var(--bg);
  padding: 2px 0;
}
.diary-card {
  background: var(--card);
  border: 2px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
  cursor: pointer;
}
.diary-card:active { transform: scale(.985); }
.diary-card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.diary-card-title { font-size: 16px; font-weight: bold; }
.diary-card-date { font-size: 12px; color: var(--ink-light); flex: none; }
.diary-card-mood { font-size: 18px; margin-right: 2px; }
.diary-card-body {
  font-size: 14px; color: var(--ink-light);
  margin-top: 6px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.diary-thumbs { display: flex; gap: 6px; margin-top: 8px; }
.diary-thumbs img {
  width: 56px; height: 56px; object-fit: cover;
  border-radius: 10px; border: 2px solid #fff;
  box-shadow: var(--shadow);
}
.diary-month-tag {
  font-size: 12px; color: var(--pink);
  background: var(--pink-soft);
  display: inline-block;
  border-radius: 999px;
  padding: 2px 12px;
  margin: 4px 0 10px;
}

/* ---------- 相册 ---------- */
.gallery-tip { font-size: 12px; color: var(--ink-light); margin: -6px 2px 12px; }
.gallery-grid { column-count: 2; column-gap: 10px; }
.gallery-grid:has(.photo-card:only-child) { column-count: 1; }
.photo-card {
  break-inside: avoid;
  margin-bottom: 10px;
  background: #fff;
  border: 2px solid var(--line);
  border-radius: 14px;
  padding: 6px 6px 8px;
  box-shadow: var(--shadow);
  cursor: pointer;
}
.photo-card:nth-child(odd)  { transform: rotate(-1.1deg); }
.photo-card:nth-child(even) { transform: rotate(1.1deg); }
.photo-card img {
  width: 100%; display: block;
  border-radius: 9px;
  aspect-ratio: auto;
  background: var(--peach-soft);
}
.photo-loading {
  width: 100%;
  aspect-ratio: 1 / 1;
  background: var(--peach-soft);
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  font-size: 30px;
  animation: photoPulse 1.2s ease-in-out infinite;
}
@keyframes photoPulse {
  0%, 100% { opacity: .55; }
  50% { opacity: 1; }
}
.photo-card figcaption {
  font-size: 12px; color: var(--ink-light);
  padding: 6px 2px 0;
  display: flex; justify-content: space-between; align-items: center; gap: 6px;
}
.photo-del { color: #E38C8C; font-size: 12px; padding: 2px 6px; }

/* ---------- 设置 ---------- */
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.field span { font-size: 13px; color: var(--ink-light); }
.field input, .field textarea {
  border: 2px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 14px;
  background: #fff;
  outline: none;
  width: 100%;
}
.field input:focus { border-color: var(--pink); }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.btn-row.right { justify-content: flex-end; }
.btn-row.space-between { justify-content: space-between; align-items: center; }
.small-btn {
  background: var(--pink);
  color: #fff;
  border-radius: 12px;
  padding: 9px 16px;
  font-size: 14px;
  box-shadow: 0 3px 8px rgba(255, 158, 181, .4);
}
.small-btn:active { transform: scale(.95); }
.small-btn.primary { background: var(--pink); }
.small-btn.ghost {
  background: #fff; color: var(--ink);
  border: 2px solid var(--line);
  box-shadow: none;
}
.small-btn.danger { background: #F1A0A0; box-shadow: none; }
.sync-status { font-size: 12px; color: var(--ink-light); margin-top: 8px; min-height: 16px; }
.sync-status.ok { color: #5CA77F; }
.sync-status.err { color: #D97070; }
.gh-ok-line {
  font-size: 13px;
  line-height: 1.7;
  white-space: pre-line;
  background: var(--mint-soft);
  border: 1.5px dashed var(--mint);
  border-radius: 12px;
  padding: 10px 12px;
  margin-bottom: 10px;
}
.version { text-align: center; font-size: 12px; color: var(--ink-light); padding: 6px 0 14px; }

/* ---------- 底部导航 ---------- */
.tabbar {
  position: fixed;
  left: 50%; transform: translateX(-50%);
  bottom: 0;
  width: 100%; max-width: 520px;
  background: rgba(255, 253, 248, .92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 2px solid var(--line);
  border-radius: 22px 22px 0 0;
  display: flex;
  padding: 8px 6px calc(8px + env(safe-area-inset-bottom));
  z-index: 50;
}
.tab {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; gap: 1px;
  font-size: 11px; color: var(--ink-light);
  border-radius: 14px;
  padding: 4px 0 2px;
  transition: all .15s;
}
.tab-ico { font-size: 21px; filter: grayscale(.35); opacity: .75; transition: all .15s; }
.tab.active { color: #E0698A; }
.tab.active .tab-ico { filter: none; opacity: 1; transform: translateY(-2px) scale(1.12); }

/* ---------- 弹窗 ---------- */
.modal { position: fixed; inset: 0; z-index: 100; }
.modal-mask { position: absolute; inset: 0; background: rgba(90, 74, 66, .35); backdrop-filter: blur(2px); }
.modal-body {
  position: absolute;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  width: min(92vw, 420px);
  max-height: 84vh;
  overflow-y: auto;
  background: var(--card);
  border: 2px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 16px 16px;
  box-shadow: 0 12px 32px rgba(120, 80, 60, .22);
  animation: pop .22s ease;
}
@keyframes pop {
  from { opacity: 0; transform: translate(-50%, -46%) scale(.94); }
  to   { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}
.modal-title { font-size: 18px; margin-bottom: 12px; text-align: center; }
.modal-tape { width: 80px; height: 18px; }

.mood-row { display: flex; justify-content: space-between; gap: 4px; margin-bottom: 12px; }
.mood-item {
  font-size: 22px;
  width: 40px; height: 40px;
  border-radius: 13px;
  border: 2px solid transparent;
  background: var(--yellow-soft);
  display: flex; align-items: center; justify-content: center;
}
.mood-item.active { border-color: var(--pink); background: var(--pink-soft); transform: scale(1.1); }

.field-row { display: flex; gap: 8px; margin-bottom: 10px; }
.field-row input {
  border: 2px solid var(--line); border-radius: 12px;
  padding: 9px 12px; font-size: 14px; outline: none;
}
.field-row input[type="date"] { flex: .8; min-width: 0; }
.field-row input[type="text"] { flex: 1; min-width: 0; }
.field-row input:focus { border-color: var(--pink); }

#diary-content {
  width: 100%;
  border: 2px solid var(--line); border-radius: 14px;
  padding: 12px; font-size: 15px;
  background: #FFFEFA;
  resize: vertical; outline: none;
}
#diary-content:focus { border-color: var(--pink); }

.diary-view-title { font-size: 19px; margin-bottom: 4px; }
.diary-view-meta { font-size: 12px; color: var(--ink-light); margin-bottom: 12px; }
.diary-view-body {
  font-size: 15px; white-space: pre-wrap;
  background: #FFFEFA; border: 2px dashed var(--line);
  border-radius: 14px; padding: 12px; margin-bottom: 12px;
}
.diary-view-photos { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.diary-view-photos img {
  width: 104px; height: 104px; object-fit: cover;
  border-radius: 12px; border: 2px solid #fff; box-shadow: var(--shadow);
}

/* ---------- 灯箱 ---------- */
.lightbox {
  position: fixed; inset: 0; z-index: 120;
  background: rgba(60, 45, 40, .82);
  display: flex; align-items: center; justify-content: center;
  cursor: zoom-out;
}
.lightbox img { max-width: 94vw; max-height: 90vh; border-radius: 10px; box-shadow: 0 10px 40px rgba(0,0,0,.4); }

/* ---------- Toast / 同步条 ---------- */
.toast {
  position: fixed;
  left: 50%; bottom: calc(96px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: rgba(90, 74, 66, .92);
  color: #fff;
  font-size: 13px;
  padding: 9px 18px;
  border-radius: 999px;
  z-index: 200;
  animation: pop .2s ease;
  max-width: 80vw; text-align: center;
}
.sync-bar {
  position: fixed;
  top: 10px; left: 50%; transform: translateX(-50%);
  background: var(--yellow);
  color: #7A5A10;
  font-size: 12px;
  padding: 5px 16px;
  border-radius: 999px;
  z-index: 90;
  box-shadow: var(--shadow);
}

/* ---------- 桌面端适配 ---------- */
@media (min-width: 900px) {
  body { font-size: 16px; }
  .app { max-width: 920px; }
  #view-home {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 20px;
    align-items: start;
  }
  #view-home .hero { grid-column: 1 / -1; }
  #view-home .widget-row { grid-column: 1 / -1; }
  #view-home .home-footer { grid-column: 1 / -1; }
  #view-home .card { margin-bottom: 20px; }
  #view-todo, #view-diary, #view-gallery, #view-settings { max-width: 620px; margin: 0 auto; }
  .hero-greeting { font-size: 30px; }
  .tabbar { max-width: 920px; }
}
